" These default mappings should either go in your .vimrc or in a file that " you're going to source from your .vimrc. For example, you can copy this file " into your ~ directory and then put the following in your .vimrc to source it " " coc.nvim lsp mappings "if filereadable(expand("~/coc-mappings.vim")) " source ~/coc-mappings.vim" "endif " " " If you're curious how to share this or your .vimrc with both vim and nvim, " you can find a great instructions about this here " https://neovim.io/doc/user/nvim.html#nvim-from-vim " " Finally, keep in mind that these are "suggested" settings. Play around with " them and change them to your liking. " If hidden is not set, TextEdit might fail. set hidden " Some servers have issues with backup files set nobackup set nowritebackup " You will have a bad experience with diagnostic messages with the default of 4000. set updatetime=300 " Don't give |ins-completion-menu| messages. set shortmess+=c " Always show signcolumns set signcolumn=yes " Use tab for trigger completion with characters ahead and navigate. " Use command ':verbose imap ' to make sure tab is not mapped by another plugin. inoremap \ pumvisible() ? "\" : \ check_back_space() ? "\" : \ coc#refresh() inoremap pumvisible() ? "\" : "\" " Used in the tab autocompletion for coc function! s:check_back_space() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction " Use to trigger completion. inoremap coc#refresh() " Use to confirm completion, `u` means break undo chain at current " position. " Coc only does snippet and additional edit on confirm. inoremap pumvisible() ? "\" : "\u\" " Use `[g` and `]g` to navigate diagnostics nmap [g (coc-diagnostic-prev) nmap ]g (coc-diagnostic-next) " Remap keys for gotos nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) " For Neovim only! Used to expand decorations in worksheets nmap ws (coc-metals-expand-decoration) " Use K to either doHover or show documentation in preview window nnoremap K :call show_documentation() function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') else call CocAction('doHover') endif endfunction " Highlight symbol under cursor on CursorHold autocmd CursorHold * silent call CocActionAsync('highlight') " Remap for rename current word nmap rn (coc-rename) " Remap for format selected region xmap f (coc-format-selected) nmap f (coc-format-selected) augroup mygroup autocmd! " Setup formatexpr specified filetype(s). autocmd FileType scala setl formatexpr=CocAction('formatSelected') " Update signature help on jump placeholder autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') augroup end " Remap for do codeAction of current line xmap a (coc-codeaction-line) nmap a (coc-codeaction-line) " Fix autofix problem of current line nmap qf (coc-fix-current) " Use `:Format` to format current buffer command! -nargs=0 Format :call CocActionAsync('format') " Use `:Fold` to fold current buffer command! -nargs=? Fold :call CocAction('fold', ) " For Neovim only! Trigger for code actions " Make sure `"codeLens.enable": true` is set in your coc config nnoremap cl :call CocActionAsync('codeLensAction') " Show all diagnostics nnoremap a :CocList diagnostics " Manage extensions nnoremap e :CocList extensions " Show commands nnoremap c :CocList commands " Find symbol of current document nnoremap o :CocList outline " Search workspace symbols nnoremap s :CocList -I symbols " Do default action for next item. nnoremap j :CocNext " Do default action for previous item. nnoremap k :CocPrev " Resume latest coc list nnoremap p :CocListResume " Notify coc.nvim that has been pressed. " Currently used for the formatOnType feature. inoremap pumvisible() ? coc#_select_confirm() \: "\u\\=coc#on_enter()\" " Toggle panel with Tree Views nnoremap t :CocCommand metals.tvp " Toggle Tree View 'metalsPackages' nnoremap tp :CocCommand metals.tvp metalsPackages " Toggle Tree View 'metalsCompile' nnoremap tc :CocCommand metals.tvp metalsCompile " Toggle Tree View 'metalsBuild' nnoremap tb :CocCommand metals.tvp metalsBuild " Reveal current current class (trait or object) in Tree View 'metalsPackages' nnoremap tf :CocCommand metals.revealInTreeView metalsPackages