summaryrefslogtreecommitdiffstatshomepage
path: root/nvim
diff options
context:
space:
mode:
Diffstat (limited to 'nvim')
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua41
1 files changed, 21 insertions, 20 deletions
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua b/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua
index 3178e75..f78d360 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua
@@ -1,22 +1,15 @@
-local M = {}
+local lsp = require("tobyvin.lsp")
+local M = {
+ codelldb = "/usr/lib/codelldb/adapter/codelldb",
+ liblldb = "/usr/lib/codelldb/lldb/lib/liblldb.so",
+}
-M._dap_adapter = function()
- local ext_path = vim.env.HOME .. "/usr/lib/codelldb/"
- local codelldb_path = ext_path .. "adapter/codelldb"
- local liblldb_path = ext_path .. "lldb/lib/liblldb.so"
-
- if not require("tobyvin.utils").isdir(ext_path) then
- vim.notify(
- "[DAP] Failed to find codelldb, falling back to default DAP adapter.",
- "warn",
- { title = "[rust-tools] codelldb not found" }
- )
- return {}
+M.dap_adapter = function()
+ if vim.fn.executable(M.codelldb) ~= 0 then
+ return {
+ adapter = require("rust-tools.dap").get_codelldb_adapter(M.codelldb, M.liblldb),
+ }
end
-
- return {
- adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path),
- }
end
M.setup = function()
@@ -26,8 +19,6 @@ M.setup = function()
return
end
- local lsp = require("tobyvin.lsp")
-
rust_tools.setup({
tools = {
autoSetHints = true,
@@ -52,8 +43,18 @@ M.setup = function()
},
},
},
+ on_attach = function(client, bufnr)
+ if vim.fn.executable(M.codelldb) == 0 then
+ vim.notify(
+ "[DAP] Failed to find codelldb, falling back to default DAP adapter.",
+ "warn",
+ { title = "[rust-tools] codelldb not found" }
+ )
+ end
+ lsp.on_attach(client, bufnr)
+ end,
}),
- dap = M._dap_adapter(),
+ dap = M.dap_adapter(),
})
end