From 56dc76e1cf79a7492c09496bf481df9354f17dee Mon Sep 17 00:00:00 2001 From: tristan Date: Sat, 19 Oct 2024 00:03:10 +0100 Subject: [PATCH] nixbook: go dap, tidying --- home/desktop/cosmic/default.nix | 3 +- lib/nixvim.nix | 60 ++++++++++++++++++++++++++++++--- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/home/desktop/cosmic/default.nix b/home/desktop/cosmic/default.nix index c8281d5..baaaa80 100644 --- a/home/desktop/cosmic/default.nix +++ b/home/desktop/cosmic/default.nix @@ -1,6 +1,7 @@ { pkgs, config, + lib, ... }: let inherit (config.lib.cosmic) Actions; @@ -43,7 +44,7 @@ in { background = { displays = { all = { - source = ../../../images/nier2.jpg; + source = lib.mkDefault config.stylix.image; }; }; }; diff --git a/lib/nixvim.nix b/lib/nixvim.nix index e763d61..51f80c6 100644 --- a/lib/nixvim.nix +++ b/lib/nixvim.nix @@ -1,4 +1,10 @@ -{pkgs, ...}: { +{pkgs, ...}: let + lua = cmd: {__raw = cmd;}; + luaFunc = cmd: lua '' + function () + ${cmd} + end''; +in { globals = { mapleader = " "; }; @@ -12,7 +18,7 @@ scrolloff = 4; undofile = true; - undodir.__raw = ''vim.fn.expand("$HOME/.local/share/nvim/undo")''; + undodir = lua ''vim.fn.expand("$HOME/.local/share/nvim/undo")''; list = true; listchars = builtins.concatStringsSep "," [ @@ -161,14 +167,48 @@ action = ""; options.desc = "Harpoon"; } + { + key = ""; + action = luaFunc "require('dap').continue()"; + options.desc = "DAP continue"; + } + { + key = "dc"; + action = luaFunc "require('dap').continue()"; + options.desc = "DAP continue"; + } + { + key = "db"; + action = luaFunc "require('dap').toggle_breakpoint()"; + options.desc = "DAP toggle breakpoint"; + } + { + key = "dn"; + action = luaFunc "require('dap').step_over()"; + options.desc = "DAP step over"; + } + { + key = "di"; + action = luaFunc "require('dap').step_into()"; + options.desc = "DAP step into"; + } + { + key = "do"; + action = luaFunc "require('dap').step_out()"; + options.desc = "DAP step out"; + } + { + key = "du"; + action = luaFunc "require('dapui').toggle()"; + options.desc = "DAP UI Toggle"; + } ]; autoCmd = [{ event = "BufWritePre"; pattern = "*.go"; # https://github.com/golang/tools/blob/master/gopls/doc/vim.md#imports-and-formatting - callback.__raw = '' - function() + callback = luaFunc '' local params = vim.lsp.util.make_range_params() params.context = {only = {"source.organizeImports"}} -- buf_request_sync defaults to a 1000ms timeout. Depending on your @@ -186,7 +226,6 @@ end end vim.lsp.buf.format({async = false}) - end ''; }]; @@ -236,6 +275,17 @@ }; }; + dap = { + enable = true; + extensions.dap-go = { + enable = true; + # tests.verbose = true; # ??? + }; + extensions.dap-ui = { + enable = true; + }; + }; + cmp = { enable = true; settings = {