mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-01 19:11:15 +00:00
feat: add dap support for rust
This commit is contained in:
parent
3a8b614ea9
commit
588d348bd2
1 changed files with 41 additions and 3 deletions
|
@ -40,6 +40,19 @@ in {
|
||||||
default = "";
|
default = "";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dap = {
|
||||||
|
enable = mkOption {
|
||||||
|
description = "Rust Debug Adapter support";
|
||||||
|
type = types.bool;
|
||||||
|
default = config.vim.languages.enableDAP;
|
||||||
|
};
|
||||||
|
package = mkOption {
|
||||||
|
description = "lldb pacakge";
|
||||||
|
type = types.package;
|
||||||
|
default = pkgs.lldb;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
|
@ -62,8 +75,8 @@ in {
|
||||||
vim.treesitter.enable = true;
|
vim.treesitter.enable = true;
|
||||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||||
})
|
})
|
||||||
(mkIf cfg.lsp.enable {
|
(mkIf (cfg.lsp.enable || cfg.dap.enable) {
|
||||||
vim.startPlugins = ["rust-tools"];
|
vim.startPlugins = ["rust-tools"] ++ optionals cfg.dap.enable [cfg.dap.package];
|
||||||
|
|
||||||
vim.lsp.lspconfig.enable = true;
|
vim.lsp.lspconfig.enable = true;
|
||||||
vim.lsp.lspconfig.sources.rust-lsp = ''
|
vim.lsp.lspconfig.sources.rust-lsp = ''
|
||||||
|
@ -78,6 +91,21 @@ in {
|
||||||
vim.keymap.set("n", "<leader>rm", rt.expand_macro.expand_macro, opts)
|
vim.keymap.set("n", "<leader>rm", rt.expand_macro.expand_macro, opts)
|
||||||
vim.keymap.set("n", "<leader>rc", rt.open_cargo_toml.open_cargo_toml, opts)
|
vim.keymap.set("n", "<leader>rc", rt.open_cargo_toml.open_cargo_toml, opts)
|
||||||
vim.keymap.set("n", "<leader>rg", function() rt.crate_graph.view_crate_graph("x11", nil) end, opts)
|
vim.keymap.set("n", "<leader>rg", function() rt.crate_graph.view_crate_graph("x11", nil) end, opts)
|
||||||
|
${optionalString cfg.dap.enable ''
|
||||||
|
vim.keymap.set("n", "<leader>rd", ":RustDebuggables<cr>", opts)
|
||||||
|
vim.keymap.set(
|
||||||
|
"n", "${config.vim.debugger.nvim-dap.mappings.continue}",
|
||||||
|
function()
|
||||||
|
local dap = require("dap")
|
||||||
|
if dap.status() == "" then
|
||||||
|
vim.cmd "RustDebuggables"
|
||||||
|
else
|
||||||
|
dap.continue()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
opts
|
||||||
|
)
|
||||||
|
''}
|
||||||
end
|
end
|
||||||
local rustopts = {
|
local rustopts = {
|
||||||
tools = {
|
tools = {
|
||||||
|
@ -94,7 +122,17 @@ in {
|
||||||
settings = {
|
settings = {
|
||||||
${cfg.lsp.opts}
|
${cfg.lsp.opts}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
|
${optionalString cfg.dap.enable ''
|
||||||
|
dap = {
|
||||||
|
adapter = {
|
||||||
|
type = "executable",
|
||||||
|
command = "${cfg.dap.package}/bin/lldb-vscode",
|
||||||
|
name = "rt_lldb",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
''}
|
||||||
}
|
}
|
||||||
rt.setup(rustopts)
|
rt.setup(rustopts)
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in a new issue