From f3ca9b3e88955979682ae56da860704e00ef4a27 Mon Sep 17 00:00:00 2001 From: Simon Walker Date: Tue, 17 Sep 2024 11:21:37 +0100 Subject: [PATCH] Install custom neovim in standalone mode --- bin/nvim-build.sh | 2 +- flake.nix | 28 ++- home/colours.nix | 215 ++-------------------- home/home.nix | 1 - home/nixvim/base.nix | 304 +++++++++++++++++++++++++++++++ home/nixvim/cody.nix | 20 +- home/nixvim/completion.nix | 2 +- home/nixvim/context.nix | 4 +- home/nixvim/dap.nix | 106 ++++++----- home/nixvim/default.nix | 302 +----------------------------- home/nixvim/diffview.nix | 2 +- home/nixvim/gitsigns.nix | 4 +- home/nixvim/hardtime.nix | 14 +- home/nixvim/lsp-format.nix | 2 +- home/nixvim/lsp.nix | 2 +- home/nixvim/markdown-preview.nix | 2 +- home/nixvim/mini.nix | 2 +- home/nixvim/neotest.nix | 68 ++++--- home/nixvim/notifications.nix | 2 +- home/nixvim/octo-nvim.nix | 10 +- home/nixvim/oil.nix | 40 ++-- home/nixvim/render-markdown.nix | 15 +- home/nixvim/statusbar.nix | 4 +- home/nixvim/telescope.nix | 2 +- home/nixvim/trouble.nix | 28 ++- home/nixvim/vim-test.nix | 52 +++--- home/nixvim/which-key.nix | 24 +-- home/nixvim/zen-mode.nix | 2 +- 28 files changed, 545 insertions(+), 714 deletions(-) create mode 100644 home/nixvim/base.nix diff --git a/bin/nvim-build.sh b/bin/nvim-build.sh index fe24e104..513ab96a 100755 --- a/bin/nvim-build.sh +++ b/bin/nvim-build.sh @@ -6,4 +6,4 @@ set -euo pipefail NIXARCH="$(nixarch)" -nom build ".#homeConfigurations.${NIXARCH}.${USER}.config.programs.nixvim.finalPackage" $* +nom build ".#nixvim" $* diff --git a/flake.nix b/flake.nix index ec2d9a34..f242635a 100644 --- a/flake.nix +++ b/flake.nix @@ -170,9 +170,12 @@ home-manager.users.simon = {...}: { imports = [ ./home/home.nix - nixvim.homeManagerModules.nixvim inputs.nix-index-database.hmModules.nix-index ]; + + home.packages = [ + self.packages.${system}.nixvim + ]; }; } vscode-server.nixosModule @@ -228,9 +231,12 @@ home-manager.users.simon = {...}: { imports = [ ./home/home.nix - nixvim.homeManagerModules.nixvim inputs.nix-index-database.hmModules.nix-index ]; + + home.packages = [ + self.packages.${system}.nixvim + ]; }; } ]; @@ -254,8 +260,12 @@ inherit pkgs; modules = [ ./home/home.nix - nixvim.homeManagerModules.nixvim inputs.nix-index-database.hmModules.nix-index + ({ ... }: { + home.packages = [ + self.packages.${system}.nixvim + ]; + }) ]; # stop infinite recusion when trying to access # pkgs.stdenv.is{Linux,Darwin} from within a module @@ -269,7 +279,6 @@ inherit pkgs; modules = [ ./minimal/home.nix - nixvim.homeManagerModules.nixvim ]; # stop infinite recusion when trying to access # pkgs.stdenv.is{Linux,Darwin} from within a module @@ -288,6 +297,17 @@ python310Packages.black ]; }; + + packages.nixvim = inputs.nixvim.legacyPackages.${system}.makeNixvimWithModule { + inherit pkgs; + module = { + imports = [ + ./home/nixvim/default.nix + ]; + }; + extraSpecialArgs = { + }; + }; } ); diff --git a/home/colours.nix b/home/colours.nix index 5fe843a3..69571161 100644 --- a/home/colours.nix +++ b/home/colours.nix @@ -5,7 +5,6 @@ inputs, ... }: let - cfg = config.me; dark-themes = [ @@ -989,151 +988,6 @@ }; }; }; - neovim-theme-blocks = { - poimandres = '' - require('poimandres').setup({}) - vim.cmd("colorscheme poimandres") - ''; - papercolor = '' - vim.cmd.highlight({ "TreesitterContext", "guibg=#f6f6ff" }) - vim.cmd [[set background=light]] - vim.cmd [[colorscheme PaperColorSlim]] - ''; - nord = '' - vim.g.nord_disable_background = true - vim.g.nord_italic = false - vim.cmd [[colorscheme nord]] - vim.cmd.highlight({ "@comment", "guifg=#d08770" }) - vim.cmd.highlight({ "TreesitterContext", "guibg=#363c4a" }) - -- markdown colours - vim.cmd.highlight({ "@markup.raw", "guifg=${current-theme.normal.yellow}" }) - ''; - github-light = '' - - vim.cmd [[set background=light]] - vim.cmd [[colorscheme github_light]] - vim.cmd.highlight({ "DiagnosticError", "guifg=Red" }) - vim.cmd.highlight({ "DiagnosticHint", "guifg=Orange" }) - vim.cmd.highlight({ "DiagnosticWarn", "guifg=Orange" }) - vim.cmd.highlight({ "DiagnosticInfo", "guifg=LightBlue" }) - vim.cmd.highlight({ "DiagnosticFloatingError", "guifg=Red" }) - vim.cmd.highlight({ "DiagnosticFloatingHint", "guifg=Orange" }) - vim.cmd.highlight({ "DiagnosticFloatingInfo", "guifg=LightBlue" }) - vim.cmd.highlight({ "DiagnosticFloatingWarn", "guifg=Orange" }) - vim.cmd.highlight({ "DiagnosticVirtualTextError", "guifg=Red" }) - vim.cmd.highlight({ "DiagnosticVirtualTextHint", "guifg=Orange" }) - vim.cmd.highlight({ "DiagnosticVirtualTextInfo", "guifg=LightBlue" }) - vim.cmd.highlight({ "DiagnosticVirtualTextWarn", "guifg=Orange" }) - vim.cmd.highlight({ "Comment", "guifg=#e69340" }) - vim.cmd.highlight({ "TreesitterContext", "guibg=#eeeeee" }) - ''; - # TODO: migrate these to nixvim - one-dark = '' - colorscheme onedark - ''; - catppuccin-macchiato = '' - -- remove underline from bottom of highlight section - vim.cmd([[ - set background=dark - colorscheme catppuccin-macchiato - ]]) - vim.cmd.highlight({ 'TreesitterContextBottom', 'gui=none' }) - ''; - catppuccin-mocha = '' - vim.cmd([[ - set background=dark - colorscheme catppuccin-mocha - ]]) - ''; - catppuccin-frappe = '' - vim.cmd([[ - set background=dark - colorscheme catppuccin-frappe - ]]) - ''; - dracula = '' - set background=dark - colorscheme dracula - ''; - solarized-light = '' - set background=light - - let g:solarized_disable_background = v:true - let g:solarized_italic_comments = v:false - let g:solarized_italic_keywords = v:false - let g:solarized_italic_functions = v:true - let g:solarized_italic_variables = v:false - let g:solarized_contrast = v:false - let g:solarized_borders = v:true - - colorscheme solarized - highlight Cursor guifg=${current-theme.cursor.cursor} guibg=${current-theme.cursor.text} - highlight TreesitterContext guibg=${current-theme.normal.white} - ''; - github = '' - vim.opt.background = "dark" - -- overrides - vim.cmd.highlight({ "Comment", "guifg=#e69340" }) - vim.cmd.highlight({ "TSComment", "guifg=#e69340" }) - vim.cmd.highlight({ "Normal", "guibg=none" }) - vim.cmd.highlight({ "NormalNC", "guibg=none" }) - -- set background colour - vim.cmd "colorscheme github_dark" - ''; - gruvbox = '' - set background=dark - let g:gruvbox_contrast_dark = "hard" - colorscheme gruvbox - highlight Comment guifg=#e69340 " brighten comments - highlight TSComment guifg=#e69340 " brighten comments - ''; - monochrome = '' - set background=dark - colorscheme fogbell - hi Normal guibg=none - ''; - srw = '' - vim.cmd([[ - set background=dark - colorscheme srw256 - hi Normal guibg=none - let g:linenr_background = 'none' - execute 'highlight TelescopeNormal guibg=' . g:linenr_background - execute 'highlight LineNr guibg=' . g:linenr_background - execute 'highlight SignColumn guibg=' . g:linenr_background - highlight TabLine guibg=none - highlight TabLineSel guibg=none - highlight TabLineFill guibg=none - execute 'highlight DiagnosticSignError ctermfg=1 guifg=Red guibg=' . g:linenr_background - execute 'highlight DiagnosticSignHint ctermfg=7 guifg=LightGrey guibg=' . g:linenr_background - execute 'highlight DiagnosticSignInfo ctermfg=4 guifg=LightBlue guibg=' . g:linenr_background - execute 'highlight DiagnosticSignWarn ctermfg=3 guifg=Orange guibg=' . g:linenr_background - highlight DiagnosticUnderlineHint guifg=Grey guisp=Grey - ]]) - ''; - catppuccin-latte = '' - vim.cmd([[ - set background=light - colorscheme catppuccin-latte - ]]) - ''; - monokai-pro = '' - vim.cmd([[ - set background=dark - let g:sonokai_style = "shusia" - let g:sonokai_disable_italic_comment = 1 - let g:sonokai_transparent_background = 2 - colorscheme sonokai - " highlight Comment guifg=#e69340 " brighten comments - " highlight TSComment guifg=#e69340 " brighten comments - " highlight NormalFloat guibg=#343136 - " highlight TabLine gui=none guibg=none guifg=${themes.monokai-pro.normal.yellow} - " highlight TabLineSel gui=none guibg=none guifg=${themes.monokai-pro.normal.white} - " highlight TabLineFill gui=none guibg=none - ]]) - ''; - }; - helix-theme = { github-light = "github_light"; @@ -1178,18 +1032,23 @@ hash = "sha256-m/+Xsbve1fuzNEKpSK6Eddoi7gKcj04o1kSFy/H/m9w="; }; }; - git-config = { - catppuccin-macchiato = if cfg.delta.diff-so-fancy then { - delta.options.diff-so-fancy = true; - } else { - includes = [ - { - path = "${inputs.catppuccin-delta}/catppuccin.gitconfig"; + git-config = + { + catppuccin-macchiato = + if cfg.delta.diff-so-fancy + then { + delta.options.diff-so-fancy = true; } - ]; - delta.options.features = "catppuccin-macchiato"; - }; - }.${cfg.theme}; + else { + includes = [ + { + path = "${inputs.catppuccin-delta}/catppuccin.gitconfig"; + } + ]; + delta.options.features = "catppuccin-macchiato"; + }; + } + .${cfg.theme}; zellij-theme = { @@ -1234,48 +1093,6 @@ in "vi_mode_cursor" "raw-colours" ]; - programs.nixvim.extraConfigLuaPost = neovim-theme-blocks.${cfg.theme}; - programs.nixvim.extraPlugins = with pkgs.vimPlugins; - { - poimandres = [ - poimandres-nvim - ]; - papercolor = [ - papercolor-theme-slim - ]; - github-light = [ - github-nvim-theme - ]; - gruvbox = [ - gruvbox - ]; - monokai-pro = [ - sonokai - ]; - nord = [ - nord-nvim - ]; - dracula = [ - dracula-nvim - ]; - catppuccin-macchiato = [ - catppuccin-nvim - ]; - catppuccin-mocha = [ - catppuccin-nvim - ]; - catppuccin-latte = [ - catppuccin-nvim - ]; - catppuccin-frappe = [ - catppuccin-nvim - ]; - solarized-light = [ - solarized-nvim - ]; - } - .${cfg.theme} - or []; programs.tmux.extraConfig = '' fg_colour="${tmux-primary-colour}" bg_colour="${tmux-background-colour}" diff --git a/home/home.nix b/home/home.nix index 2c379a29..d60de37d 100644 --- a/home/home.nix +++ b/home/home.nix @@ -39,7 +39,6 @@ in { ./kitty.nix ./mpv.nix ./nix-index.nix - ./nixvim ./packages/simon.nix ./ssh.nix ./taskwarrior.nix diff --git a/home/nixvim/base.nix b/home/nixvim/base.nix new file mode 100644 index 00000000..2237bdd0 --- /dev/null +++ b/home/nixvim/base.nix @@ -0,0 +1,304 @@ +{pkgs, ...}: let + keymap = { + key, + action, + mode ? "n", + lua ? false, + }: { + inherit action mode key lua; + options = { + noremap = true; + silent = true; + }; + }; +in { + editorconfig.enable = false; + opts = { + autowrite = true; + backspace = ["indent" "eol" "start"]; + breakindent = true; + completeopt = ["menuone" "preview"]; + complete = ["." "w" "b" "u" "t" "i"]; + cursorline = false; + expandtab = true; + gdefault = true; + hidden = true; + history = 50; + hlsearch = false; + ignorecase = true; + inccommand = "split"; + incsearch = true; + laststatus = 2; + linebreak = true; + list = false; + mouse = "a"; + number = false; + relativenumber = false; + ruler = false; + scrolloff = 8; + shiftround = true; + shiftwidth = 4; + showcmd = true; + smartcase = true; + smartindent = true; + synmaxcol = 1024; + tabstop = 4; + tags = [".git/tags"]; + termguicolors = true; + textwidth = 0; + timeoutlen = 500; + ttimeoutlen = 10; + wildmode = ["list:longest" "list:full"]; + wrap = false; + winwidth = 80; + updatetime = 4000; + switchbuf = ["useopen" "uselast"]; + conceallevel = 0; + shortmess = "tToOFIWa"; + signcolumn = "yes"; + splitright = true; + splitbelow = true; + swapfile = true; + writebackup = false; + backup = false; + backupcopy = "auto"; + backupdir = ["~/.vim/backup"]; + formatoptions = "jtcroql"; + undofile = true; + modeline = true; + lazyredraw = true; + # TODO: handle with colours.nix + background = "dark"; + grepprg = "rg --vimgrep"; + }; + autoGroups = { + lua-highlight.clear = true; + terminal-settings.clear = true; + diff-mode.clear = true; + last-position.clear = true; + }; + autoCmd = [ + # support closing fugitive window with 'q' + { + event = ["FileType"]; + pattern = ["fugitive"]; + command = "nmap q gq"; + } + # auto wrap markdown files + { + event = ["FileType"]; + pattern = ["markdown"]; + command = "setlocal wrap"; + } + # configure indent for hcl files + { + event = ["FileType"]; + pattern = ["hcl"]; + command = "setlocal shiftwidth=2 tabstop=2"; + } + { + event = ["FileType"]; + pattern = ["javascript" "typescript"]; + command = "setlocal tabstop=2 shiftwidth=2"; + } + { + event = ["TextYankPost"]; + command = "lua require'vim.highlight'.on_yank()"; + group = "lua-highlight"; + } + { + event = ["TermOpen"]; + command = "startinsert"; + group = "terminal-settings"; + } + { + event = ["BufWritePost"]; + command = "if &diff == 1 | diffupdate | endif"; + group = "diff-mode"; + } + ]; + userCommands = { + T = { + command = "split | resize 30 | term "; + complete = "shellcmd"; + force = true; + nargs = "*"; + }; + }; + keymaps = [ + # copy the entire buffer to the system clipboard + (keymap { + key = "cp"; + action = ":0,$y+"; + }) + # terminal map + (keymap { + mode = "t"; + key = ""; + action = ""; + }) + (keymap { + mode = "t"; + key = ""; + action = ""; + }) + (keymap { + mode = "t"; + key = ""; + action = ""; + }) + (keymap { + key = "W"; + action = '':mksession!|echo "Session saved"''; + }) + (keymap { + key = "Q"; + action = ":call ToggleList('Quickfix List', 'c')"; + }) + # emulate vim-vinegar which stopped working + (keymap { + key = "-"; + action = ":Explore"; + }) + (keymap { + key = ""; + action = ""; + }) + (keymap { + key = ""; + action = ""; + }) + (keymap { + key = ""; + action = ""; + }) + (keymap { + key = ""; + action = ""; + }) + # keep the cursor centered + (keymap { + key = "n"; + action = "nzzzv"; + }) + (keymap { + key = "N"; + action = "Nzzzv"; + }) + (keymap { + key = "/"; + action = "/\\v"; + }) + (keymap { + key = "?"; + action = "?\\v"; + }) + (keymap { + key = "A"; + action = "Lspsaga outline"; + }) + # fugitive + (keymap { + key = "gc"; + action = ":Git commit -v"; + }) + (keymap { + key = "gd"; + action = ":Gvdiff"; + }) + (keymap { + key = "gw"; + action = ":Gwrite"; + }) + (keymap { + key = "gr"; + action = ":Gread"; + }) + (keymap { + key = "gs"; + action = ":Git"; + }) + (keymap { + key = "ga"; + action = ":Git commit -v --amend"; + }) + ]; + globals = { + mapleader = " "; + # vim test + "test#python#runner" = "pytest"; + "test#javascript#reactscripts#options" = "--watchAll=false"; + "test#strategy" = "basic"; + }; + luaLoader.enable = true; + plugins = { + surround.enable = true; + commentary.enable = true; + fugitive.enable = true; + treesitter = { + enable = true; + gccPackage = null; + nodejsPackage = null; + settings.highlight = { + enable = true; + }; + }; + treesitter-textobjects = { + enable = true; + }; + nix.enable = true; + }; + extraPlugins = with pkgs.vimPlugins; [ + vim-eunuch + vim-unimpaired + vim-rhubarb + vim-repeat + # rustaceanvim + playground + lsp-status-nvim + nvim-nio + catppuccin-nvim + ]; + extraConfigLua = '' + -- remove underline from bottom of highlight section + vim.cmd([[ + set background=dark + colorscheme catppuccin-macchiato + ]]) + vim.cmd.highlight({ 'TreesitterContextBottom', 'gui=none' }) + ''; + extraFiles = { + "colors/lucius.vim".source = ./colors/lucius.vim; + "colors/srw256.vim".source = ./colors/srw256.vim; + }; + extraConfigVim = '' + " Add mapping to open/close the quickfix list + " Taken from: http://vim.wikia.com/wiki/Toggle_to_open_or_close_the_quickfix_window + function! GetBufferList() + redir =>buflist + silent! ls! + redir END + return buflist + endfunction + + function! ToggleList(bufname, pfx) + let buflist = GetBufferList() + for bufnum in map(filter(split(buflist, '\n'), 'v:val =~ "'.a:bufname.'"'), 'str2nr(matchstr(v:val, "\\d\\+"))') + if bufwinnr(bufnum) != -1 + exec(a:pfx.'close') + return + endif + endfor + if a:pfx == 'l' && len(getloclist(0)) == 0 + echohl ErrorMsg + echo "Location List is Empty." + return + endif + let winnr = winnr() + exec(a:pfx.'open') + if winnr() != winnr + wincmd p + endif + endfunction + ''; +} diff --git a/home/nixvim/cody.nix b/home/nixvim/cody.nix index aa1a861b..e8104352 100644 --- a/home/nixvim/cody.nix +++ b/home/nixvim/cody.nix @@ -10,16 +10,14 @@ in { options.me.nixvim.cody.enable = mkEnableOption "cody"; config = mkIf cfg.enable { - programs.nixvim = { - extraPlugins = with pkgs.vimPlugins; [ - sg-nvim - ]; - extraConfigLua = '' - require('sg').setup() - ''; - plugins.cmp.settings.sources = lib.mkBefore [ - {name = "cody";} - ]; - }; + extraPlugins = with pkgs.vimPlugins; [ + sg-nvim + ]; + extraConfigLua = '' + require('sg').setup() + ''; + plugins.cmp.settings.sources = lib.mkBefore [ + {name = "cody";} + ]; }; } diff --git a/home/nixvim/completion.nix b/home/nixvim/completion.nix index b567d61d..5a2269b8 100644 --- a/home/nixvim/completion.nix +++ b/home/nixvim/completion.nix @@ -15,7 +15,7 @@ in { description = "Require keypress to enable"; }; }; - config.programs.nixvim = mkIf cfg.enable { + config = mkIf cfg.enable { plugins = { cmp-emoji.enable = cfg.emoji; cmp_luasnip.enable = true; diff --git a/home/nixvim/context.nix b/home/nixvim/context.nix index 4855cd44..d8d014af 100644 --- a/home/nixvim/context.nix +++ b/home/nixvim/context.nix @@ -18,11 +18,11 @@ in { }; config = mkIf cfg.enable { - programs.nixvim.plugins.treesitter-context = mkIf (cfg.method == "treesitter-context") { + plugins.treesitter-context = mkIf (cfg.method == "treesitter-context") { enable = true; settings.max_lines = 3; }; - programs.nixvim.plugins.barbecue = mkIf (cfg.method == "barbecue") { + plugins.barbecue = mkIf (cfg.method == "barbecue") { enable = true; }; }; diff --git a/home/nixvim/dap.nix b/home/nixvim/dap.nix index b3f420ec..58180785 100644 --- a/home/nixvim/dap.nix +++ b/home/nixvim/dap.nix @@ -12,61 +12,59 @@ }; }; in { - programs.nixvim = { - plugins.dap = { + plugins.dap = { + enable = true; + extensions.dap-go.enable = true; + extensions.dap-python.enable = true; + extensions.dap-ui = { enable = true; - extensions.dap-go.enable = true; - extensions.dap-python.enable = true; - extensions.dap-ui = { - enable = true; - controls.enabled = false; - }; - extensions.dap-virtual-text.enable = true; + controls.enabled = false; }; - keymaps = [ - (keymap { - key = ""; - action = ":lua require('dap').step_into()"; - }) - (keymap { - key = ""; - action = ":lua require('dap').step_over()"; - }) - (keymap { - key = ""; - action = ":lua require('dap').continue()"; - }) - (keymap { - key = ""; - action = ":lua require('dap').step_out()"; - }) - (keymap { - key = "b"; - action = ":lua require('dap').toggle_breakpoint()"; - }) - # Eval var under cursor - (keymap { - key = "?"; - action = ":lua require('dapui').eval(nil, { enter = true })"; - }) - ]; - # launch dap-ui on debugger commands - extraConfigLua = '' - local dap, dapui = require("dap"), require("dapui") - dap.listeners.before.attach.dapui_config = function() - dapui.open() - end - dap.listeners.before.launch.dapui_config = function() - dapui.open() - end - dap.listeners.before.event_terminated.dapui_config = function() - dapui.close() - end - dap.listeners.before.event_exited.dapui_config = function() - dapui.close() - end - - require('dap-python').test_runner = "pytest" - ''; + extensions.dap-virtual-text.enable = true; }; + keymaps = [ + (keymap { + key = ""; + action = ":lua require('dap').step_into()"; + }) + (keymap { + key = ""; + action = ":lua require('dap').step_over()"; + }) + (keymap { + key = ""; + action = ":lua require('dap').continue()"; + }) + (keymap { + key = ""; + action = ":lua require('dap').step_out()"; + }) + (keymap { + key = "b"; + action = ":lua require('dap').toggle_breakpoint()"; + }) + # Eval var under cursor + (keymap { + key = "?"; + action = ":lua require('dapui').eval(nil, { enter = true })"; + }) + ]; + # launch dap-ui on debugger commands + extraConfigLua = '' + local dap, dapui = require("dap"), require("dapui") + dap.listeners.before.attach.dapui_config = function() + dapui.open() + end + dap.listeners.before.launch.dapui_config = function() + dapui.open() + end + dap.listeners.before.event_terminated.dapui_config = function() + dapui.close() + end + dap.listeners.before.event_exited.dapui_config = function() + dapui.close() + end + + require('dap-python').test_runner = "pytest" + ''; } diff --git a/home/nixvim/default.nix b/home/nixvim/default.nix index fbc10f40..4f964728 100644 --- a/home/nixvim/default.nix +++ b/home/nixvim/default.nix @@ -1,18 +1,6 @@ -{pkgs, ...}: let - keymap = { - key, - action, - mode ? "n", - lua ? false, - }: { - inherit action mode key lua; - options = { - noremap = true; - silent = true; - }; - }; -in { +{ imports = [ + ./base.nix ./cody.nix ./completion.nix ./context.nix @@ -64,291 +52,5 @@ in { diffview.enable = true; render-markdown.enable = true; }; - # defaults - programs.nixvim = { - enable = true; - editorconfig.enable = false; - opts = { - autowrite = true; - backspace = ["indent" "eol" "start"]; - breakindent = true; - completeopt = ["menuone" "preview"]; - complete = ["." "w" "b" "u" "t" "i"]; - cursorline = false; - expandtab = true; - gdefault = true; - hidden = true; - history = 50; - hlsearch = false; - ignorecase = true; - inccommand = "split"; - incsearch = true; - laststatus = 2; - linebreak = true; - list = false; - mouse = "a"; - number = false; - relativenumber = false; - ruler = false; - scrolloff = 8; - shiftround = true; - shiftwidth = 4; - showcmd = true; - smartcase = true; - smartindent = true; - synmaxcol = 1024; - tabstop = 4; - tags = [".git/tags"]; - termguicolors = true; - textwidth = 0; - timeoutlen = 500; - ttimeoutlen = 10; - wildmode = ["list:longest" "list:full"]; - wrap = false; - winwidth = 80; - updatetime = 4000; - switchbuf = ["useopen" "uselast"]; - conceallevel = 0; - shortmess = "tToOFIWa"; - signcolumn = "yes"; - splitright = true; - splitbelow = true; - swapfile = true; - writebackup = false; - backup = false; - backupcopy = "auto"; - backupdir = ["~/.vim/backup"]; - formatoptions = "jtcroql"; - undofile = true; - modeline = true; - lazyredraw = true; - # TODO: handle with colours.nix - background = "dark"; - grepprg = "rg --vimgrep"; - }; - autoGroups = { - lua-highlight.clear = true; - terminal-settings.clear = true; - diff-mode.clear = true; - last-position.clear = true; - }; - autoCmd = [ - # support closing fugitive window with 'q' - { - event = ["FileType"]; - pattern = ["fugitive"]; - command = "nmap q gq"; - } - # auto wrap markdown files - { - event = ["FileType"]; - pattern = ["markdown"]; - command = "setlocal wrap"; - } - # configure indent for hcl files - { - event = ["FileType"]; - pattern = ["hcl"]; - command = "setlocal shiftwidth=2 tabstop=2"; - } - { - event = ["FileType"]; - pattern = ["javascript" "typescript"]; - command = "setlocal tabstop=2 shiftwidth=2"; - } - { - event = ["TextYankPost"]; - command = "lua require'vim.highlight'.on_yank()"; - group = "lua-highlight"; - } - { - event = ["TermOpen"]; - command = "startinsert"; - group = "terminal-settings"; - } - { - event = ["BufWritePost"]; - command = "if &diff == 1 | diffupdate | endif"; - group = "diff-mode"; - } - ]; - userCommands = { - T = { - command = "split | resize 30 | term "; - complete = "shellcmd"; - force = true; - nargs = "*"; - }; - }; - keymaps = [ - # copy the entire buffer to the system clipboard - (keymap { - key = "cp"; - action = ":0,$y+"; - }) - # terminal map - (keymap { - mode = "t"; - key = ""; - action = ""; - }) - (keymap { - mode = "t"; - key = ""; - action = ""; - }) - (keymap { - mode = "t"; - key = ""; - action = ""; - }) - (keymap { - key = "W"; - action = '':mksession!|echo "Session saved"''; - }) - (keymap { - key = "Q"; - action = ":call ToggleList('Quickfix List', 'c')"; - }) - # emulate vim-vinegar which stopped working - (keymap { - key = "-"; - action = ":Explore"; - }) - (keymap { - key = ""; - action = ""; - }) - (keymap { - key = ""; - action = ""; - }) - (keymap { - key = ""; - action = ""; - }) - (keymap { - key = ""; - action = ""; - }) - # keep the cursor centered - (keymap { - key = "n"; - action = "nzzzv"; - }) - (keymap { - key = "N"; - action = "Nzzzv"; - }) - (keymap { - key = "/"; - action = "/\\v"; - }) - (keymap { - key = "?"; - action = "?\\v"; - }) - (keymap { - key = "A"; - action = "Lspsaga outline"; - }) - # fugitive - (keymap { - key = "gc"; - action = ":Git commit -v"; - }) - (keymap { - key = "gd"; - action = ":Gvdiff"; - }) - (keymap { - key = "gw"; - action = ":Gwrite"; - }) - (keymap { - key = "gr"; - action = ":Gread"; - }) - (keymap { - key = "gs"; - action = ":Git"; - }) - (keymap { - key = "ga"; - action = ":Git commit -v --amend"; - }) - ]; - globals = { - mapleader = " "; - # vim test - "test#python#runner" = "pytest"; - "test#javascript#reactscripts#options" = "--watchAll=false"; - "test#strategy" = "basic"; - }; - luaLoader.enable = true; - plugins = { - surround.enable = true; - commentary.enable = true; - fugitive.enable = true; - treesitter = { - enable = true; - gccPackage = null; - nodejsPackage = null; - settings.highlight = { - enable = true; - }; - }; - treesitter-textobjects = { - enable = true; - }; - nix.enable = true; - }; - extraPlugins = with pkgs.vimPlugins; [ - vim-eunuch - vim-unimpaired - vim-rhubarb - vim-repeat - # rustaceanvim - playground - lsp-status-nvim - nvim-nio - ]; - extraConfigLua = '' - ''; - extraFiles = { - "colors/lucius.vim".source = ./colors/lucius.vim; - "colors/srw256.vim".source = ./colors/srw256.vim; - }; - extraConfigVim = '' - " Add mapping to open/close the quickfix list - " Taken from: http://vim.wikia.com/wiki/Toggle_to_open_or_close_the_quickfix_window - function! GetBufferList() - redir =>buflist - silent! ls! - redir END - return buflist - endfunction - - function! ToggleList(bufname, pfx) - let buflist = GetBufferList() - for bufnum in map(filter(split(buflist, '\n'), 'v:val =~ "'.a:bufname.'"'), 'str2nr(matchstr(v:val, "\\d\\+"))') - if bufwinnr(bufnum) != -1 - exec(a:pfx.'close') - return - endif - endfor - if a:pfx == 'l' && len(getloclist(0)) == 0 - echohl ErrorMsg - echo "Location List is Empty." - return - endif - let winnr = winnr() - exec(a:pfx.'open') - if winnr() != winnr - wincmd p - endif - endfunction - ''; - }; }; } diff --git a/home/nixvim/diffview.nix b/home/nixvim/diffview.nix index 3f5dd8de..b3017151 100644 --- a/home/nixvim/diffview.nix +++ b/home/nixvim/diffview.nix @@ -10,7 +10,7 @@ in { enable = mkEnableOption "DiffView"; }; config = mkIf cfg.enable { - programs.nixvim.plugins.diffview = { + plugins.diffview = { enable = true; }; }; diff --git a/home/nixvim/gitsigns.nix b/home/nixvim/gitsigns.nix index 31bd4c2f..4da4470f 100644 --- a/home/nixvim/gitsigns.nix +++ b/home/nixvim/gitsigns.nix @@ -13,8 +13,8 @@ nnoremap = rebind "n"; vnoremap = rebind "v"; in { - programs.nixvim.plugins.gitsigns.enable = true; - programs.nixvim.keymaps = + plugins.gitsigns.enable = true; + keymaps = [ { mode = "n"; diff --git a/home/nixvim/hardtime.nix b/home/nixvim/hardtime.nix index 36a948cc..3305f043 100644 --- a/home/nixvim/hardtime.nix +++ b/home/nixvim/hardtime.nix @@ -1,20 +1,20 @@ -{ lib, config, ... }: -with lib; -let - cfg = config.me.nixvim.hardtime; -in { + lib, + config, + ... +}: +with lib; let + cfg = config.me.nixvim.hardtime; +in { options.me.nixvim.hardtime = { enable = mkEnableOption "hardtime"; }; config = mkIf cfg.enable { - programs.nixvim = { plugins.hardtime = { enable = true; allowDifferentKey = true; disableMouse = false; }; }; - }; } diff --git a/home/nixvim/lsp-format.nix b/home/nixvim/lsp-format.nix index c5cdd6b0..49d1226b 100644 --- a/home/nixvim/lsp-format.nix +++ b/home/nixvim/lsp-format.nix @@ -1,5 +1,5 @@ { - programs.nixvim.plugins.lsp-format = { + plugins.lsp-format = { enable = true; setup = { nix = { diff --git a/home/nixvim/lsp.nix b/home/nixvim/lsp.nix index efbffb8e..e4eb3e7d 100644 --- a/home/nixvim/lsp.nix +++ b/home/nixvim/lsp.nix @@ -23,7 +23,7 @@ in { enable = mkEnableOption "lsp"; inlay-hints = mkEnableOption "inlay-hints"; }; - config.programs.nixvim = mkIf cfg.enable { + config = mkIf cfg.enable { plugins = { lsp = { enable = true; diff --git a/home/nixvim/markdown-preview.nix b/home/nixvim/markdown-preview.nix index 0ef87cee..a692a5aa 100644 --- a/home/nixvim/markdown-preview.nix +++ b/home/nixvim/markdown-preview.nix @@ -1,5 +1,5 @@ {...}: { - programs.nixvim.plugins.markdown-preview = { + plugins.markdown-preview = { enable = true; settings.auto_close = true; }; diff --git a/home/nixvim/mini.nix b/home/nixvim/mini.nix index c0c254d7..851a58b0 100644 --- a/home/nixvim/mini.nix +++ b/home/nixvim/mini.nix @@ -11,7 +11,7 @@ in { }; config = mkIf cfg.enable { - programs.nixvim.plugins.mini = { + plugins.mini = { enable = true; modules = { # Note: not actually AI! diff --git a/home/nixvim/neotest.nix b/home/nixvim/neotest.nix index 98dcc5b8..64b3c5f0 100644 --- a/home/nixvim/neotest.nix +++ b/home/nixvim/neotest.nix @@ -21,43 +21,41 @@ with lib; let in { options.me.nixvim.neotest.enable = mkEnableOption "neotest"; config = mkIf cfg.enable { - programs.nixvim = { - plugins.neotest = { - enable = true; - adapters = { - go.enable = true; - python.enable = true; - rust.enable = true; - }; - settings = { - output_panel.open = "tabnew"; - output.enabled = false; - }; + plugins.neotest = { + enable = true; + adapters = { + go.enable = true; + python.enable = true; + rust.enable = true; }; - globals = { - cursorhold_updatetime = 100; + settings = { + output_panel.open = "tabnew"; + output.enabled = false; }; - extraPlugins = with pkgs.vimPlugins; [ - FixCursorHold-nvim - ]; - keymaps = [ - (keymap { - key = "tf"; - action = ''function() require("neotest").run.run(vim.fn.expand("%")) end''; - }) - (keymap { - key = "tl"; - action = ''function() require("neotest").run.run_last() end''; - }) - (keymap { - key = "tn"; - action = ''function() require("neotest").run.run() end''; - }) - (keymap { - key = "to"; - action = ''function() require("neotest").output_panel.toggle() end''; - }) - ]; }; + globals = { + cursorhold_updatetime = 100; + }; + extraPlugins = with pkgs.vimPlugins; [ + FixCursorHold-nvim + ]; + keymaps = [ + (keymap { + key = "tf"; + action = ''function() require("neotest").run.run(vim.fn.expand("%")) end''; + }) + (keymap { + key = "tl"; + action = ''function() require("neotest").run.run_last() end''; + }) + (keymap { + key = "tn"; + action = ''function() require("neotest").run.run() end''; + }) + (keymap { + key = "to"; + action = ''function() require("neotest").output_panel.toggle() end''; + }) + ]; }; } diff --git a/home/nixvim/notifications.nix b/home/nixvim/notifications.nix index f4f131e1..3c5a15c7 100644 --- a/home/nixvim/notifications.nix +++ b/home/nixvim/notifications.nix @@ -10,7 +10,7 @@ in { enable = mkEnableOption "Notifications"; }; - config.programs.nixvim = mkIf cfg.enable { + config = mkIf cfg.enable { plugins.fidget = { enable = true; notification.window = { diff --git a/home/nixvim/octo-nvim.nix b/home/nixvim/octo-nvim.nix index d67c45b0..c2fffccb 100644 --- a/home/nixvim/octo-nvim.nix +++ b/home/nixvim/octo-nvim.nix @@ -12,12 +12,10 @@ in { }; config = mkIf cfg.enable { - programs.nixvim = { - extraPlugins = with pkgs.vimPlugins; [ - octo-nvim - ]; + extraPlugins = with pkgs.vimPlugins; [ + octo-nvim + ]; - extraConfigLua = builtins.readFile ./octo-nvim-setup.lua; - }; + extraConfigLua = builtins.readFile ./octo-nvim-setup.lua; }; } diff --git a/home/nixvim/oil.nix b/home/nixvim/oil.nix index 0277c3d5..ec4c448d 100644 --- a/home/nixvim/oil.nix +++ b/home/nixvim/oil.nix @@ -9,29 +9,27 @@ in { options.me.nixvim.oil.enable = mkEnableOption "Oil"; config = mkIf cfg.enable { - programs.nixvim = { - plugins.oil = { - enable = true; - settings = { - columns = ["icon"]; - keymaps = { - "" = false; - }; - view_options.show_hidden = true; + plugins.oil = { + enable = true; + settings = { + columns = ["icon"]; + keymaps = { + "" = false; }; + view_options.show_hidden = true; }; - keymaps = [ - { - action = "Oil"; - mode = "n"; - lua = false; - key = "-"; - options = { - noremap = true; - silent = true; - }; - } - ]; }; + keymaps = [ + { + action = "Oil"; + mode = "n"; + lua = false; + key = "-"; + options = { + noremap = true; + silent = true; + }; + } + ]; }; } diff --git a/home/nixvim/render-markdown.nix b/home/nixvim/render-markdown.nix index 466cb70b..c7d4a6c7 100644 --- a/home/nixvim/render-markdown.nix +++ b/home/nixvim/render-markdown.nix @@ -1,13 +1,16 @@ -{ lib, config, pkgs, ... }: -with lib; -let - cfg = config.me.nixvim.render-markdown; -in { + lib, + config, + pkgs, + ... +}: +with lib; let + cfg = config.me.nixvim.render-markdown; +in { options.me.nixvim.render-markdown.enable = mkEnableOption "render-markdown"; config = mkIf cfg.enable { - programs.nixvim.extraPlugins = with pkgs.vimPlugins; [ + extraPlugins = with pkgs.vimPlugins; [ render-markdown ]; }; diff --git a/home/nixvim/statusbar.nix b/home/nixvim/statusbar.nix index 4d3689b8..ea43b6c8 100644 --- a/home/nixvim/statusbar.nix +++ b/home/nixvim/statusbar.nix @@ -8,8 +8,6 @@ with lib; let in { options.me.nixvim.statusbar.enable = mkEnableOption "Status bar"; config = mkIf cfg.enable { - programs.nixvim = { - plugins.lualine.enable = true; - }; + plugins.lualine.enable = true; }; } diff --git a/home/nixvim/telescope.nix b/home/nixvim/telescope.nix index c9228a43..ef9abffa 100644 --- a/home/nixvim/telescope.nix +++ b/home/nixvim/telescope.nix @@ -1,5 +1,5 @@ { - programs.nixvim.plugins.telescope = { + plugins.telescope = { enable = true; settings = { pickers = { diff --git a/home/nixvim/trouble.nix b/home/nixvim/trouble.nix index 9e2bfd87..8062b6fd 100644 --- a/home/nixvim/trouble.nix +++ b/home/nixvim/trouble.nix @@ -12,21 +12,19 @@ }; }; in { - programs.nixvim = { - plugins.trouble = { - enable = true; - settings = { - icons = false; - use_diagnostic_signs = false; - auto_preview = false; - }; + plugins.trouble = { + enable = true; + settings = { + icons = false; + use_diagnostic_signs = false; + auto_preview = false; }; - keymaps = [ - (keymap { - key = "yot"; - action = "function() require('trouble').toggle() end"; - lua = true; - }) - ]; }; + keymaps = [ + (keymap { + key = "yot"; + action = "function() require('trouble').toggle() end"; + lua = true; + }) + ]; } diff --git a/home/nixvim/vim-test.nix b/home/nixvim/vim-test.nix index 924c75fe..c46f79a4 100644 --- a/home/nixvim/vim-test.nix +++ b/home/nixvim/vim-test.nix @@ -25,32 +25,30 @@ in { }; config = mkIf cfg.enable { - programs.nixvim = { - extraPlugins = with pkgs.vimPlugins; [ - vim-test - ]; - keymaps = [ - (keymap { - key = "tf"; - action = ":update|:TestFile"; - }) - (keymap { - key = "tl"; - action = ":update|:TestLast"; - }) - (keymap { - key = "tn"; - action = ":update|:TestNearest"; - }) - (keymap { - key = "ta"; - action = ":update|:TestSuite"; - }) - (keymap { - key = "ts"; - action = ":update|:TestSuite"; - }) - ]; - }; + extraPlugins = with pkgs.vimPlugins; [ + vim-test + ]; + keymaps = [ + (keymap { + key = "tf"; + action = ":update|:TestFile"; + }) + (keymap { + key = "tl"; + action = ":update|:TestLast"; + }) + (keymap { + key = "tn"; + action = ":update|:TestNearest"; + }) + (keymap { + key = "ta"; + action = ":update|:TestSuite"; + }) + (keymap { + key = "ts"; + action = ":update|:TestSuite"; + }) + ]; }; } diff --git a/home/nixvim/which-key.nix b/home/nixvim/which-key.nix index 590ef6b6..ccaf98dc 100644 --- a/home/nixvim/which-key.nix +++ b/home/nixvim/which-key.nix @@ -1,14 +1,16 @@ -{ lib, config, ... }: -with lib; -let +{ + lib, + config, + ... +}: +with lib; let cfg = config.me.nixvim.which-key; -in - { - options.me.nixvim.which-key.enable = mkEnableOption "which-key"; +in { + options.me.nixvim.which-key.enable = mkEnableOption "which-key"; - config = mkIf cfg.enable { - programs.nixvim.plugins.which-key = { - enable = true; - }; + config = mkIf cfg.enable { + plugins.which-key = { + enable = true; }; - } + }; +} diff --git a/home/nixvim/zen-mode.nix b/home/nixvim/zen-mode.nix index 8c1f9939..5d089a16 100644 --- a/home/nixvim/zen-mode.nix +++ b/home/nixvim/zen-mode.nix @@ -11,7 +11,7 @@ in { me.nixvim.zen-mode.enable = mkEnableOption "Zen mode"; }; config = mkIf cfg.enable { - programs.nixvim.extraPlugins = with pkgs.vimPlugins; [ + extraPlugins = with pkgs.vimPlugins; [ zen-mode-nvim ]; };