Compare commits

...

3 commits

Author SHA1 Message Date
Ching Pei Yang
ac01c1dff6
Merge 8b6b95b59a into 3f5ed9e979 2024-07-03 22:43:01 -04:00
Ching Pei Yang
3f5ed9e979
languages/go: use dap-go for dap configurations (#319)
* deps: add nvim-dap-go

* go: use dap-go plugin for dap configurations

* docs: update release notes

---------

Co-authored-by: Pei Yang Ching <pei.ching@check24.de>
2024-07-03 18:42:26 +00:00
Pei Yang Ching
8b6b95b59a lualine: use mkDefault on backwards compat configs 2024-06-25 16:23:31 +02:00
5 changed files with 61 additions and 60 deletions

View file

@ -29,6 +29,7 @@ Release notes for release 0.7
- Fix broken treesitter-context keybinds in visual mode - Fix broken treesitter-context keybinds in visual mode
- Deprecate use of `__empty` to define empty tables in lua. Empty attrset are no - Deprecate use of `__empty` to define empty tables in lua. Empty attrset are no
longer filtered and thus should be used instead. longer filtered and thus should be used instead.
- Add dap-go for better dap configurations
[jacekpoz](https://github.com/jacekpoz): [jacekpoz](https://github.com/jacekpoz):

View file

@ -1069,6 +1069,22 @@
"type": "github" "type": "github"
} }
}, },
"plugin-nvim-dap-go": {
"flake": false,
"locked": {
"lastModified": 1716775637,
"narHash": "sha256-B8A+ven18YgePLxAN3Q/j5NFb0FeTHCQak1uzaNDX9c=",
"owner": "leoluz",
"repo": "nvim-dap-go",
"rev": "a0c5a2b991d7e9304a9a032cf177e22a4b0acda1",
"type": "github"
},
"original": {
"owner": "leoluz",
"repo": "nvim-dap-go",
"type": "github"
}
},
"plugin-nvim-dap-ui": { "plugin-nvim-dap-ui": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -1823,6 +1839,7 @@
"plugin-nvim-colorizer-lua": "plugin-nvim-colorizer-lua", "plugin-nvim-colorizer-lua": "plugin-nvim-colorizer-lua",
"plugin-nvim-cursorline": "plugin-nvim-cursorline", "plugin-nvim-cursorline": "plugin-nvim-cursorline",
"plugin-nvim-dap": "plugin-nvim-dap", "plugin-nvim-dap": "plugin-nvim-dap",
"plugin-nvim-dap-go": "plugin-nvim-dap-go",
"plugin-nvim-dap-ui": "plugin-nvim-dap-ui", "plugin-nvim-dap-ui": "plugin-nvim-dap-ui",
"plugin-nvim-docs-view": "plugin-nvim-docs-view", "plugin-nvim-docs-view": "plugin-nvim-docs-view",
"plugin-nvim-lightbulb": "plugin-nvim-lightbulb", "plugin-nvim-lightbulb": "plugin-nvim-lightbulb",

View file

@ -216,6 +216,11 @@
flake = false; flake = false;
}; };
plugin-nvim-dap-go = {
url = "github:leoluz/nvim-dap-go";
flake = false;
};
# Filetrees # Filetrees
plugin-nvim-tree-lua = { plugin-nvim-tree-lua = {
url = "github:nvim-tree/nvim-tree.lua"; url = "github:nvim-tree/nvim-tree.lua";

View file

@ -12,6 +12,7 @@
inherit (lib.types) bool enum either listOf package str; inherit (lib.types) bool enum either listOf package str;
inherit (lib.nvim.types) mkGrammarOption; inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.dag) entryAfter;
cfg = config.vim.languages.go; cfg = config.vim.languages.go;
@ -37,40 +38,6 @@
debuggers = { debuggers = {
delve = { delve = {
package = pkgs.delve; package = pkgs.delve;
dapConfig = ''
dap.adapters.delve = {
type = "server",
port = "''${port}",
executable = {
command = "${getExe cfg.dap.package}",
args = { "dap", "-l", "127.0.0.1:''${port}" },
},
}
dap.configurations.go = {
{
type = "delve",
name = "Debug",
request = "launch",
program = "''${file}",
},
{
type = "delve",
name = "Debug test", -- configuration for debugging test files
request = "launch",
mode = "test",
program = "''${file}",
},
-- works with go.mod packages and sub packages
{
type = "delve",
name = "Debug test (go.mod)",
request = "launch",
mode = "test",
program = "./''${relativeFileDirname}",
},
}
'';
}; };
}; };
in { in {
@ -102,15 +69,17 @@ in {
dap = { dap = {
enable = mkOption { enable = mkOption {
description = "Enable Go Debug Adapter"; description = "Enable Go Debug Adapter via nvim-dap-go plugin";
type = bool; type = bool;
default = config.vim.languages.enableDAP; default = config.vim.languages.enableDAP;
}; };
debugger = mkOption { debugger = mkOption {
description = "Go debugger to use"; description = "Go debugger to use";
type = enum (attrNames debuggers); type = enum (attrNames debuggers);
default = defaultDebugger; default = defaultDebugger;
}; };
package = mkOption { package = mkOption {
description = "Go debugger package."; description = "Go debugger package.";
type = package; type = package;
@ -131,8 +100,17 @@ in {
}) })
(mkIf cfg.dap.enable { (mkIf cfg.dap.enable {
vim.debugger.nvim-dap.enable = true; vim = {
vim.debugger.nvim-dap.sources.go-debugger = debuggers.${cfg.dap.debugger}.dapConfig; startPlugins = ["nvim-dap-go"];
luaConfigRC.nvim-dap-go = entryAfter ["nvim-dap"] ''
require('dap-go').setup {
delve = {
path = '${getExe cfg.dap.package}',
}
}
'';
debugger.nvim-dap.enable = true;
};
}) })
]); ]);
} }

