aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2021-12-03 07:57:20 +0000
committerJuan J. Martinez <jjm@usebox.net>2022-05-29 22:57:30 +0100
commit9ad923900317a45d216e62626c6ef32672771ee6 (patch)
tree0e0334c2b6cba84f523796ff7be3f018258507b2
parent2fcdae15d7d24fd2601f2a008c15cd6cf400172f (diff)
downloaddotnvim-9ad923900317a45d216e62626c6ef32672771ee6.tar.gz
dotnvim-9ad923900317a45d216e62626c6ef32672771ee6.zip
Using nvim-metals
-rw-r--r--init.vim7
-rw-r--r--lsc.vim (renamed from lsc-local.vim)7
-rw-r--r--metals.vim57
-rw-r--r--vimrc1
4 files changed, 68 insertions, 4 deletions
diff --git a/init.vim b/init.vim
index 0115f46..69eee22 100644
--- a/init.vim
+++ b/init.vim
@@ -3,3 +3,10 @@ let &packpath = &runtimepath
source ~/.vimrc
+" for LSC support
+"
+" general
+source ~/.vim/lsc.vim
+"
+" scala and metals
+source ~/.vim/metals.vim
diff --git a/lsc-local.vim b/lsc.vim
index 3b614ce..9b5d9c7 100644
--- a/lsc-local.vim
+++ b/lsc.vim
@@ -1,5 +1,4 @@
-"
-" Exampke of local configuration
+" vim-lsc configuation
"
let g:lsc_server_commands = {
\ 'python': {
@@ -14,9 +13,9 @@ let g:lsc_server_commands = {
\ }
\ }
\ },
- \ 'scala' : 'metals-vim',
\ 'haskell' : 'haskell-language-server-wrapper --lsp'
\ }
-" for mill build.sc
autocmd BufNewFile,BufRead *.sc set filetype=scala
+
+
diff --git a/metals.vim b/metals.vim
new file mode 100644
index 0000000..ddb7aca
--- /dev/null
+++ b/metals.vim
@@ -0,0 +1,57 @@
+" 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> <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>
+nnoremap <silent> <space>d <cmd>lua vim.lsp.diagnostic.set_loclist()<CR>
+nnoremap <silent> [c <cmd>lua vim.lsp.diagnostic.goto_prev { wrap = false }<CR>
+nnoremap <silent> ]c <cmd>lua vim.lsp.diagnostic.goto_next { wrap = false }<CR>
+
+" nvim-lsp Settings
+"
+" using latest stable
+" let g:metals_server_version = '0.9.8+10-334e402e-SNAPSHOT'
+
+" nvim-metals
+"
+:lua << EOF
+ metals_config = require'metals'.bare_config()
+ metals_config.settings = {
+ showImplicitArguments = true,
+ excludedPackages = {
+ "akka.actor.typed.javadsl",
+ "com.github.swagger.akka.javadsl"
+ }
+ }
+
+ metals_config.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
+ vim.lsp.diagnostic.on_publish_diagnostics, {
+ virtual_text = {
+ prefix = '',
+ }
+ }
+ )
+EOF
+
+if has('nvim-0.5')
+ augroup lsp
+ au!
+ au FileType scala,sbt lua require('metals').initialize_or_attach(metals_config)
+ augroup end
+endif
+
+" Helpful general settings
+"
+autocmd FileType scala setlocal omnifunc=v:lua.vim.lsp.omnifunc
+
+" Set completeopt to have a better completion experience
+set completeopt=menuone,noinsert,noselect
+
diff --git a/vimrc b/vimrc
index 23432af..8852748 100644
--- a/vimrc
+++ b/vimrc
@@ -68,6 +68,7 @@ Plug 'neovimhaskell/haskell-vim'
if has('nvim-0.5')
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
+ Plug 'scalameta/nvim-metals'
Plug 'nvim-telescope/telescope.nvim'
end