dotfiles/nvim/lua/plugins/rust-tools.lua

45 lines
1.2 KiB
Lua
Raw Normal View History

2023-09-04 23:01:56 +02:00
local nmap = require("utility").keymap('n')
2023-08-20 14:27:47 +02:00
local M = {}
2023-09-04 23:01:56 +02:00
2023-08-20 14:27:47 +02:00
function M.config()
local tools = require "rust-tools"
2023-07-11 23:48:37 +02:00
local mason = require "mason-registry"
local capabilities = require("cmp_nvim_lsp").default_capabilities()
2023-07-11 23:48:37 +02:00
local lsp_root = mason.get_package("codelldb"):get_install_path() .. "/extension/"
local lsp_path = lsp_root .. "adapter/codelldb"
local lib_path = lsp_root .. "lldb/lib/liblldb.so"
local opts = {
2023-07-10 14:30:11 +02:00
server = {
2023-07-11 23:48:37 +02:00
standalone = true,
capabilities = capabilities,
on_attach = function(_, bufnr)
nmap "<C-b>" (tools.hover_actions.hover_actions) {buffer=bufnr}
nmap "<Leader>a" (tools.code_action_group.code_action_group) {buffer=bufnr}
2023-07-10 14:30:11 +02:00
end,
["rust-analyzer"] = {
cargo = { allFeatures = true },
checkOnSave = {
-- default = "cargo check",
2023-07-10 14:30:11 +02:00
command = "clippy",
allFeatures = true,
}
2023-07-29 21:15:17 +02:00
}
2023-07-11 23:48:37 +02:00
},
dap = {
adapter = require("rust-tools.dap").get_codelldb_adapter(lsp_path, lib_path),
},
}
tools.setup(opts)
2023-07-10 14:30:11 +02:00
end
2023-08-20 14:27:47 +02:00
2023-10-29 09:47:39 +01:00
---@param config table
---@return table
return function(config)
return vim.tbl_extend("keep", config, M)
end