From 030822d6c12fb1b23c276ad7785f894d97dcf68b Mon Sep 17 00:00:00 2001 From: Gabe Venberg Date: Tue, 19 Mar 2024 16:57:23 -0500 Subject: [PATCH] start of a nixvim setup. --- neovim/.config/nvim/init.lua | 2 +- nix/flake.lock | 260 ++++++++++++++++++++++++++++++++++- nix/flake.nix | 6 + nix/git.nix | 1 - nix/home.nix | 2 +- nix/justfile | 3 + nix/nushell/nushell.nix | 1 - nix/nvim/lualine.nix | 77 +++++++++++ nix/nvim/nvim-tree.nix | 31 +++++ nix/nvim/nvim.nix | 173 +++++++++++++++++++++++ nix/nvim/spell/en.utf-8.add | 52 +++++++ nix/nvim/toggleterm.nix | 32 +++++ nix/zsh.nix | 1 - 13 files changed, 635 insertions(+), 6 deletions(-) create mode 100644 nix/nvim/lualine.nix create mode 100644 nix/nvim/nvim-tree.nix create mode 100644 nix/nvim/nvim.nix create mode 100644 nix/nvim/spell/en.utf-8.add create mode 100644 nix/nvim/toggleterm.nix diff --git a/neovim/.config/nvim/init.lua b/neovim/.config/nvim/init.lua index 56b6fde..283b76f 100644 --- a/neovim/.config/nvim/init.lua +++ b/neovim/.config/nvim/init.lua @@ -57,7 +57,7 @@ opt.shiftwidth = 0 --zero inherrits tabstop. opt.autoindent = true opt.smartindent = true opt.smarttab = true --- for space based tabs, change expandtab to false. +-- for space based tabs, change expandtab to true. opt.expandtab = true opt.softtabstop = -1 --negative value inherrits shiftwidth. --highlight search results as you type. diff --git a/nix/flake.lock b/nix/flake.lock index 18d4d0f..e2af8f6 100644 --- a/nix/flake.lock +++ b/nix/flake.lock @@ -1,5 +1,136 @@ { "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1710156081, + "narHash": "sha256-4PMY6aumJi5dLFjBzF5O4flKXmadMNq3AGUHKYfchh0=", + "owner": "numtide", + "repo": "devshell", + "rev": "bc68b058dc7e6d4d6befc4ec6c60082b6e844b7d", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-compat": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709336216, + "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "nixvim", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703887061, + "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -20,6 +151,48 @@ "type": "github" } }, + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1710714957, + "narHash": "sha256-eZCxuF58YWgaJMMRrn8oRkwRhxooe5kBS/s2wRVr9PA=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "7b3fca5adcf6c709874a8f2e0c364fe9c58db989", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1710717205, + "narHash": "sha256-Wf3gHh5uV6W1TV/A8X8QJf99a5ypDSugY4sNtdJDe0A=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "bcc8afd06e237df060c85bad6af7128e05fd61a3", + "type": "github" + }, + "original": { + "owner": "lnl7", + "repo": "nix-darwin", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1710631334, @@ -36,10 +209,95 @@ "type": "github" } }, + "nixvim": { + "inputs": { + "devshell": "devshell", + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "home-manager": "home-manager_2", + "nix-darwin": "nix-darwin", + "nixpkgs": [ + "nixpkgs" + ], + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1710856562, + "narHash": "sha256-JM24d2f60/9q7D7nzyhGm0gcH+HQsrY8Q0rGOFcJzeQ=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "0a5e0c68b829f9fec135f479e3ec34332660f93d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_2", + "gitignore": "gitignore", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ], + "nixpkgs-stable": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1708018599, + "narHash": "sha256-M+Ng6+SePmA8g06CmUZWi1AjG2tFBX9WCXElBHEKnyM=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "5df5a70ad7575f6601d91f0efec95dd9bc619431", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "home-manager": "home-manager", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "nixvim": "nixvim" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" } } }, diff --git a/nix/flake.nix b/nix/flake.nix index 73f2471..0113b8c 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -8,11 +8,16 @@ url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; + nixvim = { + url = "github:nix-community/nixvim"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { nixpkgs, home-manager, + nixvim, ... }: let system = "x86_64-linux"; @@ -26,6 +31,7 @@ # the path to your home.nix. modules = [ ./home.nix + nixvim.homeManagerModules.nixvim ]; # Optionally use extraSpecialArgs diff --git a/nix/git.nix b/nix/git.nix index 721bb59..62cf1b2 100644 --- a/nix/git.nix +++ b/nix/git.nix @@ -1,7 +1,6 @@ { config, pgks, - lib, ... }: { programs.git = { diff --git a/nix/home.nix b/nix/home.nix index 53c8d52..f44a26f 100644 --- a/nix/home.nix +++ b/nix/home.nix @@ -1,7 +1,6 @@ { config, pkgs, - lib, ... }: { # Home Manager needs a bit of information about you and the paths it should @@ -47,6 +46,7 @@ ./zsh.nix ./git.nix ./starship.nix + ./nvim/nvim.nix ]; programs.yazi.enable = true; diff --git a/nix/justfile b/nix/justfile index e932fba..0228ac3 100644 --- a/nix/justfile +++ b/nix/justfile @@ -3,3 +3,6 @@ switch: bootstrap: nix run --extra-experimental-features "nix-command flakes" --no-write-lock-file github:nix-community/home-manager/ -- --extra-experimental-features "nix-command flakes" --flake . switch + +check: + home-manager --flake . build diff --git a/nix/nushell/nushell.nix b/nix/nushell/nushell.nix index 3b7997a..8a66a80 100644 --- a/nix/nushell/nushell.nix +++ b/nix/nushell/nushell.nix @@ -1,7 +1,6 @@ { config, pkgs, - lib, ... }: { #sessionVariables, sessionPath and shellAliases are not applied to nushell. diff --git a/nix/nvim/lualine.nix b/nix/nvim/lualine.nix new file mode 100644 index 0000000..6f496e2 --- /dev/null +++ b/nix/nvim/lualine.nix @@ -0,0 +1,77 @@ +{ + configs, + pkg, + ... +}: { + programs.nixvim = { + plugins.lualine = { + enable = true; + alwaysDivideMiddle = true; + iconsEnabled = true; + sections = { + lualine_a = [ + {name = "mode";} + ]; + lualine_b = [ + {name = "branch";} + {name = "diff";} + {name = "diagnostics";} + ]; + lualine_c = [ + { + name = "filename"; + extraConfig = {path = 1;}; + } + ]; + lualine_x = [ + {name = "encoding";} + {name = "fileformat";} + {name = "filetype";} + ]; + lualine_y = [ + {name = "progress";} + ]; + lualine_z = [ + {name = "location";} + ]; + }; + + inactiveSections = { + lualine_a = []; + lualine_b = []; + lualine_c = [{name = "filename";}]; + lualine_x = [{name = "filetype";}]; + lualine_y = []; + lualine_z = []; + }; + + tabline = { + lualine_a = [ + { + name = "buffers"; + extraConfig = {mode = 4;}; + } + ]; + lualine_b = []; + lualine_c = []; + lualine_x = []; + lualine_y = []; + lualine_z = [ + { + name = "tabs"; + extraConfig = {mode = 2;}; + } + ]; + }; + + winbar = { + lualine_a = []; + lualine_b = []; + lualine_c = []; + lualine_x = []; + lualine_y = []; + lualine_z = []; + }; + }; + }; +} diff --git a/nix/nvim/nvim-tree.nix b/nix/nvim/nvim-tree.nix new file mode 100644 index 0000000..b68a814 --- /dev/null +++ b/nix/nvim/nvim-tree.nix @@ -0,0 +1,31 @@ +{ + configs, + pkg, + ... +}: { + programs.nixvim = { + plugins.nvim-tree = { + enable = true; + disableNetrw = true; + hijackCursor = true; + hijackNetrw = true; + hijackUnnamedBufferWhenOpening = true; + actions = { + useSystemClipboard = true; + changeDir.enable = true; + }; + filesystemWatchers.enable = true; + }; + keymaps = [ + { + action = ":NvimTreeToggle"; + key = "t"; + mode = "n"; + options = { + silent = true; + desc = "toggle file browser"; + }; + } + ]; + }; +} diff --git a/nix/nvim/nvim.nix b/nix/nvim/nvim.nix new file mode 100644 index 0000000..701885c --- /dev/null +++ b/nix/nvim/nvim.nix @@ -0,0 +1,173 @@ +{ + configs, + pkg, + ... +}: { + programs.nixvim = { + enable = true; + viAlias = true; + vimAlias = true; + + colorschemes.base16 = { + colorscheme = "gruvbox-dark-medium"; + 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 = [ + ./lualine.nix + ./nvim-tree.nix + ./toggleterm.nix + ]; +} diff --git a/nix/nvim/spell/en.utf-8.add b/nix/nvim/spell/en.utf-8.add new file mode 100644 index 0000000..3827808 --- /dev/null +++ b/nix/nvim/spell/en.utf-8.add @@ -0,0 +1,52 @@ +asciidoc +ASCIISite +asciidoctor +ASCIIsite +asciiDoc +nextcloud +filesystem +zsh +backend +Incrementals +incrementals +Ransomware +ransomware +hypervisor +offsite +FTL +superintelligent +homeworld +toolchain +Kata +ctl +NDSU +rebasing +posix +tmux +keybinds +dotfile +dotfiles +ctrl +sed +NGINX +timezones +Proxmox +Gabe +Venberg +Github +dotfiles +config +nvim +neovim +config +Syncthing +homelab +microcontrollers +nushell +datatypes +datetimes +filesizes +filetypes +datastructures +footguns +csv diff --git a/nix/nvim/toggleterm.nix b/nix/nvim/toggleterm.nix new file mode 100644 index 0000000..f96ee9b --- /dev/null +++ b/nix/nvim/toggleterm.nix @@ -0,0 +1,32 @@ +{ + configs, + pkg, + ... +}: { + programs.nixvim = { + plugins.toggleterm={ + enable=true; + direction="horizontal"; + insertMappings=false; + }; + keymaps = [ + { + action = "function() Floatingterm:toggle() end"; + key = "s"; + lua=true; + mode = "n"; + options = { + silent = true; + desc = "toggle scratch terminal"; + }; + } + ]; + extraConfigLuaPre = '' + local Terminal = require('toggleterm.terminal').Terminal + Floatingterm = Terminal:new({ + hidden = true, + direction = "float" + }) + ''; + }; +} diff --git a/nix/zsh.nix b/nix/zsh.nix index 0c816e7..de58f58 100644 --- a/nix/zsh.nix +++ b/nix/zsh.nix @@ -1,7 +1,6 @@ { config, pkgs, - lib, ... }: { programs.starship.enableZshIntegration = true;