feat(nvim): enable rust lsp support

main
mandlm 2022-06-24 12:41:32 +02:00
parent c9cc4f5088
commit 920f98ca75
Signed by: mandlm
GPG Key ID: 4AA25D647AA54CC7
2 changed files with 24 additions and 3 deletions

View File

@ -32,6 +32,7 @@
terraform-ls
tflint
nodePackages.bash-language-server
rust-analyzer
];
stateVersion = "22.05";
@ -143,6 +144,7 @@
# LSP
nvim-lspconfig
lsp-status-nvim
rust-tools-nvim
];
extraConfig = ''
@ -150,6 +152,7 @@
${builtins.readFile ./nvim/lua/keymaps.lua }
${builtins.readFile ./nvim/lua/options.lua }
${builtins.readFile ./nvim/lua/plugins/treesitter.lua }
${builtins.readFile ./nvim/lua/plugins/lspconfig.lua }
require("toggleterm").setup({ size = 32, open_mapping = [[<F4>]] })

View File

@ -27,7 +27,7 @@ local on_attach = function(client, bufnr)
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.formatting_sync()
vim.lsp.buf.formatting_sync({}, 3000)
end,
})
end
@ -63,10 +63,28 @@ local servers = {
local lspconfig = require("lspconfig")
for lsp, config in pairs(servers) do
for lsp, settings in pairs(servers) do
lspconfig[lsp].setup({
settings = config or {},
settings = settings,
on_attach = on_attach,
capabilities = capabilities,
})
end
require("rust-tools").setup({
server = {
on_attach = on_attach,
settings = {
["rust-analyzer"] = {
cargo = {
loadOutDirsFromCheck = true,
},
checkOnSave = { command = "clippy" },
procMacro = {
enable = true,
},
},
},
capabilities = capabilities,
},
})