diff --git a/modules/home-manager/nixvim/default.nix b/modules/home-manager/nixvim/default.nix index 3a07a02..439b395 100644 --- a/modules/home-manager/nixvim/default.nix +++ b/modules/home-manager/nixvim/default.nix @@ -1,34 +1,178 @@ -{ ... }: +{ pkgs, ... }: { + imports = [ + ./plugins + ]; + programs.nixvim = { enable = true; defaultEditor = true; vimdiffAlias = true; - enableMan = true; - colorschemes.gruvbox.enable = true; + globals = { + mapleader = " "; + maplocalleader = " "; + + have_nerd_font = true; + }; + opts = { + # Show line numbers number = true; relativenumber = true; + + # Enable mouse mode + mouse = "a"; + + # Don't show the mode + showmode = false; + + # Sync clipboard with OS + clipboard = "unnamedplus"; + + # Enable break indent + breakindent = true; + + # Save undo history + undofile = true; + + # Case-insensitive searching unless stated otherwise + ignorecase = true; + smartcase = true; + + # Keep isgncolumn on by default + signcolumn = "yes"; + + # Decrease update time + updatetime = 250; + + # Decrease mapped sequence wait time + timeoutlen = 300; + + # Configure split behavior + splitright = true; + splitbelow = true; + + # Set how neovim displays whitespace characters + list = true; + listchars.__raw = "{ tab = '» ', trail = '·', nbsp = '␣' }"; + + # Preview substitutions live + inccommand = "split"; + + # Show which line the cursor is on + cursorline = true; + + # Minimal number of screen lines to keep above and below the cursor + scrolloff = 20; + + # Set highlight on search but clear on pressing in normal mode + hlsearch = true; }; + keymaps = [ + { + mode = "n"; + key = ""; + action = "nohlsearch"; + } + + { + mode = "t"; + key = ""; + action = ""; + options = { + desc = "Exit terminal mode"; + }; + } + + { + 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 lower window"; + }; + } + + { + mode = "n"; + key = ""; + action = ""; + options = { + desc = "Move focus to the upper window"; + }; + } + ]; + + autoGroups = { + kickstart-highlight-yank = { + clear = true; + }; + }; + + # Basic autocommands + autoCmd = [ + { + event = ["TextYankPost"]; + desc = "Highlight when yanking (copying) text"; + group = "kickstart-highlight-yank"; + callback.__raw = '' + function() + vim.highlight.on_yank() + end + ''; + } + ]; + plugins = { - lualine.enable = true; - treesitter.enable = true; - telescope.enable = true; - lazygit.enable = true; - cmp.enable = true; - sleuth.enable = true; - nvim-autopairs.enable = true; - neoscroll.enable = true; - indent-blankline.enable = true; - bufferline.enable = true; - which-key.enable = true; - comment.enable = true; - dashboard.enable = true; - }; + sleuth = { + enable = true; + }; + + comment = { + enable = true; + }; + + todo-comments = { + enable = true; + signs = true; + }; + }; + + extraPlugins = with pkgs.vimPlugins; [ + nvim-web-devicons + ]; + + extraConfigLuaPre = '' + if vim.g.have_nerd_font then + require('nvim-web-devicons').setup {} + end + ''; + + extraConfigLuaPost = '' + -- vim: ts=2 sts=2 sw=2 et + ''; }; } diff --git a/modules/home-manager/nixvim/plugins/default.nix b/modules/home-manager/nixvim/plugins/default.nix new file mode 100644 index 0000000..cb967a3 --- /dev/null +++ b/modules/home-manager/nixvim/plugins/default.nix @@ -0,0 +1,11 @@ +{ ... }: + +{ + imports = [ + ./mini.nix + ./lualine.nix + ./treesitter.nix + ./telescope.nix + ./lazygit.nix + ]; +} diff --git a/modules/home-manager/nixvim/plugins/lazygit.nix b/modules/home-manager/nixvim/plugins/lazygit.nix new file mode 100644 index 0000000..7c63f64 --- /dev/null +++ b/modules/home-manager/nixvim/plugins/lazygit.nix @@ -0,0 +1,7 @@ +{ ... }: + +{ + programs.nixvim.plugins.lazygit = { + enable = true; + }; +} diff --git a/modules/home-manager/nixvim/plugins/lualine.nix b/modules/home-manager/nixvim/plugins/lualine.nix new file mode 100644 index 0000000..d44c35d --- /dev/null +++ b/modules/home-manager/nixvim/plugins/lualine.nix @@ -0,0 +1,9 @@ +{ ... }: + +{ + programs.nixvim.plugins.lualine = { + enable = true; + globalstatus = true; + iconsEnabled = true; + }; +} diff --git a/modules/home-manager/nixvim/plugins/mini.nix b/modules/home-manager/nixvim/plugins/mini.nix new file mode 100644 index 0000000..99935f3 --- /dev/null +++ b/modules/home-manager/nixvim/plugins/mini.nix @@ -0,0 +1,16 @@ +{ config, pkgs, inputs, ... }: + +{ + programs.nixvim.plugins.mini = { + enable = true; + + modules = { + ai = { + n_lines = 500; + }; + + surround = { + }; + }; + }; +} diff --git a/modules/home-manager/nixvim/plugins/telescope.nix b/modules/home-manager/nixvim/plugins/telescope.nix new file mode 100644 index 0000000..2dad57d --- /dev/null +++ b/modules/home-manager/nixvim/plugins/telescope.nix @@ -0,0 +1,99 @@ +{ config, pkgs, inputs, ... }: + +{ + programs.nixvim.plugins.telescope = { + enable = true; + + # Enable telescope extensions + extensions = { + fzf-native.enable = true; + ui-select.enable = true; + }; + + keymaps = { + "sh" = { + mode = "n"; + action = "help_tags"; + options = { + desc = "[S]earch [H]elp"; + }; + }; + + "sk" = { + mode = "n"; + action = "keymaps"; + options = { + desc = "[S]earch [K]eymaps"; + }; + }; + + "sf" = { + mode = "n"; + action = "find_files"; + options = { + desc = "[S]earch [F]iles"; + }; + }; + + "ss" = { + mode = "n"; + action = "builtin"; + options = { + desc = "[S]earch [S]elect Telescope"; + }; + }; + + "sw" = { + mode = "n"; + action = "grep_string"; + options = { + desc = "[S]earch by [G]rep"; + }; + }; + + "sg" = { + mode = "n"; + action = "live_grep"; + options = { + desc = "[S]earch by [G]rep"; + }; + }; + + "sd" = { + mode = "n"; + action = "diagnostics"; + options = { + desc = "[S]earch [D]iagnostics"; + }; + }; + + "sr" = { + mode = "n"; + action = "resume"; + options = { + desc = "[S]earch [R]esume"; + }; + }; + + "s" = { + mode = "n"; + action = "oldfiles"; + options = { + desc = "[S]earch Recent Files ('.' for repeat)"; + }; + }; + + "" = { + mode = "n"; + action = "buffers"; + options = { + desc = "[ ] Find existing buffers"; + }; + }; + }; + + settings = { + extensions.__raw = "{ ['ui-select'] = { require('telescope.themes').get_dropdown() } }"; + }; + }; +} diff --git a/modules/home-manager/nixvim/plugins/treesitter.nix b/modules/home-manager/nixvim/plugins/treesitter.nix new file mode 100644 index 0000000..7e8ec0f --- /dev/null +++ b/modules/home-manager/nixvim/plugins/treesitter.nix @@ -0,0 +1,9 @@ +{ config, pkgs, inputs, ... }: + +{ + programs.nixvim.plugins.treesitter = { + enable = true; + + indent = true; + }; +}