blob: 4f4c9327ab41d984654f082a370db041f42e4935 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
" 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.init_options.statusBarProvider = "on"
metals_config.settings = {
showImplicitArguments = true,
excludedPackages = {
"akka.actor.typed.javadsl",
"com.github.swagger.akka.javadsl"
}
}
EOF
" nvim-lsp mappings for metals
"
function! MetalsMapKeys() abort
nnoremap <buffer> <C-]> <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <buffer> K <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <buffer> gi <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <buffer> gr <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <buffer> gds <cmd>lua vim.lsp.buf.document_symbol()<CR>
nnoremap <buffer> gws <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
nnoremap <buffer> gsh <cmd>lua vim.lsp.buf.signature_help()<CR>
nnoremap <buffer> <leader>rn <cmd>lua vim.lsp.buf.rename()<CR>
nnoremap <buffer> <leader>F <cmd>lua vim.lsp.buf.formatting()<CR>
nnoremap <buffer> <leader>ca <cmd>lua vim.lsp.buf.code_action()<CR>
nnoremap <buffer> <leader>ws <cmd>lua vim.diagnostic.setqflist({severity = "W"})<CR>
nnoremap <buffer> <leader>a <cmd>lua vim.diagnostic.setqflist()<CR>
" diagnostic navigation
nnoremap <buffer> <leader>d <cmd>lua vim.diagnostic.open_float(0, {scope = "line"})<CR>
nnoremap <buffer> <leader>da <cmd>lua vim.diagnostic.setloclist()<CR>
nnoremap <buffer> <leader>dn <cmd>lua vim.diagnostic.goto_next()<CR>
nnoremap <buffer> <leader>dp <cmd>lua vim.diagnostic.goto_prev()<CR>
endfunction
if has('nvim-0.5')
augroup lsp
au!
au FileType scala,sbt lua require('metals').initialize_or_attach(metals_config)
augroup end
" virtual text is not too useful
:lua vim.diagnostic.config({ virtual_text = false, signs = true })
endif
" Helpful general settings
"
autocmd FileType scala setlocal omnifunc=v:lua.vim.lsp.omnifunc
autocmd FileType scala call MetalsMapKeys()
autocmd BufWritePre *.scala,*.sc,*.sbt :lua vim.lsp.buf.formatting_seq_sync()
autocmd BufNewFile,BufRead *.sc set filetype=scala
|