How to keep on_attach keybindings with build_options? #82
-
|
I am using rust tools and using the recommend build_options but how do i keep my keybinds that I defined in lsp.on_attach? I tried making an on_attach field with the exact same code for the regular lsp.on_attach, but that didnt seem to work? Also how am I supposed to do the language server settings with build_options? Is the way I did it correct? Thanks! My base rust analyzer setup that I want to add/share the lsp.on_attach keybinds to: lsp.preset('recommended')
local rust_settings = {
settings = {
["rust-analyzer"] = {
checkOnSave = {
allFeatures = true,
command = "clippy",
}
}
},
-- tried this but didnt work
on_attach = function(_, bufnr)
local opts = { buffer = bufnr, remap = false }
vim.keymap.set('n', '<C-x>', vim.lsp.buf.format, opts)
end
}
local rust_lsp = lsp.build_options('rust_analyzer', { rust_settings })
-- want rust-tools/rust-analyzer to use/share this keybinding
lsp.on_attach(function(client, bufnr)
local opts = { buffer = bufnr, remap = false }
vim.keymap.set('n', '<C-x>', vim.lsp.buf.format, opts)
end)
lsp.setup()
require('rust-tools').setup({
tools = {
server = rust_lsp,
inlay_hints = {
show_parameter_hints = false,
parameter_hints_prefix = "",
other_hints_prefix = "",
}
}
}) |
Beta Was this translation helpful? Give feedback.
Answered by
VonHeikemen
Dec 21, 2022
Replies: 1 comment 3 replies
-
|
Just pass the variable as the second argument. No need for the extra local rust_lsp = lsp.build_options('rust_analyzer', rust_settings) |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
Pesky01
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just pass the variable as the second argument. No need for the extra
{}