Closed Astrantia closed 1 year ago
Quickly resolved it. For anyone's future reference:
local rt = require("rust-tools")
rt.setup({
server = {
on_attach = require "lsp-format".on_attach
-- Hover actions
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
-- Code action groups
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
end,
},
})
I should be passing on_attach to rust-tools' on_attach!
I use rust-tools to dogfeed all the lsp related setup to lspconfig, and I don't need to manually add the following line
lspconfig["rust_analyzer"].setup {}
while setting up rust server. However, if I want to use lsp-format, then I have to have the following line in my config:lspconfig["rust_analyzer"].setup { on_attach = require "lsp-format".on_attach }
While adding the above line makes formatting on save work, it messes up with the prior setup done byrust-tools
. How can I use the functionality of both rust_tools and lsp-format simultaneously?