~carloabelli/dotfiles

d5a07b0a108d3d24381cfdd8453fb4aeefbc4cbd — Carlo Abelli 17 days ago a9547fe master
Improve vim mappings

- Use better capitalization
- Only enable LSP mappings in LSP buffers
- Use <Cmd> where possible
2 files changed, 17 insertions(+), 8 deletions(-)

M .config/nvim/after/plugin/fzf.vim
M .config/nvim/init.vim
M .config/nvim/after/plugin/fzf.vim => .config/nvim/after/plugin/fzf.vim +1 -1
@@ 1,3 1,3 @@
if exists(':FZF')
  nnoremap <c-p> :FZF<cr>
  nnoremap <C-p> <Cmd>FZF<CR>
endif

M .config/nvim/init.vim => .config/nvim/init.vim +16 -7
@@ 31,15 31,24 @@ set splitright
set modelines=0
set nomodeline

nnoremap Q <nop>
nnoremap Q <Nop>
nnoremap Y y$

nnoremap <silent> <c-]> <cmd>LspDefinition<cr>
nnoremap <silent> K     <cmd>LspHover<cr>
nnoremap <silent> gD    <cmd>LspImplementation<cr>
nnoremap <silent> gd    <cmd>LspDeclaration<cr>
nnoremap <silent> gr    <cmd>LspReferences<cr>
set omnifunc=lsp#complete
function! s:on_lsp_buffer_enabled() abort
  setlocal omnifunc=lsp#complete
  nnoremap <buffer> <C-]> <Cmd>LspDeclaration<CR>
  nnoremap <buffer> K <Cmd>LspHover<CR>
  nnoremap <buffer> [g <Cmd>LspPreviousDiagnostic<CR>
  nnoremap <buffer> ]g <Cmd>LspNextDiagnostic<CR>
  nnoremap <buffer> gD <Cmd>LspImplementation<CR>
  nnoremap <buffer> gd <Cmd>LspDefinition<CR>
  nnoremap <buffer> gr <Cmd>LspReferences<CR>
  nnoremap <buffer> gt <Cmd>LspTypeDefinition<CR>
endfunction
augroup lsp_install
  autocmd!
  autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup end

augroup misc
  autocmd!