Skip to content
Discussion options

You must be logged in to vote

I created in my ~/.config/nvim/after/ftplugin/ directory a rust.lua file and inside I put

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 rust_analyzer in …

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@mrcjkb
Comment options

@Andrew15-5
Comment options

@mrcjkb
Comment options

Answer selected by KisNJ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants