-
|
When using this plugin the lsp works with files that aren't in a cargo project. However when using only the built-in lsp the rust-analyzer won't work on non-project files. My question that how can i replicate the plugins behavior with only the built-in lsp. In the source code i found a few lines that indicate which options the plugin sets ( if not root_dir then
--- No project root found. Start in detached/standalone mode.
lsp_start_config.init_options = { detachedFiles = { vim.api.nvim_buf_get_name(bufnr) } }
end), but i still can't find the exact property i need. My config: ["rust_analyzer"] = function()
local lspconfig = require("lspconfig")
lspconfig.rust_analyzer.setup({
capabilities = capabilities,
on_attach = on_attach,
settings = {
cargo = {
allFeatures = true,
loadOutDirsFromCheck = true,
runBuildScripts = true,
},
-- Add clippy lints for Rust.
checkOnSave = {
allFeatures = true,
command = "clippy",
extraArgs = { "--no-deps" },
},
},
})
end,What properties do i need to add to capabilities or to settings, to enable "standalone" mode with neovim's lsp? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
|
Hey 👋
To clarify, this plugin uses Neovim's built-in LSP client. It just doesn't go through lspconfig to do so.
If you're using lspconfig, you should be able to pass A problem with lspconfig's You can, however, directly call Related: neovim/nvim-lspconfig#1854 |
Beta Was this translation helpful? Give feedback.
-
|
Thank you, the links for |
Beta Was this translation helpful? Give feedback.
-
|
I created in my local capabilities = vim.tbl_deep_extend(
"force",
{},
vim.lsp.protocol.make_client_capabilities(),
require("cmp_nvim_lsp").default_capabilities()
)
vim.keymap.set("n", "<leader>sa", function()
if not next(vim.lsp.get_clients()) then
local config = {
root_dir = vim.fn.expand("%s:h"),
capabilities = capabilities,
cmd = { "rust-analyzer" },
filetypes = { "rust" },
init_options = { detachedFiles = { vim.api.nvim_buf_get_name(0) } },
name = "rust_analyzer-standalone",
}
vim.lsp.start(config)
end
end)This code will create a keymap for rust file and enables Does anyone whether the |
Beta Was this translation helpful? Give feedback.
I created in my
~/.config/nvim/after/ftplugin/directory arust.luafile and inside I putThis code will create a keymap for rust file and enables
rust_analyzerin …