Metals config update for neovim
This commit is contained in:
parent
62d5238255
commit
5157a786f7
2 changed files with 39 additions and 10 deletions
1
home.nix
1
home.nix
|
@ -42,7 +42,6 @@
|
||||||
go
|
go
|
||||||
haskellPackages.implicit-hie
|
haskellPackages.implicit-hie
|
||||||
hugo
|
hugo
|
||||||
lazydocker
|
|
||||||
luajit
|
luajit
|
||||||
luajitPackages.luarocks
|
luajitPackages.luarocks
|
||||||
luajitPackages.luasocket
|
luajitPackages.luasocket
|
||||||
|
|
|
@ -462,19 +462,20 @@ _G.load_config = function()
|
||||||
require('lspconfig').sumneko_lua.setup(luadev)
|
require('lspconfig').sumneko_lua.setup(luadev)
|
||||||
|
|
||||||
-- metals
|
-- metals
|
||||||
-- vim.g.metals_server_version = '0.10.7+84-9d4bcf78-SNAPSHOT'
|
vim.g.metals_server_version = '0.11.8'
|
||||||
-- vim.opt_global.shortmess:remove('F'):append 'c'
|
vim.opt_global.completeopt = { "menuone", "noinsert", "noselect" }
|
||||||
|
vim.opt_global.shortmess:remove("F"):append("c")
|
||||||
local metals_config = require('metals').bare_config()
|
local metals_config = require('metals').bare_config()
|
||||||
metals_config.settings = {
|
metals_config.settings = {
|
||||||
showImplicitArguments = true,
|
showImplicitArguments = true,
|
||||||
showInferredType = true,
|
showInferredType = true,
|
||||||
bloopSbtAlreadyInstalled = true,
|
bloopSbtAlreadyInstalled = false,
|
||||||
excludedPackages = {
|
excludedPackages = {
|
||||||
"akka.actor.typed.javadsl",
|
"akka.actor.typed.javadsl",
|
||||||
"com.github.swagger.akka.javadsl",
|
"com.github.swagger.akka.javadsl",
|
||||||
"akka.stream.javadsl",
|
"akka.stream.javadsl",
|
||||||
},
|
},
|
||||||
fallbackScalaVersion = "2.13.6",
|
fallbackScalaVersion = "2.13.8",
|
||||||
superMethodLensesEnabled = true,
|
superMethodLensesEnabled = true,
|
||||||
javaHome = "/Users/salar/.nix-profile"
|
javaHome = "/Users/salar/.nix-profile"
|
||||||
}
|
}
|
||||||
|
@ -486,10 +487,17 @@ _G.load_config = function()
|
||||||
|
|
||||||
require("metals").setup_dap()
|
require("metals").setup_dap()
|
||||||
end
|
end
|
||||||
vim.cmd [[augroup lsp]]
|
metals_config.init_options.statusBarProvider = "on"
|
||||||
vim.cmd [[au!]]
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
vim.cmd [[au FileType scala,sbt lua require("metals").initialize_or_attach(metals_config)]]
|
metals_config.capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
|
||||||
vim.cmd [[augroup end]]
|
local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = { "scala", "sbt" },
|
||||||
|
callback = function()
|
||||||
|
require("metals").initialize_or_attach(metals_config)
|
||||||
|
end,
|
||||||
|
group = nvim_metals_group,
|
||||||
|
})
|
||||||
|
|
||||||
-- Map :Format to vim.lsp.buf.formatting()
|
-- Map :Format to vim.lsp.buf.formatting()
|
||||||
vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
|
vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
|
||||||
|
@ -514,7 +522,29 @@ _G.load_config = function()
|
||||||
{ name = "path" },
|
{ name = "path" },
|
||||||
{ name = 'nvim_lua' },
|
{ name = 'nvim_lua' },
|
||||||
{ name = 'nvim_lsp_signature_help' }
|
{ name = 'nvim_lsp_signature_help' }
|
||||||
}
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
-- None of this made sense to me when first looking into this since there
|
||||||
|
-- is no vim docs, but you can't have select = true here _unless_ you are
|
||||||
|
-- also using the snippet stuff. So keep in mind that if you remove
|
||||||
|
-- snippets you need to remove this select
|
||||||
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||||
|
-- I use tabs... some say you should stick to ins-completion but this is just here as an example
|
||||||
|
["<Tab>"] = function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
["<S-Tab>"] = function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
cmp.event:on(
|
cmp.event:on(
|
||||||
'confirm_done',
|
'confirm_done',
|
||||||
|
|
Loading…
Reference in a new issue