From 8cda9923dcf8dfb13fef0efd18ee3f554d28d949 Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Thu, 23 Mar 2023 16:20:14 -0400 Subject: [PATCH] fix some bugs --- .vimrc | 48 +++-------- .vimrc.bundles | 202 ++++++++++++++++++++++---------------------- .vimrc.lua | 57 +++++++------ coc-nvim-config.vim | 4 +- utils.vim | 7 ++ 5 files changed, 152 insertions(+), 166 deletions(-) diff --git a/.vimrc b/.vimrc index 142bd90..e14f484 100644 --- a/.vimrc +++ b/.vimrc @@ -64,14 +64,19 @@ 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+=- - " 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 - " set it to the first line when editing a git commit message - au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0]) + 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 + 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 " Restore cursor to file position in previous editing session @@ -104,11 +109,6 @@ " set showmode " Display the current mode 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) if has('cmdline_info') @@ -143,11 +143,6 @@ set shiftwidth=4 " Use indents of 4 spaces set tabstop=4 " An indentation every four columns 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 splitright " Puts new vsplit windows to the right of the current @@ -160,28 +155,8 @@ set listchars=tab:•\ ,trail:•,extends:»,precedes:« " Unprintable chars mapping - "Remove all trailing whitespace by pressing ws - fun! TrimWhitespace() - let l:save = winsaveview() - keeppatterns %s/\s\+$//e - call winrestview(l:save) - endfun - nnoremap ws :call TrimWhitespace() set nospell " Spell checking off - - 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 endif " } - diff --git a/.vimrc.bundles b/.vimrc.bundles index 48b089c..5002bb1 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -7,7 +7,7 @@ " KEY_MAPS " 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:autocomplte_enable = v:true 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:swap_dict = [ - \ ['false', '0', 'dark' ], - \ ['true' , '1', 'light']] + \ ['v:false', '0', 'dark', 'false' ], + \ ['v:true' , '1', 'light', 'true']] " convinient function to swap between two options nmap t :call SwapWord() @@ -59,9 +59,9 @@ nmap t :call SwapWord() \ && g:copilot_enable && executable('node')) 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 - " Plug 'roxma/nvim-yarp', Cond(g:vim_type == 'vim') - " Plug 'roxma/vim-hug-neovim-rpc', Cond(g:vim_type == 'vim') + " " To use Python remote plugin features in Vim for wilder, can be skipped + " " Plug 'roxma/nvim-yarp', 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 'simeji/winresizer', Cond(!g:high_performence) @@ -75,7 +75,7 @@ nmap t :call SwapWord() Plug 'RRethy/vim-illuminate', Cond(!g:high_performence) "Plug 'easymotion/vim-easymotion' Plug 'mhinz/vim-startify' - Plug 'ludovicchabant/vim-gutentags' + " Plug 'ludovicchabant/vim-gutentags' Plug 'christoomey/vim-tmux-navigator' Plug 'airblade/vim-rooter' @@ -168,6 +168,7 @@ nmap t :call SwapWord() " plugins to mess around with them " import ultilities functions + execute('source ' . g:mydotfiles_directory . '/utils.vim') function! HasPlug(plug_name, ...) @@ -217,12 +218,12 @@ endfunction " { if HasPlug('vim-floaterm') let g:floaterm_wintype = 'float' - let g:floaterm_keymap_toggle = '' + let g:floaterm_keymap_toggle = '' let g:floaterm_position = 'bottomright' let g:floaterm_width = 0.5 let g:floaterm_height = 0.5 autocmd QuitPre * :FloatermKill! - tmap N + autocmd FileType floaterm tmap endif if HasPlug('Copilot.vim') " imap (copilot-next) @@ -269,6 +270,7 @@ endfunction 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', '') @@ -280,6 +282,7 @@ endfunction 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') @@ -293,47 +296,35 @@ endfunction let g:vista_last_row = found endif endfunction - autocmd BufLeave * call VistaH2() - " autocmd WinLeave call VistaH2() 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\") - else - execute "normal! :q!\" - endif - endif - endfunction - - " close vista when it is the last window - " autocmd BufEnter * if winnr('$') == 1 && bufname() == "__vista__" | execute "normal! :q!\" | endif - " autocmd BufEnter * call VistaHelper() - endif if HasPlug('indentLine') let g:indentLine_fileTypeExclude = ['startify'] 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 = { - \ 'vim': ['vimVar', 'vimString', 'vimFuncName', - \ 'vimFunction', 'vimUserFunc', 'vimFunc'], + \ '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'] + 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 autocmd! - autocmd VimEnter * 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 endif @@ -342,6 +333,7 @@ endfunction call wilder#setup({ \ 'modes': [':'], \ 'next_key': '', + \ 'previous_key': '', \ 'enable_cmdline_enter': 0, \ }) @@ -420,6 +412,7 @@ endfunction 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 @@ -452,7 +445,6 @@ endfunction endif " } - " bling/vim-bufferline { if HasPlug("vim-bufferline") && HasPlug("vim-airline") let g:bufferline_echo = 0 let g:bufferline_modified = '+' @@ -461,10 +453,10 @@ endfunction let g:bufferline_active_buffer_left = '' let g:bufferline_active_buffer_right = '' + let g:bufferline_inactive_highlight = 'airline_b_inactive' + let g:bufferline_active_highlight = 'airline_b_bold' endif - " } - " mbbill/undotree { if HasPlug("undotree") nnoremap ut :UndotreeToggle @@ -490,7 +482,16 @@ endfunction let g:NERDTreeMinimalMenu = v:true let g:NERDTreeMinimalUI = v:true - "nnoremap :NERDTreeToggle + 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() let my_filetype = &filetype let specical_fts = ['nerdtree', 'startify'] @@ -519,6 +520,7 @@ endfunction " 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 + " } " nvim-tree.lua { @@ -572,17 +574,20 @@ endfunction " This must use my fork version of bufferline let g:bufferline_max_length = &columns - 22 function! AirlineBufferNumber() - return len(g:index_to_buffer) . " " + return len(g:index_to_buffer) endfunction call airline#parts#define_function('bufnum', 'AirlineBufferNumber') call airline#parts#define_function('cocstatus', 'AirlineCocStatus') 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() let _airline_section_y = '' if HasPlug('coc.nvim') - let _airline_section_y .= airline#section#create(['cocstatus']) + let _airline_section_y = airline#section#create(['cocstatus']) endif " this create function returns a format string for status line (:h " 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_y = _airline_section_y let g:airline_section_z = airline#section#create(['filetype']) - " see source for current list - function s:aireline_refresh(timer) - if exists(':AirlineRefresh') - :AirlineRefresh! - end + function s:airline_refresh(timer) + :AirlineRefresh! endfunction - autocmd! CursorMoved * call s:aireline_refresh(0) + autocmd! CursorMoved * call s:airline_refresh(0) " if !g:high_performence " call timer_start(100, 's:aireline_refresh', {'repeat' : -1 }) " endif - function! s:airlineconfig() - let g:my_config[&background].airline_theme = g:airline_theme - endfunction - autocmd AirlineAu User AirlineAfterTheme call s:airlineconfig() - 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 autocmd! + autocmd User AirlineAfterTheme call s:airlineconfig() autocmd User AirlineAfterInit call AirlineInit() augroup end @@ -647,12 +659,7 @@ endfunction \ '' : 'V', \ } - if HasPlug("vim-airline-themes/") - "let g:airline_theme = 'solarized' - endif endif - " } - "endif " junegunn/fzf { if HasPlug("fzf") && HasPlug("fzf.vim") @@ -678,6 +685,7 @@ endfunction \ 'grep -R --line-number --exclude-dir=".git;.svn" --color=always -- '.shellescape(), 1, \ fzf#vim#with_preview(), 0) endif + command! -bang -nargs=* CFile \ call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case --vimgrep -- " \ .shellescape(). " ".expand('%'), @@ -685,17 +693,25 @@ endfunction function! FzfColorSelect(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 ) - call SetStatusLineTheme(g:colo2airline[a:color_name]) + call SetStatusLineTheme(&background, g:colo2airline[a:color_name]) endif endfunction + function! FzfAirlineColorSelect(color_name) + call SetStatusLineTheme(&background, a:color_name) + endfunction + noremap fr :Rg noremap ff :Files noremap ft :CFile noremap fc :call fzf#vim#colors({ \ 'sink': function('FzfColorSelect')}) + noremap fa :call fzf#run(fzf#wrap({ + \ 'source': airline#util#themes(''), + \ 'sink': function('FzfAirlineColorSelect')})) endif " } @@ -771,7 +787,7 @@ endfunction function! Everforest_trans_enable() let g:everforest_transparent_background = 2 colorscheme everforest - call SetStatusLineTheme('everforest') + call SetStatusLineTheme(&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 @@ -779,7 +795,7 @@ endfunction function! Everforest_trans_disable() let g:everforest_transparent_background = 0 colorscheme everforest - call SetStatusLineTheme('everforest') + call SetStatusLineTheme(&background, 'everforest') endfunction function! CB_dark_tb_enable_everforest() call Everforest_trans_enable() @@ -823,43 +839,33 @@ endfunction """"""""""""""""""""""""""""""""""""""" nmap db :call ShowHighLightGroup() - function! SetDarkTheme(...) - let colors_name = a:0 > 0 ? a:1 : g:my_config.dark.theme + function! SetTheme(bg, ...) + let colors_name = a:0 > 0 ? a:1 : g:my_config[a:bg].theme 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) - if &background == 'light' - set background=dark + if &background != a:bg + execute('set background='.a:bg) 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 endfunction " Change bottom airline/lualine theme - function! SetStatusLineTheme(...) + function! SetStatusLineTheme(bg, ...) if has('nvim-0.5') " lualine will change theme automatically else 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 execute('AirlineTheme ' . theme) catch - let theme = g:default_config[&background].airline_theme + let theme = g:default_config[a:bg].airline_theme execute('AirlineTheme ' . theme) endtry + let g:my_config[a:bg].airline_theme = theme endif endif endfunction @@ -910,13 +916,8 @@ endfunction " Allow to trigger background function! ToggleBG() " Inversion - if &background == "dark" - call SetLightTheme() - else - call SetDarkTheme() - endif - call SetStatusLineTheme(g:my_config[&background].airline_theme) - + let newbg = &background == "dark" ? 'light' : 'dark' + call SetTheme(newbg) if g:my_config[&background].transparent call EnableTransparent() else @@ -927,7 +928,6 @@ endfunction " persistent config over colorscheme change function! Theme_persistent(...) let color_name = a:0 > 0 ? a:1 : ColourSchemeName() - let g:my_config.background = &background let g:my_config[&background].theme = color_name endfunction @@ -940,23 +940,15 @@ endfunction set termguicolors endif - if g:my_config.background == 'dark' - if HasColorscheme(g:my_config.dark.theme) - call SetDarkTheme() - else - call SetDarkTheme(g:my_config.dark.default) - endif - call SetStatusLineTheme(g:my_config.dark.airline_theme) + let bg = g:my_config.background + if HasColorscheme(g:my_config[bg].theme) + call SetTheme(bg) else - if HasColorscheme(g:my_config.dark.theme) - call SetLightTheme() - else - call SetLightTheme(g:my_config.light.default) - endif - call SetStatusLineTheme(g:my_config.light.airline_theme) + call SetTheme(bg, g:my_config[bg].default) endif + call SetStatusLineTheme(bg) - if g:my_config[g:my_config.background].transparent + if g:my_config[bg].transparent call EnableTransparent() else call DisableTransparent() @@ -1015,6 +1007,8 @@ endfunction " For them please check plugin Preferences) " { + nnoremap ws :call TrimWhitespace() + " Toggle dark/light theme noremap bg :call ToggleBG() @@ -1028,6 +1022,10 @@ endfunction " leader s change all occurence nnoremap s :%s/\<\>/ + " disable two easily mispressed yet useless key + nnoremap q: + nnoremap Q + " leader num change tab " only for vim or nvim without lualine @@ -1048,7 +1046,7 @@ endfunction " } " 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') endif diff --git a/.vimrc.lua b/.vimrc.lua index c824060..62f72f1 100644 --- a/.vimrc.lua +++ b/.vimrc.lua @@ -140,7 +140,7 @@ local function toggleterm_config() 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 = 2, + winblend = 20, row = vim.o.lines * 0.5 - 3, col = vim.o.columns * 0.5, }, @@ -502,33 +502,39 @@ local function nvim_tree_config() vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 - -- set termguicolors to enable highlight groups - vim.opt.termguicolors = true + local api = require('nvim-tree.api') + 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', '', api.node.open.edit, opts('Open')) + end + + vim.api.nvim_set_keymap('n', 'e', ':NvimTreeFindFileToggle', + { desc = 'Toggle nvim-tree', noremap = true, silent = true, nowait = true }) require("nvim-tree").setup({ sort_by = "case_sensitive", + on_attach = M.on_attach, view = { width = 30, - mappings = { - list = { - { key = "C-[", action = "dir_up" }, - { key = "C-]", action = "cd" }, - { key = "", 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 = { dotfiles = false, @@ -539,15 +545,14 @@ local function nvim_tree_config() resize_window = true, window_picker = { exclude = { - filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, - buftype = { "nofile", "terminal", "help" }, + filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame", "vista" }, + buftype = { "nofile", "terminal", "help" }, }, }, }, }, }) - vim.api.nvim_set_keymap('n', 'e', ':NvimTreeFindFileToggle', { noremap = true, silent = true }) end if vim_version_minor >= 5 then diff --git a/coc-nvim-config.vim b/coc-nvim-config.vim index 161a9c0..2838696 100644 --- a/coc-nvim-config.vim +++ b/coc-nvim-config.vim @@ -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-tsserver'] +" let g:coc_global_extensions = ['coc-pyright', 'coc-tsserver'] let g:coc_data_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.rounded', v:true) call coc#config(section.'.floatConfig.highlight', 'Normal') + " transparent setting (only for neovim) + call coc#config(section.'.floatConfig.winblend', 6) endfor diff --git a/utils.vim b/utils.vim index efc23ed..4daa975 100644 --- a/utils.vim +++ b/utils.vim @@ -197,3 +197,10 @@ function! GenVimAsciiArt(buffer_str_len) endif return ascii_art endfunction + +"Remove all trailing whitespace by pressing ws +fun! TrimWhitespace() + let l:save = winsaveview() + keeppatterns %s/\s\+$//e + call winrestview(l:save) +endfun