Adding a scala configuration

This commit is contained in:
Zoe Roux
2022-04-08 14:49:45 +02:00
parent bcf520e887
commit a7e11e4344
5 changed files with 41 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.DS_Store

View File

@@ -54,6 +54,7 @@ local lsp_keymaps = function(bufnr)
["<leader>l"] = {
r = { '<cmd>lua vim.lsp.buf.rename()<CR>', "Rename" },
a = { '<cmd>lua vim.lsp.buf.code_action()<CR>', "Code action" },
l = { '<cmd>lua vim.lsp.codelens.run()<CR>', "Run code lens" },
f = { '<cmd>lua vim.lsp.buf.formatting()<CR>', "Format" },
}
}, {
@@ -61,9 +62,14 @@ local lsp_keymaps = function(bufnr)
})
end
local lsp_codelens = function()
-- vim.cmd [[ autocmd BufEnter,CursorHold,InsertLeave <buffer> lua vim.lsp.codelens.refresh() ]]
end
M.on_attach = function(client, bufnr)
lsp_keymaps(bufnr)
lsp_highlight_document(client)
lsp_codelens()
end
local capabilities = vim.lsp.protocol.make_client_capabilities()

View File

@@ -2,4 +2,5 @@ require "lsp.lsp-install"
require("lsp.handlers").setup()
require "lsp.cmp"
require "lsp.signature"
require "lsp.metals"

View File

@@ -0,0 +1,32 @@
local ok, metals = pcall(require, "metals")
if not ok then
return
end
-- NOTE: You may or may not want java included here. You will need it if you want basic Java support
-- but it may also conflict if you are using something like nvim-jdtls which also works on a java filetype
-- autocmd.
vim.cmd [[
augroup lsp
au!
au FileType java,scala,sbt lua require("metals").initialize_or_attach(metals_config)
augroup end
]]
metals_config = metals.bare_config()
-- Example of settings
metals_config.settings = {
showImplicitArguments = true,
}
metals_config.on_attach = function(client, bufnr)
metals.setup_dap()
require "lsp.handlers".on_attach(client, bufnr)
end
local tok, telescope = pcall(require, "telescope")
if not tok then
return
end
telescope.load_extension('metals')

View File

@@ -79,6 +79,7 @@ return packer.startup(function(use)
'williamboman/nvim-lsp-installer',
}
use "Hoffs/omnisharp-extended-lsp.nvim"
use({'scalameta/nvim-metals', requires = { "nvim-lua/plenary.nvim" }})
use "b0o/schemastore.nvim"
use {
"hrsh7th/cmp-nvim-lsp",