fix some bugs
This commit is contained in:
@@ -64,14 +64,19 @@
|
|||||||
set hidden " Allow buffer switching without saving
|
set hidden " Allow buffer switching without saving
|
||||||
set iskeyword-=. " '.' is an end of word designator
|
set iskeyword-=. " '.' is an end of word designator
|
||||||
set iskeyword-=# " '#' is an end of word designator
|
set iskeyword-=# " '#' is an end of word designator
|
||||||
|
|
||||||
set iskeyword+=-
|
set iskeyword+=-
|
||||||
" let '-' not be an end of word designator
|
|
||||||
"set iskeyword-=_ " '_' is an end of word designator
|
|
||||||
|
|
||||||
" Instead of reverting the cursor to the last position in the buffer, we
|
augroup FileFormat
|
||||||
" set it to the first line when editing a git commit message
|
autocmd!
|
||||||
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
|
autocmd FileType javascript,typescript,lua setlocal tabstop=2 shiftwidth=2 softtabstop=2
|
||||||
|
" autocmd FileType c,cpp,python,java setlocal tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
|
||||||
|
autocmd FileType haskell,puppet,ruby,yml setlocal expandtab shiftwidth=2 softtabstop=2
|
||||||
|
autocmd FileType vim execute('setlocal iskeyword='.&iskeyword.',:')
|
||||||
|
" Instead of reverting the cursor to the last position in the buffer, we
|
||||||
|
" set it to the first line when editing a git commit message
|
||||||
|
autocmd FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
|
||||||
|
augroup END
|
||||||
|
|
||||||
" http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
|
" http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
|
||||||
" Restore cursor to file position in previous editing session
|
" Restore cursor to file position in previous editing session
|
||||||
@@ -104,11 +109,6 @@
|
|||||||
" set showmode " Display the current mode
|
" set showmode " Display the current mode
|
||||||
set nocursorline " Highlight current line
|
set nocursorline " Highlight current line
|
||||||
|
|
||||||
" get rid of current line highlight, instead just highlight the number column
|
|
||||||
" augroup CLClear
|
|
||||||
" autocmd! ColorScheme * hi clear CursorLine
|
|
||||||
" augroup END
|
|
||||||
|
|
||||||
set cmdheight=1 " get rid of the extra useless line at the bottom(if not working, probably a plugin is changing the value)
|
set cmdheight=1 " get rid of the extra useless line at the bottom(if not working, probably a plugin is changing the value)
|
||||||
|
|
||||||
if has('cmdline_info')
|
if has('cmdline_info')
|
||||||
@@ -143,11 +143,6 @@
|
|||||||
set shiftwidth=4 " Use indents of 4 spaces
|
set shiftwidth=4 " Use indents of 4 spaces
|
||||||
set tabstop=4 " An indentation every four columns
|
set tabstop=4 " An indentation every four columns
|
||||||
set softtabstop=4 " Let backspace delete indent
|
set softtabstop=4 " Let backspace delete indent
|
||||||
augroup FileFormat
|
|
||||||
autocmd!
|
|
||||||
autocmd FileType javascript,typescript,lua setlocal tabstop=2 shiftwidth=2 softtabstop=2
|
|
||||||
" autocmd FileType c,cpp,python,java setlocal tabstop=4 shiftwidth=4 softtabstop=4
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
|
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
|
||||||
set splitright " Puts new vsplit windows to the right of the current
|
set splitright " Puts new vsplit windows to the right of the current
|
||||||
@@ -160,28 +155,8 @@
|
|||||||
|
|
||||||
set listchars=tab:•\ ,trail:•,extends:»,precedes:« " Unprintable chars mapping
|
set listchars=tab:•\ ,trail:•,extends:»,precedes:« " Unprintable chars mapping
|
||||||
|
|
||||||
"Remove all trailing whitespace by pressing <leader>ws
|
|
||||||
fun! TrimWhitespace()
|
|
||||||
let l:save = winsaveview()
|
|
||||||
keeppatterns %s/\s\+$//e
|
|
||||||
call winrestview(l:save)
|
|
||||||
endfun
|
|
||||||
nnoremap <leader>ws :call TrimWhitespace()<CR>
|
|
||||||
set nospell " Spell checking off
|
set nospell " Spell checking off
|
||||||
|
|
||||||
|
|
||||||
set matchpairs+=<:> " Match, to be used with %
|
set matchpairs+=<:> " Match, to be used with %
|
||||||
"set comments=sl:/*,mb:*,elx:*/ " auto format comment blocks
|
|
||||||
|
|
||||||
autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
|
|
||||||
autocmd FileType haskell,puppet,ruby,yml setlocal expandtab shiftwidth=2 softtabstop=2
|
|
||||||
|
|
||||||
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
|
|
||||||
|
|
||||||
" Workaround vim-commentary for Haskell
|
|
||||||
autocmd FileType haskell setlocal commentstring=--\ %s
|
|
||||||
" Workaround broken colour highlighting in Haskell
|
|
||||||
autocmd FileType haskell,rust setlocal nospell
|
|
||||||
|
|
||||||
" }
|
" }
|
||||||
|
|
||||||
@@ -324,4 +299,3 @@
|
|||||||
source ~/.vimrc.bundles
|
source ~/.vimrc.bundles
|
||||||
endif
|
endif
|
||||||
" }
|
" }
|
||||||
|
|
||||||
|
|||||||
+100
-102
@@ -7,7 +7,7 @@
|
|||||||
" KEY_MAPS
|
" KEY_MAPS
|
||||||
" OTHER_CONFIGS
|
" OTHER_CONFIGS
|
||||||
|
|
||||||
let g:debug_mode = v:false
|
let g:debug_mode = v:true
|
||||||
let g:high_performence = v:false " set true will also disable animation
|
let g:high_performence = v:false " set true will also disable animation
|
||||||
let g:autocomplte_enable = v:true
|
let g:autocomplte_enable = v:true
|
||||||
let g:copilot_enable = v:false
|
let g:copilot_enable = v:false
|
||||||
@@ -20,8 +20,8 @@ let g:classic_vim_ui = v:true
|
|||||||
let g:animation_enable = v:true
|
let g:animation_enable = v:true
|
||||||
|
|
||||||
let g:swap_dict = [
|
let g:swap_dict = [
|
||||||
\ ['false', '0', 'dark' ],
|
\ ['v:false', '0', 'dark', 'false' ],
|
||||||
\ ['true' , '1', 'light']]
|
\ ['v:true' , '1', 'light', 'true']]
|
||||||
" convinient function to swap between two options
|
" convinient function to swap between two options
|
||||||
nmap <leader><leader>t :call SwapWord()<CR>
|
nmap <leader><leader>t :call SwapWord()<CR>
|
||||||
|
|
||||||
@@ -59,9 +59,9 @@ nmap <leader><leader>t :call SwapWord()<CR>
|
|||||||
\ && g:copilot_enable && executable('node'))
|
\ && g:copilot_enable && executable('node'))
|
||||||
|
|
||||||
Plug 'gelguy/wilder.nvim', Cond((g:vim_type == 'vim' \|\| g:classic_vim_ui) && !g:high_performence)
|
Plug 'gelguy/wilder.nvim', Cond((g:vim_type == 'vim' \|\| g:classic_vim_ui) && !g:high_performence)
|
||||||
" To use Python remote plugin features in Vim for wilder, can be skipped
|
" " To use Python remote plugin features in Vim for wilder, can be skipped
|
||||||
" Plug 'roxma/nvim-yarp', Cond(g:vim_type == 'vim')
|
" " Plug 'roxma/nvim-yarp', Cond(g:vim_type == 'vim')
|
||||||
" Plug 'roxma/vim-hug-neovim-rpc', Cond(g:vim_type == 'vim')
|
Plug 'roxma/vim-hug-neovim-rpc', Cond(g:vim_v >= 800 && has('python3'))
|
||||||
|
|
||||||
Plug 'dstein64/vim-startuptime', Cond(!g:high_performence)
|
Plug 'dstein64/vim-startuptime', Cond(!g:high_performence)
|
||||||
Plug 'simeji/winresizer', Cond(!g:high_performence)
|
Plug 'simeji/winresizer', Cond(!g:high_performence)
|
||||||
@@ -75,7 +75,7 @@ nmap <leader><leader>t :call SwapWord()<CR>
|
|||||||
Plug 'RRethy/vim-illuminate', Cond(!g:high_performence)
|
Plug 'RRethy/vim-illuminate', Cond(!g:high_performence)
|
||||||
"Plug 'easymotion/vim-easymotion'
|
"Plug 'easymotion/vim-easymotion'
|
||||||
Plug 'mhinz/vim-startify'
|
Plug 'mhinz/vim-startify'
|
||||||
Plug 'ludovicchabant/vim-gutentags'
|
" Plug 'ludovicchabant/vim-gutentags'
|
||||||
|
|
||||||
Plug 'christoomey/vim-tmux-navigator'
|
Plug 'christoomey/vim-tmux-navigator'
|
||||||
Plug 'airblade/vim-rooter'
|
Plug 'airblade/vim-rooter'
|
||||||
@@ -168,6 +168,7 @@ nmap <leader><leader>t :call SwapWord()<CR>
|
|||||||
" plugins to mess around with them
|
" plugins to mess around with them
|
||||||
|
|
||||||
" import ultilities functions
|
" import ultilities functions
|
||||||
|
|
||||||
execute('source ' . g:mydotfiles_directory . '/utils.vim')
|
execute('source ' . g:mydotfiles_directory . '/utils.vim')
|
||||||
|
|
||||||
function! HasPlug(plug_name, ...)
|
function! HasPlug(plug_name, ...)
|
||||||
@@ -217,12 +218,12 @@ endfunction
|
|||||||
" {
|
" {
|
||||||
if HasPlug('vim-floaterm')
|
if HasPlug('vim-floaterm')
|
||||||
let g:floaterm_wintype = 'float'
|
let g:floaterm_wintype = 'float'
|
||||||
let g:floaterm_keymap_toggle = '<c-\>'
|
let g:floaterm_keymap_toggle = '<C-\>'
|
||||||
let g:floaterm_position = 'bottomright'
|
let g:floaterm_position = 'bottomright'
|
||||||
let g:floaterm_width = 0.5
|
let g:floaterm_width = 0.5
|
||||||
let g:floaterm_height = 0.5
|
let g:floaterm_height = 0.5
|
||||||
autocmd QuitPre * :FloatermKill!<CR>
|
autocmd QuitPre * :FloatermKill!<CR>
|
||||||
tmap <C-[> <c-w>N
|
autocmd FileType floaterm tmap <buffer> <C-[> <C-\><C-n>
|
||||||
endif
|
endif
|
||||||
if HasPlug('Copilot.vim')
|
if HasPlug('Copilot.vim')
|
||||||
" imap <expr> <C-n> <Plug>(copilot-next)
|
" imap <expr> <C-n> <Plug>(copilot-next)
|
||||||
@@ -269,6 +270,7 @@ endfunction
|
|||||||
let g:vista#renderer#enable_kind = 1
|
let g:vista#renderer#enable_kind = 1
|
||||||
let g:vista#renderer#enable_icon = 1
|
let g:vista#renderer#enable_icon = 1
|
||||||
|
|
||||||
|
" return to last position of vista
|
||||||
let g:vista_last_row = v:null
|
let g:vista_last_row = v:null
|
||||||
function VistaCursorJump()
|
function VistaCursorJump()
|
||||||
" let found = vista#util#BinarySearch(g:vista.raw, line('.'), 'line', '')
|
" let found = vista#util#BinarySearch(g:vista.raw, line('.'), 'line', '')
|
||||||
@@ -280,6 +282,7 @@ endfunction
|
|||||||
call cursor(vlnum, 3)
|
call cursor(vlnum, 3)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" save tag for VistaCursorJump use
|
||||||
function VistaH2()
|
function VistaH2()
|
||||||
if exists('*vista#util#BinarySearch')
|
if exists('*vista#util#BinarySearch')
|
||||||
let bufs = map(filter(copy(getbufinfo()), 'v:val.listed'), 'v:val.bufnr')
|
let bufs = map(filter(copy(getbufinfo()), 'v:val.listed'), 'v:val.bufnr')
|
||||||
@@ -293,47 +296,35 @@ endfunction
|
|||||||
let g:vista_last_row = found
|
let g:vista_last_row = found
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
autocmd BufLeave * call VistaH2()
|
autocmd BufLeave * call VistaH2()
|
||||||
" autocmd WinLeave call VistaH2()
|
|
||||||
autocmd FileType vista call VistaCursorJump()
|
autocmd FileType vista call VistaCursorJump()
|
||||||
|
|
||||||
function VistaHelper()
|
|
||||||
if winnr('$') == 1 && bufname() == "__vista__"
|
|
||||||
let bufs = map(filter(copy(getbufinfo()), 'v:val.listed'), 'v:val.bufnr')
|
|
||||||
if len(bufs) > 1
|
|
||||||
execute("normal! :bw\<CR>")
|
|
||||||
else
|
|
||||||
execute "normal! :q!\<CR>"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" close vista when it is the last window
|
|
||||||
" autocmd BufEnter * if winnr('$') == 1 && bufname() == "__vista__" | execute "normal! :q!\<CR>" | endif
|
|
||||||
" autocmd BufEnter * call VistaHelper()
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if HasPlug('indentLine')
|
if HasPlug('indentLine')
|
||||||
let g:indentLine_fileTypeExclude = ['startify']
|
let g:indentLine_fileTypeExclude = ['startify']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if HasPlug('vim-illuminate') && g:vim_type == 'vim'
|
if HasPlug('vim-illuminate') && g:vim_type == 'vim' " nvim doesn't need this config
|
||||||
let g:Illuminate_ftHighlightGroups = {
|
let g:Illuminate_ftHighlightGroups = {
|
||||||
\ 'vim': ['vimVar', 'vimString', 'vimFuncName',
|
\ 'vim:blacklist': ['vimLet', 'vimFuncKey', 'vimNotFunc', 'vimOperParen', 'vimLineComment'],
|
||||||
\ 'vimFunction', 'vimUserFunc', 'vimFunc'],
|
|
||||||
\ 'java:blacklist' : [ 'javaType', 'javaScopeDecl', 'javaMethodDecl',
|
\ 'java:blacklist' : [ 'javaType', 'javaScopeDecl', 'javaMethodDecl',
|
||||||
\ 'javaComment', 'javaStorageClass', 'javaClassDecl', 'javaExternal',
|
\ 'javaComment', 'javaStorageClass', 'javaClassDecl', 'javaExternal',
|
||||||
\ 'javaTypedef', 'javaLineComment', 'javaStatement', 'javaCommentTitle', 'javaDocComment' ],
|
\ 'javaTypedef', 'javaLineComment', 'javaStatement', 'javaCommentTitle', 'javaDocComment' ],
|
||||||
\ 'lua:blacklist' : [ 'luaComment', 'luaCond', 'luaStatement', 'luaFunction' ]
|
\ 'lua:blacklist' : [ 'luaComment', 'luaCond', 'luaStatement', 'luaFunction' ]
|
||||||
\ }
|
\ }
|
||||||
let g:Illuminate_ftwhitelist = ['vim', 'sh', 'python', 'rust', 'java', 'c', 'cpp', 'javascript', 'typescript', 'lua']
|
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(timer)
|
||||||
|
hi illuminatedWord cterm=underline gui=underline
|
||||||
|
endfunction
|
||||||
augroup illuminate_augroup
|
augroup illuminate_augroup
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd VimEnter * hi illuminatedWord cterm=underline gui=underline
|
|
||||||
autocmd ColorScheme * hi illuminatedWord cterm=underline gui=underline
|
autocmd ColorScheme * hi illuminatedWord cterm=underline gui=underline
|
||||||
|
autocmd VimEnter * call timer_start(100, 's:init_illuminate')
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -342,6 +333,7 @@ endfunction
|
|||||||
call wilder#setup({
|
call wilder#setup({
|
||||||
\ 'modes': [':'],
|
\ 'modes': [':'],
|
||||||
\ 'next_key': '<tab>',
|
\ 'next_key': '<tab>',
|
||||||
|
\ 'previous_key': '<S-Tab>',
|
||||||
\ 'enable_cmdline_enter': 0,
|
\ 'enable_cmdline_enter': 0,
|
||||||
\ })
|
\ })
|
||||||
|
|
||||||
@@ -420,6 +412,7 @@ endfunction
|
|||||||
if exists("*gutentags#statusline()")
|
if exists("*gutentags#statusline()")
|
||||||
set statusline+=%{gutentags#statusline()}
|
set statusline+=%{gutentags#statusline()}
|
||||||
endif
|
endif
|
||||||
|
let g:gutentags_trace = 1
|
||||||
let g:gutentags_cache_dir=g:vim_dir . '/.vimtags/'
|
let g:gutentags_cache_dir=g:vim_dir . '/.vimtags/'
|
||||||
let g:gutentags_project_root=['.git', '.hg', '.svn', '.bzr', '_darcs', '_FOSSIL_', '.fslckout', 'src']
|
let g:gutentags_project_root=['.git', '.hg', '.svn', '.bzr', '_darcs', '_FOSSIL_', '.fslckout', 'src']
|
||||||
endif
|
endif
|
||||||
@@ -452,7 +445,6 @@ endfunction
|
|||||||
endif
|
endif
|
||||||
" }
|
" }
|
||||||
|
|
||||||
" bling/vim-bufferline {
|
|
||||||
if HasPlug("vim-bufferline") && HasPlug("vim-airline")
|
if HasPlug("vim-bufferline") && HasPlug("vim-airline")
|
||||||
let g:bufferline_echo = 0
|
let g:bufferline_echo = 0
|
||||||
let g:bufferline_modified = '+'
|
let g:bufferline_modified = '+'
|
||||||
@@ -461,10 +453,10 @@ endfunction
|
|||||||
|
|
||||||
let g:bufferline_active_buffer_left = ''
|
let g:bufferline_active_buffer_left = ''
|
||||||
let g:bufferline_active_buffer_right = ''
|
let g:bufferline_active_buffer_right = ''
|
||||||
|
let g:bufferline_inactive_highlight = 'airline_b_inactive'
|
||||||
|
let g:bufferline_active_highlight = 'airline_b_bold'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" }
|
|
||||||
|
|
||||||
" mbbill/undotree {
|
" mbbill/undotree {
|
||||||
if HasPlug("undotree")
|
if HasPlug("undotree")
|
||||||
nnoremap <leader>ut :UndotreeToggle<CR>
|
nnoremap <leader>ut :UndotreeToggle<CR>
|
||||||
@@ -490,7 +482,16 @@ endfunction
|
|||||||
let g:NERDTreeMinimalMenu = v:true
|
let g:NERDTreeMinimalMenu = v:true
|
||||||
let g:NERDTreeMinimalUI = v:true
|
let g:NERDTreeMinimalUI = v:true
|
||||||
|
|
||||||
"nnoremap <C-e> :NERDTreeToggle<CR>
|
function! NERDTreeEchoPathHandler(node)
|
||||||
|
echo a:node.path.str()
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
autocmd! User nerdtree call NERDTreeAddKeyMap({
|
||||||
|
\ 'key': 'p',
|
||||||
|
\ 'callback': 'NERDTreeEchoPathHandler',
|
||||||
|
\ 'quickhelpText': 'echo full path of current node',
|
||||||
|
\ 'scope': 'Node' })
|
||||||
|
|
||||||
function! NERDTreeFindToggle()
|
function! NERDTreeFindToggle()
|
||||||
let my_filetype = &filetype
|
let my_filetype = &filetype
|
||||||
let specical_fts = ['nerdtree', 'startify']
|
let specical_fts = ['nerdtree', 'startify']
|
||||||
@@ -519,6 +520,7 @@ endfunction
|
|||||||
" Exit Vim if NERDTree is the only window remaining in the only tab.
|
" 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
|
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" }
|
" }
|
||||||
|
|
||||||
" nvim-tree.lua {
|
" nvim-tree.lua {
|
||||||
@@ -572,17 +574,20 @@ endfunction
|
|||||||
" This must use my fork version of bufferline
|
" This must use my fork version of bufferline
|
||||||
let g:bufferline_max_length = &columns - 22
|
let g:bufferline_max_length = &columns - 22
|
||||||
function! AirlineBufferNumber()
|
function! AirlineBufferNumber()
|
||||||
return len(g:index_to_buffer) . " "
|
return len(g:index_to_buffer)
|
||||||
endfunction
|
endfunction
|
||||||
call airline#parts#define_function('bufnum', 'AirlineBufferNumber')
|
call airline#parts#define_function('bufnum', 'AirlineBufferNumber')
|
||||||
call airline#parts#define_function('cocstatus', 'AirlineCocStatus')
|
call airline#parts#define_function('cocstatus', 'AirlineCocStatus')
|
||||||
call airline#parts#define_accent('cocstatus', 'italic')
|
call airline#parts#define_accent('cocstatus', 'italic')
|
||||||
|
call airline#parts#define_accent('bufnum', 'bold')
|
||||||
|
call airline#parts#define_accent('bufnum', 'italic')
|
||||||
|
call airline#parts#define_accent('filetype', 'italic')
|
||||||
|
|
||||||
|
let g:airline_experimental = g:vim_v >= 900 ? 1 : 0
|
||||||
function! AirlineInit()
|
function! AirlineInit()
|
||||||
let _airline_section_y = ''
|
let _airline_section_y = ''
|
||||||
if HasPlug('coc.nvim')
|
if HasPlug('coc.nvim')
|
||||||
let _airline_section_y .= airline#section#create(['cocstatus'])
|
let _airline_section_y = airline#section#create(['cocstatus'])
|
||||||
endif
|
endif
|
||||||
" this create function returns a format string for status line (:h
|
" this create function returns a format string for status line (:h
|
||||||
" stl). the string we append is what will happend if we pass
|
" stl). the string we append is what will happend if we pass
|
||||||
@@ -596,27 +601,34 @@ endfunction
|
|||||||
let g:airline_section_x = airline#section#create(['bufnum'])
|
let g:airline_section_x = airline#section#create(['bufnum'])
|
||||||
let g:airline_section_y = _airline_section_y
|
let g:airline_section_y = _airline_section_y
|
||||||
let g:airline_section_z = airline#section#create(['filetype'])
|
let g:airline_section_z = airline#section#create(['filetype'])
|
||||||
|
|
||||||
" see source for current list
|
" see source for current list
|
||||||
function s:aireline_refresh(timer)
|
function s:airline_refresh(timer)
|
||||||
if exists(':AirlineRefresh')
|
:AirlineRefresh!
|
||||||
:AirlineRefresh!
|
|
||||||
end
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
autocmd! CursorMoved * call s:aireline_refresh(0)
|
autocmd! CursorMoved * call s:airline_refresh(0)
|
||||||
" if !g:high_performence
|
" if !g:high_performence
|
||||||
" call timer_start(100, 's:aireline_refresh', {'repeat' : -1 })
|
" call timer_start(100, 's:aireline_refresh', {'repeat' : -1 })
|
||||||
" endif
|
" endif
|
||||||
|
|
||||||
function! s:airlineconfig()
|
|
||||||
let g:my_config[&background].airline_theme = g:airline_theme
|
|
||||||
endfunction
|
|
||||||
autocmd AirlineAu User AirlineAfterTheme call s:airlineconfig()
|
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:airlineconfig()
|
||||||
|
" TODO
|
||||||
|
" the problem is that colorscheme command will trigger this function
|
||||||
|
" and at that time background=new but airline_theme=old
|
||||||
|
" Right now I decide to modify airline them first and if the
|
||||||
|
" colorscheme has it's own ariline theme it will override user
|
||||||
|
" choice.
|
||||||
|
" call add(g:msgs, g:ccc)
|
||||||
|
" call add(g:msgs, g:airline_theme)
|
||||||
|
" call add(g:msgs, &background)
|
||||||
|
" let g:my_config[&background].airline_theme = g:airline_theme
|
||||||
|
endfunction
|
||||||
|
|
||||||
augroup AirlineAu
|
augroup AirlineAu
|
||||||
autocmd!
|
autocmd!
|
||||||
|
autocmd User AirlineAfterTheme call s:airlineconfig()
|
||||||
autocmd User AirlineAfterInit call AirlineInit()
|
autocmd User AirlineAfterInit call AirlineInit()
|
||||||
augroup end
|
augroup end
|
||||||
|
|
||||||
@@ -647,12 +659,7 @@ endfunction
|
|||||||
\ '' : 'V',
|
\ '' : 'V',
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
if HasPlug("vim-airline-themes/")
|
|
||||||
"let g:airline_theme = 'solarized'
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
" }
|
|
||||||
"endif
|
|
||||||
|
|
||||||
" junegunn/fzf {
|
" junegunn/fzf {
|
||||||
if HasPlug("fzf") && HasPlug("fzf.vim")
|
if HasPlug("fzf") && HasPlug("fzf.vim")
|
||||||
@@ -678,6 +685,7 @@ endfunction
|
|||||||
\ 'grep -R --line-number --exclude-dir=".git;.svn" --color=always -- '.shellescape(<q-args>), 1,
|
\ 'grep -R --line-number --exclude-dir=".git;.svn" --color=always -- '.shellescape(<q-args>), 1,
|
||||||
\ fzf#vim#with_preview(), <bang>0)
|
\ fzf#vim#with_preview(), <bang>0)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
command! -bang -nargs=* CFile
|
command! -bang -nargs=* CFile
|
||||||
\ call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case --vimgrep -- "
|
\ call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case --vimgrep -- "
|
||||||
\ .shellescape(<q-args>). " ".expand('%'),
|
\ .shellescape(<q-args>). " ".expand('%'),
|
||||||
@@ -685,17 +693,25 @@ endfunction
|
|||||||
|
|
||||||
function! FzfColorSelect(color_name)
|
function! FzfColorSelect(color_name)
|
||||||
execute("colorscheme " . a:color_name)
|
execute("colorscheme " . a:color_name)
|
||||||
call Theme_persistent(a:color_name)
|
let g:my_config.background = &background
|
||||||
|
let g:my_config[&background].theme = a:color_name
|
||||||
if has_key(g:colo2airline, a:color_name )
|
if has_key(g:colo2airline, a:color_name )
|
||||||
call SetStatusLineTheme(g:colo2airline[a:color_name])
|
call SetStatusLineTheme(&background, g:colo2airline[a:color_name])
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! FzfAirlineColorSelect(color_name)
|
||||||
|
call SetStatusLineTheme(&background, a:color_name)
|
||||||
|
endfunction
|
||||||
|
|
||||||
noremap <leader>fr :Rg<CR>
|
noremap <leader>fr :Rg<CR>
|
||||||
noremap <leader>ff :Files<CR>
|
noremap <leader>ff :Files<CR>
|
||||||
noremap <leader>ft :CFile<CR>
|
noremap <leader>ft :CFile<CR>
|
||||||
noremap <leader>fc :call fzf#vim#colors({
|
noremap <leader>fc :call fzf#vim#colors({
|
||||||
\ 'sink': function('FzfColorSelect')})<CR>
|
\ 'sink': function('FzfColorSelect')})<CR>
|
||||||
|
noremap <leader>fa :call fzf#run(fzf#wrap({
|
||||||
|
\ 'source': airline#util#themes(''),
|
||||||
|
\ 'sink': function('FzfAirlineColorSelect')}))<CR>
|
||||||
endif
|
endif
|
||||||
" }
|
" }
|
||||||
|
|
||||||
@@ -771,7 +787,7 @@ endfunction
|
|||||||
function! Everforest_trans_enable()
|
function! Everforest_trans_enable()
|
||||||
let g:everforest_transparent_background = 2
|
let g:everforest_transparent_background = 2
|
||||||
colorscheme everforest
|
colorscheme everforest
|
||||||
call SetStatusLineTheme('everforest')
|
call SetStatusLineTheme(&background, 'everforest')
|
||||||
" hack to fix caret characters appearing in the statusline when StatusLine
|
" 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)
|
" and StatusLineNC has same highlight(https://vi.stackexchange.com/questions/15873/carets-in-status-line)
|
||||||
hi StatusLine guifg=#d3c6aa ctermfg=223
|
hi StatusLine guifg=#d3c6aa ctermfg=223
|
||||||
@@ -779,7 +795,7 @@ endfunction
|
|||||||
function! Everforest_trans_disable()
|
function! Everforest_trans_disable()
|
||||||
let g:everforest_transparent_background = 0
|
let g:everforest_transparent_background = 0
|
||||||
colorscheme everforest
|
colorscheme everforest
|
||||||
call SetStatusLineTheme('everforest')
|
call SetStatusLineTheme(&background, 'everforest')
|
||||||
endfunction
|
endfunction
|
||||||
function! CB_dark_tb_enable_everforest()
|
function! CB_dark_tb_enable_everforest()
|
||||||
call Everforest_trans_enable()
|
call Everforest_trans_enable()
|
||||||
@@ -823,43 +839,33 @@ endfunction
|
|||||||
"""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""
|
||||||
nmap <Leader>db :call ShowHighLightGroup()<CR>
|
nmap <Leader>db :call ShowHighLightGroup()<CR>
|
||||||
|
|
||||||
function! SetDarkTheme(...)
|
function! SetTheme(bg, ...)
|
||||||
let colors_name = a:0 > 0 ? a:1 : g:my_config.dark.theme
|
let colors_name = a:0 > 0 ? a:1 : g:my_config[a:bg].theme
|
||||||
if HasColorscheme(colors_name)
|
if HasColorscheme(colors_name)
|
||||||
|
let g:my_config.background = a:bg
|
||||||
|
let g:my_config[a:bg].theme = colors_name
|
||||||
|
call SetStatusLineTheme(a:bg)
|
||||||
execute("colorscheme " . colors_name)
|
execute("colorscheme " . colors_name)
|
||||||
if &background == 'light'
|
if &background != a:bg
|
||||||
set background=dark
|
execute('set background='.a:bg)
|
||||||
endif
|
endif
|
||||||
let g:my_config.dark.theme = colors_name
|
|
||||||
let g:my_config.background = 'dark'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! SetLightTheme(...)
|
|
||||||
let colors_name = a:0 > 0 ? a:1 : g:my_config.light.theme
|
|
||||||
if HasColorscheme(colors_name)
|
|
||||||
execute("colorscheme " . colors_name)
|
|
||||||
if &background == 'dark'
|
|
||||||
set background=light
|
|
||||||
endif
|
|
||||||
let g:my_config.light.theme = colors_name
|
|
||||||
let g:my_config.background = 'light'
|
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Change bottom airline/lualine theme
|
" Change bottom airline/lualine theme
|
||||||
function! SetStatusLineTheme(...)
|
function! SetStatusLineTheme(bg, ...)
|
||||||
if has('nvim-0.5')
|
if has('nvim-0.5')
|
||||||
" lualine will change theme automatically
|
" lualine will change theme automatically
|
||||||
else
|
else
|
||||||
if HasPlug('vim-airline') && HasPlug('vim-airline-themes') && exists(':AirlineTheme')
|
if HasPlug('vim-airline') && HasPlug('vim-airline-themes') && exists(':AirlineTheme')
|
||||||
let theme = a:0 > 0 ? a:1 : g:my_config[&background].airline_theme
|
let theme = a:0 > 0 ? a:1 : g:my_config[a:bg].airline_theme
|
||||||
try
|
try
|
||||||
execute('AirlineTheme ' . theme)
|
execute('AirlineTheme ' . theme)
|
||||||
catch
|
catch
|
||||||
let theme = g:default_config[&background].airline_theme
|
let theme = g:default_config[a:bg].airline_theme
|
||||||
execute('AirlineTheme ' . theme)
|
execute('AirlineTheme ' . theme)
|
||||||
endtry
|
endtry
|
||||||
|
let g:my_config[a:bg].airline_theme = theme
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@@ -910,13 +916,8 @@ endfunction
|
|||||||
" Allow to trigger background
|
" Allow to trigger background
|
||||||
function! ToggleBG()
|
function! ToggleBG()
|
||||||
" Inversion
|
" Inversion
|
||||||
if &background == "dark"
|
let newbg = &background == "dark" ? 'light' : 'dark'
|
||||||
call SetLightTheme()
|
call SetTheme(newbg)
|
||||||
else
|
|
||||||
call SetDarkTheme()
|
|
||||||
endif
|
|
||||||
call SetStatusLineTheme(g:my_config[&background].airline_theme)
|
|
||||||
|
|
||||||
if g:my_config[&background].transparent
|
if g:my_config[&background].transparent
|
||||||
call EnableTransparent()
|
call EnableTransparent()
|
||||||
else
|
else
|
||||||
@@ -927,7 +928,6 @@ endfunction
|
|||||||
" persistent config over colorscheme change
|
" persistent config over colorscheme change
|
||||||
function! Theme_persistent(...)
|
function! Theme_persistent(...)
|
||||||
let color_name = a:0 > 0 ? a:1 : ColourSchemeName()
|
let color_name = a:0 > 0 ? a:1 : ColourSchemeName()
|
||||||
|
|
||||||
let g:my_config.background = &background
|
let g:my_config.background = &background
|
||||||
let g:my_config[&background].theme = color_name
|
let g:my_config[&background].theme = color_name
|
||||||
endfunction
|
endfunction
|
||||||
@@ -940,23 +940,15 @@ endfunction
|
|||||||
set termguicolors
|
set termguicolors
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if g:my_config.background == 'dark'
|
let bg = g:my_config.background
|
||||||
if HasColorscheme(g:my_config.dark.theme)
|
if HasColorscheme(g:my_config[bg].theme)
|
||||||
call SetDarkTheme()
|
call SetTheme(bg)
|
||||||
else
|
|
||||||
call SetDarkTheme(g:my_config.dark.default)
|
|
||||||
endif
|
|
||||||
call SetStatusLineTheme(g:my_config.dark.airline_theme)
|
|
||||||
else
|
else
|
||||||
if HasColorscheme(g:my_config.dark.theme)
|
call SetTheme(bg, g:my_config[bg].default)
|
||||||
call SetLightTheme()
|
|
||||||
else
|
|
||||||
call SetLightTheme(g:my_config.light.default)
|
|
||||||
endif
|
|
||||||
call SetStatusLineTheme(g:my_config.light.airline_theme)
|
|
||||||
endif
|
endif
|
||||||
|
call SetStatusLineTheme(bg)
|
||||||
|
|
||||||
if g:my_config[g:my_config.background].transparent
|
if g:my_config[bg].transparent
|
||||||
call EnableTransparent()
|
call EnableTransparent()
|
||||||
else
|
else
|
||||||
call DisableTransparent()
|
call DisableTransparent()
|
||||||
@@ -1015,6 +1007,8 @@ endfunction
|
|||||||
" For them please check plugin Preferences)
|
" For them please check plugin Preferences)
|
||||||
" {
|
" {
|
||||||
|
|
||||||
|
nnoremap <leader>ws :call TrimWhitespace()<CR>
|
||||||
|
|
||||||
" Toggle dark/light theme
|
" Toggle dark/light theme
|
||||||
noremap <silent> <leader>bg :call ToggleBG()<CR>
|
noremap <silent> <leader>bg :call ToggleBG()<CR>
|
||||||
|
|
||||||
@@ -1028,6 +1022,10 @@ endfunction
|
|||||||
" leader s change all occurence
|
" leader s change all occurence
|
||||||
nnoremap <Leader>s :%s/\<<C-r><C-w>\>/<C-r><C-w>
|
nnoremap <Leader>s :%s/\<<C-r><C-w>\>/<C-r><C-w>
|
||||||
|
|
||||||
|
" disable two easily mispressed yet useless key
|
||||||
|
nnoremap q: <nop>
|
||||||
|
nnoremap Q <nop>
|
||||||
|
|
||||||
" leader num change tab
|
" leader num change tab
|
||||||
" only for vim or nvim without lualine
|
" only for vim or nvim without lualine
|
||||||
|
|
||||||
@@ -1048,7 +1046,7 @@ endfunction
|
|||||||
" }
|
" }
|
||||||
|
|
||||||
" Lua configuration
|
" Lua configuration
|
||||||
if g:vim_type == 'nvim' && filereadable(g:mydotfiles_directory . '.vimrc.lua')
|
if has('nvim') && filereadable(g:mydotfiles_directory . '.vimrc.lua')
|
||||||
execute('source ' . g:mydotfiles_directory . '/.vimrc.lua')
|
execute('source ' . g:mydotfiles_directory . '/.vimrc.lua')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
+31
-26
@@ -140,7 +140,7 @@ local function toggleterm_config()
|
|||||||
border = 'rounded',
|
border = 'rounded',
|
||||||
width = function(term) return math.floor(vim.o.columns * 0.5) end,
|
width = function(term) return math.floor(vim.o.columns * 0.5) end,
|
||||||
height = function(term) return math.floor(vim.o.lines * 0.5) end,
|
height = function(term) return math.floor(vim.o.lines * 0.5) end,
|
||||||
winblend = 2,
|
winblend = 20,
|
||||||
row = vim.o.lines * 0.5 - 3,
|
row = vim.o.lines * 0.5 - 3,
|
||||||
col = vim.o.columns * 0.5,
|
col = vim.o.columns * 0.5,
|
||||||
},
|
},
|
||||||
@@ -502,33 +502,39 @@ local function nvim_tree_config()
|
|||||||
vim.g.loaded_netrw = 1
|
vim.g.loaded_netrw = 1
|
||||||
vim.g.loaded_netrwPlugin = 1
|
vim.g.loaded_netrwPlugin = 1
|
||||||
|
|
||||||
-- set termguicolors to enable highlight groups
|
local api = require('nvim-tree.api')
|
||||||
vim.opt.termguicolors = true
|
local M = {}
|
||||||
|
|
||||||
-- setup with some options
|
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({
|
require("nvim-tree").setup({
|
||||||
sort_by = "case_sensitive",
|
sort_by = "case_sensitive",
|
||||||
|
on_attach = M.on_attach,
|
||||||
view = {
|
view = {
|
||||||
width = 30,
|
width = 30,
|
||||||
mappings = {
|
|
||||||
list = {
|
|
||||||
{ key = "C-[", action = "dir_up" },
|
|
||||||
{ key = "C-]", action = "cd" },
|
|
||||||
{ key = "<C-k>", action = "toggle_file_info" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
renderer = {
|
|
||||||
group_empty = true,
|
|
||||||
icons = {
|
|
||||||
show = {
|
|
||||||
file = show_icon,
|
|
||||||
folder = show_icon,
|
|
||||||
folder_arrow = show_icon,
|
|
||||||
git = show_icon,
|
|
||||||
modified = show_icon,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
filters = {
|
filters = {
|
||||||
dotfiles = false,
|
dotfiles = false,
|
||||||
@@ -539,15 +545,14 @@ local function nvim_tree_config()
|
|||||||
resize_window = true,
|
resize_window = true,
|
||||||
window_picker = {
|
window_picker = {
|
||||||
exclude = {
|
exclude = {
|
||||||
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
|
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame", "vista" },
|
||||||
buftype = { "nofile", "terminal", "help" },
|
buftype = { "nofile", "terminal", "help" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>e', ':NvimTreeFindFileToggle<CR>', { noremap = true, silent = true })
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim_version_minor >= 5 then
|
if vim_version_minor >= 5 then
|
||||||
|
|||||||
+3
-1
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
" let g:coc_global_extensions = ['coc-pyright', 'coc-rls', 'coc-clangd', 'coc-tsserver', 'coc-html', 'coc-cmake', 'coc-json', 'coc-sh', 'coc-java']
|
" let g:coc_global_extensions = ['coc-pyright', 'coc-rls', 'coc-clangd', 'coc-tsserver', 'coc-html', 'coc-cmake', 'coc-json', 'coc-sh', 'coc-java']
|
||||||
let g:coc_global_extensions = ['coc-pyright', 'coc-tsserver']
|
" let g:coc_global_extensions = ['coc-pyright', 'coc-tsserver']
|
||||||
|
|
||||||
let g:coc_data_home = g:vim_dir . '/coc'
|
let g:coc_data_home = g:vim_dir . '/coc'
|
||||||
let g:coc_config_home = g:vim_dir . '/coc'
|
let g:coc_config_home = g:vim_dir . '/coc'
|
||||||
@@ -97,4 +97,6 @@ for section in ['suggest', 'diagnostic', 'signature', 'hover']
|
|||||||
call coc#config(section.'.floatConfig.border', v:true)
|
call coc#config(section.'.floatConfig.border', v:true)
|
||||||
call coc#config(section.'.floatConfig.rounded', v:true)
|
call coc#config(section.'.floatConfig.rounded', v:true)
|
||||||
call coc#config(section.'.floatConfig.highlight', 'Normal')
|
call coc#config(section.'.floatConfig.highlight', 'Normal')
|
||||||
|
" transparent setting (only for neovim)
|
||||||
|
call coc#config(section.'.floatConfig.winblend', 6)
|
||||||
endfor
|
endfor
|
||||||
|
|||||||
@@ -197,3 +197,10 @@ function! GenVimAsciiArt(buffer_str_len)
|
|||||||
endif
|
endif
|
||||||
return ascii_art
|
return ascii_art
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"Remove all trailing whitespace by pressing <leader>ws
|
||||||
|
fun! TrimWhitespace()
|
||||||
|
let l:save = winsaveview()
|
||||||
|
keeppatterns %s/\s\+$//e
|
||||||
|
call winrestview(l:save)
|
||||||
|
endfun
|
||||||
|
|||||||
Reference in New Issue
Block a user