summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-07-05 16:49:59 -0500
committerToby Vincent <tobyv13@gmail.com>2022-07-05 16:49:59 -0500
commitf30e09d3c8884185ad9eceae8699eb900f731b2c (patch)
treea24d13d639e06d928ca826cb2c3d74dac8f39a1e
parentf9d21358a0cbe8722f4ec0b92a1c00cfc36c1b0c (diff)
fix(nvim): only run codelldb check on rust lsp attach
-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