update nvim

This commit is contained in:
Alexander Bocken 2022-05-01 19:01:10 +02:00
parent fe8594f819
commit affab904cb
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8

View File

@ -7,40 +7,33 @@ if ! filereadable(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autolo
autocmd VimEnter * PlugInstall autocmd VimEnter * PlugInstall
endif endif
call plug#begin(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/plugged"')) call plug#begin(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/plugged"'))
Plug 'tpope/vim-surround' Plug 'tpope/vim-surround'
Plug 'preservim/nerdtree' Plug 'preservim/nerdtree'
Plug 'junegunn/goyo.vim' Plug 'junegunn/goyo.vim'
Plug 'PotatoesMaster/i3-vim-syntax'
Plug 'jreybert/vimagit' Plug 'jreybert/vimagit'
Plug 'lukesmithxyz/vimling' Plug 'lukesmithxyz/vimling'
Plug 'vimwiki/vimwiki' Plug 'vimwiki/vimwiki'
Plug 'bling/vim-airline' Plug 'vim-airline/vim-airline'
Plug 'tpope/vim-commentary' Plug 'tpope/vim-commentary'
Plug 'kovetskiy/sxhkd-vim' Plug 'neoclide/coc.nvim', {'branch': 'master', 'commit': '2ad659d8b1a3d7bef7dca7d33c6ab9363a729100', 'do': 'yarn install --frozen-lockfile'}
Plug 'ap/vim-css-color' Plug 'ap/vim-css-color'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'lervag/vimtex' Plug 'lervag/vimtex'
Plug 'terryma/vim-multiple-cursors'
Plug 'dense-analysis/ale'
Plug 'arcticicestudio/nord-vim' Plug 'arcticicestudio/nord-vim'
Plug 'tpope/vim-fugitive'
Plug 'rhysd/vim-grammarous' Plug 'rhysd/vim-grammarous'
" Plug 'goballooning/vim-live-latex-preview' Plug 'da-h/AirLatex.vim', {'do': ':UpdateRemotePlugins'}
call plug#end() call plug#end()
" Integrated spell-check set title
"set spell
" set spellang = en,de
nnoremap <silent> <F11> :set spell!<cr>
inoremap <silent> <F11> <C-O>:set spell!<cr>
set bg=light set bg=light
set go=a set go=a
set mouse=a set mouse=a
set nohlsearch set nohlsearch
set clipboard+=unnamedplus set clipboard+=unnamedplus
set noshowmode
set noruler
set laststatus=0
set noshowcmd
colorscheme nord colorscheme nord
@ -51,30 +44,60 @@ colorscheme nord
syntax on syntax on
set encoding=utf-8 set encoding=utf-8
set number relativenumber set number relativenumber
" Enable autocompletion: " Enable autocompletion:
set wildmode=longest,list,full set wildmode=longest,list,full
" Disables automatic commenting on newline: " Disables automatic commenting on newline:
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" Perform dot commands over visual blocks:
vnoremap . :normal .<CR>
" Goyo plugin makes text more readable when writing prose: " Goyo plugin makes text more readable when writing prose:
map <leader>f :Goyo \| set bg=light \| set linebreak<CR> map <leader>f :Goyo \| set bg=light \| set linebreak<CR>
" Spell-check set to <leader>o, 'o' for 'orthography': " Spell-check set to <leader>o, 'o' for 'orthography':
map <leader>o :setlocal spell! spelllang=en_us<CR> map <leader>o :setlocal spell! spelllang=en_us<CR>
" Splits open at the bottom and right, which is non-retarded, unlike vim defaults. " Splits open at the bottom and right, which is non-retarded, unlike vim defaults.
set splitbelow splitright set splitbelow splitright
" Nerd tree " Nerd tree
map <leader>n :NERDTreeToggle<CR> map <leader>n :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
if has('nvim')
let NERDTreeBookmarksFile = stdpath('data') . '/NERDTreeBookmarks'
else
let NERDTreeBookmarksFile = '~/.vim' . '/NERDTreeBookmarks'
endif
" AirLatex
" your login-name
let g:AirLatexUsername="cookies:overleaf_session2=s%"
" optional: set server name
let g:AirLatexDomain="www.overleaf.com"
let g:AirLatexAllowInsecure=0
" vimtex:
let g:vimtex_compiler_latexmk = { 'build_dir' : '',
\ 'callback' : 1,
\ 'continuous' : 1,
\ 'executable' : 'latexmk',
\ 'hooks' : [],
\ 'options' : [
\ '-pdflatex="pdflatex --shell-escape %O %S"',
\ '-verbose',
\ '-file-line-error',
\ '-synctex=1',
\ '-interaction=nonstopmode',
\ ],
\}
" vimling: " vimling:
nm <leader>d :call ToggleDeadKeys()<CR> "nm <leader><leader>d :call ToggleDeadKeys()<CR>
imap <leader>d <esc>:call ToggleDeadKeys()<CR>a "imap <leader><leader>d <esc>:call ToggleDeadKeys()<CR>a
nm <leader>i :call ToggleIPA()<CR> "nm <leader><leader>i :call ToggleIPA()<CR>
imap <leader>i <esc>:call ToggleIPA()<CR>a "imap <leader><leader>i <esc>:call ToggleIPA()<CR>a
nm <leader>q :call ToggleProse()<CR> "nm <leader><leader>q :call ToggleProse()<CR>
" Shortcutting split navigation, saving a keypress: " Shortcutting split navigation, saving a keypress:
map <C-h> <C-w>h map <C-h> <C-w>h
@ -86,7 +109,7 @@ colorscheme nord
map Q gq map Q gq
" Check file in shellcheck: " Check file in shellcheck:
map <leader>s :!clear && shellcheck %<CR> map <leader>s :!clear && shellcheck -x %<CR>
" Open my bibliography file in split " Open my bibliography file in split
map <leader>b :vsp<space>$BIB<CR> map <leader>b :vsp<space>$BIB<CR>
@ -96,18 +119,16 @@ colorscheme nord
nnoremap S :%s//g<Left><Left> nnoremap S :%s//g<Left><Left>
" Compile document, be it groff/LaTeX/markdown/etc. " Compile document, be it groff/LaTeX/markdown/etc.
map <leader>c :w! \| !compiler <c-r>%<CR> map <leader>c :w! \| !compiler "<c-r>%"<CR>
" Open corresponding .pdf/.html or preview " Open corresponding .pdf/.html or preview
map <leader>p :!opout <c-r>%<CR><CR> map <leader>p :!opout <c-r>%<CR><CR>
" start browser-sync for easier refresh with web-dev
nnoremap <leader>bs :!browser-sync start --server --files . > /dev/null 2>&1 &<CR>
" Runs a script that cleans out tex build files whenever I close out of a .tex file. " Runs a script that cleans out tex build files whenever I close out of a .tex file.
autocmd VimLeave *.tex !texclear % autocmd VimLeave *.tex !texclear %
" Copy selected text to system clipboard (requires gvim/nvim/vim-x11 installed):
vnoremap <C-c> "+y
map <C-p> "+P
" Ensure files are read as what I want: " Ensure files are read as what I want:
let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'} let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'}
map <leader>v :VimwikiIndex map <leader>v :VimwikiIndex
@ -119,27 +140,26 @@ colorscheme nord
" Save file as sudo on files that require root permission " Save file as sudo on files that require root permission
cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit! cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
" Enable Goyo by default for mutt writting " Enable Goyo by default for mutt writing
autocmd BufRead,BufNewFile /tmp/neomutt* let g:goyo_width=80 autocmd BufRead,BufNewFile /tmp/neomutt* let g:goyo_width=80
autocmd BufRead,BufNewFile /tmp/neomutt* :Goyo | set bg=light autocmd BufRead,BufNewFile /tmp/neomutt* :Goyo | set bg=light
autocmd BufRead,BufNewFile /tmp/neomutt* map ZZ :Goyo\|x!<CR> autocmd BufRead,BufNewFile /tmp/neomutt* map ZZ :Goyo\|x!<CR>
autocmd BufRead,BufNewFile /tmp/neomutt* map ZQ :Goyo\|q!<CR> autocmd BufRead,BufNewFile /tmp/neomutt* map ZQ :Goyo\|q!<CR>
" Automatically deletes all trailing whitespace and newlines at end of file on save. " Automatically deletes all trailing whitespace and newlines at end of file on save. & reset cursor position
autocmd BufWritePre * let currPos = getpos(".")
autocmd BufWritePre * %s/\s\+$//e autocmd BufWritePre * %s/\s\+$//e
autocmd BufWritepre * %s/\n\+\%$//e autocmd BufWritePre * %s/\n\+\%$//e
autocmd BufWritePre *.[ch] %s/\%$/\r/e
autocmd BufWritePre * cal cursor(currPos[1], currPos[2])
" When shortcut files are updated, renew bash and ranger configs with new material: " When shortcut files are updated, renew bash and ranger configs with new material:
autocmd BufWritePost files,directories !shortcuts autocmd BufWritePost bm-files,bm-dirs !shortcuts
" Run xrdb whenever Xdefaults or Xresources are updated. " Run xrdb whenever Xdefaults or Xresources are updated.
autocmd BufWritePost *Xresources,*Xdefaults !xrdb -merge % autocmd BufRead,BufNewFile Xresources,Xdefaults,xresources,xdefaults set filetype=xdefaults
" Update binds when sxhkdrc is updated. autocmd BufWritePost Xresources,Xdefaults,xresources,xdefaults !xrdb %
autocmd BufWritePost *sxhkdrc !pkill -USR1 sxhkd " Recompile dwmblocks on config edit.
autocmd BufWritePost ~/.local/src/dwmblocks/config.h !cd ~/.local/src/dwmblocks/; sudo make install && { killall -q dwmblocks;setsid -f dwmblocks }
" Turns off highlighting on the bits of code that are changed, so the line that is changed is highlighted but the actual text that has changed stands out on the line and is readable.
if &diff
highlight! link DiffText MatchParen
endif
" Navigating with guides " Navigating with guides
inoremap <leader><leader> <Esc>/<++><Enter>"_c4l inoremap <leader><leader> <Esc>/<++><Enter>"_c4l
@ -147,171 +167,29 @@ endif
map <leader><leader> <Esc>/<++><Enter>"_c4l map <leader><leader> <Esc>/<++><Enter>"_c4l
" Enable completion where available. " Turns off highlighting on the bits of code that are changed, so the line that is changed is highlighted but the actual text that has changed stands out on the line and is readable.
" This setting must be set before ALE is loaded. if &diff
" highlight! link DiffText MatchParen
" You should not turn this setting on if you wish to use ALE as a completion
" source for other completion plugins, like Deoplete.
let g:ale_completion_enabled = 1
""""COC config
" TextEdit might fail if hidden is not set.
set hidden
" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup
" Give more space for displaying messages.
set cmdheight=2
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
set signcolumn=no
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
"inoremap <silent><expr> <TAB>
" \ pumvisible() ? "\<C-n>" :
" \ <SID>check_back_space() ? "\<TAB>" :
" \ coc#refresh()
"inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
"inoremap <expr><S-C-space> pumvisible() ? "\<C-p>" : "\<C-h>"
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
" position. Coc only does snippet and additional edit on confirm.
" <cr> could be remapped by other vim plugin, try `:verbose imap <CR>`.
if exists('*complete_info')
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
else
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
endif endif
" Use `[g` and `]g` to navigate diagnostics " Function for toggling the bottom statusbar:
nmap <silent> [g <Plug>(coc-diagnostic-prev) let s:hidden_all = 1
nmap <silent> ]g <Plug>(coc-diagnostic-next) function! ToggleHiddenAll()
if s:hidden_all == 0
" GoTo code navigation. let s:hidden_all = 1
nmap <silent> gd <Plug>(coc-definition) set noshowmode
nmap <silent> gy <Plug>(coc-type-definition) set noruler
nmap <silent> gi <Plug>(coc-implementation) set laststatus=0
nmap <silent> gr <Plug>(coc-references) set noshowcmd
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else else
call CocAction('doHover') let s:hidden_all = 0
set showmode
set ruler
set laststatus=2
set showcmd
endif endif
endfunction endfunction
nnoremap <leader>h :call ToggleHiddenAll()<CR>
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>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
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap keys for applying codeAction to the current line.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
" Introduce function text object
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap if <Plug>(coc-funcobj-i)
omap af <Plug>(coc-funcobj-a)
" Use <TAB> for selections ranges.
" NOTE: Requires 'textDocument/selectionRange' support from the language server.
" coc-tsserver, coc-python are the examples of servers that support it.
nmap <silent> <TAB> <Plug>(coc-range-select)
xmap <silent> <TAB> <Plug>(coc-range-select)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format')
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" Mappings using CoCList:
" Show all diagnostics.
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions.
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
" Show commands.
nnoremap <silent> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document.
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols.
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list.
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
"""VimTex
let g:vimtex_view_method = 'zathura'
let g:latex_view_general_viewer = 'zathura'
let g:vimtex_log_verbose = 0
let g:vimtex_quickfix_open_on_warning = 0
"""Fix E10 error for some tex stuff:
set nocompatible
"""LATEX """LATEX
" Word count: " Word count:
autocmd FileType tex map <leader>w :w !detex \| wc -w<CR> autocmd FileType tex map <leader>w :w !detex \| wc -w<CR>
@ -388,28 +266,34 @@ set nocompatible
autocmd FileType html inoremap ,yl <font color="yellow"></font><Esc>F>a autocmd FileType html inoremap ,yl <font color="yellow"></font><Esc>F>a
autocmd FileType html inoremap ,dt <dt></dt><Enter><dd><++></dd><Enter><++><esc>2kcit autocmd FileType html inoremap ,dt <dt></dt><Enter><dd><++></dd><Enter><++><esc>2kcit
autocmd FileType html inoremap ,dl <dl><Enter><Enter></dl><enter><enter><++><esc>3kcc autocmd FileType html inoremap ,dl <dl><Enter><Enter></dl><enter><enter><++><esc>3kcc
autocmd FileType html inoremap &<space> &amp;<space> "autocmd FileType html inoremap &<space> &amp;<space>
autocmd FileType html inoremap á &aacute; autocmd FileType html inoremap ,fr <sup></sup>&frasl;<sub><++></sub><++><esc>2T/2hi
autocmd FileType html inoremap é &eacute; autocmd FileType html inoremap ,o<space> <i><sup></sup></i>
autocmd FileType html inoremap í &iacute; autocmd FileType html inoremap ,cr <i><sup></sup></i>
autocmd FileType html inoremap ó &oacute; autocmd FileType html inoremap ,pl <p lang=la></p><esc>Taa
autocmd FileType html inoremap ú &uacute; autocmd FileType html inoremap ,pd <p lang=de></p><esc>Tea
autocmd FileType html inoremap ä &auml; autocmd FileType html inoremap ,dg °C
autocmd FileType html inoremap ë &euml; "autocmd FileType html inoremap á &aacute;
autocmd FileType html inoremap ï &iuml; "autocmd FileType html inoremap é &eacute;
autocmd FileType html inoremap ö &ouml; "autocmd FileType html inoremap í &iacute;
autocmd FileType html inoremap ü &uuml; "autocmd FileType html inoremap ó &oacute;
autocmd FileType html inoremap ã &atilde; "autocmd FileType html inoremap ú &uacute;
autocmd FileType html inoremap &etilde; "autocmd FileType html inoremap ä &auml;
autocmd FileType html inoremap ĩ &itilde; "autocmd FileType html inoremap ë &euml;
autocmd FileType html inoremap õ &otilde; "autocmd FileType html inoremap ï &iuml;
autocmd FileType html inoremap ũ &utilde; "autocmd FileType html inoremap ö &ouml;
autocmd FileType html inoremap ñ &ntilde; "autocmd FileType html inoremap ü &uuml;
autocmd FileType html inoremap à &agrave; "autocmd FileType html inoremap ã &atilde;
autocmd FileType html inoremap è &egrave; "autocmd FileType html inoremap ẽ &etilde;
autocmd FileType html inoremap ì &igrave; "autocmd FileType html inoremap ĩ &itilde;
autocmd FileType html inoremap ò &ograve; "autocmd FileType html inoremap õ &otilde;
autocmd FileType html inoremap ù &ugrave; "autocmd FileType html inoremap ũ &utilde;
"autocmd FileType html inoremap ñ &ntilde;
"autocmd FileType html inoremap à &agrave;
"autocmd FileType html inoremap è &egrave;
"autocmd FileType html inoremap ì &igrave;
"autocmd FileType html inoremap ò &ograve;
"autocmd FileType html inoremap ù &ugrave;
""".bib """.bib
@ -437,3 +321,173 @@ set nocompatible
""".xml """.xml
autocmd FileType xml inoremap ,e <item><Enter><title><++></title><Enter><guid<space>isPermaLink="false"><++></guid><Enter><pubDate><Esc>:put<Space>=strftime('%a, %d %b %Y %H:%M:%S %z')<Enter>kJA</pubDate><Enter><link><++></link><Enter><description><![CDATA[<++>]]></description><Enter></item><Esc>?<title><enter>cit autocmd FileType xml inoremap ,e <item><Enter><title><++></title><Enter><guid<space>isPermaLink="false"><++></guid><Enter><pubDate><Esc>:put<Space>=strftime('%a, %d %b %Y %H:%M:%S %z')<Enter>kJA</pubDate><Enter><link><++></link><Enter><description><![CDATA[<++>]]></description><Enter></item><Esc>?<title><enter>cit
autocmd FileType xml inoremap ,a <a href="<++>"><++></a><++><Esc>F"ci" autocmd FileType xml inoremap ,a <a href="<++>"><++></a><++><Esc>F"ci"
"""I like COC
" Set internal encoding of vim, not needed on neovim, since coc.nvim using some
" unicode characters in the file autoload/float.vim
set encoding=utf-8
" TextEdit might fail if hidden is not set.
set hidden
" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup
" Give more space for displaying messages.
set cmdheight=2
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
if has("nvim-0.5.0") || has("patch-8.1.1564")
" Recently vim can merge signcolumn and number column into one
set signcolumn=number
else
set signcolumn=yes
endif
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ "\<tab>"
inoremap <expr><S-tab> pumvisible() ? "\<C-p>" : "\<C-h>"
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" 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>"
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" 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 (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>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
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
" Run the Code Lens action on the current line.
nmap <leader>cl <Plug>(coc-codelens-action)
" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
" 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
" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of language server.
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocActionAsync('format')
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport')
" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" 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>
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <silent><expr> <NUL> coc#refresh()