" nvim-metals settings " :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 lua vim.lsp.buf.definition() nnoremap K lua vim.lsp.buf.hover() nnoremap gi lua vim.lsp.buf.implementation() nnoremap gr lua vim.lsp.buf.references() nnoremap gds lua vim.lsp.buf.document_symbol() nnoremap gws lua vim.lsp.buf.workspace_symbol() nnoremap gsh lua vim.lsp.buf.signature_help() nnoremap rn lua vim.lsp.buf.rename() nnoremap oi lua require('metals').organize_imports() nnoremap F lua vim.lsp.buf.format() nnoremap ca lua vim.lsp.buf.code_action() nnoremap aw lua vim.diagnostic.setqflist({severity = "W"}) nnoremap a lua vim.diagnostic.setqflist() " diagnostic navigation nnoremap d lua vim.diagnostic.open_float(0, {scope = "line", border="single"}) nnoremap da lua vim.diagnostic.setloclist() nnoremap dn lua vim.diagnostic.goto_next() nnoremap dp lua vim.diagnostic.goto_prev() endfunction augroup lsp au! au FileType scala,sbt lua require('metals').initialize_or_attach(metals_config) augroup end " 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.format() autocmd BufNewFile,BufRead *.sc set filetype=scala