aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2021-12-06 15:31:35 +0000
committerJuan J. Martinez <jjm@usebox.net>2022-05-29 22:57:31 +0100
commitc3e9eb7e419400f301f33ba913e5eb55f046122c (patch)
tree5b614837af6c3ccdffc7874708c8903a25e68851
parent3e87924df99f8def1d0bc643a1d4bf1d178cd964 (diff)
downloaddotnvim-c3e9eb7e419400f301f33ba913e5eb55f046122c.tar.gz
dotnvim-c3e9eb7e419400f301f33ba913e5eb55f046122c.zip
Only LSP mappings for Scala
-rw-r--r--metals.vim43
1 files changed, 23 insertions, 20 deletions
diff --git a/metals.vim b/metals.vim
index 435ed40..253e351 100644
--- a/metals.vim
+++ b/metals.vim
@@ -1,23 +1,3 @@
-" nvim-lsp Mappings
-"
-nnoremap <silent> <C-]> <cmd>lua vim.lsp.buf.definition()<CR>
-nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
-nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>
-nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
-nnoremap <silent> gds <cmd>lua vim.lsp.buf.document_symbol()<CR>
-nnoremap <silent> gws <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
-nnoremap <silent> gsh <cmd>lua vim.lsp.buf.signature_help()<CR>
-nnoremap <silent> <leader>rn <cmd>lua vim.lsp.buf.rename()<CR>
-nnoremap <silent> <leader>F <cmd>lua vim.lsp.buf.formatting()<CR>
-nnoremap <silent> <leader>ca <cmd>lua vim.lsp.buf.code_action()<CR>
-nnoremap <silent> <leader>ws <cmd>lua require'metals'.worksheet_hover()<CR>
-nnoremap <silent> <leader>a <cmd>lua require'metals'.open_all_diagnostics()<CR>
-
-" diagnostic navigation
-nnoremap <silent> <leader>d <cmd>lua vim.diagnostic.open_float(0, {scope = "line"})<CR>
-nnoremap <silent> <leader>dn <cmd>lua vim.diagnostic.goto_next()<CR>
-nnoremap <silent> <leader>dp <cmd>lua vim.diagnostic.goto_next()<CR>
-
" nvim-lsp Settings
"
" using latest stable
@@ -37,6 +17,28 @@ nnoremap <silent> <leader>dp <cmd>lua vim.diagnostic.goto_next()<CR>
}
EOF
+" nvim-lsp mappings for metals
+"
+function! MetalsMapKeys() abort
+ nnoremap <silent> <C-]> <cmd>lua vim.lsp.buf.definition()<CR>
+ nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
+ nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>
+ nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
+ nnoremap <silent> gds <cmd>lua vim.lsp.buf.document_symbol()<CR>
+ nnoremap <silent> gws <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
+ nnoremap <silent> gsh <cmd>lua vim.lsp.buf.signature_help()<CR>
+ nnoremap <silent> <leader>rn <cmd>lua vim.lsp.buf.rename()<CR>
+ nnoremap <silent> <leader>F <cmd>lua vim.lsp.buf.formatting()<CR>
+ nnoremap <silent> <leader>ca <cmd>lua vim.lsp.buf.code_action()<CR>
+ nnoremap <silent> <leader>ws <cmd>lua require'metals'.worksheet_hover()<CR>
+ nnoremap <silent> <leader>a <cmd>lua require'metals'.open_all_diagnostics()<CR>
+
+ " diagnostic navigation
+ nnoremap <silent> <leader>d <cmd>lua vim.diagnostic.open_float(0, {scope = "line"})<CR>
+ nnoremap <silent> <leader>dn <cmd>lua vim.diagnostic.goto_next()<CR>
+ nnoremap <silent> <leader>dp <cmd>lua vim.diagnostic.goto_next()<CR>
+endfunction
+
if has('nvim-0.5')
augroup lsp
au!
@@ -49,4 +51,5 @@ endif
" Helpful general settings
"
autocmd FileType scala setlocal omnifunc=v:lua.vim.lsp.omnifunc
+autocmd FileType scala call MetalsMapKeys()