View file

@ -4,7 +4,7 @@
... ...
}: let }: let
inherit (builtins) map; inherit (builtins) map;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge mkDefault;
inherit (lib.trivial) boolToString; inherit (lib.trivial) boolToString;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
@ -23,7 +23,7 @@ in {
(mkIf (breadcrumbsCfg.enable && breadcrumbsCfg.source == "nvim-navic") { (mkIf (breadcrumbsCfg.enable && breadcrumbsCfg.source == "nvim-navic") {
vim.statusline.lualine.setupOpts = { vim.statusline.lualine.setupOpts = {
# TODO: rewrite in new syntax # TODO: rewrite in new syntax
winbar.lualine_c = [ winbar.lualine_c = mkDefault [
[ [
"navic" "navic"
(mkLuaInline "draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender}") (mkLuaInline "draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender}")
@ -41,36 +41,36 @@ in {
''; '';
# this is for backwards-compatibility # this is for backwards-compatibility
# NOTE: since lualine relies heavily on mixed list + key-value table syntax in lua e.g. {1, 2, three = 3}
# and we don't have a good syntax for that we're keeping the old options for now
statusline.lualine.setupOpts = { statusline.lualine.setupOpts = {
options = { options = {
icons_enabled = cfg.icons.enable; icons_enabled = mkDefault cfg.icons.enable;
theme = cfg.theme; theme = mkDefault cfg.theme;
component_separators = [cfg.componentSeparator.left cfg.componentSeparator.right]; component_separators = mkDefault [cfg.componentSeparator.left cfg.componentSeparator.right];
section_separators = [cfg.sectionSeparator.left cfg.sectionSeparator.right]; section_separators = mkDefault [cfg.sectionSeparator.left cfg.sectionSeparator.right];
globalstatus = cfg.globalStatus; globalstatus = mkDefault cfg.globalStatus;
refresh = cfg.refresh; refresh = mkDefault cfg.refresh;
always_divide_middle = mkDefault cfg.alwaysDivideMiddle;
}; };
sections = { sections = {
lualine_a = map mkLuaInline (cfg.activeSection.a ++ cfg.extraActiveSection.a); lualine_a = mkDefault (map mkLuaInline (cfg.activeSection.a ++ cfg.extraActiveSection.a));
lualine_b = map mkLuaInline (cfg.activeSection.b ++ cfg.extraActiveSection.b); lualine_b = mkDefault (map mkLuaInline (cfg.activeSection.b ++ cfg.extraActiveSection.b));
lualine_c = map mkLuaInline (cfg.activeSection.c ++ cfg.extraActiveSection.c); lualine_c = mkDefault (map mkLuaInline (cfg.activeSection.c ++ cfg.extraActiveSection.c));
lualine_x = map mkLuaInline (cfg.activeSection.x ++ cfg.extraActiveSection.x); lualine_x = mkDefault (map mkLuaInline (cfg.activeSection.x ++ cfg.extraActiveSection.x));
lualine_y = map mkLuaInline (cfg.activeSection.y ++ cfg.extraActiveSection.y); lualine_y = mkDefault (map mkLuaInline (cfg.activeSection.y ++ cfg.extraActiveSection.y));
lualine_z = map mkLuaInline (cfg.activeSection.z ++ cfg.extraActiveSection.z); lualine_z = mkDefault (map mkLuaInline (cfg.activeSection.z ++ cfg.extraActiveSection.z));
}; };
inactive_sections = { inactive_sections = {
lualine_a = map mkLuaInline (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a); lualine_a = mkDefault (map mkLuaInline (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a));
lualine_b = map mkLuaInline (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b); lualine_b = mkDefault (map mkLuaInline (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b));
lualine_c = map mkLuaInline (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c); lualine_c = mkDefault (map mkLuaInline (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c));
lualine_x = map mkLuaInline (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x); lualine_x = mkDefault (map mkLuaInline (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x));
lualine_y = map mkLuaInline (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y); lualine_y = mkDefault (map mkLuaInline (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y));
lualine_z = map mkLuaInline (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z); lualine_z = mkDefault (map mkLuaInline (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z));
}; };
# probably don't need this?
tabline = [];
}; };
}; };
}) })