mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 18:31:35 +00:00
treewide: begin restructuring the module tree
This commit is contained in:
parent
e1835f6c46
commit
7c730a78e5
254 changed files with 749 additions and 664 deletions
72
modules/plugins/debugger/nvim-dap/config.nix
Normal file
72
modules/plugins/debugger/nvim-dap/config.nix
Normal file
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere entryAfter;
|
||||
|
||||
cfg = config.vim.debugger.nvim-dap;
|
||||
self = import ./nvim-dap.nix {inherit lib;};
|
||||
mappingDefinitions = self.options.vim.debugger.nvim-dap.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkMerge [
|
||||
(mkIf cfg.enable {
|
||||
vim.startPlugins = ["nvim-dap"];
|
||||
|
||||
vim.luaConfigRC =
|
||||
{
|
||||
# TODO customizable keymaps
|
||||
nvim-dap = entryAnywhere ''
|
||||
local dap = require("dap")
|
||||
vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "ErrorMsg", linehl = "", numhl = "" })
|
||||
'';
|
||||
}
|
||||
// mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources;
|
||||
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkSetLuaBinding mappings.continue "require('dap').continue")
|
||||
(mkSetLuaBinding mappings.restart "require('dap').restart")
|
||||
(mkSetLuaBinding mappings.terminate "require('dap').terminate")
|
||||
(mkSetLuaBinding mappings.runLast "require('dap').run_last")
|
||||
|
||||
(mkSetLuaBinding mappings.toggleRepl "require('dap').repl.toggle")
|
||||
(mkSetLuaBinding mappings.hover "require('dap.ui.widgets').hover")
|
||||
(mkSetLuaBinding mappings.toggleBreakpoint "require('dap').toggle_breakpoint")
|
||||
|
||||
(mkSetLuaBinding mappings.runToCursor "require('dap').run_to_cursor")
|
||||
(mkSetLuaBinding mappings.stepInto "require('dap').step_into")
|
||||
(mkSetLuaBinding mappings.stepOut "require('dap').step_out")
|
||||
(mkSetLuaBinding mappings.stepOver "require('dap').step_over")
|
||||
(mkSetLuaBinding mappings.stepBack "require('dap').step_back")
|
||||
|
||||
(mkSetLuaBinding mappings.goUp "require('dap').up")
|
||||
(mkSetLuaBinding mappings.goDown "require('dap').down")
|
||||
];
|
||||
})
|
||||
(mkIf (cfg.enable && cfg.ui.enable) {
|
||||
vim.startPlugins = ["nvim-dap-ui" "nvim-nio"];
|
||||
|
||||
vim.luaConfigRC.nvim-dap-ui = entryAfter ["nvim-dap"] (''
|
||||
local dapui = require("dapui")
|
||||
dapui.setup()
|
||||
''
|
||||
+ optionalString cfg.ui.autoStart ''
|
||||
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||
dapui.open()
|
||||
end
|
||||
dap.listeners.before.event_terminated["dapui_config"] = function()
|
||||
dapui.close()
|
||||
end
|
||||
dap.listeners.before.event_exited["dapui_config"] = function()
|
||||
dapui.close()
|
||||
end
|
||||
'');
|
||||
vim.maps.normal = mkSetLuaBinding mappings.toggleDapUI "require('dapui').toggle";
|
||||
})
|
||||
];
|
||||
}
|
6
modules/plugins/debugger/nvim-dap/default.nix
Normal file
6
modules/plugins/debugger/nvim-dap/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./nvim-dap.nix
|
||||
];
|
||||
}
|
46
modules/plugins/debugger/nvim-dap/nvim-dap.nix
Normal file
46
modules/plugins/debugger/nvim-dap/nvim-dap.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) bool attrsOf str;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
in {
|
||||
options.vim.debugger.nvim-dap = {
|
||||
enable = mkEnableOption "debugging via nvim-dap";
|
||||
|
||||
ui = {
|
||||
enable = mkEnableOption "UI extension for nvim-dap";
|
||||
autoStart = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Automatically Opens and Closes DAP-UI upon starting/closing a debugging session";
|
||||
};
|
||||
};
|
||||
|
||||
sources = mkOption {
|
||||
default = {};
|
||||
description = "List of debuggers to install";
|
||||
type = attrsOf str;
|
||||
};
|
||||
|
||||
mappings = {
|
||||
continue = mkMappingOption "Contiue" "<leader>dc";
|
||||
restart = mkMappingOption "Restart" "<leader>dR";
|
||||
terminate = mkMappingOption "Terminate" "<leader>dq";
|
||||
runLast = mkMappingOption "Re-run Last Debug Session" "<leader>d.";
|
||||
|
||||
toggleRepl = mkMappingOption "Toggle Repl" "<leader>dr";
|
||||
hover = mkMappingOption "Hover" "<leader>dh";
|
||||
toggleBreakpoint = mkMappingOption "Toggle breakpoint" "<leader>db";
|
||||
|
||||
runToCursor = mkMappingOption "Continue to the current cursor" "<leader>dgc";
|
||||
stepInto = mkMappingOption "Step into function" "<leader>dgi";
|
||||
stepOut = mkMappingOption "Step out of function" "<leader>dgo";
|
||||
stepOver = mkMappingOption "Next step" "<leader>dgj";
|
||||
stepBack = mkMappingOption "Step back" "<leader>dgk";
|
||||
|
||||
goUp = mkMappingOption "Go up stacktrace" "<leader>dvo";
|
||||
goDown = mkMappingOption "Go down stacktrace" "<leader>dvi";
|
||||
|
||||
toggleDapUI = mkMappingOption "Toggle DAP-UI" "<leader>du";
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue