From 25b2b07a4605ec178444f449a832ac1dd8f5c904 Mon Sep 17 00:00:00 2001 From: Gabe Venberg Date: Wed, 20 Mar 2024 00:20:20 -0500 Subject: [PATCH] added a few more plugins, got cmp+luasnip working. LSP is the last major milestone now. --- nix/home.nix | 1 + nix/nvim/cmp/cmp.nix | 58 ++++++++ nix/nvim/gitsigns.nix | 22 +++ nix/nvim/keybinds.nix | 95 ++++++++++++ nix/nvim/lsp/lsp.nix | 11 ++ nix/nvim/lsp/outline.nix | 22 +++ nix/nvim/lualine.nix | 2 +- nix/nvim/nvim-tree.nix | 2 +- nix/nvim/nvim.nix | 162 ++------------------- nix/nvim/options.nix | 70 +++++++++ nix/nvim/simpleplugins.nix | 19 +++ nix/nvim/telescope.nix | 116 +++++++++++++++ nix/nvim/toggleterm.nix | 12 +- nix/nvim/treesitter/rainbow-delimiters.nix | 20 +++ nix/nvim/treesitter/treesitter.nix | 22 +++ nix/nvim/which-key.nix | 15 ++ 16 files changed, 490 insertions(+), 159 deletions(-) create mode 100644 nix/nvim/cmp/cmp.nix create mode 100644 nix/nvim/gitsigns.nix create mode 100644 nix/nvim/keybinds.nix create mode 100644 nix/nvim/lsp/lsp.nix create mode 100644 nix/nvim/lsp/outline.nix create mode 100644 nix/nvim/options.nix create mode 100644 nix/nvim/simpleplugins.nix create mode 100644 nix/nvim/telescope.nix create mode 100644 nix/nvim/treesitter/rainbow-delimiters.nix create mode 100644 nix/nvim/treesitter/treesitter.nix create mode 100644 nix/nvim/which-key.nix diff --git a/nix/home.nix b/nix/home.nix index f44a26f..ffea625 100644 --- a/nix/home.nix +++ b/nix/home.nix @@ -1,6 +1,7 @@ { config, pkgs, + helpers, ... }: { # Home Manager needs a bit of information about you and the paths it should diff --git a/nix/nvim/cmp/cmp.nix b/nix/nvim/cmp/cmp.nix new file mode 100644 index 0000000..4809f71 --- /dev/null +++ b/nix/nvim/cmp/cmp.nix @@ -0,0 +1,58 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + plugins.luasnip.enable = true; + plugins.friendly-snippets.enable=true; + plugins.cmp = { + enable = true; + autoEnableSources = true; + settings = { + sources = [ + {name = "luasnip";} + {name = "treesitter";} + {name = "path";} + {name = "emoji";} + {name = "buffer";} + {name = "latex_symbols";} + {name = "digraphs";} + {name = "spell";} + ]; + snippet = { + expand = "luasnip"; + }; + mapping = { + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.close()"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.confirm({ select = false })"; + "" = '' + function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") + else + fallback() + end + end + ''; + "" = '' + function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") + else + fallback() + end + end + ''; + }; + }; + }; + }; +} diff --git a/nix/nvim/gitsigns.nix b/nix/nvim/gitsigns.nix new file mode 100644 index 0000000..9a0ff0f --- /dev/null +++ b/nix/nvim/gitsigns.nix @@ -0,0 +1,22 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + plugins.gitsigns = { + enable = true; + }; + keymaps = [ + { + action = ":Gitsigns toggle_current_line_blame"; + key = "gb"; + mode = "n"; + options = { + silent = true; + desc = "toggle git blame"; + }; + } + ]; + }; +} diff --git a/nix/nvim/keybinds.nix b/nix/nvim/keybinds.nix new file mode 100644 index 0000000..c2c753d --- /dev/null +++ b/nix/nvim/keybinds.nix @@ -0,0 +1,95 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + globals = { + mapleader = ";"; + }; + + keymaps = [ + { + action = ":setlocal spell!"; + key = "cs"; + mode = "n"; + options = { + silent = true; + desc = "toggle spell check"; + }; + } + { + action = ":bnext"; + key = "gf"; + mode = "n"; + options = { + silent = true; + desc = "next buffer"; + }; + } + { + action = ":bprevious"; + key = "gF"; + mode = "n"; + options = { + silent = true; + desc = "prev buffer"; + }; + } + { + action = "h"; + key = ""; + mode = "n"; + options = { + silent = true; + desc = "move to right split"; + }; + } + { + action = "j"; + key = ""; + mode = "n"; + options = { + silent = true; + desc = "move to below split"; + }; + } + { + action = "k"; + key = ""; + mode = "n"; + options = { + silent = true; + desc = "move to above split"; + }; + } + { + action = "l"; + key = ""; + mode = "n"; + options = { + silent = true; + desc = "move to left split"; + }; + } + { + action = "za"; + key = ""; + mode = "n"; + options = { + silent = true; + desc = "toggle fold"; + }; + } + { + action = ":nohls"; + key = "h"; + mode = "n"; + options = { + silent = true; + desc = "clear highlighting"; + }; + } + ]; + }; +} diff --git a/nix/nvim/lsp/lsp.nix b/nix/nvim/lsp/lsp.nix new file mode 100644 index 0000000..ba8d1f6 --- /dev/null +++ b/nix/nvim/lsp/lsp.nix @@ -0,0 +1,11 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + }; + imports = [ + # ./outline.nix + ]; +} diff --git a/nix/nvim/lsp/outline.nix b/nix/nvim/lsp/outline.nix new file mode 100644 index 0000000..bab6d46 --- /dev/null +++ b/nix/nvim/lsp/outline.nix @@ -0,0 +1,22 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + keymaps = [ + { + action = ":Outline"; + key = "o"; + mode = "n"; + options = { + silent = true; + desc = "toggle outline"; + }; + } + ]; + extraPlugins = [ + pkgs.vimPlugins.outline-nvim + ]; + }; +} diff --git a/nix/nvim/lualine.nix b/nix/nvim/lualine.nix index 6f496e2..0a9eea1 100644 --- a/nix/nvim/lualine.nix +++ b/nix/nvim/lualine.nix @@ -1,6 +1,6 @@ { configs, - pkg, + pkgs, ... }: { programs.nixvim = { diff --git a/nix/nvim/nvim-tree.nix b/nix/nvim/nvim-tree.nix index b68a814..16c60aa 100644 --- a/nix/nvim/nvim-tree.nix +++ b/nix/nvim/nvim-tree.nix @@ -1,6 +1,6 @@ { configs, - pkg, + pkgs, ... }: { programs.nixvim = { diff --git a/nix/nvim/nvim.nix b/nix/nvim/nvim.nix index 701885c..74f16b0 100644 --- a/nix/nvim/nvim.nix +++ b/nix/nvim/nvim.nix @@ -1,6 +1,7 @@ { configs, - pkg, + pkgs, + helpers, ... }: { programs.nixvim = { @@ -13,161 +14,20 @@ enable = true; }; - options = { - mouse = "a"; - lazyredraw = true; - termguicolors = true; - autoread = true; - swapfile = false; - history = 500; - formatoptions = "rojq"; - # dont hard wrap - textwidth = 0; - wrapmargin = 0; - breakindent = true; - # highlight after col - colorcolumn = "80,100,120"; - # add ruler to side of screen - number = true; - numberwidth = 3; - #display cursor cordinates - ruler = true; - #always leave 5 cells between cursor and side of window - scrolloff = 5; - # better command line completion - wildmenu = true; - # ignore case if all lowercase - ignorecase = true; - smartcase = true; - # show unfinished keycombos in statusbar - showcmd = true; - # regex stuff - magic = true; - # always show statusline - laststatus = 2; - # tab stuff - tabstop = 4; - shiftwidth = 0; - autoindent = true; - smartindent = true; - smarttab = true; - # for true tabs, change to false - expandtab = true; - softtabstop = -1; - # highlight search results as you type - hlsearch = true; - incsearch = true; - # folding stuff - foldlevelstart = 5; - foldmethod = "indent"; - foldcolumn = "auto:4"; - foldenable = true; - # display whitespace as other chars - list = true; - listchars = { - tab = ">-"; - eol = "↲"; - nbsp = "␣"; - trail = "•"; - extends = "⟩"; - precedes = "⟨"; - }; - showbreak = "↪"; - }; - clipboard.providers.xsel.enable = true; - - globals = { - mapleader = ";"; - }; - - keymaps = [ - { - action = ":setlocal spell!"; - key = "cs"; - mode = "n"; - options = { - silent = true; - desc = "toggle spell check"; - }; - } - { - action = ":bnext"; - key = "gf"; - mode = "n"; - options = { - silent = true; - desc = "next buffer"; - }; - } - { - action = ":bprevious"; - key = "gF"; - mode = "n"; - options = { - silent = true; - desc = "prev buffer"; - }; - } - { - action = "h"; - key = ""; - mode = "n"; - options = { - silent = true; - desc = "move to right split"; - }; - } - { - action = "j"; - key = ""; - mode = "n"; - options = { - silent = true; - desc = "move to below split"; - }; - } - { - action = "k"; - key = ""; - mode = "n"; - options = { - silent = true; - desc = "move to above split"; - }; - } - { - action = "l"; - key = ""; - mode = "n"; - options = { - silent = true; - desc = "move to left split"; - }; - } - { - action = "za"; - key = ""; - mode = "n"; - options = { - silent = true; - desc = "toggle fold"; - }; - } - { - action = ":nohls"; - key = "h"; - mode = "n"; - options = { - silent = true; - desc = "clear highlighting"; - }; - } - ]; }; imports = [ + ./keybinds.nix + ./options.nix + ./simpleplugins.nix ./lualine.nix ./nvim-tree.nix ./toggleterm.nix + ./gitsigns.nix + ./which-key.nix + ./telescope.nix + ./treesitter/treesitter.nix + ./cmp/cmp.nix + ./lsp/lsp.nix ]; } diff --git a/nix/nvim/options.nix b/nix/nvim/options.nix new file mode 100644 index 0000000..3ac7717 --- /dev/null +++ b/nix/nvim/options.nix @@ -0,0 +1,70 @@ +{ + configs, + pkgs, + lib, + ... +}: { + programs.nixvim = { + options = { + mouse = "a"; + lazyredraw = true; + termguicolors = true; + autoread = true; + swapfile = false; + history = 500; + formatoptions = "rojq"; + # dont hard wrap + textwidth = 0; + wrapmargin = 0; + breakindent = true; + # highlight after col + colorcolumn = "80,100,120"; + # add ruler to side of screen + number = true; + numberwidth = 3; + #display cursor cordinates + ruler = true; + #always leave 5 cells between cursor and side of window + scrolloff = 5; + # better command line completion + wildmenu = true; + # ignore case if all lowercase + ignorecase = true; + smartcase = true; + # show unfinished keycombos in statusbar + showcmd = true; + # regex stuff + magic = true; + # always show statusline + laststatus = 2; + # tab stuff + tabstop = 4; + shiftwidth = 0; + autoindent = true; + smartindent = true; + smarttab = true; + # for true tabs, change to false + expandtab = true; + softtabstop = -1; + # highlight search results as you type + hlsearch = true; + incsearch = true; + # folding stuff + foldlevelstart = 5; + foldmethod = lib.mkDefault "indent"; + foldcolumn = "auto:4"; + foldenable = true; + # display whitespace as other chars + list = true; + listchars = { + tab = ">-"; + eol = "↲"; + nbsp = "␣"; + trail = "•"; + extends = "⟩"; + precedes = "⟨"; + }; + showbreak = "↪"; + }; + }; +} diff --git a/nix/nvim/simpleplugins.nix b/nix/nvim/simpleplugins.nix new file mode 100644 index 0000000..ca4dd67 --- /dev/null +++ b/nix/nvim/simpleplugins.nix @@ -0,0 +1,19 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + plugins.comment-nvim.enable = true; + plugins.marks.enable = true; + plugins.surround.enable = true; + plugins.todo-comments.enable = true; + plugins.leap = { + enable = true; + addDefaultMappings = true; + }; + extraPlugins = [ + pkgs.vimPlugins.vim-numbertoggle + ]; + }; +} diff --git a/nix/nvim/telescope.nix b/nix/nvim/telescope.nix new file mode 100644 index 0000000..ffda359 --- /dev/null +++ b/nix/nvim/telescope.nix @@ -0,0 +1,116 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + plugins.telescope = { + enable = true; + }; + plugins.which-key.registrations = { + "f" = "+telescope"; + "fg" = "+telescope git"; + }; + keymaps = [ + { + action = ":Telescope find_files"; + key = "ff"; + mode = "n"; + options = { + silent = true; + desc = "files"; + }; + } + { + action = ":Telescope live_grep"; + key = "fg"; + mode = "n"; + options = { + silent = true; + desc = "grep"; + }; + } + { + action = ":Telescope buffers"; + key = "fb"; + mode = "n"; + options = { + silent = true; + desc = "buffers"; + }; + } + { + action = ":Telescope marks"; + key = "fm"; + mode = "n"; + options = { + silent = true; + desc = "marks"; + }; + } + { + action = ":Telescope registers"; + key = "fr"; + mode = "n"; + options = { + silent = true; + desc = "registers"; + }; + } + { + action = ":Telescope keymaps"; + key = "fk"; + mode = "n"; + options = { + silent = true; + desc = "keymaps"; + }; + } + { + action = ":Telescope current_buffer_fuzzy_find"; + key = "fz"; + mode = "n"; + options = { + silent = true; + desc = "fuzzy find"; + }; + } + { + action = ":Telescope git_commits"; + key = "fgc"; + mode = "n"; + options = { + silent = true; + desc = "commits"; + }; + } + { + action = ":Telescope git_branches"; + key = "fgb"; + mode = "n"; + options = { + silent = true; + desc = "branches"; + }; + } + { + action = ":Telescope git_stash"; + key = "fgs"; + mode = "n"; + options = { + silent = true; + desc = "stash"; + }; + } + { + action = ":Telescope git_commits"; + key = "fgc"; + mode = "n"; + options = { + silent = true; + desc = "commits"; + }; + } + ]; + }; +} diff --git a/nix/nvim/toggleterm.nix b/nix/nvim/toggleterm.nix index f96ee9b..7f75e5e 100644 --- a/nix/nvim/toggleterm.nix +++ b/nix/nvim/toggleterm.nix @@ -1,19 +1,19 @@ { configs, - pkg, + pkgs, ... }: { programs.nixvim = { - plugins.toggleterm={ - enable=true; - direction="horizontal"; - insertMappings=false; + plugins.toggleterm = { + enable = true; + direction = "horizontal"; + insertMappings = false; }; keymaps = [ { action = "function() Floatingterm:toggle() end"; key = "s"; - lua=true; + lua = true; mode = "n"; options = { silent = true; diff --git a/nix/nvim/treesitter/rainbow-delimiters.nix b/nix/nvim/treesitter/rainbow-delimiters.nix new file mode 100644 index 0000000..86a5e01 --- /dev/null +++ b/nix/nvim/treesitter/rainbow-delimiters.nix @@ -0,0 +1,20 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + plugins.rainbow-delimiters = { + enable = true; + highlight = [ + "RainbowDelimiterYellow" + "RainbowDelimiterBlue" + "RainbowDelimiterOrange" + "RainbowDelimiterGreen" + "RainbowDelimiterViolet" + "RainbowDelimiterCyan" + # "RainbowDelimiterRed" + ]; + }; + }; +} diff --git a/nix/nvim/treesitter/treesitter.nix b/nix/nvim/treesitter/treesitter.nix new file mode 100644 index 0000000..2099592 --- /dev/null +++ b/nix/nvim/treesitter/treesitter.nix @@ -0,0 +1,22 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + plugins.treesitter = { + enable = true; + folding = true; + indent = true; + nixvimInjections = true; + }; + plugins.treesitter-context.enable = true; + plugins.indent-blankline.enable = true; + extraPlugins = [ + pkgs.vimPlugins.treesj + ]; + }; + imports = [ + ./rainbow-delimiters.nix + ]; +} diff --git a/nix/nvim/which-key.nix b/nix/nvim/which-key.nix new file mode 100644 index 0000000..e8886b8 --- /dev/null +++ b/nix/nvim/which-key.nix @@ -0,0 +1,15 @@ +{ + configs, + pkgs, + ... +}: { + programs.nixvim = { + options = { + timeout = true; + timeoutlen = 300; + }; + plugins.which-key = { + enable = true; + }; + }; +}