refactor: simplify dotfiles configuration
check / validate (push) Canceled after 0s

This commit is contained in:
2026-08-12 15:57:01 +00:00
parent 56b90dad19
commit 2928ef3bc0
97 changed files with 740 additions and 5610 deletions
-1
View File
@@ -1 +0,0 @@
theme_config.vim
@@ -1,85 +0,0 @@
" Base16 Classic Dark vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes)
" For vim-airline (https://github.com/vim-airline/vim-airline)
" By Jason Heeris (http://heeris.id.au)
let s:scheme_slug = 'sunbather_dark'
let g:airline#themes#{s:scheme_slug}#palette = {}
" GUI color definitions
let s:gui00 = '#151515'
let s:gui01 = '#202020'
let s:gui02 = '#303030'
let s:gui03 = '#505050'
let s:gui04 = '#B0B0B0'
let s:gui05 = '#D0D0D0'
let s:gui06 = '#E0E0E0'
let s:gui07 = '#F5F5F5'
let s:gui08 = '#AC4142'
let s:gui09 = '#D28445'
let s:gui0A = '#F4BF75'
let s:gui0B = '#90A959'
let s:gui0C = '#75B5AA'
let s:gui0D = '#6A9FB5'
let s:gui0E = '#AA759F'
let s:gui0F = '#8F5536'
" Terminal color definitions
let s:cterm00 = "00"
let s:cterm03 = "08"
let s:cterm05 = "07"
let s:cterm07 = "15"
let s:cterm08 = "01"
let s:cterm0A = "03"
let s:cterm0B = "02"
let s:cterm0C = "06"
let s:cterm0D = "04"
let s:cterm0E = "05"
if exists("base16colorspace") && base16colorspace == "256"
let s:cterm01 = "18"
let s:cterm02 = "19"
let s:cterm04 = "20"
let s:cterm06 = "21"
let s:cterm09 = "16"
let s:cterm0F = "17"
else
let s:cterm01 = "10"
let s:cterm02 = "11"
let s:cterm04 = "12"
let s:cterm06 = "13"
let s:cterm09 = "09"
let s:cterm0F = "14"
endif
let g:airline#themes#{s:scheme_slug}#palette.normal = airline#themes#generate_color_map(
\ [ s:gui01, s:gui04, s:cterm01, s:cterm04 ],
\ [ s:gui04, s:gui02, s:cterm04, s:cterm02 ],
\ [ s:gui04, s:gui01, s:cterm04, s:cterm01 ])
let g:airline#themes#{s:scheme_slug}#palette.normal_modified = {
\ 'airline_c' : [ s:gui07, s:gui01, s:cterm07, s:cterm01 ]}
let g:airline#themes#{s:scheme_slug}#palette.insert = airline#themes#generate_color_map(
\ [ s:gui01, s:gui0B, s:cterm01, s:cterm0B ],
\ [ s:gui04, s:gui02, s:cterm04, s:cterm02 ],
\ [ s:gui04, s:gui01, s:cterm04, s:cterm01 ])
let g:airline#themes#{s:scheme_slug}#palette.insert_modified = {
\ 'airline_c' : [ s:gui07, s:gui01, s:cterm07, s:cterm01 ]}
let g:airline#themes#{s:scheme_slug}#palette.replace = airline#themes#generate_color_map(
\ [ s:gui01, s:gui0E, s:cterm01, s:cterm0E ],
\ [ s:gui04, s:gui02, s:cterm04, s:cterm02 ],
\ [ s:gui04, s:gui01, s:cterm04, s:cterm01 ])
let g:airline#themes#{s:scheme_slug}#palette.replace_modified = {
\ 'airline_c' : [ s:gui07, s:gui01, s:cterm07, s:cterm01 ]}
let g:airline#themes#{s:scheme_slug}#palette.visual = airline#themes#generate_color_map(
\ [ s:gui01, s:gui09, s:cterm01, s:cterm09 ],
\ [ s:gui04, s:gui02, s:cterm04, s:cterm02 ],
\ [ s:gui04, s:gui01, s:cterm04, s:cterm01 ])
let g:airline#themes#{s:scheme_slug}#palette.visual_modified = {
\ 'airline_c' : [ s:gui07, s:gui01, s:cterm07, s:cterm01 ]}
let g:airline#themes#{s:scheme_slug}#palette.inactive = airline#themes#generate_color_map(
\ [ s:gui01, s:gui01, s:cterm01, s:cterm01 ],
\ [ s:gui04, s:gui01, s:cterm04, s:cterm01 ],
\ [ s:gui05, s:gui01, s:cterm05, s:cterm01 ])
@@ -1,85 +0,0 @@
" Base16 Summerfruit Light vim-airline-theme (https://github.com/dawikur/base16-vim-airline-themes)
" For vim-airline (https://github.com/vim-airline/vim-airline)
" By Christopher Corley (http://christop.club/)
let s:scheme_slug = 'sunbather_light'
let g:airline#themes#{s:scheme_slug}#palette = {}
" GUI color definitions
let s:gui00 = '#FFFFFF'
let s:gui01 = '#E0E0E0'
let s:gui02 = '#D0D0D0'
let s:gui03 = '#B0B0B0'
let s:gui04 = '#000000'
let s:gui05 = '#101010'
let s:gui06 = '#151515'
let s:gui07 = '#202020'
let s:gui08 = '#FF0086'
let s:gui09 = '#FD8900'
let s:gui0A = '#ABA800'
let s:gui0B = '#00C918'
let s:gui0C = '#1FAAAA'
let s:gui0D = '#3777E6'
let s:gui0E = '#AD00A1'
let s:gui0F = '#CC6633'
" Terminal color definitions
let s:cterm00 = "00"
let s:cterm03 = "08"
let s:cterm05 = "07"
let s:cterm07 = "15"
let s:cterm08 = "01"
let s:cterm0A = "03"
let s:cterm0B = "02"
let s:cterm0C = "06"
let s:cterm0D = "04"
let s:cterm0E = "05"
if exists("base16colorspace") && base16colorspace == "256"
let s:cterm01 = "18"
let s:cterm02 = "19"
let s:cterm04 = "20"
let s:cterm06 = "21"
let s:cterm09 = "16"
let s:cterm0F = "17"
else
let s:cterm01 = "10"
let s:cterm02 = "11"
let s:cterm04 = "12"
let s:cterm06 = "13"
let s:cterm09 = "09"
let s:cterm0F = "14"
endif
let g:airline#themes#{s:scheme_slug}#palette.normal = airline#themes#generate_color_map(
\ [ s:gui01, s:gui04, s:cterm01, s:cterm04 ],
\ [ s:gui04, s:gui02, s:cterm04, s:cterm02 ],
\ [ s:gui04, s:gui01, s:cterm04, s:cterm01 ])
let g:airline#themes#{s:scheme_slug}#palette.normal_modified = {
\ 'airline_c' : [ s:gui07, s:gui01, s:cterm07, s:cterm01 ]}
let g:airline#themes#{s:scheme_slug}#palette.insert = airline#themes#generate_color_map(
\ [ s:gui01, s:gui0B, s:cterm01, s:cterm0B ],
\ [ s:gui04, s:gui02, s:cterm04, s:cterm02 ],
\ [ s:gui04, s:gui01, s:cterm04, s:cterm01 ])
let g:airline#themes#{s:scheme_slug}#palette.insert_modified = {
\ 'airline_c' : [ s:gui07, s:gui01, s:cterm07, s:cterm01 ]}
let g:airline#themes#{s:scheme_slug}#palette.replace = airline#themes#generate_color_map(
\ [ s:gui01, s:gui0E, s:cterm01, s:cterm0E ],
\ [ s:gui04, s:gui02, s:cterm04, s:cterm02 ],
\ [ s:gui04, s:gui01, s:cterm04, s:cterm01 ])
let g:airline#themes#{s:scheme_slug}#palette.replace_modified = {
\ 'airline_c' : [ s:gui07, s:gui01, s:cterm07, s:cterm01 ]}
let g:airline#themes#{s:scheme_slug}#palette.visual = airline#themes#generate_color_map(
\ [ s:gui01, s:gui09, s:cterm01, s:cterm09 ],
\ [ s:gui04, s:gui02, s:cterm04, s:cterm02 ],
\ [ s:gui04, s:gui01, s:cterm04, s:cterm01 ])
let g:airline#themes#{s:scheme_slug}#palette.visual_modified = {
\ 'airline_c' : [ s:gui07, s:gui01, s:cterm07, s:cterm01 ]}
let g:airline#themes#{s:scheme_slug}#palette.inactive = airline#themes#generate_color_map(
\ [ s:gui01, s:gui01, s:cterm01, s:cterm01 ],
\ [ s:gui04, s:gui01, s:cterm04, s:cterm01 ],
\ [ s:gui05, s:gui01, s:cterm05, s:cterm01 ])
-27
View File
@@ -1,27 +0,0 @@
" vim build with clipboard support doesn't need this and it work
" better than neovim
func s:helper()
call system('printf "%s" '.shellescape(join(v:event['regcontents'], "\n")).' | xclip -sel clip' )
endfunc
func! clipboard#get()
endfunc
func! clipboard#enable()
augroup WSLClipboard
au!
au TextYankPost * call s:helper()
augroup END
endfunc
func! clipboard#disable()
augroup WSLClipboard
au!
augroup END
endfunc
func! clipboard#paste()
return system('xclip -o -sel clip' )
endfunc
-45
View File
@@ -1,45 +0,0 @@
let s:path = get(g:, '_config_path', fnamemodify(
\ resolve(expand('<sfile>:p')), ':h:h').'/_config.vim')
let s:config = {}
function! config#saveConfig()
let p = utils#readvar(s:path)
if type(p) != type({})
let p = {}
endif
let vim_type = has('nvim') ? 'nvim' : 'vim'
let config = has_key(p, vim_type) && type(p[vim_type]) == v:t_dict
\ ? p[vim_type] : {}
let config = utils#merge(config, s:config)
" vim and nvim may have diferenrt available plugins
let p[vim_type] = config
call utils#savevar(p, s:path)
endfunction
function! s:loadConfig()
let result = utils#readvar(s:path)
" if it is dictionary
let vim_type = has('nvim') ? 'nvim' : 'vim'
if type(result) == v:t_dict
if has_key(result, vim_type)
let config = result[vim_type]
if type(config) == v:t_dict
let s:config = config
return
endif
endif
endif
endfunction
function! config#setConfig(dict)
let s:config = utils#merge(s:config, a:config)
endfunction
function! config#init()
call config#loadConfig()
augroup config
autocmd!
autocmd VimLeave * call config#saveConfig()
augroup END
endfunction
-171
View File
@@ -1,171 +0,0 @@
" this intent to create a list of options that can be toggled on/off
let s:options = {}
if !has('nvim')
import autoload 'fuzzyy/utils/selector.vim'
endif
" opt is a dictionary with the following keys(* = required):
" togglefunc and enablefunc/disablefunc are mutually exclusive
" params:
" - name: name of the option
" - opt: a dictionary with following options():
" - desc: description,
" - togglefunc: function reference, if exists, enablefunc and disablefunc
" will be ignored,
" - enablefunc: function reference, if this exists, disablefunc must exists
" as well and vice verse
" - disablefunc: function reference,
" - isEnabled: string, true or false or function reference. only needed when
" using enablefunc and disablefunc
function! options#add(name, opt) abort
if (!has_key(a:opt, 'togglefunc')
\ && (!has_key(a:opt, 'enablefunc') || !has_key(a:opt, 'disablefunc')))
throw 'invalid option (togglefunc or enablefunc/disablefunc must be set))'
endif
if !has_key(a:opt, 'isEnabled') && !has_key(a:opt, 'togglefunc')
throw 'specify initial state(isEnabled) or set togglefunc'
endif
for key in ['togglefunc', 'enablefunc', 'disablefunc']
if has_key(a:opt, key) && type(a:opt[key]) != v:t_func
throw key . ' must be a function reference'
endif
endfor
if !has_key(a:opt, 'desc')
let a:opt['desc'] = ''
endif
let s:options[a:name] = a:opt
endfunction
" Register a simple vim option
" params:
" - name: name of the option
" - dictionary(optional):
" - desc: description of the option
function! options#addVimOption(name, ...) abort
let opt = {}
func opt.togglefunc(key)
if eval('&' . a:key)
execute('set no' . a:key)
else
execute('set ' . a:key)
endif
endfunc
if a:0 > 0
let opt['desc'] = a:1
endif
call options#add(a:name, opt)
endfunction
function! options#getAll() abort
let list = []
for [key, val] in items(s:options)
let desc = val.desc != '' ? ' - ' . val.desc : ''
call add(list, [key, key . desc])
endfor
return list
endfunction
function! options#getAllRaw() abort
let list = []
for [key, val] in items(s:options)
call add(list, [key, desc])
endfor
return list
endfunction
function! options#toggle(name) abort
if !has_key(s:options, a:name)
throw 'invalid option name: ' . a:name
endif
let opt = s:options[a:name]
if has_key(opt, 'togglefunc')
call opt.togglefunc(a:name)
else
if type(opt.isEnabled) == v:t_func
let isEnabled = opt.isEnabled()
else
let isEnabled = opt.isEnabled
endif
if isEnabled
call opt.disablefunc()
else
call opt.enablefunc()
endif
if type(opt.isEnabled) != v:t_func
let s:options[a:name].isEnabled = opt.isEnabled ? v:false : v:true
endif
endif
endfunction
function! options#preSet()
call options#addVimOption('number', 'show line number')
call options#addVimOption('relativenumber')
let colorcolumnOpt = {
\ 'desc': 'show color column',
\ 'isEnabled': &colorcolumn != ''
\ }
function colorcolumnOpt.togglefunc(...)
if &colorcolumn == ''
let &colorcolumn = '80'
else
let &colorcolumn = ''
endif
endfunction
call options#add('colorcolumn', colorcolumnOpt)
let toggleBgOpt = {
\ 'desc': 'toggle dark/light theme',
\ }
function toggleBgOpt.togglefunc(...)
call theme#toggleBg()
endfunction
call options#add('dark/light', toggleBgOpt)
endfunction
function! s:select(wid, result)
let result = a:result[0]
if result != v:null
let key = s:rmap[result]
call options#toggle(key)
endif
endfunction
function! options#fzf_options()
let list = []
let s:rmap = {}
for [key, val] in items(s:options)
let desc = val.desc != '' ? key . ' - ' . val.desc : key
call add(list, desc)
let s:rmap[desc] = key
endfor
let s:fzf_list = list
call selector.Start( list,
\ {
\ 'select_cb' : function('s:select'),
\ 'yoffset' : 0.3,
\ 'height' : 0.4,
\ 'title' : 'Options',
\ 'width' : 0.4
\ })
endfunc
function! options#init()
call options#preSet()
if !has('nvim')
command! -nargs=0 Options call options#fzf_options()
nnoremap <silent> <leader>fo :Options<CR>
endif
endfunction
-8
View File
@@ -1,8 +0,0 @@
func! os#getOS()
if has("win64") || has("win32") || has("win16")
return "Windows"
else
return substitute(system('uname'), '\n', '', '')
endif
endfunc
+98 -361
View File
@@ -1,383 +1,120 @@
let s:path = get(g:, 'theme_config_path', fnamemodify(
\ resolve(expand('<sfile>:p')), ':h:h').'/theme_config.vim')
let s:path = get(g:, 'vim_dir', expand('~/.vim')) . '/theme.json'
let s:defaults = {
\ 'background': 'dark',
\ 'dark': {'theme': 'moonfly', 'transparent': v:false},
\ 'light': {'theme': 'PaperColor', 'transparent': v:false}}
let s:config = deepcopy(s:defaults)
let s:applying = v:false
let s:transparent_groups = [
\ 'Normal', 'NormalNC', 'EndOfBuffer', 'Folded', 'LineNr', 'SignColumn',
\ 'StatusLine', 'StatusLineNC', 'VertSplit', 'WinSeparator', 'NormalFloat']
let s:themefixes = []
let s:bgType = has('termguicolors') ? 'guibg' : 'ctermbg'
" sometimes even in termguicolors, when guibg is not set, the bg will fall
" back to use ctermbg, so we have to set them both to none
let s:bgNonType = !has('termguicolors') ? 'guibg=NONE' : 'ctermbg=NONE'
let s:transBlendOpt = has('nvim') ? ' blend=0' : ''
let s:default_config = {
\ 'background': 'dark',
\ 'light': {
\ 'theme': 'sunbather_light',
\ 'default': 'sunbather_light',
\ 'transparent': v:false,
\ 'airline_theme': 'sunbather_light',
\ },
\ 'dark': {
\ 'theme': 'base16-harmonic-dark',
\ 'default': 'base16-harmonic-dark',
\ 'transparent': v:false,
\ 'airline_theme': 'base16-harmonic-dark',
\ },
\ }
" When enable transparent background, these group will be set to transparent
let s:transgroups = [
\ 'Normal', 'NormalNC', 'Comment', 'Constant', 'Special', 'Identifier',
\ 'Folded', 'Statusline', 'StatuslineNC',
\ 'Statement', 'PreProc', 'Type', 'Underlined', 'String', 'Function',
\ 'Conditional', 'Repeat', 'Operator', 'Structure', 'LineNr', 'NonText',
\ 'SignColumn', 'CursorLineNr', 'EndOfBuffer', 'VertSplit',
\ 'DiagnosticSignWarn', 'DiagnosticSignError', 'DiagnosticSignInfo',]
" background group that will be set to normal's background color
let s:cleanbg = ['DiagnosticSignWarn', 'DiagnosticSignError', 'DiagnosticSignInfo',
\ 'VertSplit', 'LineNr', 'SignColumn', 'NormalFloat']
let s:config = get(g:, 'theme_config', s:default_config)
function! theme#setConfig(bg, key, value)
let s:config[a:bg][a:key] = a:value
endfunction
" register extra transparent hi group
function! theme#getCleanBg()
return s:cleanbg
endfunction
function! theme#getBgType()
return s:bgType
endfunction
function! theme#getTransGroup()
return s:transgroups
endfunction
" register extra transparent hi group
function theme#addCleanBg(group)
let li = type(a:group) == 1 ? [a:group] : a:group
for hi in li
if index(s:cleanbg, hi) == -1
call add(s:cleanbg, hi)
endif
endfor
endfunction
" register extra transparent hi group
function theme#addTransGroup(group)
let li = type(a:group) == 1 ? [a:group] : a:group
for hi in li
if index(s:transgroups, hi) == -1
call add(s:transgroups, hi)
endif
endfor
endfunction
function! theme#setColor(bg, ...)
let colors_name = a:0 > 0 ? a:1 : s:config[a:bg].theme
if !utils#hascolorscheme(colors_name)
let colors_name = 'default'
endif
noa let &bg = a:bg
call theme#setStlColor(a:bg)
let s:config.background = a:bg
let s:config[a:bg].theme = colors_name
noa execute("colorscheme " . colors_name)
if &background != a:bg
noa let &bg = a:bg
endif
" some theme will pick their own airline theme or airline will
" automatically pick theme based on colorscheme
if exists('g:airline_theme') && g:airline_theme != s:config[a:bg].airline_theme
call theme#setStlColor(a:bg, g:airline_theme)
endif
endfunction
" Change bottom airline/lualine theme
function! theme#setStlColor(bg, ...)
if has('nvim-0.5')
" lualine will change theme automatically
function! s:Merge(defaults, override) abort
let l:result = deepcopy(a:defaults)
if type(a:override) != v:t_dict
return l:result
endif
for [l:key, l:value] in items(a:override)
if type(l:value) == v:t_dict && type(get(l:result, l:key)) == v:t_dict
let l:result[l:key] = s:Merge(l:result[l:key], l:value)
else
if utils#hasplug('vim-airline') && exists(':AirlineTheme')
let theme = a:0 > 0 ? a:1 : s:config[a:bg].airline_theme
try
execute('AirlineTheme ' . theme)
catch
let theme = s:default_config[a:bg].airline_theme
execute('AirlineTheme ' . theme)
endtry
let s:config[a:bg].airline_theme = theme
endif
let l:result[l:key] = l:value
endif
endfor
return l:result
endfunction
function! theme#inTransparent()
return s:config[&background].transparent
function! s:Available(name) abort
return !empty(globpath(&runtimepath, 'colors/' . a:name . '.vim', 1, 1))
endfunction
" return 1 if link to other group
" return 2 if not exists
" return 0 if normal
function! s:hiType(group)
try
let hi = execute('hi '.a:group)
if hi =~# 'link'
return 2
endif
catch
return 1
endtry
return 0
function! s:ApplyTransparency() abort
if !s:config[&background].transparent
return
endif
for l:group in s:transparent_groups
execute 'highlight ' . l:group . ' guibg=NONE ctermbg=NONE'
endfor
endfunction
function s:applyTransparent()
let tail = ' ' . s:bgType . '=NONE term=NONE gui=NONE cterm=NONE '
if has('nvim')
let tail .= s:transBlendOpt
else
let tail .= s:bgNonType
endif
for group in s:transgroups
if s:hiType(group) != 0
continue
endif
" cterm and term sometimes are set to reverse so we need to clean them
" too
" for the last part, we can't clear all terms or it will fall back to
" default which is not transparent
execute('hi! '.group . tail)
endfor
call s:generalThemeFix()
" for group in s:cleanbg
" if s:hiType(group) != 0
" continue
" endif
" execute('hi! '.group . tail)
" endfor
function! s:Load() abort
if !filereadable(s:path)
return deepcopy(s:defaults)
endif
try
let l:saved = json_decode(join(readfile(s:path), "\n"))
return s:Merge(s:defaults, l:saved)
catch
return deepcopy(s:defaults)
endtry
endfunction
" some callback function to enable transparent background
" for specific colorscheme
" or general callback for all colorscheme when specific colorscheme callback
" is not available
" g:dark_transparent_enable_cb
" g:light_transparent_enable_cb
function! theme#enableTransparent() abort
let colorscheme_name = utils#colorschemename()
let bg = &background
if exists('g:'.bg.'_transparent_enable_cb') && g:dark_transparent_enable_cb != ''
let cb_name = get(g:, bg.'_transparent_enable_cb', '')
if cb_name != ''
execute('call '.cb_name.'()')
endif
elseif exists('g:Transparent_enable_func')
if type(g:Transparent_enable_func) != v:t_func
echoerr 'g:Transparent_enable_func is not a function'
endif
call g:Transparent_enable_func()
else
call s:applyTransparent()
augroup SetTransparent
autocmd!
autocmd ColorScheme * call s:applyTransparent()
augroup END
endif
let s:config[bg].transparent = v:true
function! theme#save() abort
try
call mkdir(fnamemodify(s:path, ':h'), 'p')
call writefile([json_encode(s:config)], s:path)
catch
" A read-only home directory should not prevent Vim from exiting cleanly.
endtry
endfunction
function! theme#disableTransparent() abort
augroup SetTransparent
autocmd!
augroup END
let bg = &background
let s:config[bg].transparent = v:false
let colorscheme_name = utils#colorschemename()
if exists('g:'.bg.'_transparent_disable_cb')
let cb_name = get(g:, bg.'_transparent_disable_cb', '')
if cb_name != ''
execute('call '.cb_name.'()')
endif
elseif exists('g:Transparent_disable_func')
if type(g:Transparent_disable_func) != v:t_func
echoerr 'g:Transparent_disable_func is not a function'
endif
call g:Transparent_disable_func()
else
execute('colorscheme ' . s:config[bg].theme)
endif
function! theme#apply(name) abort
let l:background = &background
let l:name = s:Available(a:name) ? a:name
\ : (l:background ==# 'dark' ? 'sunbather_dark' : 'sunbather_light')
let s:applying = v:true
try
execute 'colorscheme ' . l:name
finally
let s:applying = v:false
endtry
let &background = l:background
let s:config.background = l:background
let s:config[l:background].theme = l:name
call s:ApplyTransparency()
endfunction
" ToggleTransparent background
function! theme#toggleTransparent()
if s:config[&background].transparent
call theme#disableTransparent()
else
call theme#enableTransparent()
endif
function! theme#toggleBg() abort
let l:background = &background ==# 'dark' ? 'light' : 'dark'
let l:theme = s:config[l:background].theme
let s:applying = v:true
try
let &background = l:background
finally
let s:applying = v:false
endtry
let s:config.background = l:background
call theme#apply(l:theme)
endfunction
" Allow to trigger background
function! theme#toggleBg()
" Inversion
let newbg = &background == "dark" ? 'light' : 'dark'
call theme#setColor(newbg)
if s:config[&background].transparent
call theme#enableTransparent()
elseif !s:config[&background].transparent
call theme#disableTransparent()
endif
function! theme#toggleTransparent() abort
let s:config[&background].transparent = !s:config[&background].transparent
if s:config[&background].transparent
call s:ApplyTransparency()
else
call theme#apply(s:config[&background].theme)
endif
endfunction
function! theme#saveConfig()
let p = utils#readvar(s:path)
if type(p) != type({})
let p = {}
endif
let vim_type = has('nvim') ? 'nvim' : 'vim'
let config = has_key(p, vim_type) && type(p[vim_type]) == 4
\ ? p[vim_type] : {}
let config = utils#merge(config, s:config)
" vim and nvim may have diferenrt available plugins
let p[vim_type] = config
call utils#savevar(p, s:path)
function! theme#onColorScheme(name) abort
if s:applying
return
endif
if a:name !~# '^sunbather_' && index(['everforest', 'moonfly', 'PaperColor'], a:name) < 0
return
endif
let s:config.background = &background
let s:config[&background].theme = a:name
call s:ApplyTransparency()
endfunction
function! theme#loadConfig()
let result = utils#readvar(s:path)
" if it is dictionary
let vim_type = has('nvim') ? 'nvim' : 'vim'
if type(result) == 4
if has_key(result, vim_type)
let config = result[vim_type]
if type(config) == 4
return config
endif
endif
endif
return {}
endfunction
function! theme#getHiTerms(group)
let output = execute('hi ' . a:group)
if stridx(output, 'links to') > 0
let higroup = matchstr(output, 'links.to.\?\zs\S\+\ze')
return theme#getHiTerms(higroup)
endif
let list = split(output, '')
let dict = {}
for item in list
if stridx(item, '=') > 0
let splited = split(item, '=')
let dict[splited[0]] = splited[1]
endif
endfor
for item in ['guibg', 'ctermbg', 'term', 'cterm', 'guifg', 'ctermfg']
if ! has_key(dict, item)
let dict[item] = 'NONE'
endif
endfor
return dict
endfunction
function! theme#getHiTerm(group, term)
" Store output of group to variable
let output = theme#getHiTerms(a:group)
return output[a:term]
endfunction
function! s:regiesterThemeFix(Func)
call add(s:theme_fix, a:Func)
endfunction
function! s:generalThemeFix()
" The following is for getting rid of the vim split bar and match its
" and number cols' color with backgroud
" if theme#inTransparent()
" return
" endif
if &bg != s:config.background
execute('set bg=' . s:config.background)
endif
let normal = theme#getHiTerms('normal')
let hiTerms = ' '
for term in ['guibg', 'ctermbg', 'term', 'cterm']
let hiTerms .= term . '=' . normal[term] . ' '
endfor
for group in s:cleanbg
" if s:hiType(group) != 0
" continue
" endif
" transBlendOpt is used to prevent hi from being clear
execute('hi! ' . group . hiTerms)
endfor
" highlight cursorline number only
" this needs option set cursorlineopt=number
if s:hiType('CursorLineNr') == 0
hi! CursorLineNr guibg=NONE ctermbg=NONE cterm=bold gui=bold
endif
for Func in s:themefixes
call Func()
endfor
endfunction
function! theme#Init()
if has('termguicolors')
set termguicolors
endif
if has('nvim')
set fillchars+=stl:\ ,stlnc:\ ,
endif
let s:config = utils#merge(s:default_config, theme#loadConfig())
let bg = s:config.background
if utils#hascolorscheme(s:config[bg].theme)
call theme#setColor(bg)
else
call theme#setColor(bg, s:config[bg].default)
endif
if s:config[bg].transparent
call theme#enableTransparent()
else
call theme#disableTransparent()
endif
call s:generalThemeFix()
if exists('*options#add')
let toggle_transparent = { 'desc' : 'Toggle transparent background' }
func toggle_transparent.togglefunc(...)
call theme#toggleTransparent()
endfunc
call options#add('toggle_transparent', toggle_transparent)
endif
augroup GeneralTheme
autocmd!
autocmd ColorScheme * call s:generalThemeFix()
autocmd ColorScheme * let s:config.background = &bg | call theme#setColor(&bg, expand('<amatch>'))
autocmd VimLeave * call theme#saveConfig()
augroup END
endfunction
function! theme#getConfig()
return s:config
function! theme#Init() abort
let s:config = s:Load()
let &background = get(s:config, 'background', 'dark')
call theme#apply(s:config[&background].theme)
augroup DotfilesTheme
autocmd!
autocmd ColorScheme * call theme#onColorScheme(expand('<amatch>'))
autocmd VimLeavePre * call theme#save()
augroup END
endfunction
-194
View File
@@ -1,194 +0,0 @@
" return a python version available (from 3 to 2)
fun! utils#get_usable_py()
let py = ''
if executable('python3')
let py = 'python3'
elseif executable('python2')
let py = 'python2'
elseif executable('python')
let py = 'python'
endif
return py
endfun
" Check if plugin exists
function! utils#hasplug(plug_name, ...)
let plug_dir_name = get(a:, 1, a:plug_name) " optional argument for the name of plug's folder
if has_key(g:plugs, a:plug_name) && isdirectory(g:plugin_dir . "/" . plug_dir_name)
if has_key(g:plugs[a:plug_name], 'for') || has_key(g:plugs[a:plug_name], 'on')
if (has_key(g:plugs[a:plug_name], 'for') && len(g:plugs[a:plug_name]['for']) == 0) ||
\ (has_key(g:plugs[a:plug_name], 'on') && len(g:plugs[a:plug_name]['on']) == 0)
return v:false
endif
endif
return v:true
endif
return v:false
endfunction
" This function is used to save a variable to a file
function! utils#savevar(var, file)
let serialized = string(a:var)
call writefile([serialized], a:file)
endfun
" This function is used to retrieve a variable from a file
" only first line is count
function! utils#readvar(file)
if !filereadable(a:file)
return v:null
endif
let serialized = readfile(a:file)
if(len(serialized) == 0)
return v:null
endif
execute "let result = " . serialized[0]
return result
endfun
" Merge two dictionaries, also recursively merging nested keys.
" Use extend() if you don't need to merge nested keys.
fun! utils#merge(defaults, override)
let l:new = copy(a:defaults)
for [l:k, l:v] in items(a:override)
let l:new[l:k] = (type(l:v) is v:t_dict && type(get(l:new, l:k)) is v:t_dict)
\ ? utils#merge(l:new[l:k], l:v)
\ : l:v
endfor
return l:new
endfun
"Remove all trailing whitespace by pressing <leader>ws
fun! utils#trimwhitespace()
let l:save = winsaveview()
keeppatterns %s/\s*\r\=$//e
call winrestview(l:save)
endfun
function! utils#hascolorscheme(name)
let scheme = a:name
let colors = globpath(&runtimepath, printf('colors/%s.vim', scheme), 1, 1)
if len(colors) > 0 | return 1 | endif
let colors += globpath(&packpath, printf('pack/*/start/*/colors/%s.vim', scheme), 1, 1)
if len(colors) > 0 | return 1 | endif
let colors += globpath(&packpath, printf('pack/*/opt/*/colors/%s.vim', scheme), 1, 1)
if len(colors) > 0 | return 1 | endif
if has('nvim')
let colors = globpath(&runtimepath, printf('colors/%s.lua', scheme), 1, 1)
if len(colors) > 0 | return 1 | endif
let colors += globpath(&packpath, printf('pack/*/start/*/colors/%s.lua', scheme), 1, 1)
if len(colors) > 0 | return 1 | endif
let colors += globpath(&packpath, printf('pack/*/opt/*/colors/%s.lua', scheme), 1, 1)
if len(colors) > 0 | return 1 | endif
endif
return 0
endfunction
" get current colorscheme name
" return default if not found
function! utils#colorschemename()
return execute('colo')[1:]
try
return g:colors_name
catch /^Vim:E121/
return "default"
catch /.*/
return "default"
endtry
endfunction
" debug function print out highlight group of cursor position
function! utils#showHiGroup(...)
if !exists("*synstack")
return
endif
let l = a:0 == 2 ? a:1 : line('.')
let c = a:0 == 2 ? a:2 : col('.')
echo map(synstack(l, c), 'synIDattr(v:val, "name")')
:echo "hi<" . synIDattr(synID(l,c,1),"name") . '> trans<'
\ . synIDattr(synID(l,c,0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(l,c,1)),"name") . ">"
endfunc
" get highlight group information and return as dictionary
function! utils#getHi(group)
let output = execute('hi ' . a:group)
let list = split(output, '\s\+')
let dict = {}
for item in list
if match(item, '=') > 0
let splited = split(item, '=')
let dict[splited[0]] = splited[1]
endif
endfor
return dict
endfunction
function! utils#isTransparent()
let dict = utils#getHi('Normal')
let isGui = &termguicolors
if isGui
if !has_key(dict, 'guibg')
return 1
endif
elseif !isGui
if !has_key(dict, 'ctermfg')
return 1
endif
endif
return 0
endfunction
function! s:scratch()
split
noswapfile hide enew
setlocal buftype=nofile
setlocal bufhidden=hide
setlocal nobuflisted
endfunction
" search highlight group with pattern
function! utils#searchHi(pattern)
execute("filter /" . a:pattern . "/ highlight")
" color not working
" let temp_reg = @"
" redir @"
" silent! execute("filter /" . a:pattern . "/ highlight")
" redir END
" let output = copy(@")
" let @" = temp_reg
" call s:scratch()
" put! =output
endfunc
function! utils#swapword()
let word = expand("<cword>")
let l1 = g:swap_dict[0]
let l2 = g:swap_dict[1]
let inx = index(l1, word)
if inx != -1
let newword = l2[inx]
else
let inx = index(l2, word)
if inx != -1
let newword = l1[inx]
endif
endif
if inx != -1
execute "normal ciw" . newword . "\<Esc>"
endif
endfunction
function! utils#files(...)
if a:0 > 0
let path = a:1
else
let path = getcwd()
endif
let files = glob(path . '/**', 1, 1, 1)
return files
endfunction
-98
View File
@@ -1,98 +0,0 @@
#!/usr/bin/env python3
""" preview.py theme arg
"""
import os
import sys
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
RED = '\033[31m'
YELLOW = '\033[33m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
def is_tool(name):
"""Check whether `name` is on PATH and marked as executable."""
from shutil import which
return which(name) is not None
def get_preview_tool():
exec = None
if is_tool('bat'):
exec = 'bat'
elif is_tool('batcat'):
exec = 'batcat'
elif is_tool('cat'):
exec = 'cat'
return exec
if __name__ == '__main__':
theme = sys.argv[1]
if theme == 'light':
theme = 'ansi'
tcolor = '31'
color = bcolors.RED
else:
theme = '1337'
tcolor = '33'
color = bcolors.YELLOW
filepath = ''.join(sys.argv[2:])
args = filepath.split(":")
args += [None, None]
file = args[0]
center = args[1]
# print(sys.argv[2:])
# exit(0)
# if os.name == 'nt':
# file += args[1]
# center = args[2]
if file == None or not os.path.isfile(file):
print("File not found {}".format(file))
exit(0)
if center is None: center = 0
batcmd = get_preview_tool()
cmdstr = None
if file[0] == '-':
file = './' + file
if batcmd:
if batcmd == 'cat':
if center:
cmdstr = 'cat -n {} | perl -pe "s/^.*?\s{}\s.*?$/\e[1;{}m$&\e[0m/g"'.format(file, center, tcolor)
else:
cmdstr = 'cat -n {}'.format(file)
elif batcmd == 'bat':
cmdstr = 'bat --theme={} --style=numbers --color=always \
--pager=never --highlight-line={} "{}"'.format(theme, center, file)
if cmdstr:
os.system(cmdstr)
else:
f = open(file, 'r')
Lines = f.readlines()
center = int(center)
linenr = 1
for line in Lines:
if linenr == center:
print("{}{:4d} {}{}".format(color, linenr, line, bcolors.ENDC), end='')
else:
print("{:4d} {}".format(linenr, line), end='')
linenr += 1
f.close()
-30
View File
@@ -1,30 +0,0 @@
if has('gui') || exists('g:neovide')
set guifont=Hack\ Nerd\ Font:h13
" neovide doesn't support copy from host, so we have to map it ourselves
if exists('g:neovide')
func! s:enabletp()
let g:neovide_transparency=0.9
endfunc
func! s:disabletp()
let g:neovide_transparency=1.0
endfunc
let g:Transparent_disable_func = function('s:disabletp')
let g:Transparent_enable_func = function('s:enabletp')
let g:neovide_transparency=0.9
" let g:neovide_transparency_point=0.8
if g:os == 'Darwin'
nnoremap <D-v> "+p
cnoremap <D-v> <c-r>+
inoremap <D-v> <c-r>+
else
nnoremap <C-v> "+p
cnoremap <C-v> <c-r>+
inoremap <C-v> <c-r>+
endif
endif
endif
-276
View File
@@ -1,276 +0,0 @@
-- The lua implementation of the fzy string matching algorithm
local SCORE_GAP_LEADING = -0.005
local SCORE_GAP_TRAILING = -0.005
local SCORE_GAP_INNER = -0.01
local SCORE_MATCH_CONSECUTIVE = 1.0
local SCORE_MATCH_SLASH = 0.9
local SCORE_MATCH_WORD = 0.8
local SCORE_MATCH_CAPITAL = 0.7
local SCORE_MATCH_DOT = 0.6
local SCORE_MAX = math.huge
local SCORE_MIN = -math.huge
local MATCH_MAX_LENGTH = 1024
local fzy = {}
-- Check if `needle` is a subsequence of the `haystack`.
--
-- Usually called before `score` or `positions`.
--
-- Args:
-- needle (string)
-- haystack (string)
-- case_sensitive (bool, optional): defaults to false
--
-- Returns:
-- bool
function fzy.has_match(needle, haystack, case_sensitive)
if not case_sensitive then
needle = string.lower(needle)
haystack = string.lower(haystack)
end
local j = 1
for i = 1, string.len(needle) do
j = string.find(haystack, needle:sub(i, i), j, true)
if not j then
return false
else
j = j + 1
end
end
return true
end
local function is_lower(c)
return c:match("%l")
end
local function is_upper(c)
return c:match("%u")
end
local function precompute_bonus(haystack)
local match_bonus = {}
local last_char = "/"
for i = 1, string.len(haystack) do
local this_char = haystack:sub(i, i)
if last_char == "/" or last_char == "\\" then
match_bonus[i] = SCORE_MATCH_SLASH
elseif last_char == "-" or last_char == "_" or last_char == " " then
match_bonus[i] = SCORE_MATCH_WORD
elseif last_char == "." then
match_bonus[i] = SCORE_MATCH_DOT
elseif is_lower(last_char) and is_upper(this_char) then
match_bonus[i] = SCORE_MATCH_CAPITAL
else
match_bonus[i] = 0
end
last_char = this_char
end
return match_bonus
end
local function compute(needle, haystack, D, M, case_sensitive)
-- Note that the match bonuses must be computed before the arguments are
-- converted to lowercase, since there are bonuses for camelCase.
local match_bonus = precompute_bonus(haystack)
local n = string.len(needle)
local m = string.len(haystack)
if not case_sensitive then
needle = string.lower(needle)
haystack = string.lower(haystack)
end
-- Because lua only grants access to chars through substring extraction,
-- get all the characters from the haystack once now, to reuse below.
local haystack_chars = {}
for i = 1, m do
haystack_chars[i] = haystack:sub(i, i)
end
for i = 1, n do
D[i] = {}
M[i] = {}
local prev_score = SCORE_MIN
local gap_score = i == n and SCORE_GAP_TRAILING or SCORE_GAP_INNER
local needle_char = needle:sub(i, i)
for j = 1, m do
if needle_char == haystack_chars[j] then
local score = SCORE_MIN
if i == 1 then
score = ((j - 1) * SCORE_GAP_LEADING) + match_bonus[j]
elseif j > 1 then
local a = M[i - 1][j - 1] + match_bonus[j]
local b = D[i - 1][j - 1] + SCORE_MATCH_CONSECUTIVE
score = math.max(a, b)
end
D[i][j] = score
prev_score = math.max(score, prev_score + gap_score)
M[i][j] = prev_score
else
D[i][j] = SCORE_MIN
prev_score = prev_score + gap_score
M[i][j] = prev_score
end
end
end
end
-- Compute a matching score.
--
-- Args:
-- needle (string): must be a subequence of `haystack`, or the result is
-- undefined.
-- haystack (string)
-- case_sensitive (bool, optional): defaults to false
--
-- Returns:
-- number: higher scores indicate better matches. See also `get_score_min`
-- and `get_score_max`.
function fzy.score(needle, haystack, case_sensitive)
local n = string.len(needle)
local m = string.len(haystack)
if n == 0 or m == 0 or m > MATCH_MAX_LENGTH or n > m then
return SCORE_MIN
elseif n == m then
return SCORE_MAX
else
local D = {}
local M = {}
compute(needle, haystack, D, M, case_sensitive)
return M[n][m]
end
end
-- Compute the locations where fzy matches a string.
--
-- Determine where each character of the `needle` is matched to the `haystack`
-- in the optimal match.
--
-- Args:
-- needle (string): must be a subequence of `haystack`, or the result is
-- undefined.
-- haystack (string)
-- case_sensitive (bool, optional): defaults to false
--
-- Returns:
-- {int,...}: indices, where `indices[n]` is the location of the `n`th
-- character of `needle` in `haystack`.
-- number: the same matching score returned by `score`
function fzy.positions(needle, haystack, case_sensitive)
local n = string.len(needle)
local m = string.len(haystack)
if n == 0 or m == 0 or m > MATCH_MAX_LENGTH or n > m then
return {}, SCORE_MIN
elseif n == m then
local consecutive = {}
for i = 1, n do
consecutive[i] = i
end
return consecutive, SCORE_MAX
end
local D = {}
local M = {}
compute(needle, haystack, D, M, case_sensitive)
local positions = {}
local match_required = false
local j = m
for i = n, 1, -1 do
while j >= 1 do
if D[i][j] ~= SCORE_MIN and (match_required or D[i][j] == M[i][j]) then
match_required = (i ~= 1) and (j ~= 1) and (
M[i][j] == D[i - 1][j - 1] + SCORE_MATCH_CONSECUTIVE)
positions[i] = j
j = j - 1
break
else
j = j - 1
end
end
end
return positions, M[n][m]
end
-- Apply `has_match` and `positions` to an array of haystacks.
--
-- Args:
-- needle (string)
-- haystack ({string, ...})
-- case_sensitive (bool, optional): defaults to false
--
-- Returns:
-- {{idx, positions, score}, ...}: an array with one entry per matching line
-- in `haystacks`, each entry giving the index of the line in `haystacks`
-- as well as the equivalent to the return value of `positions` for that
-- line.
function fzy.filter(needle, haystacks, case_sensitive)
local result = {}
local idx = 1
for line in haystacks() do
if fzy.has_match(needle, line, case_sensitive) then
local p, s = fzy.positions(needle, line, case_sensitive)
table.insert(result, vim.list({idx, vim.list(p), s}))
end
idx = idx + 1
end
table.sort(result, function(a,b) return a[3] > b[3] end)
return vim.list(result)
end
-- The lowest value returned by `score`.
--
-- In two special cases:
-- - an empty `needle`, or
-- - a `needle` or `haystack` larger than than `get_max_length`,
-- the `score` function will return this exact value, which can be used as a
-- sentinel. This is the lowest possible score.
function fzy.get_score_min()
return SCORE_MIN
end
-- The score returned for exact matches. This is the highest possible score.
function fzy.get_score_max()
return SCORE_MAX
end
-- The maximum size for which `fzy` will evaluate scores.
function fzy.get_max_length()
return MATCH_MAX_LENGTH
end
-- The minimum score returned for normal matches.
--
-- For matches that don't return `get_score_min`, their score will be greater
-- than than this value.
function fzy.get_score_floor()
return MATCH_MAX_LENGTH * SCORE_GAP_INNER
end
-- The maximum score for non-exact matches.
--
-- For matches that don't return `get_score_max`, their score will be less than
-- this value.
function fzy.get_score_ceiling()
return MATCH_MAX_LENGTH * SCORE_MATCH_CONSECUTIVE
end
-- The name of the currently-running implmenetation, "lua" or "native".
function fzy.get_implementation_name()
return "lua"
end
return fzy
@@ -1,18 +0,0 @@
if HasPlug('github-nvim-theme') then
require('aerial').setup({
-- optionally use on_attach to set keymaps when aerial has attached to a buffer
layout = {
width = 50,
default_direction = "right",
preserve_equality = true,
},
on_attach = function(bufnr)
-- Jump forwards/backwards with '{' and '}'
vim.keymap.set('n', '{', '<cmd>AerialPrev<CR>', { buffer = bufnr })
vim.keymap.set('n', '}', '<cmd>AerialNext<CR>', { buffer = bufnr })
end
})
-- You probably also want to set a keymap to toggle aerial
vim.keymap.set('n', '<leader>v', '<cmd>AerialToggle!<CR>')
end
@@ -1,13 +0,0 @@
if HasPlug('github-nvim-theme') then
-- Example config in Lua
require("github-theme").setup({
-- Overwrite the highlight groups
overrides = function(c)
return {
NormalFloat = { link = 'Pmenu' },
}
end
})
end
@@ -1,50 +0,0 @@
if HasPlug('gitsigns.nvim') then
require('gitsigns').setup({
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map('n', ']c', function()
if vim.wo.diff then return ']c' end
vim.schedule(function() gs.next_hunk() end)
return '<Ignore>'
end, { expr = true })
map('n', '[c', function()
if vim.wo.diff then return '[c' end
vim.schedule(function() gs.prev_hunk() end)
return '<Ignore>'
end, { expr = true })
-- Actions
map({ 'n', 'v' }, '<leader>hs', ':Gitsigns stage_hunk<CR>')
map({ 'n', 'v' }, '<leader>hr', ':Gitsigns reset_hunk<CR>')
map('n', '<leader>hS', gs.stage_buffer)
map('n', '<leader>hu', gs.undo_stage_hunk)
map('n', '<leader>hR', gs.reset_buffer)
map('n', '<leader>hp', gs.preview_hunk)
map('n', '<leader>hb', function() gs.blame_line { full = true } end)
map('n', '<leader>tb', gs.toggle_current_line_blame)
map('n', '<leader>hd', gs.diffthis)
map('n', '<leader>hD', function() gs.diffthis('~') end)
map('n', '<leader>td', gs.toggle_deleted)
-- Text object
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
end
})
vim.fn['theme#addCleanBg']({ 'GitSignsAdd', 'GitSignsStagedChange',
'GitSignsStagedDelete', 'GitSignsDelete', 'GitSignsChange',
'GitGutterAdd', 'GitGutterChange', 'GitGutterDelete', 'GitGutterChangeDelete',
})
end
@@ -1,4 +0,0 @@
if HasPlug('impatient.nvim') then
require('impatient')
end
@@ -1,12 +0,0 @@
if not Animation_enable then
if HasPlug('indent-blankline.nvim') then
-- Example config in Lua
require("ibl").setup {
exclude = {
buftypes = {"lspinfo", "packer", "checkhealth",
"help", "man", "", "startify"},
}
}
end
end
@@ -1,60 +0,0 @@
-------------------OPTIONS-----------------------
-- enable animation of command like "<C-u>" and "<C-d>", or cursor
-- jump animation. (Performence will be effected)
Animation_enable = vim.g.animation_enable
High_performence = vim.g.high_performence
-- false basicly enable plugins like noice, nvim-notify etc.
Classic_vim_ui = vim.g.classic_vim_ui
------------------VIM OPTIONS-----------------------
vim.o.signcolumn = 'auto:2'
------------------UTILITIES----------------------
Vim_version = vim.version()
Vim_version_minor = Vim_version['minor']
function HasPlug(name)
return vim.fn['utils#hasplug'](name)
end
-- use to print object
function _G.put(...)
local objects = {}
for i = 1, select('#', ...) do
local v = select(i, ...)
table.insert(objects, vim.inspect(v))
end
print(table.concat(objects, '\n'))
return ...
end
Which_key = nil
function Wk_register(opt)
if Which_key == nil then
return
end
Which_key.register(opt)
end
Show_icon = false
if HasPlug('nvim-web-devicons') then
Show_icon = true
end
----------------CONFIGURATION--------------------
local plugin_setting_paths = vim.fn.split(vim.fn.glob(vim.g.dotvimdir
.. "/lua/lua-plugin-settings/*config.lua"), '\n')
local plugin_settings = vim.fn.map(plugin_setting_paths, 'fnamemodify(v:val, ":t:r")')
for _idx, name in pairs(plugin_settings) do
require('lua-plugin-settings.'..name)
end
@@ -1,50 +0,0 @@
if HasPlug('iron.nvim') then
local iron = require("iron.core")
iron.setup {
config = {
-- Whether a repl should be discarded or not
scratch_repl = true,
-- Your repl definitions come here
repl_definition = {
sh = {
-- Can be a table or a function that
-- returns a table (see below)
command = { "zsh" }
}
},
-- How the repl window will be displayed
-- See below for more information
repl_open_cmd = require('iron.view').bottom(40),
},
-- Iron doesn't set keymaps by default anymore.
-- You can set them here or manually add keymaps to the functions in iron.core
keymaps = {
send_motion = "<space>sc",
visual_send = "<space>sc",
send_file = "<space>sf",
send_line = "<space>sl",
send_mark = "<space>sm",
mark_motion = "<space>mc",
mark_visual = "<space>mc",
remove_mark = "<space>md",
cr = "<space>s<cr>",
interrupt = "<space>s<space>",
exit = "<space>sq",
clear = "<space>cl",
},
-- If the highlight is on, you can change how it looks
-- For the available options, check nvim_set_hl
highlight = {
italic = true
},
ignore_blank_lines = true, -- ignore blank lines when sending visual select lines
}
-- iron also has a list of commands, see :h iron-commands for all available commands
vim.keymap.set('n', '<space>rs', '<cmd>IronRepl<cr>')
vim.keymap.set('n', '<space>rr', '<cmd>IronRestart<cr>')
vim.keymap.set('n', '<space>rf', '<cmd>IronFocus<cr>')
vim.keymap.set('n', '<space>rh', '<cmd>IronHide<cr>')
end
@@ -1,4 +0,0 @@
if HasPlug('leap.nvim') then
require('leap').add_default_mappings()
end
@@ -1,108 +0,0 @@
if HasPlug('lualine.nvim') then
-- custom lualine plugin show coc lsp status
local function cocstatus()
local loading = { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" }
local step = #loading
local ok, result = pcall(vim.fn.CocAction, 'services')
if not ok then
return
end
local ft = vim.bo.filetype
local state, id
for _, entry in ipairs(result) do
if entry['languageIds'][1] == ft then
state = entry['state']
id = entry['id']
break
end
end
local speed = 1600
local loadidx = (vim.loop.now() % speed)
local msg = id
if state == "starting" then
return msg .. " " .. loading[math.floor(loadidx / (step * (speed / 100))) + 1]
elseif state == "running" then
return msg
end
return ''
end
local _section_x = {}
local _section_y = {}
-- if HasPlug('coc.nvim') then table.insert(_section_x, cocstatus) end
table.insert(_section_x, cocstatus)
local disabled_filetypes_data = {}
if Vim_version_minor < 7 then
-- globalstatus only work for nvim >= 0.7
disabled_filetypes_data = { -- Filetypes to disable lualine for.
statusline = {}, -- only ignores the ft for statusline.
winbar = {}, -- only ignores the ft for winbar.
'NvimTree',
'vista',
}
end
local opt = {
options = {
icons_enabled = Show_icon,
theme = 'auto', -- lualine theme
-- component_separators = { left = '', right = ''},
-- section_separators = { left = '', right = ''},
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
always_divide_middle = false,
globalstatus = true,
disabled_filetypes = disabled_filetypes_data,
refresh = { statusline = 200 }
},
sections = {
lualine_a = { 'mode' },
lualine_b = {},
lualine_c = {
{
'buffers',
mode = 2,
max_length = function()
return vim.o.columns - 30
end,
filetype_names = {
TelescopePrompt = 'Telescope',
dashboard = 'Dashboard',
packer = 'Packer',
fzf = 'FZF',
alpha = 'Alpha',
NvimTree = 'NvimTree',
vista = 'Vista',
},
symbols = {
alternate_file = '',
},
}
},
-- lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_x = _section_x,
lualine_y = _section_y,
lualine_z = { 'location' }
},
}
require('lualine').setup(opt)
vim.fn['theme#addTransGroup']({'lualine_c_inactive', 'lualine_c_normal'})
vim.o.fillchars ='eob: ,vert:│,stl: ,stlnc: ,'
for i = 1, 9 do
-- :nnoremap <silent> <Leader>1 :LualineBuffersJump 1<CR>
vim.api.nvim_set_keymap('n', '<Leader>' .. i, ':LualineBuffersJump ' .. i .. '<CR>',
{ noremap = true, silent = true, nowait = true })
end
for i = 10, 20 do
-- :nnoremap <silent> <Leader>1 :LualineBuffersJump 1<CR>
vim.api.nvim_set_keymap('n', '<Space>' .. i, ':LualineBuffersJump ' .. i .. '<CR>',
{ noremap = true, silent = true, nowait = true })
end
end
@@ -1,30 +0,0 @@
if HasPlug('mini.animate') and Animation_enable then
local animate = require('mini.animate')
animate.setup({
cursor = {
-- Whether to enable this animation
enable = true,
-- Timing of animation (how steps will progress in time)
-- timing = --<function: implements linear total 250ms animation duration>,
},
scroll = {
-- Whether to enable this animation
enable = true,
-- Timing of animation (how steps will progress in time)
timing = animate.gen_timing.linear({ duration = 150, unit = 'total' }),
},
open = {
-- Whether to enable this animation
enable = false,
},
})
vim.api.nvim_create_autocmd("FileType", {
pattern = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason",
"NvimTree", "vista", "toggleterm", "noice" },
callback = function()
vim.b.minianimate_disable = true
end,
})
end
@@ -1,4 +0,0 @@
if HasPlug('mini.colors') then
require('mini.colors').setup()
end
@@ -1,21 +0,0 @@
if HasPlug('mini.indentscope') then
MiniIndentscope = require('mini.indentscope')
MiniIndentscope.setup({
symbol = '│',
-- draw = {
-- animation = MiniIndentscope.gen_animation.linear({
-- easing = 'out',
-- duration = 150,
-- unit = 'total'
-- })
-- },
})
vim.api.nvim_create_autocmd("FileType", {
pattern = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason",
"NvimTree", "vista", "startify", "toggleterm" },
callback = function()
vim.b.miniindentscope_disable = true
end,
})
end
@@ -1,47 +0,0 @@
if not Classic_vim_ui
and HasPlug('noice.nvim')
and HasPlug('nvim-notify')
and HasPlug('nui.nvim') then
require("noice").setup({
lsp = {
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true,
},
},
presets = {
bottom_search = true, -- use a classic bottom cmdline for search
-- command_palette = true, -- position the cmdline and popupmenu together
long_message_to_split = true, -- long messages will be sent to a split
inc_rename = false, -- enables an input dialog for inc-rename.nvim
lsp_doc_border = false, -- add a border to hover docs and signature help
},
cmdline = {
enabled = true, -- enables the Noice cmdline UI
view = "cmdline", -- view for rendering the cmdline. Change to `cmdline` to get a classic cmdline at the bottom
opts = {}, -- global options for the cmdline. See section on views
format = {
-- cmdline = false,
search_down = false,
search_up = false,
help = { pattern = '', icon = '' },
},
},
messages = {
-- NOTE: If you enable messages, then the cmdline is enabled automatically.
-- This is a current Neovim limitation.
enabled = true, -- enables the Noice messages UI
view = "notify", -- default view for messages
view_error = "notify", -- view for errors
view_warn = "notify", -- view for warnings
view_history = "messages", -- view for :messages
view_search = false, -- view for search count messages. Set to `false` to disable
},
})
vim.fn['theme#addTransGroup']({'NotifyERRORBody', 'NotifyWARNBody', 'NotifyINFOBody', 'NotifyDEBUGBody', 'NotifyTRACEBody',
'NotifyERRORBorder', 'NotifyWARNBorder', 'NotifyINFOBorder', 'NotifyDEBUGBorder', 'NotifyTRACEBorder'})
end
@@ -1,17 +0,0 @@
if HasPlug('nvim-scrollbar') then
require("scrollbar").setup({
excluded_filetypes = {
"prompt",
"TelescopePrompt",
"noice",
"startify",
"vista",
},
excluded_buftypes = {
"terminal",
"nofile",
"help",
},
})
end
@@ -1,68 +0,0 @@
if HasPlug('nvim-tree.lua') then
local api = require('nvim-tree.api')
local M = {}
function M.print_node_path()
local node = api.tree.get_node_under_cursor()
print(node.absolute_path)
end
function M.on_attach(bufnr)
local function opts(desc)
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
-- vim.keymap.set('n', 'u', api.node.navigate.parent, opts('Parent Directory'))
vim.keymap.set('n', 'u', api.tree.change_root_to_parent, opts('Up'))
vim.keymap.set('n', 'a', api.fs.create, opts('Create'))
vim.keymap.set('n', 'dd', api.fs.remove, opts('Delete'))
vim.keymap.set('n', 'rn', api.fs.rename_basename, opts('Rename: Basename'))
vim.keymap.set('n', 'I', api.tree.toggle_gitignore_filter, opts('Toggle Git Ignore'))
vim.keymap.set('n', 'cd', api.tree.change_root_to_node, opts('CD'))
vim.keymap.set('n', 'X', api.tree.collapse_all, opts('Collapse'))
vim.keymap.set('n', 'O', api.tree.expand_all, opts('Expand All'))
vim.keymap.set('n', 'p', M.print_node_path, opts('Print node path'))
vim.keymap.set('n', 'o', api.node.open.edit, opts('Open'))
vim.keymap.set('n', '<CR>', api.node.open.edit, opts('Open'))
end
vim.api.nvim_set_keymap('n', '<Leader>e', ':NvimTreeFindFileToggle<CR>',
{ desc = 'Toggle nvim-tree', noremap = true, silent = true, nowait = true })
require("nvim-tree").setup({
sync_root_with_cwd = true,
respect_buf_cwd = true,
update_focused_file = {
enable = true,
update_root = true,
},
sort_by = "case_sensitive",
on_attach = M.on_attach,
view = {
width = 30,
},
filters = {
dotfiles = false,
},
git = {
ignore = false,
},
actions = {
open_file = {
quit_on_open = true,
resize_window = true,
window_picker = {
exclude = {
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame", "vista" },
buftype = { "nofile", "terminal", "help" },
},
},
},
},
})
vim.fn['theme#addTransGroup']({'NvimTreeWinSeparator', 'NvimTreeNormal', 'NvimTreeNormalNC'})
end
@@ -1,17 +0,0 @@
if HasPlug('nvim-treesitter') then
require('nvim-treesitter.configs').setup {
ensure_installed = { "c", "bash", "lua", "python", "vim" },
sync_install = false,
auto_install = true,
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
indent = {
enable = true
}
}
vim.o.foldmethod = 'expr'
vim.o.foldexpr = 'nvim_treesitter#foldexpr()'
end
@@ -1,26 +0,0 @@
if HasPlug('project.nvim') then
require("project_nvim").setup {
detection_methods = { "lsp", "pattern" },
patterns = { ".git" },
-- Don't calculate root dir on specific directories
-- Ex: { "~/.cargo/*", ... }
exclude_dirs = {},
-- Show hidden files in telescope
show_hidden = false,
-- When set to false, you will get a message when project.nvim changes your
-- directory.
silent_chdir = true,
-- Path where project.nvim will store the project history for use in
-- telescope
datapath = vim.g.vim_dir .. "/.vimproject/"
}
-- if HasPlug('telescope.nvim') then
-- require('telescope').load_extension('projects')
-- vim.keymap.set('n', '<leader>fp', require'telescope'.extensions.projects.projects,
-- { desc = "Lists projects" })
-- end
end
@@ -1,109 +0,0 @@
if HasPlug('telescope.nvim') then
local actions = require("telescope.actions")
local action_state = require "telescope.actions.state"
local telescope = require("telescope")
local builtin = require('telescope.builtin')
local telescopeConfig = require("telescope.config")
local vimgrep_arguments = { unpack(telescopeConfig.values.vimgrep_arguments) }
table.insert(vimgrep_arguments, "--hidden")
require('telescope.pickers.layout_strategies').horizontal_merged = function(picker, max_columns, max_lines,
layout_config)
local layout = require('telescope.pickers.layout_strategies').horizontal(picker, max_columns, max_lines,
layout_config)
layout.prompt.title = ''
layout.results.title = ''
-- layout.prompt.borderchars = { '─', '│', '─', '│', '┌', '┐', '┘', '└' }
return layout
end
telescope.setup {
pickers = {
colorscheme = {
enable_preview = true,
mappings = {
i = {
["<CR>"] = function(bufnr)
local selection = action_state.get_selected_entry()
actions.select_default()
local bg = vim.o.background
vim.fn['theme#setColor'](bg, selection.value)
end,
},
},
}
},
defaults = {
hidden = true,
vimgrep_arguments = vimgrep_arguments,
file_ignore_patterns = {"^node_modules/", "^.git/"},
layout_config = {
-- prompt_position = "top",
},
layout_strategy = "horizontal_merged",
},
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
}
}
}
if HasPlug('telescope-fzf-native.nvim') then
telescope.load_extension('fzf')
end
vim.fn['theme#addCleanBg']({ 'TelescopeNormal', 'TelescopeBorder', 'TelescopePromptNormal',
'TelescopePromptBorder', 'TelescopePromptPrefix', 'TelescopeResultsTitle', 'TelescopePreviewTitle',
'TelescopePromptTitle', 'TelescopePromptCounter' })
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = "Search files inside cwd" })
-- need to install ripgrep
vim.keymap.set('n', '<leader>fr', builtin.live_grep, { desc = "Regex search inside files" })
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = "Search buffers" })
vim.keymap.set('n', '<leader>fc', builtin.colorscheme, { desc = "Search colorscheme" })
vim.keymap.set('n', '<leader>fs', builtin.treesitter, { desc = "Lists Function names, variables, from Treesitter!" })
vim.keymap.set('n', '<leader>fh', builtin.highlights, { desc = "Lists highlight" })
vim.keymap.set('n', '<leader>fd', builtin.help_tags, { desc = "Lists highlight" })
Wk_register({ ["<leader>f"] = { name = "+Telescope" } })
vim.api.nvim_create_autocmd("User", {
pattern = "TelescopePreviewerLoaded",
command = "setlocal wrap number"
})
-- options picker
local pickers = require "telescope.pickers"
local finders = require "telescope.finders"
local conf = require("telescope.config").values
function _G.telescope_option_picker()
local opts = require("telescope.themes").get_dropdown {}
pickers.new(opts, {
prompt_title = "Options",
finder = finders.new_table {
results = vim.fn['options#getAll'](),
entry_maker = function(entry)
return {
value = entry,
display = entry[2],
ordinal = entry[2],
}
end
},
sorter = conf.generic_sorter(opts),
attach_mappings = function(prompt_bufnr, map)
actions.select_default:replace(function()
actions.close(prompt_bufnr)
local selection = action_state.get_selected_entry()
vim.fn['options#toggle'](selection['value'][1])
end)
return true
end,
}):find()
end
vim.keymap.set('n', '<leader>fo', telescope_option_picker, { desc = "Lists Function names, variables, from Treesitter!" })
end
@@ -1,79 +0,0 @@
if HasPlug('toggleterm.nvim') then
require("toggleterm").setup({
open_mapping = [[<c-\>]],
direction = 'float',
float_opts = {
border = 'rounded',
width = function(term) return math.floor(vim.o.columns * 0.5) end,
height = function(term) return math.floor(vim.o.lines * 0.5) end,
winblend = 20,
row = vim.o.lines * 0.5 - 3,
col = vim.o.columns * 0.5,
},
})
function _G.set_terminal_keymaps()
local opts = { buffer = 0 }
vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
vim.keymap.set('t', 'jk', [[<C-\><C-n>]], opts)
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
vim.keymap.set('t', '<C-w>', [[<C-\><C-n><C-w>]], opts)
end
-- vim.cmd('autocmd TermOpen term://* lua set_terminal_keymaps()')
vim.cmd('autocmd FileType toggleterm lua set_terminal_keymaps()')
local Terminal = require('toggleterm.terminal').Terminal
local ipythonId = 779
local ipython = Terminal:new({
size = function(term)
if term.direction == "horizontal" then
return 15 elseif term.direction == "vertical" then
return vim.o.columns * 0.4
end
end,
cmd = "ipython",
hidden = true,
direction = "vertical",
close_on_exit = false,
auto_scroll = true,
id = ipythonId,
})
function _ipython_toggle()
local currentWindow=vim.fn.winnr()
ipython:toggle(vim.o.columns * 0.5, 'vertical')
vim.cmd(currentWindow .. "wincmd w")
end
vim.api.nvim_set_keymap("n", "<leader>tp", "<cmd>lua _ipython_toggle()<CR>", { noremap = true, silent = true })
vim.api.nvim_set_keymap("n", "<leader>tl", string.format("<cmd>ToggleTermSendCurrentLine %d<CR>", ipythonId),
{ noremap = true, silent = true })
-- sends all the (whole) lines in your visual selection
vim.api.nvim_set_keymap("v", "<leader>tl", string.format(":ToggleTermSendVisualLines %d<CR>", ipythonId),
{ noremap = true, silent = true })
-- sends only the visually selected text (this can be a block of text
vim.api.nvim_set_keymap("x", "<leader>tl", string.format(":ToggleTermSendVisualSelection %d<CR>", ipythonId),
{ noremap = true, silent = true })
print(vim.o.shell)
if vim.o.shell == 'pwsh' or vim.o.shell == 'powershell' then
local powershell_options = {
shellcmdflag = "-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;",
shellredir = "-RedirectStandardOutput %s -NoNewWindow -Wait",
shellpipe = "2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode",
shellquote = "",
shellxquote = "",
}
for option, value in pairs(powershell_options) do
vim.opt[option] = value
end
end
end
@@ -1,30 +0,0 @@
if HasPlug('vim-illuminate') then
local illuminate = require('illuminate')
illuminate.configure({
providers = {
'lsp',
'treesitter',
'regex',
},
delay = 0,
filetype_overrides = {},
filetypes_denylist = {
'dirvish',
'fugitive',
'NvimTree',
'help',
'vista',
'aerial',
},
filetypes_allowlist = {},
modes_denylist = {},
modes_allowlist = {},
providers_regex_syntax_denylist = {},
providers_regex_syntax_allowlist = {},
under_cursor = true,
large_file_cutoff = nil,
large_file_overrides = nil,
min_count_to_highlight = 1,
})
end
@@ -1,11 +0,0 @@
if HasPlug('which-key.nvim') then
Which_key = require("which-key")
Which_key.setup({
triggers_blacklist = {
i = { "j", "k" },
v = { "j", "k" },
c = { "w" },
},
})
end
-9
View File
@@ -1,9 +0,0 @@
if exists("g:loaded_vim_config")
finish
endif
let g:loaded_vim_config = 1
let os = os#getOS()
call options#init()
@@ -1,6 +0,0 @@
if utils#hasplug('Copilot.vim')
" imap <expr> <C-n> <Plug>(copilot-next)
" imap <expr> <C-p> <Plug>(copilot-prev)
endif
@@ -1,8 +0,0 @@
if utils#hasplug('coc-fzf')
let g:coc_fzf_preview = 'right:50%'
nnoremap <silent> <leader>fs :CocFzfList outline<CR>
let s:preview_exe = expand(g:dotvimdir.'/bin/preview.py')
let g:coc_fzf_opts = ['--border-label', 'Coc Outlines', '--border-label-pos', '9', '--no-scrollbar', '--no-hscroll', '--no-separator']
endif
@@ -1,184 +0,0 @@
if utils#hasplug('coc.nvim')
" let g:coc_global_extensions = ['coc-pyright', 'coc-tsserver', 'coc-vimlsp',
" \ 'coc-marksman']
" for tabline info
" coc-sumneko-lua offers autocomplete for neovim lua api
let g:coc_global_extensions = ['coc-nav', 'coc-sumneko-lua']
" warning that coc work best for vim >= 8.3
let g:coc_disable_startup_warning = 1
let g:coc_data_home = g:vim_dir . '/coc'
let g:coc_config_home = g:vim_dir . '/coc'
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
set updatetime=300
" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
endif
endfunction
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <space>f <Plug>(coc-format-selected)
nmap <space>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif
" Mappings for CoCList
" Show all diagnostics.
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions.
" nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
" Show commands.
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document.
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols.
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list.
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
"COC LSP SETTING
let g:coc_user_config = {
\ 'suggest.noselect': v:true,
\ 'suggest.enablePreselect': v:false, }
call coc#config("java.jdt.ls.vmargs", '-javaagent:' . g:dotfiledir . '/config/coc/java/lombok-1.18.26.jar')
call coc#config("java.jdt.ls.lombokSupport.enabled", v:false)
call coc#config("java.inlayHints.parameterNames.enabled", v:false)
call coc#config("inlayHint.enable", v:false)
if has('nvim')
" nvim has tree-sitter
call coc#config("semanticTokens.enable", v:false)
else
call coc#config("semanticTokens.enable", v:true)
endif
call coc#config("sumneko-lua.enableNvimLuaDev", v:true)
for section in ['suggest', 'diagnostic', 'signature', 'hover']
call coc#config(section.'.floatConfig.border', v:true)
call coc#config(section.'.floatConfig.rounded', v:true)
call coc#config(section.'.floatConfig.highlight', 'Normal')
" transparent setting (only for neovim)
" call coc#config(section.'.floatConfig.winblend', 6)
endfor
function! CocHighlight()
hi! CocErrorHighlight guifg=#E74C3C term=underline,bold gui=underline,bold cterm=underline,bold
hi! CocErrorSign guifg=#E74C3C
hi! CocWarningHighlight guifg=#E74C3C term=underline gui=underline cterm=underline
hi! CocWarningSign guifg=#E67E22
hi CocInfoHighlight term=underline gui=underline cterm=underline
hi CocHintHighlight term=underline gui=underline cterm=underline
hi CocUnusedHighlight term=underline gui=underline cterm=underline
endfunction
call theme#addCleanBg(['CocWarningSign', 'CocErrorSign'])
augroup CocHighlight
autocmd!
autocmd ColorScheme * call CocHighlight()
augroup END
function! Breadcrumbs()
if ! exists('b:coc_nav')
return ''
endif
let items = b:coc_nav
" let t = '  '
let t = ' '
let c = 0
for obj in items
let hi = obj['highlight']
let name = obj['name']
if c == 0
let t ..= '%#'.. hi ..'#' .. name .. '%#Normal#'
else
let t ..= '  %#'.. hi ..'#' .. name .. '%#Normal#'
endif
let c += 1
endfor
return t
endfunction
func! s:sigbar_enable()
set tabline=%#Normal#🌠%{%Breadcrumbs()%}
set showtabline=2
endfunc
func! s:sigbar_disable()
set tabline=
set showtabline=1
endfunc
" set tabline=%=%#Normal#%=%{%Breadcrumbs()%}
" set showtabline=2
let sigbar_opt = {
\ 'desc': 'Show function signature bar',
\ 'enablefunc': function('s:sigbar_enable'),
\ 'disablefunc': function('s:sigbar_disable'),
\ 'isEnabled': 0,
\ }
call options#add('signature bar', sigbar_opt)
call theme#addTransGroup(['CocFloating'])
endif
@@ -1,3 +0,0 @@
if utils#hasplug('coc.nvim')
let g:codi#virtual_text = 0
endif
@@ -1,4 +0,0 @@
if utils#hasplug('ctrlp.vim')
let g:ctrlp_map = '<leader>ff'
endif
@@ -1,32 +0,0 @@
if utils#hasplug('everforest')
let g:everforest_better_performance = 1
let g:everforest_background = 'hard'
" let g:everforest_enable_italic = 1
function! Everforest_trans_enable()
let g:everforest_transparent_background = 2
colorscheme everforest
call theme#setStlColor(&background, 'everforest')
" hack to fix caret characters appearing in the statusline when StatusLine
" and StatusLineNC has same highlight(https://vi.stackexchange.com/questions/15873/carets-in-status-line)
hi StatusLine guifg=#d3c6aa ctermfg=223
endfunction
function! Everforest_trans_disable()
let g:everforest_transparent_background = 0
colorscheme everforest
call theme#setStlColor(&background, 'everforest')
endfunction
function! CB_dark_tb_enable_everforest()
call Everforest_trans_enable()
endfunction
function! CB_light_tb_enable_everforest()
call Everforest_trans_enable()
endfunction
function! CB_dark_tb_disable_everforest()
call Everforest_trans_disable()
endfunction
function! CB_light_tb_disable_everforest()
call Everforest_trans_disable()
endfunction
endif
@@ -1,121 +0,0 @@
if utils#hasplug("fzf") && utils#hasplug("fzf.vim")
" [Buffers] Jump to the existing window if possible
let g:fzf_buffers_jump = 1
"let $FZF_DEFAULT_COMMAND='find . \( -name node_modules -o -name .git \) -prune -o -print'
" - CTRL-/ will toggle preview window.
let g:fzf_preview_window = ['right:50%']
hi! fzfborderhi term=bold cterm=bold ctermbg=236 gui=bold guibg=#272c42
hi! fzfqueryhi term=underline cterm=underline gui=underline
let g:fzf_force_termguicolors = 1
if g:os != 'Windows'
let $FZF_DEFAULT_COMMAND = "find . -type f -not -path '*/\.git/*'"
endif
let s:preview_exe = expand(g:dotvimdir.'/bin/preview.py')
let s:color_opts = ['--color', 'gutter:-1,bg+:-1,bg:-1,preview-bg:-1,preview-fg:-1,fg+:-1']
" check if ripgrep is installed
function! FzfRg()
let s:previewcmd = join([utils#get_usable_py(), s:preview_exe, &bg, '{}'])
if ! executable('rg')
let cmd = 'grep -R --line-number --exclude-dir=".git;.svn" --color=always -- '.shellescape('')
else
let cmd = "rg --column --line-number --no-heading --color=always --smart-case -- ".shellescape('')
endif
let options = s:color_opts + ['--border-label', 'Grep', '--border-label-pos', '9', '--no-scrollbar',
\ '--no-hscroll', '--no-separator', '--preview', s:previewcmd]
let with_preview = fzf#vim#with_preview()
if len(with_preview) == 0
let with_preview = {'options':['--preview-window','right:50%' ] + options}
else
" make fzf preview repect colorsheme
let with_preview.options = with_preview.options[:-3] + options
endif
call fzf#vim#grep(cmd, 1, with_preview, 0)
endfunction
function! FzfFiles(...)
let s:previewcmd = join([utils#get_usable_py(), s:preview_exe, &bg, '{}'])
let options = s:color_opts + ['--border-label', 'Files', '--border-label-pos', '9', '--no-scrollbar',
\ '--no-hscroll', '--no-separator', '--preview', s:previewcmd]
let with_preview = fzf#vim#with_preview()
if len(with_preview) == 0
" in windows with_preview return empty dict
let with_preview = {'options':['--preview-window','right:50%' ] + options}
else
let with_preview.options = with_preview.options[:-3] + options
endif
let dir = ''
if a:0 >= 1 && isdirectory(expand(a:1))
let dir = a:1
endif
call fzf#vim#files(dir, with_preview, 0)
endfunction
function! FzfColorSelect(color_name)
call theme#setColor(&bg, a:color_name)
endfunction
function! FzfAirlineColorSelect(color_name)
call theme#setStlColor(&background, a:color_name)
endfunction
let $FZF_DEFAULT_OPTS='--color=' . s:color_opts[1]
function! FzfHelpTags()
let s:previewcmd = join([utils#get_usable_py(), s:preview_exe, &bg, '{}'])
let options = s:color_opts + ['--border-label', 'Files', '--border-label-pos', '9', '--no-scrollbar',
\ '--no-hscroll', '--no-separator']
let with_preview = fzf#vim#with_preview({ "placeholder": "--tag {2}:{3}:{4}" })
if len(with_preview) == 0
" in windows with_preview return empty dict
let with_preview = {'options':['--preview-window','right:50%' ] + options}
else
let with_preview.options = with_preview.options + options
endif
call fzf#vim#helptags(with_preview, 0)
endfunction
let s:optionmap = {}
let s:feedfzf = []
func! s:optioncb(str)
call options#toggle(s:optionmap[a:str])
endfunc
func! FzfOptions()
let s:feedfzf = []
let s:optsource = options#getAll()
for e in s:optsource
let s:optionmap[e[1]] = e[0]
call add(s:feedfzf, e[1])
endfor
call fzf#run(fzf#wrap({
\ 'source': s:feedfzf,
\ 'sink': function('s:optioncb'),
\ 'options': ['--border-label', 'Options'],
\ 'window': { 'width': 0.4, 'height': 0.6 }
\ }))
endfunc
" noremap <leader>fo :call FzfOptions()<CR>
" noremap <leader>fr :call FzfRg()<CR>
" noremap <leader>ff :call FzfFiles()<CR>
noremap <leader>fh :call FzfHelpTags()<CR>
" noremap <leader>fb :BLines<CR>
noremap <leader>fu :call FzfFiles('~')<CR>
if utils#hasplug('fzf-color-preview')
let g:FzfColorComfirmCb = function('FzfColorSelect')
let g:FzfAirlineComfirmCb = function('FzfAirlineColorSelect')
noremap <leader>fa :AirlinePreview<CR>
noremap <leader>fc :ColorsPreview<CR>
else
noremap <leader>fc :Colors<CR>
endif
endif
@@ -1,16 +0,0 @@
if utils#hasplug('goyo.vim')
nnoremap <leader><leader>g :Goyo<CR>
let g:goyo_width= floor(&co * 0.65)
function! s:fix()
" resize the goyo after being messed up by other plugins
au BufEnter * if winnr('$') == '5' | exe "normal \<c-w>=" | endif
endfunction
augroup GoyoAu
au!
augroup END
autocmd User GoyoEnter au GoyoAu BufEnter * if winnr('$') == '5' | exe "normal \<c-w>=" | endif
autocmd User GoyoLeave augroup GoyoAu | au! | augroup END
endif
@@ -1,5 +0,0 @@
if utils#hasplug('indentLine')
let g:indentLine_char = '│'
let g:indentLine_setConceal = 0
endif
@@ -1,136 +0,0 @@
" giveup
if utils#hasplug('lightline.vim')
set noshowmode
set laststatus=2
" enable bufferline
" let g:bufferline_echo = 1
let g:bufferline_inactive_highlight = 'Search'
let g:bufferline_active_highlight = 'Search'
let g:bufferline_forbided_col = 32
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode'],
\ [ 'bufferline'] ],
\ 'right': [['lineinfo'], ['cocstatus']],
\ },
\ 'inactive': {
\ 'left': [],
\ 'right': [],
\ },
\ 'component_expand': {
\ 'bufferline': 'BufferlineStr',
\ },
\ 'component_function': {
\ 'cocstatus': 'AirlineCocStatus',
\ },
\ }
function! s:restore()
let g:lightline.active = {
\ 'left': [ [ 'mode'],
\ [ 'bufferline'] ],
\ 'right': [['lineinfo'], ['cocstatus']],
\ }
call lightline#init()
call lightline#update()
endfunction
let s:special_ft = ['nerdtree', 'vista']
let s:special_bt = ['nofile']
function! s:lightlineInit()
let g:lightline.active = {
\ 'left': [],
\ 'right': [],
\ }
call lightline#init()
call lightline#update()
echom 'hello'. &bt
autocmd WinLeave * ++once call s:restore()
endfunction
" \ 'bufferline': 'lightline#bufferline#buffers'
augroup Lightline
autocmd!
" autocmd BufWinEnter * call s:lightlineInit()
" autocmd WinNew * call s:funck()
autocmd FileType nerdtree call s:lightlineInit()
" autocmd BufWritePost,TextChanged,TextChangedI,BufNew,BufEnter * call lightline#update()
augroup END
function! BufferlineStr()
call bufferline#get_echo_string()
let s = bufferline#get_status_string()
return s
endfunction
function! s:lightline_update()
if !exists('g:loaded_lightline')
return
endif
try
if g:colors_name =~# 'wombat\|solarized\|landscape\|jellybeans\|seoul256\|Tomorrow'
let g:lightline.colorscheme =
\ substitute(substitute(g:colors_name, '-', '_', 'g'), '256.*', '', '')
call lightline#init()
call lightline#colorscheme()
call lightline#update()
endif
catch
endtry
endfunction
augroup LightlineColorscheme
autocmd!
autocmd ColorScheme * call s:lightline_update()
augroup END
function! AirlineCocStatus()
if ! exists('*CocAction')
return
endif
let loading = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
try
let result = CocAction('services')
catch
" call timer_start(200, {->execute('AirlineRefresh')})
return 'no coc '
endtry
let state = ''
let id = ''
for e in result
if e['languageIds'][0] == &ft
let state = e['state']
let id = e['id']
endif
endfor
if id == ''
return 'no lsp '
endif
" messy way to get time in millisecond in vim
let time = float2nr(str2float(reltime()->reltimestr()[4:]) * 1000)
let speed = 800
let loadidx = time % speed
let msg = id
if state == "starting"
if ! exists('s:cocstatustimer') || len(timer_info(s:cocstatustimer)) == 0
let s:cocstatustimer = timer_start(100, {->execute('AirlineRefresh')}, {'repeat': 800})
endif
return msg . " " . loading[loadidx/(speed/10)] . " "
elseif state == "running"
if exists('s:cocstatustimer')
call timer_stop(s:cocstatustimer)
unlet s:cocstatustimer
endif
return msg . " ✔ "
endif
return ''
endfunction
endif
@@ -1,13 +0,0 @@
if utils#hasplug('minimap.vim')
nnoremap <silent> mm :MinimapToggle<CR>
let g:minimap_highlight_search = 1
let g:minimap_git_colors = 1
let g:minimap_enable_highlight_colorgroup = 1
let g:minimap_block_filetypes = ['fugitive', 'nvim-tree', 'tagbar', 'fzf', 'telescope', 'NvimTree', 'nerdtree']
let g:minimap_block_buftypes = ['help', 'nerdtree', 'nofile', 'nowrite', 'quickfix', 'terminal', 'prompt', 'NvimTree']
let g:minimap_close_filetypes = ['startify', 'netrw', 'vim-plug', 'NvimTree']
let g:minimap_range_color = 'Visual'
let g:minimap_cursor_color = 'Cursor'
endif
@@ -1,53 +0,0 @@
if utils#hasplug('nerdtree')
if utils#hasplug('vim-nerdtree-syntax-highlight')
let g:NERDTreeLimitedSyntax = 1
endif
let g:NERDShutUp=1
" work around for nerdtree bug: https://github.com/preservim/nerdtree/issues/1321
let g:NERDTreeMinimalMenu = v:true
let g:NERDTreeMinimalUI = v:true
function! NERDTreeFindToggle()
let has_nerdtree = 0
let winfo = getwininfo()
for obj in winfo
let bufnr = obj['bufnr']
let ft = getbufvar(bufnr, '&filetype')
if ft == 'nerdtree'
let has_nerdtree = 1
break
endif
endfor
if has_nerdtree
:NERDTreeClose
else
" we cannot use NERDTreeFind on startify as it is not a file
if &ft == 'startify' || &ft == ''
:NERDTreeToggle
else
:NERDTreeFind
" NERDTreeToggleVCS
endif
endif
endfunction
nnoremap <silent> <leader>e :call NERDTreeFindToggle()<CR>
"let NERDTreeShowBookmarks=1
let NERDTreeChDirMode = 0
let NERDTreeQuitOnOpen = 1
let NERDTreeMouseMode = 2
let NERDTreeShowHidden = 1
" remapping
let g:NERDTreeMapOpenExpl = ''
if utils#hasplug('vim-devicons') || utils#hasplug('nerdfont.vim')
let NERDTreeDirArrowCollapsible = ''
let NERDTreeDirArrowExpandable = ''
else
" let NERDTreeDirArrowCollapsible = ''
" let NERDTreeDirArrowExpandable = ''
endif
" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
endif
@@ -1,24 +0,0 @@
if utils#hasplug('papercolor-theme')
function! CB_dark_tb_enable_PaperColor()
let g:PaperColor_Theme_Options = {
\ 'theme': {'default.dark': { 'transparent_background': 1 }}}
colorscheme PaperColor
endfunction
function! CB_light_tb_enable_PaperColor()
let g:PaperColor_Theme_Options = {
\ 'theme': {'default.light': { 'transparent_background': 1 }}}
colorscheme PaperColor
endfunction
function! CB_dark_tb_disable_PaperColor()
let g:PaperColor_Theme_Options = {
\ 'theme': {'default.dark': { 'transparent_background': 0 }}}
colorscheme PaperColor
endfunction
function! CB_light_tb_disable_PaperColor()
let g:PaperColor_Theme_Options = {
\ 'theme': {'default.light': { 'transparent_background': 0 }}}
colorscheme PaperColor
endfunction
endif
@@ -1,14 +0,0 @@
if utils#hasplug('tagbar')
let g:tagbar_width = 30
let g:tagbar_sort = 0
let g:tagbar_compact = 2
let g:tagbar_autoshowtag = 1
let g:tagbar_foldlevel = 99
let g:tagbar_no_status_line = 1
let g:tagbar_visibility_symbols = {
\ 'public' : '+',
\ 'protected' : '#',
\ 'private' : '-'
\ }
nnoremap <silent> <leader>v <cmd>TagbarToggle<CR>
endif
@@ -1,159 +0,0 @@
if utils#hasplug("vim-airline")
" Extensions
function! AirlineCocStatus()
if ! exists('*CocAction')
return
endif
let loading = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
try
let result = CocAction('services')
catch
" call timer_start(200, {->execute('AirlineRefresh')})
return 'no coc '
endtry
let state = ''
let id = ''
for e in result
if e['languageIds'][0] == &ft
let state = e['state']
let id = e['id']
endif
endfor
if id == ''
return 'no lsp '
endif
" messy way to get time in millisecond in vim
let time = float2nr(str2float(reltime()->reltimestr()[4:]) * 1000)
let speed = 800
let loadidx = time % speed
let msg = id
if state == "starting"
if ! exists('s:cocstatustimer') || len(timer_info(s:cocstatustimer)) == 0
let s:cocstatustimer = timer_start(100, {->execute('AirlineRefresh')}, {'repeat': 800})
endif
return msg . " " . loading[loadidx/(speed/10)] . " "
elseif state == "running"
if exists('s:cocstatustimer')
call timer_stop(s:cocstatustimer)
unlet s:cocstatustimer
endif
return msg . " ✔ "
endif
return ''
endfunction
function! AirlineBufferNumber()
return len(g:index_to_buffer)
endfunction
" This must use my fork version of bufferline
" the number of cols bufferline cannot use out of max of screen cols
let g:bufferline_forbided_col = 32
let g:airline_experimental = g:vim_v >= 900 ? 1 : 0
function! AirlineInit()
" call airline#parts#define_function('bufnum', 'AirlineBufferNumber')
call airline#parts#define_function('cocstatus', 'AirlineCocStatus')
call airline#parts#define_minwidth('mode', 10)
let _airline_section_y = ''
if utils#hasplug('coc.nvim')
" let _airline_section_y = airline#section#create(['cocstatus'])
endif
let g:airline_section_a = airline#section#create(['mode'])
let g:airline_section_b = ''
let g:airline_section_error = ''
let g:airline_section_warning = ''
" let g:airline_section_x = airline#section#create(['bufnum'])
let g:airline_section_x = ''
let g:airline_section_y = _airline_section_y
let g:airline_section_z = airline#section#create(['cocstatus', '│ ', '%(%l:%c%)'])
endfunction
function! AirlineColouriseSplits()
" get rid of the vertical split between two windows in statusline
hi! link StatusLine airline_z
hi! link StatusLineNC airline_z_inactive
endfunction
augroup AirlineAu
autocmd!
autocmd ColorScheme * call AirlineColouriseSplits()
autocmd User AirlineAfterInit ++once call AirlineInit()
augroup end
" let g:airline_left_sep = ''
" let g:airline_left_alt_sep = ''
" let g:airline_right_sep = ''
" let g:airline_right_alt_sep = ''
function s:airline_refresh(...)
" this has to be set late otherwise it will cause 'mode' extension be
" skipped at startup
let g:airline_skip_empty_sections = 1
endfunction
call RegisterLateInit(function('s:airline_refresh'), 1)
" let g:airline_skip_empty_sections = 1
let g:airline_inactive_collapse = 1
let g:airline_focuslost_inactive = 0
let g:airline_extensions = ['bufferline']
let g:airline_filetype_overrides = {
\ 'vista': ['Vista', ''],
\ 'minimap': ['', ''],
\ 'nerdtree': [ get(g:, 'NERDTreeStatusline', 'NERD'), ''],
\ }
" hide airline in startify
function! HideStartify(...)
let ctx = a:2
if ! ctx.active
return 1
end
if &filetype == 'startify'
let builder = a:1
call builder.add_section('Normal', '')
return 1
endif
if &filetype == 'help'
let builder = a:1
call builder.add_section('airline_a_bold', ' Help ')
call builder.add_section('airline_c', ' %f')
return 1
endif
endfunction
call airline#add_statusline_func('HideStartify')
" " without this airline will overwrite some setting like bufferline_active_buffer_left, etc.
let g:airline#extensions#bufferline#overwrite_variables = 0
" call theme#addTransGroup(['airline_c', 'airline_c_bold'])
" let g:airline_mode_map = {
" \ '__' : '-',
" \ 'c' : 'C',
" \ 'i' : 'I',
" \ 'ic' : 'I',
" \ 'ix' : 'I',
" \ 'n' : 'N',
" \ 'multi' : 'M',
" \ 'ni' : 'N',
" \ 'no' : 'N',
" \ 'R' : 'R',
" \ 'Rv' : 'R',
" \ 's' : 'S',
" \ 'S' : 'S',
" \ '' : 'S',
" \ 't' : 'T',
" \ 'v' : 'V',
" \ 'V' : 'V',
" \ '' : 'V',
" \ }
endif
@@ -1,17 +0,0 @@
if utils#hasplug("vim-bufferline")
let g:bufferline_echo = 0
let g:bufferline_modified = '+'
" scrolling with fixed current buffer position
let g:bufferline_active_buffer_left = '['
let g:bufferline_active_buffer_right = ']'
if utils#hasplug("vim-airline")
let g:bufferline_inactive_highlight = 'airline_c'
let g:bufferline_active_highlight = 'airline_c_bold'
elseif ! utils#hasplug("vim-global-statusline")
call bufferline#init_echo()
endif
endif
@@ -1,5 +0,0 @@
if utils#hasplug("vim-devicons")
let g:webdevicons_enable_airline_statusline = 0
endif
@@ -1,53 +0,0 @@
if utils#hasplug('vim-floaterm')
let g:floaterm_keymap_toggle = '<C-\>'
let g:floaterm_wintype = 'float'
let g:floaterm_position = 'bottomright'
let g:floaterm_width = 0.5
let g:floaterm_height = 0.5
let g:floaterm_autohide = 2
call theme#addCleanBg(['FloatermBorder', 'Floaterm'])
autocmd QuitPre * :FloatermKill!<CR>
" press <c-[> ener normal mode in terminal. autocmd prevent this key map
" in other plugin like fzf
autocmd FileType floaterm tmap <buffer> <C-[> <C-w>N
function! s:hasterm(name)
let bufs = floaterm#buflist#gather()
for bufnr in bufs
let bufinfo = getbufinfo(bufnr)[0]
let termname = bufinfo['variables']['floaterm_name']
if termname == a:name
return v:true
endif
endfor
return v:false
endfunction
function! ToggleRepl()
let name = 'REPL'
let currentWindow=winnr()
if s:hasterm(name)
execute('FloatermToggle ' . name)
else
:FloatermNew --name=REPL --width=0.5 --wintype=vsplit --position=botright --autoclose=2 ipython
endif
exe currentWindow . "wincmd w"
endfunction
function! ToggleNormal()
let name = 'normalterm'
if s:hasterm(name)
execute('FloatermToggle ' . name)
else
:FloatermNew --name=normalterm --width=0.5 --height=0.5 --wintype=float --position=bottomright --autoclose=2
endif
endfunction
nnoremap <silent> <leader>tp :call ToggleRepl()<CR>
nnoremap <silent> <leader>tn :call ToggleNormal()<CR>
vnoremap <silent> <leader>tl :FloatermSend --name=REPL<CR>
endif
@@ -1,5 +0,0 @@
if utils#hasplug('vim-gitgutter')
call theme#addCleanBg(['GitGutterAdd', 'GitGutterChange', 'GitGutterDelete', 'GitGutterChangeDelete'])
nnoremap <leader>gt :GitGutterBufferToggle<CR>
endif
@@ -1,10 +0,0 @@
if utils#hasplug("vim-gutentags")
if exists("*gutentags#statusline()")
set statusline+=%{gutentags#statusline()}
endif
let g:gutentags_trace = 1
let g:gutentags_cache_dir=g:vim_dir . '/.vimtags/'
let g:gutentags_project_root=['.git', '.hg', '.svn', '.bzr', '_darcs', '_FOSSIL_', '.fslckout', 'src']
endif
@@ -1,35 +0,0 @@
if utils#hasplug('vim-illuminate') && g:vim_type == 'vim' " nvim doesn't need this config
let g:Illuminate_highlightUnderCursor = 1
let g:Illuminate_ftHighlightGroups = {
\ 'vim:blacklist': ['vimLet', 'vimFuncKey', 'vimNotFunc', 'vimOperParen', 'vimLineComment'],
\ 'java:blacklist' : [ 'javaType', 'javaScopeDecl', 'javaMethodDecl',
\ 'javaComment', 'javaStorageClass', 'javaClassDecl', 'javaExternal',
\ 'javaTypedef', 'javaLineComment', 'javaStatement', 'javaCommentTitle', 'javaDocComment' ],
\ 'lua:blacklist' : [ 'luaComment', 'luaCond', 'luaStatement', 'luaFunction' ]
\ }
let g:Illuminate_ftwhitelist = ['vim', 'sh', 'python', 'rust', 'java',
\ 'c', 'cpp', 'javascript', 'typescript', 'lua']
" ugly workaround for the bug that illuminate not working after first enter vim
" {
function s:init_illuminate(...)
let bgType = theme#getBgType()
let bg = theme#getHiTerm('Visual', bgType)
if bg != 'NONE' && &bg == 'dark'
execute('hi illuminatedWord '.bgType.'='.bg)
execute('hi illuminatedCurWord '.bgType.'='.bg)
else
hi illuminatedWord cterm=underline gui=underline
hi illuminatedCurWord cterm=underline gui=underline
end
endfunction
call RegisterLateInit(function('s:init_illuminate'), 0)
" }
augroup illuminate_augroup
autocmd!
autocmd ColorScheme * call s:init_illuminate()
augroup END
endif
@@ -1,5 +0,0 @@
if utils#hasplug('vim-matchup')
let g:matchup_matchparen_offscreen = {}
call theme#addCleanBg('MatchWord')
endif
@@ -1,8 +0,0 @@
if utils#hasplug("vim-rooter")
let g:rooter_patterns = ['.vscode', '.git', '*.sln', 'src']
let g:rooter_change_directory_for_non_project_files = ''
let g:rooter_silent_chdir = 0
" let g:rooter_manual_only = 1
endif
@@ -1,5 +0,0 @@
if utils#hasplug("vim-sneak")
let g:sneak#label = 1
" map f <Plug>Sneak_s
" map F <Plug>Sneak_S
endif
@@ -1,58 +0,0 @@
if utils#hasplug("vim-startify")
if has('nvim')
let buffer_str_len = (&columns - 60) / 2
let buf_str = repeat(' ', buffer_str_len)
let ascii_art = [
\ buf_str . '',
\ buf_str . '',
\ buf_str . ' __ __ ________ ______ __ __ ______ __ __ ',
\ buf_str . '| \ | \| \ / \ | \ | \| \| \ / \',
\ buf_str . '| $$\ | $$| $$$$$$$$| $$$$$$\| $$ | $$ \$$$$$$| $$\ / $$',
\ buf_str . '| $$$\| $$| $$__ | $$ | $$| $$ | $$ | $$ | $$$\ / $$$',
\ buf_str . '| $$$$\ $$| $$ \ | $$ | $$ \$$\ / $$ | $$ | $$$$\ $$$$',
\ buf_str . '| $$\$$ $$| $$$$$ | $$ | $$ \$$\ $$ | $$ | $$\$$ $$ $$',
\ buf_str . '| $$ \$$$$| $$_____ | $$__/ $$ \$$ $$ _| $$_ | $$ \$$$| $$',
\ buf_str . '| $$ \$$$| $$ \ \$$ $$ \$$$ | $$ \| $$ \$ | $$',
\ buf_str . ' \$$ \$$ \$$$$$$$$ \$$$$$$ \$ \$$$$$$ \$$ \$$',
\]
else
let buffer_str_len = (&columns - 30) / 2
let buf_str = repeat(' ', buffer_str_len)
let ascii_art = [
\ buf_str . '',
\ buf_str . '',
\ buf_str . ' __ __ ______ __ __ ',
\ buf_str . '| \ | \| \| \ / \',
\ buf_str . '| $$ | $$ \$$$$$$| $$\ / $$',
\ buf_str . '| $$ | $$ | $$ | $$$\ / $$$',
\ buf_str . ' \$$\ / $$ | $$ | $$$$\ $$$$',
\ buf_str . ' \$$\ $$ | $$ | $$\$$ $$ $$',
\ buf_str . ' \$$ $$ _| $$_ | $$ \$$$| $$',
\ buf_str . ' \$$$ | $$ \| $$ \$ | $$',
\ buf_str . ' \$ \$$$$$$ \$$ \$$',
\]
endif
let g:startify_padding_left = &columns / 2 - &columns / 4 - &columns / 8
let g:startify_custom_header = ascii_art
let g:startify_change_to_dir = 0
let g:startify_files_number = 5
let g:startify_bookmarks = [ g:dotfiledir . 'main.vim' ]
let g:startify_lists = [
\ { 'header': startify#pad([' RECENT']), 'type': 'files' },
\ { 'header': startify#pad([' SESSIONS']), 'type': 'sessions' },
\ { 'header': startify#pad([' BOOKMARKS']), 'type': 'bookmarks' },
\ ]
" session related KeyBinding. These KeyBinding uses function from startify
nnoremap <silent> <leader><leader>s :SSave!<CR>
nnoremap <silent> <leader><leader>l :SLoad<CR>
nnoremap <silent> <leader><leader>d :SDelete!<CR>
nnoremap <silent> <leader><leader>c :SClose<CR>
au VimLeave * SSave! last
endif
@@ -1,11 +0,0 @@
if utils#hasplug('vim-tmux-navigator')
let g:tmux_navigator_no_mappings = 1
noremap <silent> <c-h> :<C-U>TmuxNavigateLeft<cr>
noremap <silent> <c-j> :<C-U>TmuxNavigateDown<cr>
noremap <silent> <c-k> :<C-U>TmuxNavigateUp<cr>
noremap <silent> <c-l> :<C-U>TmuxNavigateRight<cr>
" noremap <silent> {Previous-Mapping} :<C-U>TmuxNavigatePrevious<cr>
endif
@@ -1,28 +0,0 @@
vim9script
highlight link fuzzyyMatching error
g:fuzzyy_dropdown = 1
g:enable_fuzzyy_MRU_files = 1
g:fuzzyy_window_layout = {
FuzzyFiles: {
width: 0.8,
},
FuzzyMRUFiles: {
preview: 1,
},
FuzzyBuffers: {
preview: 1,
width: 0.8,
preview_ratio: 0.5,
},
FuzzyGrep: {
preview: 1,
width: 0.8,
preview_ratio: 0.5,
},
}
g:fuzzyy_buffers_keymap = {
'delete_buffer': "\<c-g>",
'close_buffer': "\<c-l>",
}
nnoremap <silent> <leader>fl :FuzzyCmdHistory<CR>
@@ -1,188 +0,0 @@
vim9script
if utils#hasplug('vim-global-statusline')
g:stl_nonbtbg = 'folded'
g:stl_bg = 'normal'
g:bufferline_forbided_col = 32
def ReverseHl(name: string, hl: string)
var hl_terms = theme#getHiTerms(hl)
var normal_terms = theme#getHiTerms('normal')
for [term, val] in items(hl_terms)
if val == 'NONE'
hl_terms[term] = normal_terms[term]
endif
endfor
exe 'hi ' .. name .. ' guibg=' .. hl_terms['guifg'] .. ' guifg='
.. hl_terms['guibg'] .. ' ctermbg=' .. hl_terms['ctermfg']
.. ' ctermfg=' .. hl_terms['ctermbg']
enddef
def StlHighlight()
hi normalModeGstl cterm=reverse gui=reverse
ReverseHl('insertModeGstl', 'function')
ReverseHl('visualModeGstl', 'statement')
ReverseHl('commandModeGstl', 'number')
enddef
autocmd ColorScheme * StlHighlight()
var mode_color = {
n: 'normalModeGstl',
i: 'insertModeGstl',
v: 'visualModeGstl',
V: 'visualModeGstl',
c: 'commandModeGstl',
}
var mode_str = {
n: ' NORMAL ',
i: ' INSERT ',
v: ' VISUAL ',
V: ' V-LINE ',
c: ' COMMAND ',
}
mode_str[nr2char(22)] = ' V-BLOCK '
mode_color[nr2char(22)] = 'curSearch'
def Modestr(): void
var m = mode()
if has_key(mode_str, m)
g:StlSetPart(0, mode_str[m], mode_color[m], 'mode')
else
echom char2nr(m)
g:StlSetPart(0, ' ' .. &ft .. ' ', 'TabLineSel', 'mode')
endif
g:StlRefresh()
enddef
def Fnstr(): void
g:StlSetPart(10, 'filename: ' .. bufname(), '', 'filename')
g:StlRefresh()
enddef
def Bufstr(): void
var bufstr = bufferline#get_echo_string()
g:StlSetPart(9, ' ' .. bufstr, '', 'bufstr')
g:StlRefresh()
enddef
def Lncol(): void
var col = virtcol(".")
var ln = line('.')
var m = mode()
var color = ''
if has_key(mode_color, m)
color = mode_color[m]
else
color = 'TabLineSel'
endif
g:StlSetPart(&co - 9, printf(" %d:%d", ln, col), color, 'linenr')
g:StlRefresh()
enddef
var cocstatustimer = -1
def Cocstatus(): string
const loading = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
var results = []
var result = '𐄂'
var fticon = '𐄂'
try
if exists('g:CocAction')
results = g:CocAction('services')
endif
catch
endtry
var state = ''
var id = ''
if len(results) == 0
timer_start(100, function(Lsp))
endif
for e in results
if e['languageIds'][0] == &ft
state = e['state']
id = e['id']
endif
endfor
# messy way to get time in millisecond in vim
var time = float2nr(str2float(reltime()->reltimestr()[4 : ]) * 1000)
var speed = 800
var loadidx = time % speed
var msg = id
if state == "starting"
if len(timer_info(cocstatustimer)) == 0
cocstatustimer = timer_start(100, function(Lsp), {'repeat': 800})
endif
fticon = loading[loadidx / (speed / 10)]
elseif state == "running"
if len(timer_info(cocstatustimer)) != 0
timer_stop(cocstatustimer)
cocstatustimer = -1
endif
if exists('g:WebDevIconsGetFileTypeSymbol')
fticon = g:WebDevIconsGetFileTypeSymbol()
endif
endif
# return fticon .. ' ' .. result
return 'lsp ' .. fticon
enddef
def Lsp(...timer: list<any>): void
var s = Cocstatus()
g:StlSetPart(&co - 17, ' ' .. s .. ' ', '', 'lsp')
g:StlRefresh()
enddef
var fancytimer = 0
def Fancy(...timer: list<any>): void
var expressions = [' (◕_◕)', ' (◕‿◕)', '\(◕◡◕\)', ' (◣_◢)', ' (◣‿◢)', '\(◣◡◣\)', ' (◠‿◠)', ' (◠_◠)', '\(◠◡◠\)', ' (◡‿◡)', ' (◡_◡)', '\(◡◡◡\)', ' (┳Д┳)', ' (个_个)', ' ( ≧Д≦)', ' 흫_흫', ' 句_句']
# var letters = [𝔞 𝔟 𝔠 𝔡 𝔢 𝔣 𝔤 𝔥 𝔦 𝔧 𝔨 𝔩 𝔪 𝔫 𝔬 𝔭 𝔮 𝔯 𝔰 𝔱 𝔲 𝔳 𝔴 𝔵 𝔶 𝔷]
# string "I love you" using unicode letters
var lang = ''
if &ft == 'python'
lang = '𝕻𝖞𝖙𝖍𝖔𝖓'
elseif &ft == 'java'
lang = '𝕵𝖆𝖛𝖆'
elseif &ft == 'javascript'
lang = '𝕵𝖆𝖛𝖆𝖘𝖈𝖗𝖎𝖕𝖙'
elseif &ft == 'lua'
lang = '𝕷𝖚𝖆'
elseif &ft == 'vim'
lang = '𝓥𝓲𝓶 𝓢𝓬𝓻𝓲𝓹𝓽'
else
lang = &ft
endif
var str = lang .. ' 𝔦𝔰 𝔱𝔥𝔢 𝔟𝔢𝔰𝔱 𝔩𝔞𝔫𝔤𝔲𝔞𝔤𝔢'
# fancytimer = (fancytimer + 1) % len(str)
g:StlSetPart(&co - 27 - strcharlen(str), str, '', 'fancy')
enddef
def Theme(): void
# const light = '☀'
# const dark = '☽'
const light = '🌕'
const dark = '🌑'
var theme = &bg == 'light' ? light : dark
g:StlSetPart(&co - 23, '│ ' .. theme, '', 'bgc')
g:StlRefresh()
enddef
def EnterInit(): void
# Theme()
Lncol()
Lsp()
# autocmd GlobalStl ColorScheme * Theme()
enddef
augroup GlobalStl
autocmd!
autocmd VimEnter,ModeChanged * Modestr() | Lncol()
autocmd BufEnter,BufDelete,BufWritePost * Bufstr() | Modestr()
autocmd CursorHold * Lncol()
autocmd BufEnter,BufReadPost * Lsp()
autocmd VimEnter * EnterInit()
augroup END
endif
@@ -1,7 +0,0 @@
if utils#hasplug('vimtex')
noremap <leader>lc :VimtexCompile<CR>
noremap <leader>lv :VimtexView<CR>
if g:os == 'Darwin'
let g:vimtex_view_method = 'skim'
endif
endif
@@ -1,60 +0,0 @@
if utils#hasplug('vista.vim')
let g:vista_default_executive = 'vim_lsp'
if utils#hasplug('coc.nvim')
let g:vista_default_executive = 'coc'
elseif executable('ctags')
let g:vista_default_executive = 'ctags'
endif
nnoremap <silent> <leader>v :Vista!!<CR>
let g:vista_cursor_delay = 0
let g:vista_echo_cursor = 0
let g:vista_echo_cursor_strategy = 'floating_win'
let g:vista_close_on_jump = 0
let g:vista_floating_delay = 0
let g:vista_ignore_kinds = ['Variable', 'Field', 'EnumMember',
\ 'String', 'Object', 'Array', 'Constant', 'Package', 'Boolean', 'Number'
\ ]
let g:vista_floating_border = 'rounded'
let g:vista_disable_statusline = 1
" let g:vista_keep_fzf_colors = 1
let g:vista_update_on_text_changed_delay = 0
let g:vista_update_on_text_changed = 1
let g:vista#renderer#enable_kind = 1
let g:vista#renderer#enable_icon = 1
" return to last position of vista
let g:vista_last_row = v:null
function! VistaCursorJump()
" let found = vista#util#BinarySearch(g:vista.raw, line('.'), 'line', '')
let found = g:vista_last_row
if empty(found)
return
endif
let vlnum = get(found, 'vlnum', v:null)
call cursor(vlnum, 3)
endfunction
" save tag for VistaCursorJump use
function! VistaH2()
if exists('*vista#util#BinarySearch')
let bufs = map(filter(copy(getbufinfo()), 'v:val.listed'), 'v:val.bufnr')
if index(bufs, bufnr('%')) < 0
return
endif
let found = vista#util#BinarySearch(g:vista.raw, line('.'), 'line', '')
if empty(found)
return
endif
let g:vista_last_row = found
endif
endfunction
augroup VistaAu
autocmd!
autocmd BufLeave * call VistaH2()
autocmd FileType vista call VistaCursorJump()
augroup END
endif
@@ -1,31 +0,0 @@
if utils#hasplug('wilder.nvim')
call wilder#setup({
\ 'modes': [':'],
\ 'next_key': '<tab>',
\ 'previous_key': '<S-Tab>',
\ 'enable_cmdline_enter': 0,
\ })
call wilder#set_option('pipeline', [
\ wilder#debounce(10),
\ wilder#branch(
\ wilder#cmdline_pipeline({'language': g:vim_type == 'nvim' ? 'python' : 'vim'}),
\ ),
\ ])
if g:vim_type == 'vim'
call wilder#set_option('renderer', wilder#popupmenu_renderer())
else
call wilder#set_option('renderer', wilder#popupmenu_renderer(
\ wilder#popupmenu_border_theme({
\ 'highlights': {
\ 'default': 'Normal',
\ },
\ 'pumblend': 20,
\ 'border': 'rounded',
\ })))
endif
endif
@@ -1,8 +0,0 @@
if utils#hasplug("winresizer")
let g:winresizer_vert_resize = 2
let g:winresizer_horiz_resize = 2
" nnoremap <C-w>r :WinResizerStartResize<CR>
let g:winresizer_start_key = '<C-w>r'
endif
@@ -1,3 +0,0 @@
if utils#hasplug("zoxide.vim")
endif