From c8f53dfe2e7c78f18927837757a5a8b972a3f4fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 10 Aug 2023 18:40:07 +0200 Subject: [PATCH 01/12] feat: better zoxide alias and completions --- modules/profiles/base.nix | 9 +++++++-- modules/programs/fish.nix | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/profiles/base.nix b/modules/profiles/base.nix index 9727af2..d6d6523 100644 --- a/modules/profiles/base.nix +++ b/modules/profiles/base.nix @@ -55,7 +55,7 @@ in cat = "bat"; rm = "rm -i"; mv = "mv -i"; - cd = "z"; + cd = "__zoxide_z"; nixos-switch = nom-system-command "sudo nixos-rebuild switch --flake ~/.dotfiles"; nixos-boot = nom-system-command "sudo nixos-rebuild boot --flake ~/.dotfiles"; @@ -167,7 +167,12 @@ in "--bind alt-j:preview-down,alt-k:preview-up" ]; }; - zoxide.enable = true; + zoxide = { + enable = true; + options = [ + "--cmd c" + ]; + }; }; home = { username = "moritz"; diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index 549a363..aac66b3 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -43,6 +43,9 @@ in # visual mode, but due to fish_cursor_default, is redundant here set fish_cursor_visual block + # Completions + complete -c c -kfa '(zoxide query -l | sed "s|$HOME|~|")' + # Variables ${exportedVariables} ''; From 3180e6408529b7a17db57af89f5cbef3ce496148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 10 Aug 2023 18:40:41 +0200 Subject: [PATCH 02/12] feat(nvim): format init.lua --- modules/programs/nvim/default.nix | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index f126481..3503476 100644 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -63,9 +63,7 @@ let ); lazySpecs = listToStringMultiLine id (map lazySpecFromPlugin cfg.plugins); lazy = '' - require("lazy").setup({ - ${lazySpecs} - }) + require("lazy").setup(${lazySpecs}) ''; in { @@ -213,7 +211,17 @@ in else neovide ) ]; - + xdg.configFile."nvim/init.lua" = { + source = + let + text = lib.concatLines [ (builtins.readFile ./options.lua) lazy ]; + in + pkgs.runCommand "init.lua" { inherit text; } '' + touch $out + echo -n "$text" > $out + ${getExe pkgs.stylua} $out + ''; + }; programs.neovim = { enable = true; package = pkgs.neovim-nightly; @@ -221,7 +229,6 @@ in vimdiffAlias = true; withNodeJs = true; withPython3 = true; - extraLuaConfig = lib.concatLines [ (builtins.readFile ./options.lua) lazy ]; extraPython3Packages = ps: let plugins = map (getAttr "plugin") cfg.plugins; From 44adf708623aecf2524c061f781275017b566e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 10 Aug 2023 18:41:34 +0200 Subject: [PATCH 03/12] refactor!: simplify dunst config --- modules/services/dunst.nix | 262 +------------------------------------ 1 file changed, 3 insertions(+), 259 deletions(-) diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix index 898faaa..db80828 100644 --- a/modules/services/dunst.nix +++ b/modules/services/dunst.nix @@ -12,265 +12,9 @@ in options.my.services.dunst.enable = mkEnableOption "dunst"; config = lib.mkIf cfg.enable { - home-manager.users.moritz = { - services.dunst = { - enable = true; - settings = { - global = { - ### Display ### - - # Which monitor should the notifications be displayed on. - monitor = 0; - - # Display notification on focused monitor. Possible modes are: - # mouse: follow mouse pointer - # keyboard: follow window with keyboard focus - # none: don't follow anything - # - # "keyboard" needs a window manager that exports the - # _NET_ACTIVE_WINDOW property. - # This should be the case for almost all modern window managers. - # - # If this option is set to mouse or keyboard, the monitor option - # will be ignored. - follow = "mouse"; - - # The geometry of the window: - # [{width}]x{height}[+/-{x}+/-{y}] - # The geometry of the message window. - # The height is measured in number of notifications everything else - # in pixels. If the width is omitted but the height is given - # ("-geometry x2"), the message window expands over the whole screen - # (dmenu-like). If width is 0, the window expands to the longest - # message displayed. A positive x is measured from the left, a - # negative from the right side of the screen. Y is measured from - # the top and down respectively. - # The width can be negative. In this case the actual width is the - # screen width minus the width defined in within the geometry option. - geometry = "0x4-25+25"; - - # Show how many messages are currently hidden (because of geometry). - indicate_hidden = "yes"; - - # Shrink window if it's smaller than the width. Will be ignored if - # width is 0. - shrink = "no"; - - # The transparency of the window. Range: [0; 100]. - # This option will only work if a compositing window manager is - # present (e.g. xcompmgr, compiz, etc.). - transparency = "15"; - - # The height of the entire notification. If the height is smaller - # than the font height and padding combined, it will be raised - # to the font height and padding. - notification_height = 0; - - # Draw a line of "separator_height" pixel height between two - # notifications. - # Set to 0 to disable. - separator_height = 1; - - # Padding between text and separator. - padding = 8; - - # Horizontal padding. - horizontal_padding = 10; - - # Defines width in pixels of frame around the notification window. - # Set to 0 to disable. - frame_width = 0; - - # Sort messages by urgency. - sort = "yes"; - - # Don't remove messages, if the user is idle (no mouse or keyboard input) - # for longer than idle_threshold seconds. - # Set to 0 to disable. - # A client can set the 'transient' hint to bypass this. See the rules - # section for how to disable this if necessary - idle_threshold = 120; - - ### Text ### - - font = "Monospace 10"; - - # The spacing between lines. If the height is smaller than the - # font height, it will get raised to the font height. - line_height = 0; - - # Possible values are: - # full: Allow a small subset of html markup in notifications: - # bold - # italic - # strikethrough - # underline - # - # For a complete reference see - # . - # - # strip: This setting is provided for compatibility with some broken - # clients that send markup even though it's not enabled on the - # server. Dunst will try to strip the markup but the parsing is - # simplistic so using this option outside of matching rules for - # specific applications *IS GREATLY DISCOURAGED*. - # - # no: Disable markup parsing, incoming notifications will be treated as - # plain text. Dunst will not advertise that it has the body-markup - # capability if this is set as a global setting. - # - # It's important to note that markup inside the format option will be parsed - # regardless of what this is set to. - markup = "full"; - - # The format of the message. Possible variables are: - # %a appname - # %s summary - # %b body - # %i iconname (including its path) - # %I iconname (without its path) - # %p progress value if set ([ 0%] to [100%]) or nothing - # %n progress value if set without any extra characters - # %% Literal % - # Markup is allowed - format = '' - %s %p - %b''; - - # Alignment of message text. - # Possible values are "left", "center" and "right". - alignment = "left"; - - # Vertical alignment of message text and icon. - # Possible values are "top", "center" and "bottom". - vertical_alignment = "center"; - - # Show age of message if message is older than show_age_threshold - # seconds. - # Set to -1 to disable. - show_age_threshold = 60; - - # Split notifications into multiple lines if they don't fit into - # geometry. - word_wrap = "yes"; - - # When word_wrap is set to no, specify where to make an ellipsis in long lines. - # Possible values are "start", "middle" and "end". - ellipsize = "middle"; - - # Ignore newlines '\n' in notifications. - ignore_newline = "no"; - - # Stack together notifications with the same content - stack_duplicates = true; - - # Hide the count of stacked notifications with the same content - hide_duplicate_count = false; - - # Display indicators for URLs (U) and actions (A). - show_indicators = "yes"; - - ### Icons ### - - # Align icons left/right/off - icon_position = "left"; - - # Scale small icons up to this size, set to 0 to disable. Helpful - # for e.g. small files or high-dpi screens. In case of conflict, - # max_icon_size takes precedence over this. - min_icon_size = 0; - - # Scale larger icons down to this size, set to 0 to disable - max_icon_size = 64; - - # Paths to default icons. - # icon_path = /usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/ - - ### History ### - - # Should a notification popped up from history be sticky or timeout - # as if it would normally do. - sticky_history = "yes"; - - # Maximum amount of notifications kept in history - history_length = 20; - - ### Misc/Advanced ### - - # dmenu path. - dmenu = "${pkgs.rofi}/bin/rofi -p dunst"; - - # Browser for opening urls in context menu. - browser = "${pkgs.firefox}/bin/firefox -new-tab"; - - # Always run rule-defined scripts, even if the notification is suppressed - always_run_script = true; - - # Define the title of the windows spawned by dunst - title = "Dunst"; - - # Define the class of the windows spawned by dunst - class = "Dunst"; - - # Print a notification on startup. - # This is mainly for error detection, since dbus (re-)starts dunst - # automatically after a crash. - startup_notification = false; - - # Manage dunst's desire for talking - # Can be one of the following values: - # crit: Critical features. Dunst aborts - # warn: Only non-fatal warnings - # mesg: Important Messages - # info: all unimportant stuff - # debug: all less than unimportant stuff - verbosity = "mesg"; - - # Define the corner radius of the notification window - # in pixel size. If the radius is 0, you have no rounded - # corners. - # The radius will be automatically lowered if it exceeds half of the - # notification height to avoid clipping text and/or icons. - corner_radius = 0; - - # Ignore the dbus closeNotification message. - # Useful to enforce the timeout set by dunst configuration. Without this - # parameter, an application may close the notification sent before the - # user defined timeout. - ignore_dbusclose = false; - - ### Legacy - - # Use the Xinerama extension instead of RandR for multi-monitor support. - # This setting is provided for compatibility with older nVidia drivers that - # do not support RandR and using it on systems that support RandR is highly - # discouraged. - # - # By enabling this setting dunst will not be able to detect when a monitor - # is connected or disconnected which might break follow mode if the screen - # layout changes. - force_xinerama = false; - - ### mouse - - # Defines list of actions for each mouse event - # Possible values are: - # * none: Don't do anything. - # * do_action: If the notification has exactly one action, or one is marked as default, - # invoke it. If there are multiple and no default, open the context menu. - # * close_current: Close current notification. - # * close_all: Close all notifications. - # These values can be strung together for each mouse event, and - # will be executed in sequence. - mouse_left_click = "close_current"; - mouse_middle_click = "do_action, close_current"; - mouse_right_click = "close_all"; - }; - urgency_low.timeout = 10; - urgency_normal.timeeout = 10; - urgency_critical.timeout = 0; - }; - }; + home-manager.users.moritz.services.dunst.enable = true; + home-manager.users.moritz.services.dunst.settings.global = { + font = "Monospace 10"; }; }; } From 92b9ac12334ee5ad6af5187d04083eb77133571f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 11 Aug 2023 17:38:26 +0200 Subject: [PATCH 04/12] feat(nvim): simplify lsp config --- flake.lock | 68 ------------------- flake.nix | 12 ---- modules/programs/nvim/plugins/default.nix | 7 -- .../programs/nvim/plugins/nvim-lspconfig.lua | 45 ++++++------ overlays/vimPlugins.nix | 22 ------ 5 files changed, 22 insertions(+), 132 deletions(-) diff --git a/flake.lock b/flake.lock index 14e7bc4..b24bece 100644 --- a/flake.lock +++ b/flake.lock @@ -55,38 +55,6 @@ "type": "github" } }, - "cmp-async-path": { - "flake": false, - "locked": { - "lastModified": 1673896803, - "narHash": "sha256-dgAiVbdMiKjiKWk+dJf/Zz8T20+D4OalGH5dTzYi5aM=", - "owner": "FelipeLema", - "repo": "cmp-async-path", - "rev": "d8229a93d7b71f22c66ca35ac9e6c6cd850ec61d", - "type": "github" - }, - "original": { - "owner": "FelipeLema", - "repo": "cmp-async-path", - "type": "github" - } - }, - "copilot-lua": { - "flake": false, - "locked": { - "lastModified": 1688190439, - "narHash": "sha256-lD9FdbKKZ6d/BjIfqp0Ust2hqSYNLpCFWxuaKUO9qLs=", - "owner": "zbirenbaum", - "repo": "copilot.lua", - "rev": "e48bd7020a98be217d85c006a298656294fd6210", - "type": "github" - }, - "original": { - "owner": "zbirenbaum", - "repo": "copilot.lua", - "type": "github" - } - }, "darwin": { "inputs": { "nixpkgs": [ @@ -470,22 +438,6 @@ "type": "github" } }, - "leap-spooky-nvim": { - "flake": false, - "locked": { - "lastModified": 1687792124, - "narHash": "sha256-EPqbsG7KFHdnbW430+BSrPeOoVy99KtIC8OpFbV1ycw=", - "owner": "ggandor", - "repo": "leap-spooky.nvim", - "rev": "e003f2aa376190148f2e7731a60c89239335013c", - "type": "github" - }, - "original": { - "owner": "ggandor", - "repo": "leap-spooky.nvim", - "type": "github" - } - }, "lowdown-src": { "flake": false, "locked": { @@ -502,22 +454,6 @@ "type": "github" } }, - "lspsaga-nvim": { - "flake": false, - "locked": { - "lastModified": 1689849495, - "narHash": "sha256-tD3UxJUtYoxUMTFF4gfKChVfI5SxZQ2C12WRF73Ahc4=", - "owner": "glepnir", - "repo": "lspsaga.nvim", - "rev": "0c20101ac826961a7052c4ad9d5f7f791b4adab1", - "type": "github" - }, - "original": { - "owner": "glepnir", - "repo": "lspsaga.nvim", - "type": "github" - } - }, "master": { "locked": { "lastModified": 1689880801, @@ -848,15 +784,11 @@ "agenix": "agenix", "arkenfox-userjs": "arkenfox-userjs", "asus-touchpad-numpad-driver": "asus-touchpad-numpad-driver", - "cmp-async-path": "cmp-async-path", - "copilot-lua": "copilot-lua", "flake-utils": "flake-utils", "home-manager": "home-manager_2", "hypr-contrib": "hypr-contrib", "hyprland": "hyprland", "hyprpaper": "hyprpaper", - "leap-spooky-nvim": "leap-spooky-nvim", - "lspsaga-nvim": "lspsaga-nvim", "master": "master", "neovim-nightly-overlay": "neovim-nightly-overlay", "nil": "nil", diff --git a/flake.nix b/flake.nix index 42191c8..724cd7c 100644 --- a/flake.nix +++ b/flake.nix @@ -35,24 +35,12 @@ # Neovim neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay"; - cmp-async-path.url = "github:FelipeLema/cmp-async-path"; - cmp-async-path.flake = false; - - copilot-lua.flake = false; - copilot-lua.url = "github:zbirenbaum/copilot.lua"; - - lspsaga-nvim.flake = false; - lspsaga-nvim.url = "github:glepnir/lspsaga.nvim"; - nvim-treesitter-textsubjects.flake = false; nvim-treesitter-textsubjects.url = "github:RRethy/nvim-treesitter-textsubjects"; smartcolumn-nvim.flake = false; smartcolumn-nvim.url = "github:m4xshen/smartcolumn.nvim"; - leap-spooky-nvim.flake = false; - leap-spooky-nvim.url = "github:ggandor/leap-spooky.nvim"; - telekasten-nvim.flake = false; telekasten-nvim.url = "github:renerocksai/telekasten.nvim"; diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix index c6372f2..d8ab853 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/default.nix @@ -132,13 +132,6 @@ with builtins; { plugin = which-key-nvim; } { plugin = lspkind-nvim; } { plugin = lsp_lines-nvim; } - { - plugin = lspsaga-nvim-original; - dependencies = [ - { plugin = nvim-web-devicons; } - { plugin = nvim-treesitter.withAllGrammars; } - ]; - } { plugin = nvim-ufo; dependencies = [ diff --git a/modules/programs/nvim/plugins/nvim-lspconfig.lua b/modules/programs/nvim/plugins/nvim-lspconfig.lua index 35cce24..12f12db 100644 --- a/modules/programs/nvim/plugins/nvim-lspconfig.lua +++ b/modules/programs/nvim/plugins/nvim-lspconfig.lua @@ -53,51 +53,50 @@ capabilities.textDocument.foldingRange = { } require("ufo").setup() -require("lspsaga").setup({ - symbol_in_winbar = { - enable = false, - }, - lightbulb = { - enable = false, - enable_in_insert = false, - }, -}) - local lspconfig = require("lspconfig") local on_attach_def = function(_, bufnr) require("which-key").register({ - K = { "Lspsaga hover_doc ++quiet", "show info" }, + K = { vim.lsp.buf.hover, "Hover" }, [""] = { l = { - d = { "Lspsaga show_cursor_diagnostics", "open diagnostic window" }, - c = { "Lspsaga code_action", "code action" }, - r = { "Lspsaga rename", "rename" }, - i = { "Lspsaga hover_doc ++keep", "show info (sticky)" }, + d = { vim.diagnostic.open_float, "Open diagnostic window" }, + c = { vim.lsp.buf.code_action, "Code action" }, + r = { vim.lsp.buf.rename, "Rename" }, f = { function() vim.lsp.buf.format({ async = true }) end, - "format (lsp)", + "Format (lsp)", mode = { "n", "v" }, }, }, t = { - l = { lsp_lines.toggle, "lsp lines" }, + l = { lsp_lines.toggle, "Lsp lines" }, }, }, g = { - d = { "Lspsaga peek_definition", "Goto definition" }, - t = { "Lspsaga peek_type_definition", "Goto type defininition" }, - h = { "Lspsaga lsp_finder", "Lsp finder" }, - r = { "Telescope lsp_references", "Goto reference" }, + d = { + function() + require("telescope.builtin").lsp_definitions({ reuse_win = true }) + end, + "Goto definition", + }, + t = { + function() + require("telescope.builtin").lsp_type_definitions({ reuse_win = true }) + end, + "Goto type defininition", + }, + r = { "Telescope lsp_references", "Goto references" }, D = { vim.lsp.buf.declaration, "Goto declaration" }, I = { "Telescope lsp_implementations", "Goto implementation" }, + K = { vim.lsp.buf.signature_help, "Signature help" }, }, ["["] = { - d = { "Lspsaga diagnostic_jump_prev", "Previous diagnostic" }, + d = { vim.diagnostic.goto_prev, "Previous diagnostic" }, }, ["]"] = { - d = { "Lspsaga diagnostic_jump_next", "Next diagnostic" }, + d = { vim.diagnostic.goto_next, "Next diagnostic" }, }, }, { buffer = bufnr, silent = true }) end diff --git a/overlays/vimPlugins.nix b/overlays/vimPlugins.nix index 0b8727b..5daec2e 100644 --- a/overlays/vimPlugins.nix +++ b/overlays/vimPlugins.nix @@ -16,28 +16,6 @@ with lib.my; src = inputs.smartcolumn-nvim; }; - copilot-lua = prev.vimPlugins.copilot-lua.overrideAttrs (_: { - version = mkVersionInput inputs.copilot-lua; - src = inputs.copilot-lua; - }); - - lspsaga-nvim-original = prev.vimPlugins.lspsaga-nvim-original.overrideAttrs (_: { - version = mkVersionInput inputs.lspsaga-nvim; - src = inputs.lspsaga-nvim; - }); - - cmp-async-path = prev.vimPlugins.cmp-path.overrideAttrs (_: { - pname = "cmp-async-path"; - version = mkVersionInput inputs.cmp-async-path; - src = inputs.cmp-async-path; - }); - - leap-spooky-nvim = prev.vimUtils.buildVimPluginFrom2Nix { - pname = "leap-spooky-nvim"; - version = mkVersionInput inputs.leap-spooky-nvim; - src = inputs.leap-spooky-nvim; - }; - telekasten-nvim = prev.vimUtils.buildVimPluginFrom2Nix { pname = "telekasten-nvim"; version = mkVersionInput inputs.telekasten-nvim; From 670921dda25ec4fc6d65dc243392cd6dffb7733b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 11 Aug 2023 17:39:02 +0200 Subject: [PATCH 05/12] refactor(nvim): cleanup --- modules/programs/nvim/plugins/default.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix index d8ab853..c73009a 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/default.nix @@ -20,7 +20,6 @@ with builtins; { key = "="; cmd = "Format"; desc = "format (formatter)"; } ]; conf = readFile ./formatter-nvim.lua; - dependencies = [{ plugin = which-key-nvim; }]; } { plugin = oil-nvim; @@ -141,8 +140,8 @@ with builtins; ]; } { - event = [ "VeryLazy" ]; plugin = vim-fugitive; + event = [ "VeryLazy" ]; } { plugin = vim-tmux-navigator; @@ -225,7 +224,7 @@ with builtins; } { plugin = markdown-preview-nvim; - lazy = false; + ft = [ "md" ]; } { plugin = coq_nvim; From 64509b4cc1869f8ecfeaadb15dd0f4c628da4c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 11 Aug 2023 17:39:19 +0200 Subject: [PATCH 06/12] feat(nvim): replace noice.nvim with dressing.nvim --- modules/programs/nvim/plugins/default.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix index c73009a..6db0f7f 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/default.nix @@ -35,12 +35,6 @@ with builtins; lazy = false; conf = readFile ./mini-nvim.lua; } - { - plugin = noice-nvim; - lazy = false; - conf = readFile ./noice-nvim.lua; - dependencies = [{ plugin = nui-nvim; }]; - } { plugin = trouble-nvim; keys = [ @@ -260,5 +254,9 @@ with builtins; require("treesitter-context").setup({}) ''; } + { + plugin = dressing-nvim; + event = [ "VeryLazy" ]; + } ]; } From 31012a6274a7242396786a7d3abbb9cbc9d3f86a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 11 Aug 2023 17:39:48 +0200 Subject: [PATCH 07/12] fix(virtualisation): bug with virt-manager --- modules/virtualisation/virtualisation.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/virtualisation/virtualisation.nix b/modules/virtualisation/virtualisation.nix index 67f4c17..0f32600 100644 --- a/modules/virtualisation/virtualisation.nix +++ b/modules/virtualisation/virtualisation.nix @@ -17,6 +17,8 @@ in package = pkgs.libvirt; }; + programs.dconf.enable = true; + users.users.moritz = { extraGroups = [ "libvirtd" ]; packages = with pkgs; [ virt-manager virt-viewer ]; From 0c591c04359d0f7597b05bbbe7fd2b43c08d9ce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 11 Aug 2023 18:59:52 +0200 Subject: [PATCH 08/12] feat(nvim): add hmts.nvim --- flake.lock | 17 +++++++++++++++++ flake.nix | 3 +++ modules/programs/fish.nix | 10 +++++----- modules/programs/nvim/default.nix | 12 +++--------- modules/programs/nvim/plugins/default.nix | 14 +++++++++----- overlays/vimPlugins.nix | 6 ++++++ 6 files changed, 43 insertions(+), 19 deletions(-) diff --git a/flake.lock b/flake.lock index b24bece..5d00940 100644 --- a/flake.lock +++ b/flake.lock @@ -319,6 +319,22 @@ "type": "github" } }, + "hmts-nvim": { + "flake": false, + "locked": { + "lastModified": 1691525513, + "narHash": "sha256-il5m+GlNt0FzZjefl1q8ZxWHg0+gQps0vigt+eoIy8A=", + "owner": "calops", + "repo": "hmts.nvim", + "rev": "594dd17c870afb7f6517723c8963f6eb144e3c0d", + "type": "github" + }, + "original": { + "owner": "calops", + "repo": "hmts.nvim", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -785,6 +801,7 @@ "arkenfox-userjs": "arkenfox-userjs", "asus-touchpad-numpad-driver": "asus-touchpad-numpad-driver", "flake-utils": "flake-utils", + "hmts-nvim": "hmts-nvim", "home-manager": "home-manager_2", "hypr-contrib": "hypr-contrib", "hyprland": "hyprland", diff --git a/flake.nix b/flake.nix index 724cd7c..88905ad 100644 --- a/flake.nix +++ b/flake.nix @@ -44,6 +44,9 @@ telekasten-nvim.flake = false; telekasten-nvim.url = "github:renerocksai/telekasten.nvim"; + hmts-nvim.flake = false; + hmts-nvim.url = "github:calops/hmts.nvim"; + # Hyprland hypr-contrib.url = "github:hyprwm/contrib"; hyprland.url = "github:hyprwm/Hyprland"; diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index aac66b3..efc2dac 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -50,22 +50,22 @@ in ${exportedVariables} ''; functions = { - gi = with pkgs; '' + gi = '' set url https://www.gitignore.io/api if test (count $argv) -eq 0 set choice ( curl -sL $url/list \ | string split "," \ - | ${fzf}/bin/fzf -m \ + | ${getExe pkgs.fzf} -m \ | string join "," ) else set choice (string join "," $argv[1..]) end - if ${gum}/bin/gum confirm "Overwrite current .gitignore?" - ${curl}/bin/curl -sL $url/$choice > .gitignore + if ${getExe pkgs.gum} confirm "Overwrite current .gitignore?" + ${getExe pkgs.curl} -sL $url/$choice > .gitignore else - ${curl}/bin/curl -sL $url/$choice >> .gitignore + ${getExe pkgs.curl} -sL $url/$choice >> .gitignore end ''; fish_greeting = ""; diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index 3503476..c7983f1 100644 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -12,14 +12,8 @@ let id = x: x; listToString = sep: f: list: ''{ ${concatStringsSep sep (map f list)} }''; listToStringOneLine = listToString ", "; - listToStringMultiLine = listToString ",\n"; - keybinding = - { key - , cmd - , func - , mode - , desc - }: + listToStringMultiLine' = listToString ",\n" id; + keybinding = { key, cmd, func, mode, desc }: let cmdString = if cmd != null @@ -62,7 +56,7 @@ let ++ (optional (priority != null) "priority = ${toString priority}") ); lazySpecs = listToStringMultiLine id (map lazySpecFromPlugin cfg.plugins); - lazy = '' + lazy = /* lua */ '' require("lazy").setup(${lazySpecs}) ''; in diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix index 6db0f7f..9d4c4fe 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/default.nix @@ -47,7 +47,7 @@ with builtins; { key = "st"; cmd = "TodoTelescope"; desc = "Todo"; } { key = "[q"; - func = ''function() + func = /* lua */ ''function() if require("trouble").is_open() then require("trouble").previous({ skip_groups = true, jump = true }) else @@ -58,7 +58,7 @@ with builtins; } { key = "]q"; - func = ''function() + func = /* lua */ ''function() if require("trouble").is_open() then require("trouble").next({ skip_groups = true, jump = true }) else @@ -200,7 +200,7 @@ with builtins; { plugin = comment-nvim; event = [ "BufReadPost" "BufNewFile" ]; - conf = '' + conf = /* lua */ '' require("Comment").setup() ''; } @@ -243,14 +243,14 @@ with builtins; { plugin = nvim-surround; event = [ "BufReadPost" "BufNewFile" ]; - conf = '' + conf = /* lua */ '' require("nvim-surround").setup({}) ''; } { plugin = nvim-treesitter-context; event = [ "BufReadPost" "BufNewFile" ]; - conf = '' + conf = /* lua */ '' require("treesitter-context").setup({}) ''; } @@ -258,5 +258,9 @@ with builtins; plugin = dressing-nvim; event = [ "VeryLazy" ]; } + { + plugin = hmts-nvim; + ft = [ "nix" ]; + } ]; } diff --git a/overlays/vimPlugins.nix b/overlays/vimPlugins.nix index 5daec2e..eba8e54 100644 --- a/overlays/vimPlugins.nix +++ b/overlays/vimPlugins.nix @@ -21,5 +21,11 @@ with lib.my; version = mkVersionInput inputs.telekasten-nvim; src = inputs.telekasten-nvim; }; + + hmts-nvim = prev.vimUtils.buildVimPluginFrom2Nix { + pname = "hmts-nvim"; + version = mkVersionInput inputs.hmts-nvim; + src = inputs.hmts-nvim; + }; }; } From 1566dc84f41b449f622728f27064b4fc84a538aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 11 Aug 2023 19:00:11 +0200 Subject: [PATCH 09/12] refactor(nvim): condense functions --- modules/programs/nvim/default.nix | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index c7983f1..f39da7c 100644 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -24,38 +24,28 @@ let then func else abort "Either cmd or function must be set" ); + descString = optionalString (desc != null) "desc = ${quote desc},"; in - ''{ ${quote key}, ${cmdString}, mode = ${quote mode}, ${optionalString (desc != null) "desc = ${quote desc},"} }''; + ''{ ${quote key}, ${cmdString}, mode = ${quote mode}, ${descString} }''; lazySpecFromPlugin = - { plugin - , dependencies - , init - , conf - , lazy - , event - , enabled - , cmd - , ft - , priority - , keys - }: - listToStringMultiLine id + { plugin, dependencies, init, conf, lazy, event, enabled, cmd, ft, priority, keys }: + listToStringMultiLine' ([ "dir = ${quote plugin}" "name = ${quote (getName plugin)}" ] ++ (optional (lazy != null) "lazy = ${boolToString lazy}") ++ (optional (!enabled) "enabled = ${boolToString enabled}") - ++ (optional (dependencies != [ ]) "dependencies = ${listToStringMultiLine id (map lazySpecFromPlugin dependencies)}") + ++ (optional (dependencies != [ ]) "dependencies = ${listToStringMultiLine' (map lazySpecFromPlugin dependencies)}") ++ (optional (init != null) "init = function(plugin)\n${toString init}\nend") ++ (optional (conf != null) "config = function(plugin, opts)\n${toString conf}\nend") - ++ (optional (keys != [ ]) "keys = ${listToStringMultiLine id (map keybinding keys)}") + ++ (optional (keys != [ ]) "keys = ${listToStringMultiLine' (map keybinding keys)}") ++ (optional (event != [ ]) "event = ${listToStringOneLine quote event}") ++ (optional (cmd != [ ]) "cmd = ${listToStringOneLine quote cmd}") ++ (optional (ft != [ ]) "ft = ${listToStringOneLine quote ft}") ++ (optional (priority != null) "priority = ${toString priority}") ); - lazySpecs = listToStringMultiLine id (map lazySpecFromPlugin cfg.plugins); + lazySpecs = listToStringMultiLine' (map lazySpecFromPlugin cfg.plugins); lazy = /* lua */ '' require("lazy").setup(${lazySpecs}) ''; From d6b95fdef6c04fcb3c5735772beb36a6a359befb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 11 Aug 2023 19:00:43 +0200 Subject: [PATCH 10/12] feat(nvim): add lsp inlay hints --- modules/programs/nvim/plugins/nvim-lspconfig.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/programs/nvim/plugins/nvim-lspconfig.lua b/modules/programs/nvim/plugins/nvim-lspconfig.lua index 12f12db..d2ab5b5 100644 --- a/modules/programs/nvim/plugins/nvim-lspconfig.lua +++ b/modules/programs/nvim/plugins/nvim-lspconfig.lua @@ -54,7 +54,7 @@ capabilities.textDocument.foldingRange = { require("ufo").setup() local lspconfig = require("lspconfig") -local on_attach_def = function(_, bufnr) +local on_attach_def = function(client, bufnr) require("which-key").register({ K = { vim.lsp.buf.hover, "Hover" }, [""] = { @@ -71,7 +71,13 @@ local on_attach_def = function(_, bufnr) }, }, t = { - l = { lsp_lines.toggle, "Lsp lines" }, + l = { lsp_lines.toggle, "LSP lines" }, + i = { + function() + vim.lsp.inlay_hint(bufnr, nil) + end, + "LSP inlay hints", + }, }, }, g = { @@ -99,6 +105,12 @@ local on_attach_def = function(_, bufnr) d = { vim.diagnostic.goto_next, "Next diagnostic" }, }, }, { buffer = bufnr, silent = true }) + + if client.server_capabilities.inlayHintProvider then + vim.defer_fn(function() + vim.lsp.inlay_hint(bufnr, true) + end, 1000) + end end local lspconfig_default_options = { From 403d88f161c0667be93e3f815756cd2db8152a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sat, 12 Aug 2023 08:05:05 +0200 Subject: [PATCH 11/12] feat(nvim): improve inlay hint startup Rust analyzer seems to be one of the few lsp servers which needs a small timeout for inlay hints to show up correctly. All other servers get their inlay hints activated without delay. --- modules/programs/nvim/plugins/nvim-lspconfig.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/programs/nvim/plugins/nvim-lspconfig.lua b/modules/programs/nvim/plugins/nvim-lspconfig.lua index d2ab5b5..e663322 100644 --- a/modules/programs/nvim/plugins/nvim-lspconfig.lua +++ b/modules/programs/nvim/plugins/nvim-lspconfig.lua @@ -107,9 +107,13 @@ local on_attach_def = function(client, bufnr) }, { buffer = bufnr, silent = true }) if client.server_capabilities.inlayHintProvider then + local slow_lsp_servers = { + "rust_analyzer", + } + local timeout = vim.tbl_contains(slow_lsp_servers, client.name, {}) and 500 or 0 vim.defer_fn(function() vim.lsp.inlay_hint(bufnr, true) - end, 1000) + end, timeout) end end @@ -173,6 +177,9 @@ lspconfig_setup("lua_ls", { format = { enable = false, }, + hint = { + enable = true, + }, }, }, }) From 55d8df866bb6f1823586ac2609ba4346028eb47e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sat, 12 Aug 2023 08:07:33 +0200 Subject: [PATCH 12/12] feat(nvim): add neodev.nvim --- modules/programs/nvim/plugins/default.nix | 14 +++++++++++++- modules/programs/nvim/plugins/nvim-lspconfig.lua | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix index 9d4c4fe..68088b8 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/default.nix @@ -123,7 +123,6 @@ with builtins; ]; } { plugin = which-key-nvim; } - { plugin = lspkind-nvim; } { plugin = lsp_lines-nvim; } { plugin = nvim-ufo; @@ -131,6 +130,19 @@ with builtins; { plugin = promise-async; } ]; } + { + plugin = neodev-nvim; + conf = /* lua */ '' + require("neodev").setup({ + override = function(root_dir, library) + if root_dir:find("/home/moritz/.dotfiles/", 1, true) == 1 then + library.enabled = true + library.plugins = true + end + end, + }) + ''; + } ]; } { diff --git a/modules/programs/nvim/plugins/nvim-lspconfig.lua b/modules/programs/nvim/plugins/nvim-lspconfig.lua index e663322..7fbc917 100644 --- a/modules/programs/nvim/plugins/nvim-lspconfig.lua +++ b/modules/programs/nvim/plugins/nvim-lspconfig.lua @@ -160,6 +160,7 @@ lspconfig_setup("lua_ls", { runtime = { -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) version = "LuaJIT", + path = vim.split(package.path, ";"), }, diagnostics = { -- Get the language server to recognize the `vim` global