From 407f9431020033d779172160aa4d4cf3371fb641 Mon Sep 17 00:00:00 2001 From: Leonhard Kost Date: Sun, 6 Jul 2025 22:46:23 +0200 Subject: [PATCH] Modularize nixvim config --- modules/home-manager/default.nix | 2 +- modules/home-manager/nixvim.nix | 128 ------------------ modules/home-manager/nixvim/default.nix | 19 +++ modules/home-manager/nixvim/keymaps.nix | 35 +++++ modules/home-manager/nixvim/opts.nix | 37 +++++ .../home-manager/nixvim/plugins/default.nix | 19 +++ .../home-manager/nixvim/plugins/lualine.nix | 21 +++ .../nixvim/plugins/nvim-autopairs.nix | 9 ++ .../nixvim/plugins/treesitter.nix | 16 +++ .../home-manager/nixvim/plugins/which-key.nix | 9 ++ 10 files changed, 166 insertions(+), 129 deletions(-) delete mode 100644 modules/home-manager/nixvim.nix create mode 100644 modules/home-manager/nixvim/default.nix create mode 100644 modules/home-manager/nixvim/keymaps.nix create mode 100644 modules/home-manager/nixvim/opts.nix create mode 100644 modules/home-manager/nixvim/plugins/default.nix create mode 100644 modules/home-manager/nixvim/plugins/lualine.nix create mode 100644 modules/home-manager/nixvim/plugins/nvim-autopairs.nix create mode 100644 modules/home-manager/nixvim/plugins/treesitter.nix create mode 100644 modules/home-manager/nixvim/plugins/which-key.nix diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 24594f1..1be763e 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -2,6 +2,6 @@ imports = [ ./git.nix ./fish.nix - ./nixvim.nix + ./nixvim ]; } diff --git a/modules/home-manager/nixvim.nix b/modules/home-manager/nixvim.nix deleted file mode 100644 index 8956242..0000000 --- a/modules/home-manager/nixvim.nix +++ /dev/null @@ -1,128 +0,0 @@ -{ pkgs, ... }: { - programs.nixvim = { - enable = true; - viAlias = true; - vimAlias = true; - vimdiffAlias = true; - defaultEditor = true; - - colorschemes.tokyonight.enable = true; - - globals.mapleader = " "; - - opts = { - number = true; - relativenumber = true; - showmode = false; - - breakindent = true; - - undofile = true; - - ignorecase = true; - smartcase = true; - - signcolumn = "yes"; - - updatetime = 250; - timeoutlen = 300; - - splitright = true; - splitbelow = true; - - list = true; - listchars = { tab = "» "; trail = "·"; nbsp = "␣"; }; - - inccommand = "split"; - - cursorline = true; - - scrolloff = 10; - - confirm = true; - }; - - keymaps = [ - { - mode = "n"; - key = ""; - action = "nohlsearch"; - options.silent = true; - } - - { - mode = "n"; - key = ""; - action = ""; - options.desc = "Move focus to the left window"; - } - { - mode = "n"; - key = ""; - action = ""; - options.desc = "Move focus to the right window"; - } - { - mode = "n"; - key = ""; - action = ""; - options.desc = "Move focus to the upper window"; - } - { - mode = "n"; - key = ""; - action = ""; - options.desc = "Move focus to the lower window"; - } - ]; - - plugins.lz-n.enable = true; - - plugins.nvim-autopairs = { - enable = true; - lazyLoad = { - enable = true; - settings.event = "InsertEnter"; - }; - }; - - plugins.indent-blankline.enable = true; - - plugins.lualine = { - enable = true; - settings = { - options = { section_separators = ""; component_separators = ""; }; - sections = { - lualine_b = [ { __unkeyed-1 = "branch"; icon = ""; } ]; - lualine_c = [ "filename" ]; - lualine_x = [ "filetype" ]; - }; - }; - }; - - plugins.treesitter = { - enable = true; - settings = { - auto_install = true; - highlight.enable = true; - indent.enable = true; - }; - }; - - plugins.which-key = { - enable = true; - lazyLoad = { - enable = true; - settings.event = "VimEnter"; - }; - }; - - extraPackages = with pkgs; [ - gcc - ]; - - extraPlugins = with pkgs.vimPlugins; [ - vim-sleuth - ]; - }; -} diff --git a/modules/home-manager/nixvim/default.nix b/modules/home-manager/nixvim/default.nix new file mode 100644 index 0000000..41e39f5 --- /dev/null +++ b/modules/home-manager/nixvim/default.nix @@ -0,0 +1,19 @@ +{ + imports = [ + ./opts.nix + ./keymaps.nix + ./plugins + ]; + + programs.nixvim = { + enable = true; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + defaultEditor = true; + + colorschemes.tokyonight.enable = true; + + globals.mapleader = " "; + }; +} diff --git a/modules/home-manager/nixvim/keymaps.nix b/modules/home-manager/nixvim/keymaps.nix new file mode 100644 index 0000000..317990c --- /dev/null +++ b/modules/home-manager/nixvim/keymaps.nix @@ -0,0 +1,35 @@ +{ + programs.nixvim.keymaps = [ + { + mode = "n"; + key = ""; + action = "nohlsearch"; + options.silent = true; + } + + { + mode = "n"; + key = ""; + action = ""; + options.desc = "Move focus to the left window"; + } + { + mode = "n"; + key = ""; + action = ""; + options.desc = "Move focus to the right window"; + } + { + mode = "n"; + key = ""; + action = ""; + options.desc = "Move focus to the upper window"; + } + { + mode = "n"; + key = ""; + action = ""; + options.desc = "Move focus to the lower window"; + } + ]; +} diff --git a/modules/home-manager/nixvim/opts.nix b/modules/home-manager/nixvim/opts.nix new file mode 100644 index 0000000..27c9f32 --- /dev/null +++ b/modules/home-manager/nixvim/opts.nix @@ -0,0 +1,37 @@ +{ + programs.nixvim.opts = { + number = true; + relativenumber = true; + showmode = false; + + breakindent = true; + + undofile = true; + + ignorecase = true; + smartcase = true; + + signcolumn = "yes"; + + updatetime = 250; + timeoutlen = 300; + + splitright = true; + splitbelow = true; + + list = true; + listchars = { + tab = "» "; + trail = "·"; + nbsp = "␣"; + }; + + inccommand = "split"; + + cursorline = true; + + scrolloff = 10; + + confirm = true; + }; +} diff --git a/modules/home-manager/nixvim/plugins/default.nix b/modules/home-manager/nixvim/plugins/default.nix new file mode 100644 index 0000000..34dcacd --- /dev/null +++ b/modules/home-manager/nixvim/plugins/default.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: { + imports = [ + ./treesitter.nix + ./lualine.nix + ./nvim-autopairs.nix + ./which-key.nix + ]; + + programs.nixvim = { + plugins = { + lz-n.enable = true; + indent-blankline.enable = true; + }; + + extraPlugins = with pkgs.vimPlugins; [ + vim-sleuth + ]; + }; +} diff --git a/modules/home-manager/nixvim/plugins/lualine.nix b/modules/home-manager/nixvim/plugins/lualine.nix new file mode 100644 index 0000000..799b4da --- /dev/null +++ b/modules/home-manager/nixvim/plugins/lualine.nix @@ -0,0 +1,21 @@ +{ + programs.nixvim.plugins.lualine = { + enable = true; + settings = { + options = { + section_separators = ""; + component_separators = ""; + }; + sections = { + lualine_b = [ + { + __unkeyed-1 = "branch"; + icon = ""; + } + ]; + lualine_c = ["filename"]; + lualine_x = ["filetype"]; + }; + }; + }; +} diff --git a/modules/home-manager/nixvim/plugins/nvim-autopairs.nix b/modules/home-manager/nixvim/plugins/nvim-autopairs.nix new file mode 100644 index 0000000..e272f5d --- /dev/null +++ b/modules/home-manager/nixvim/plugins/nvim-autopairs.nix @@ -0,0 +1,9 @@ +{ + programs.nixvim.plugins.nvim-autopairs = { + enable = true; + lazyLoad = { + enable = true; + settings.event = "InsertEnter"; + }; + }; +} diff --git a/modules/home-manager/nixvim/plugins/treesitter.nix b/modules/home-manager/nixvim/plugins/treesitter.nix new file mode 100644 index 0000000..1a5fcce --- /dev/null +++ b/modules/home-manager/nixvim/plugins/treesitter.nix @@ -0,0 +1,16 @@ +{ pkgs, ... }: { + programs.nixvim = { + plugins.treesitter = { + enable = true; + settings = { + auto_install = true; + highlight.enable = true; + indent.enable = true; + }; + }; + + extraPackages = with pkgs; [ + gcc + ]; + }; +} diff --git a/modules/home-manager/nixvim/plugins/which-key.nix b/modules/home-manager/nixvim/plugins/which-key.nix new file mode 100644 index 0000000..40a4a2a --- /dev/null +++ b/modules/home-manager/nixvim/plugins/which-key.nix @@ -0,0 +1,9 @@ +{ + programs.nixvim.plugins.which-key = { + enable = true; + lazyLoad = { + enable = true; + settings.event = "VimEnter"; + }; + }; +}