diff --git a/README.md b/README.md index 1aef355..b24e780 100644 --- a/README.md +++ b/README.md @@ -133,8 +133,10 @@ sudo launchctl start org.nixos.nix-daemon ```bash just deploy - # or + # or on an x64 arch: nix-shell -p nixos-anywhere --run "nixos-anywhere --flake .#nixos " + # or on another arch: + nix-shell -p nixos-anywhere --run "nixos-anywhere --flake .#nixos --build-on-remote" ``` 6. Updating a deployed system diff --git a/home-manager/home.nix b/home-manager/home.nix index 935755d..99958a2 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -3,7 +3,7 @@ home.stateVersion = "25.05"; imports = [ - ./kickstart.nixvim/nixvim.nix + ./nixvim/flake.nix ]; home.packages = with pkgs; [ diff --git a/home-manager/kickstart.nixvim/LICENSE b/home-manager/kickstart.nixvim/LICENSE deleted file mode 100755 index 9cf1062..0000000 --- a/home-manager/kickstart.nixvim/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/home-manager/kickstart.nixvim/README.md b/home-manager/kickstart.nixvim/README.md deleted file mode 100644 index d4645e8..0000000 --- a/home-manager/kickstart.nixvim/README.md +++ /dev/null @@ -1,112 +0,0 @@ -# kickstart.nixvim - ->**NOTE** -> This repo is a WORK IN PROGRESS - -## Introduction - -This repo is a personal project to learn Nix & Nixvim within NixOS while also learning/setting up [kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim). -I have attempted to be as true to kickstart as possible while adding new and updated comments to help those learning Nix. - -### Caveats - -1. Nix does not lend itself to the same separation paradigms used by kickstart.nvim. The idea of keeping the configuration as a single file -similar to kickstart.nvim was originally planned but as I translated more of the init.lua over I found Nix lended itself better to a more -modular implementation. This means most plugins have their own .nix files that are imported into the base nixvim.nix file. -2. I used as little lua code as possible in the .nix files but due to Nixvim being a relatively new Nix module not everything can be natively configured. Any lua code will slowly be removed as new Nixvim features come out that allow for native methods of configuation. -3. I did not include Lazy nor Mason as I felt those both went against the Nix philosophy of having all your dependencies installed and managed through the .nix files. While it is possible to configure Lazy in Nixvim the implementation is very limited at the moment. Further enhancements to Lazy which would allow lazy loading are being discussed [here](https://github.com/nix-community/nixvim/issues/421) and I may update this repo to use Lazy when these features are implemented. -4. kickstart.nixvim is somewhat slower than kickstart.nvim, some of this has to do with the fact that this repo is not using Lazy. I'll have to do futher investigation to identify how else to speed up this implementation. - -# Installation - -This installation process assumes you understand the basics of importing and adding dependencies to your .nix configuration file. -This installation process also assumes you are running NixOS, this repo should work the same with a home-manager configuration not on NixOS but I have not confirmed this yet. I plan to add more options for installation once i've had the time to study Nix a bit more. - -## Install External Dependencies - -- Basic utils: `git`, C Compiler (`gcc`) -- [ripgrep](https://github.com/BurntSushi/ripgrep#installation) -- Clipboard tool (xclip/xsel/win32yank or other depending on platform) -- A [Nerd Font](https://www.nerdfonts.com/): optional, provides various icons - - if you have it set `have_nerd_font` in `nixvim.nix` to true -- Language Dependencies: - - If you want to write Typescript, you will need `npm` - - If you want to write Golang, you will need `go` - - etc. - -## Installing Nixvim Module - -This repo is currently setup to be imported into your current NixOS/Home-Manager module. -To setup the Nixvim module follow the steps found [here](https://nix-community.github.io/nixvim/user-guide/install.html) under the **Usage as a module (NixOS, home-manager, nix-darwin)** section. - -## Setting up kickstart.nixvim - ->**NOTE** -> Backup your previous configuration (if any exists) -> This can be found on Linux under the path `$XDG_CONFIG_HOME/nvim` or `~/.config/nvim` - -1. [Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repo -so that you have your own copy that you can update and version control. ->**NOTE** -> This is not required but recommended so you can version control your own kickstart.nixvim configuration. -2. Clone kickstart.nixvim - * If you created your own fork - ```sh - cd /etc/nixos/ - git clone https://github.com//kickstart.nixvim.git - ``` - * If you skipped creating a fork - ```sh - cd /etc/nixos/ - git clone https://github.com/JMartJonesy/kickstart.nixvim.git - ``` -3. Import nixvim.nix into your .nix configuration file - * Example of the line to add into your configuration.nix file (or home.nix if you are using home-manager) - ```nix - imports = [ - ./kickstart.nixvim/nixvim.nix - ]; - ``` -4. Open nixvim.nix and uncomment one of the nixvim module imports at the top of the file. Choose the module depending on which module installation method you use from the [Installing Nixvim Module](#installing-nixvim-module) section above (Home-Manager module, NixOS module, or Darwin Module). - * The module should be passed into your configuration through the `inputs` nixos param - ```nix - # Uncomment if you are using the home-manager module - #inputs.nixvim.homeManagerModules.nixvim - # Uncomment if you are using the nixos module - #inputs.nixvim.nixosModules.nixvim - # Uncomment if you are using the nix-darwin module - #inputs.nixvim.nixDarwinModules.nixvim - ``` -5. Rebuild your NixOS configuration - * Without using Flake - ```sh - nixos-rebuild switch - ``` -6. Confirm your init.lua file has been created and loads without errors - * Open the generated init.lua file and confirm no error dialog appears when opening - ```sh - nvim ~/.config/nvim/init.lua - ``` - -# FAQ - -* What should I do if I already have a pre-existing neovim configuration? - * You should back it up and then delete all associated files. - * This includes your existing init.lua and the neovim files in `~/.local` - which can be deleted with `rm -rf ~/.local/share/nvim/` -* Can I keep my existing configuration in parallel to kickstart.nixvim? - * Yes! You can use [NVIM_APPNAME](https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME)`=nvim-NAME` - to maintain multiple configurations. For example, move your old configuration to - `~/.config/nvim-backup` and create an alias: - ``` - alias nvim-backup='NVIM_APPNAME="nvim-backup" nvim' - ``` - When you run Neovim using `nvim-backup` alias it will use the alternative - config directory and the matching local directory - `~/.local/share/nvim-backup`. -* What if I want to "uninstall" kickstart.nixvim: - 1. Remove nixvim.nix import from your configuration.nix file (or home.nix if you are using home-manager) - 2. Remove the kickstart.nixvim directory `rm -r /etc/nixos/kickstart.nixvim` - 3. Remove any .local nvim files `rm -rf ~/.local/share/nvim/` - 4. **Optional:** Move your previously backed up lua configuration files to `$XDG_CONFIG_HOME/nvim` or `~/.config/nvim` - 5. Rebuild your NixOS configuration `nixos-rebuild switch` diff --git a/home-manager/kickstart.nixvim/nixvim.nix b/home-manager/kickstart.nixvim/nixvim.nix deleted file mode 100755 index 664efc0..0000000 --- a/home-manager/kickstart.nixvim/nixvim.nix +++ /dev/null @@ -1,269 +0,0 @@ -{ pkgs, ... }: { - imports = [ - ./plugins/conform.nix - ./plugins/gitsigns.nix - ./plugins/indent-blankline.nix - ./plugins/lsp.nix - ./plugins/lualine.nix - ./plugins/number-toggle.nix - ./plugins/nvim-cmp.nix - ./plugins/nvim-surround.nix - ./plugins/rustaceanvim.nix - ./plugins/telescope.nix - ./plugins/todo-comments.nix - ./plugins/treesitter.nix - ./plugins/which-key.nix - - # NOTE: Configure your own plugins `see https://nix-community.github.io/nixvim/` - # Add your plugins to ./plugins/custom/plugins and import them below - ]; - - programs.nixvim = { - enable = true; - defaultEditor = true; - - # You can easily change to a different colorscheme. - # Add your colorscheme here and enable it. - # Don't forget to disable the colorschemes you arent using - # - # If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - colorschemes = { - # https://nix-community.github.io/nixvim/colorschemes/tokyonight/index.html - gruvbox = { - enable = true; - }; - }; - - # https://nix-community.github.io/nixvim/NeovimOptions/index.html?highlight=globals#globals - globals = { - # Set as the leader key - # See `:help mapleader` - mapleader = " "; - maplocalleader = " "; - - # Set to true if you have a Nerd Font installed and selected in the terminal - have_nerd_font = false; - }; - - # See `:help 'clipboard'` - clipboard = { - providers = { - wl-copy.enable = true; # For Wayland - xsel.enable = true; # For X11 - }; - - # Sync clipboard between OS and Neovim - # Remove this option if you want your OS clipboard to remain independent. - register = "unnamedplus"; - }; - - # [[ Setting options ]] - # See `:help vim.opt` - # NOTE: You can change these options as you wish! - # For more options, you can see `:help option-list` - # https://nix-community.github.io/nixvim/NeovimOptions/index.html?highlight=globals#opts - opts = { - # Show line numbers - number = true; - # You can also add relative line numbers, to help with jumping. - # Experiment for yourself to see if you like it! - relativenumber = true; - - # Enable mouse mode, can be useful for resizing splits for example! - mouse = "a"; - - # Don't show the mode, since it's already in the statusline - showmode = false; - - # Enable break indent - breakindent = true; - - # Save undo history - undofile = true; - - # Case-insensitive searching UNLESS \C or one or more capital letters in the search term - ignorecase = true; - smartcase = true; - - # Keep signcolumn on by default - signcolumn = "yes"; - - # Decrease update time - updatetime = 250; - - # Decrease mapped sequence wait time - # Displays which-key popup sooner - timeoutlen = 300; - - # Configure how new splits should be opened - splitright = true; - splitbelow = true; - - # Sets how neovim will display certain whitespace characters in the editor - # See `:help 'list'` - # and `:help 'listchars'` - list = true; - # NOTE: .__raw here means that this field is raw lua code - listchars.__raw = "{ tab = '» ', trail = '·', nbsp = '␣' }"; - - # Preview substitutions live, as you type! - inccommand = "split"; - - # Show which line your cursor is on - cursorline = true; - - # Minimal number of screen lines to keep above and below the cursor. - scrolloff = 10; - - # if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), - # instead raise a dialog asking if you wish to save the current file(s) - # See `:help 'confirm'` - confirm = true; - - # See `:help hlsearch` - hlsearch = true; - }; - - # [[ Basic Keymaps ]] - # See `:help vim.keymap.set()` - # https://nix-community.github.io/nixvim/keymaps/index.html - keymaps = [ - # Clear highlights on search when pressing in normal mode - { - mode = "n"; - key = ""; - action = "nohlsearch"; - } - # Exit terminal mode in the builtin terminal with a shortcut that is a bit easier - # for people to discover. Otherwise, you normally need to press , which - # is not what someone will guess without a bit more experience. - # - # NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping - # or just use to exit terminal mode - { - mode = "t"; - key = ""; - action = ""; - options = { - desc = "Exit terminal mode"; - }; - } - # TIP: Disable arrow keys in normal mode - /* - { - mode = "n"; - key = ""; - action = "echo 'Use h to move!!'"; - } - { - mode = "n"; - key = ""; - action = "echo 'Use l to move!!'"; - } - { - mode = "n"; - key = ""; - action = "echo 'Use k to move!!'"; - } - { - mode = "n"; - key = ""; - action = "echo 'Use j to move!!'"; - } - */ - # Keybinds to make split navigation easier. - # Use CTRL+ to switch between windows - # - # See `:help wincmd` for a list of all window commands - { - 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"; - }; - } - ]; - - # https://nix-community.github.io/nixvim/NeovimOptions/autoGroups/index.html - autoGroups = { - kickstart-highlight-yank = { - clear = true; - }; - }; - - # [[ Basic Autocommands ]] - # See `:help lua-guide-autocommands` - # https://nix-community.github.io/nixvim/NeovimOptions/autoCmd/index.html - autoCmd = [ - # Highlight when yanking (copying) text - # Try it with `yap` in normal mode - # See `:help vim.highlight.on_yank()` - { - event = [ "TextYankPost" ]; - desc = "Highlight when yanking (copying) text"; - group = "kickstart-highlight-yank"; - callback.__raw = '' - function() - vim.highlight.on_yank() - end - ''; - } - ]; - - plugins = { - # Adds icons for plugins to utilize in ui - web-devicons.enable = true; - - # Detect tabstop and shiftwidth automatically - # https://nix-community.github.io/nixvim/plugins/sleuth/index.html - sleuth = { - enable = true; - }; - }; - - # https://nix-community.github.io/nixvim/NeovimOptions/index.html?highlight=extraplugins#extraplugins - extraPlugins = with pkgs.vimPlugins; [ - # Useful for getting pretty icons, but requires a Nerd Font. - nvim-web-devicons # TODO: Figure out how to configure using this with telescope - ]; - - # TODO: Figure out where to move this - # https://nix-community.github.io/nixvim/NeovimOptions/index.html?highlight=extraplugins#extraconfigluapre - extraConfigLuaPre = '' - if vim.g.have_nerd_font then - require('nvim-web-devicons').setup {} - end - ''; - - # The line beneath this is called `modeline`. See `:help modeline` - # https://nix-community.github.io/nixvim/NeovimOptions/index.html?highlight=extraplugins#extraconfigluapost - extraConfigLuaPost = '' - -- vim: ts=2 sts=2 sw=2 et - ''; - }; -} diff --git a/home-manager/kickstart.nixvim/plugins/conform.nix b/home-manager/kickstart.nixvim/plugins/conform.nix deleted file mode 100755 index b479e20..0000000 --- a/home-manager/kickstart.nixvim/plugins/conform.nix +++ /dev/null @@ -1,61 +0,0 @@ -{ pkgs, ... }: { - programs.nixvim = { - # Dependencies - # - # https://nix-community.github.io/nixvim/NeovimOptions/index.html?highlight=extraplugins#extrapackages - extraPackages = with pkgs; [ - # Used to format Lua code - codespell - ruff - rustfmt - shellcheck - shfmt - stylua - ]; - - # Autoformat - # https://nix-community.github.io/nixvim/plugins/conform-nvim.html - plugins.conform-nvim = { - enable = true; - settings = { - notify_on_error = false; - formatters_by_ft = { - bash = [ - "shellcheck" - "shfmt" - ]; - cpp = [ "clang_format" ]; - lua = [ "stylua" ]; - python = [ "ruff" ]; - rust = [ "rustfmt" ]; - - # Conform can also run multiple formatters sequentially - # python = [ "isort "black" ]; - # - # You can use a sublist to tell conform to run *until* a formatter - # is found - # javascript = [ [ "prettierd" "prettier" ] ]; - - # Use the "*" filetype to run formatters on all filetypes. - "*" = [ "codespell" ]; - }; - }; - }; - - # https://nix-community.github.io/nixvim/keymaps/index.html - keymaps = [ - { - mode = ""; - key = "f"; - action.__raw = '' - function() - require('conform').format { async = true, lsp_fallback = true } - end - ''; - options = { - desc = "[F]ormat buffer"; - }; - } - ]; - }; -} diff --git a/home-manager/kickstart.nixvim/plugins/custom/plugins/README.md b/home-manager/kickstart.nixvim/plugins/custom/plugins/README.md deleted file mode 100644 index 30c2668..0000000 --- a/home-manager/kickstart.nixvim/plugins/custom/plugins/README.md +++ /dev/null @@ -1 +0,0 @@ -Add your custom plugins here diff --git a/home-manager/kickstart.nixvim/plugins/gitsigns.nix b/home-manager/kickstart.nixvim/plugins/gitsigns.nix deleted file mode 100755 index 9bb4a2d..0000000 --- a/home-manager/kickstart.nixvim/plugins/gitsigns.nix +++ /dev/null @@ -1,222 +0,0 @@ -{ - programs.nixvim = { - # Adds git related signs to the gutter, as well as utilities for managing changes - # See `:help gitsigns` to understand what the configuration keys do - # https://nix-community.github.io/nixvim/plugins/gitsigns/index.html - plugins.gitsigns = { - enable = true; - settings = { - signs = { - add = { text = "+"; }; - change = { text = "~"; }; - delete = { text = "_"; }; - topdelete = { text = "‾"; }; - changedelete = { text = "~"; }; - }; - }; - }; - - # NOTE: add gitsigns recommended keymaps if you are interested - # https://nix-community.github.io/nixvim/keymaps/index.html - keymaps = [ - # Navigation - { - mode = "n"; - key = "]c"; - action.__raw = '' - function() - if vim.wo.diff then - vim.cmd.normal { ']c', bang = true } - else - require('gitsigns').nav_hunk 'next' - end - end - ''; - options = { - desc = "Jump to next git [c]hange"; - }; - } - { - mode = "n"; - key = "[c"; - action.__raw = '' - function() - if vim.wo.diff then - vim.cmd.normal { '[c', bang = true } - else - require('gitsigns').nav_hunk 'prev' - end - end - ''; - options = { - desc = "Jump to previous git [c]hange"; - }; - } - - # Actions - # visual mode - { - mode = "v"; - key = "hs"; - action.__raw = '' - function() - require('gitsigns').stage_hunk { vim.fn.line '.', vim.fn.line 'v' } - end - ''; - options = { - desc = "git [s]tage hunk"; - }; - } - { - mode = "v"; - key = "hr"; - action.__raw = '' - function() - require('gitsigns').reset_hunk { vim.fn.line '.', vim.fn.line 'v' } - end - ''; - options = { - desc = "git [r]eset hunk"; - }; - } - # normal mode - { - mode = "n"; - key = "hs"; - action.__raw = '' - function() - require('gitsigns').stage_hunk() - end - ''; - options = { - desc = "git [s]tage hunk"; - }; - } - { - mode = "n"; - key = "hr"; - action.__raw = '' - function() - require('gitsigns').reset_hunk() - end - ''; - options = { - desc = "git [r]eset hunk"; - }; - } - { - mode = "n"; - key = "hS"; - action.__raw = '' - function() - require('gitsigns').stage_buffer() - end - ''; - options = { - desc = "git [S]tage buffer"; - }; - } - { - mode = "n"; - key = "hu"; - # `undo_stage_hunk` is deprecated. See https://github.com/nvim-lua/kickstart.nvim/issues/1319 - # Replacement `stage_hunk` was accidentally merged. See https://github.com/nvim-lua/kickstart.nvim/pull/1321#issuecomment-2664265962 - action.__raw = '' - function() - require('gitsigns').undo_stage_hunk() - end - ''; - options = { - desc = "git [u]ndo stage hunk"; - }; - } - { - mode = "n"; - key = "hR"; - action.__raw = '' - function() - require('gitsigns').reset_buffer() - end - ''; - options = { - desc = "git [R]eset buffer"; - }; - } - { - mode = "n"; - key = "hp"; - action.__raw = '' - function() - require('gitsigns').preview_hunk() - end - ''; - options = { - desc = "git [p]review hunk"; - }; - } - { - mode = "n"; - key = "hb"; - action.__raw = '' - function() - require('gitsigns').blame_line() - end - ''; - options = { - desc = "git [b]lame line"; - }; - } - { - mode = "n"; - key = "hd"; - action.__raw = '' - function() - require('gitsigns').diffthis() - end - ''; - options = { - desc = "git [d]iff against index"; - }; - } - { - mode = "n"; - key = "hD"; - action.__raw = '' - function() - require('gitsigns').diffthis '@' - end - ''; - options = { - desc = "git [D]iff against last commit"; - }; - } - # Toggles - { - mode = "n"; - key = "tb"; - action.__raw = '' - function() - require('gitsigns').toggle_current_line_blame() - end - ''; - options = { - desc = "[T]oggle git show [b]lame line"; - }; - } - { - mode = "n"; - key = "tD"; - # `toggle_deleted` is deprecated. See https://github.com/nvim-lua/kickstart.nvim/issues/1319 - # Replacement `preview_hunk_inline` was accidentally merged. See https://github.com/nvim-lua/kickstart.nvim/pull/1321#issuecomment-2664265962 - action.__raw = '' - function() - require('gitsigns').toggle_deleted() - end - ''; - options = { - desc = "[T]oggle git show [D]eleted"; - }; - } - ]; - }; -} diff --git a/home-manager/kickstart.nixvim/plugins/indent-blankline.nix b/home-manager/kickstart.nixvim/plugins/indent-blankline.nix deleted file mode 100755 index 5629b25..0000000 --- a/home-manager/kickstart.nixvim/plugins/indent-blankline.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ - programs.nixvim = { - # Add indentation guides even on blank lines - # For configuration see `:help ibl` - # https://nix-community.github.io/nixvim/plugins/indent-blankline/index.html - plugins.indent-blankline = { - enable = true; - }; - }; -} diff --git a/home-manager/kickstart.nixvim/plugins/lsp.nix b/home-manager/kickstart.nixvim/plugins/lsp.nix deleted file mode 100755 index 7a8d485..0000000 --- a/home-manager/kickstart.nixvim/plugins/lsp.nix +++ /dev/null @@ -1,287 +0,0 @@ -{ pkgs, ... }: { - programs.nixvim = { - # Dependencies - # { 'Bilal2453/luvit-meta', lazy = true }, - - extraPackages = with pkgs; [ - basedpyright - clang-tools - cmake-language-server - fish-lsp - gitlint - isort - lua-language-server - nil - nodePackages.jsonlint - pyright - ruff - stylua - typos - typos-lsp - ]; - - plugins.cmp-nvim-lsp.enable = true; - plugins.cmp-cmdline.enable = true; - plugins.cmp-nvim-lsp-signature-help.enable = true; - - # Useful status updates for LSP. - # https://nix-community.github.io/nixvim/plugins/fidget/index.html - plugins.fidget = { - enable = true; - }; - - # https://nix-community.github.io/nixvim/NeovimOptions/index.html?highlight=extraplugi#extraplugins - extraPlugins = with pkgs.vimPlugins; [ - # NOTE: This is where you would add a vim plugin that is not implemented in Nixvim, also see extraConfigLuaPre below - # - # TODO: Add luvit-meta when Nixos package is added - ]; - - # https://nix-community.github.io/nixvim/NeovimOptions/autoGroups/index.html - autoGroups = { - "kickstart-lsp-attach" = { - clear = true; - }; - }; - - # Brief aside: **What is LSP?** - # - # LSP is an initialism you've probably heard, but might not understand what it is. - # - # LSP stands for Language Server Protocol. It's a protocol that helps editors - # and language tooling communicate in a standardized fashion. - # - # In general, you have a "server" which is some tool built to understand a particular - # language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers - # (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone - # processes that communicate with some "client" - in this case, Neovim! - # - # LSP provides Neovim with features like: - # - Go to definition - # - Find references - # - Autocompletion - # - Symbol Search - # - and more! - # - # Thus, Language Servers are external tools that must be installed separately from - # Neovim which are configured below in the `server` section. - # - # If you're wondering about lsp vs treesitter, you can check out the wonderfully - # and elegantly composed help section, `:help lsp-vs-treesitter` - # - # https://nix-community.github.io/nixvim/plugins/lsp/index.html - plugins.lsp = { - enable = true; - inlayHints = true; - - # Enable the following language servers - # Feel free to add/remove any LSPs that you want here. They will automatically be installed. - # - # Add any additional override configuration in the following tables. Available keys are: - # - cmd: Override the default command used to start the server - # - filetypes: Override the default list of associated filetypes for the server - # - capabilities: Override fields in capabilities. Can be used to disable certain LSP features. - # - settings: Override the default settings passed when initializing the server. - # For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ - servers = { - clangd = { - enable = true; - }; - # gopls = { - # enable = true; - # }; - basedpyright = { - enable = true; - }; - # ...etc. See `https://nix-community.github.io/nixvim/plugins/lsp` for a list of pre-configured LSPs - # - # Some languages (like typscript) have entire language plugins that can be useful: - # `https://nix-community.github.io/nixvim/plugins/typescript-tools/index.html?highlight=typescript-tools#pluginstypescript-toolspackage` - # - # But for many setups the LSP (`tsserver`) will work just fine - # tsserver = { - # enable = true; - # }; - - lua_ls = { - enable = true; - - # cmd = { - # }; - # filetypes = { - # }; - settings = { - completion = { - callSnippet = "Replace"; - }; - # diagnostics = { - # disable = [ - # "missing-fields" - # ]; - # }; - }; - }; - }; - - keymaps = { - # Diagnostic keymaps - diagnostic = { - "q" = { - mode = "n"; - action = "setloclist"; - desc = "Open diagnostic [Q]uickfix list"; - }; - }; - - extra = [ - # Jump to the definition of the word under your cusor. - # This is where a variable was first declared, or where a function is defined, etc. - # To jump back, press . - { - mode = "n"; - key = "gd"; - action.__raw = "require('telescope.builtin').lsp_definitions"; - options = { - desc = "LSP: [G]oto [D]efinition"; - }; - } - # Find references for the word under your cursor. - { - mode = "n"; - key = "gr"; - action.__raw = "require('telescope.builtin').lsp_references"; - options = { - desc = "LSP: [G]oto [R]eferences"; - }; - } - # Jump to the implementation of the word under your cursor. - # Useful when your language has ways of declaring types without an actual implementation. - { - mode = "n"; - key = "gI"; - action.__raw = "require('telescope.builtin').lsp_implementations"; - options = { - desc = "LSP: [G]oto [I]mplementation"; - }; - } - # Jump to the type of the word under your cursor. - # Useful when you're not sure what type a variable is and you want to see - # the definition of its *type*, not where it was *defined*. - { - mode = "n"; - key = "D"; - action.__raw = "require('telescope.builtin').lsp_type_definitions"; - options = { - desc = "LSP: Type [D]efinition"; - }; - } - # Fuzzy find all the symbols in your current document. - # Symbols are things like variables, functions, types, etc. - { - mode = "n"; - key = "ds"; - action.__raw = "require('telescope.builtin').lsp_document_symbols"; - options = { - desc = "LSP: [D]ocument [S]ymbols"; - }; - } - # Fuzzy find all the symbols in your current workspace. - # Similar to document symbols, except searches over your entire project. - { - mode = "n"; - key = "ws"; - action.__raw = "require('telescope.builtin').lsp_dynamic_workspace_symbols"; - options = { - desc = "LSP: [W]orkspace [S]ymbols"; - }; - } - ]; - - lspBuf = { - # Rename the variable under your cursor. - # Most Language Servers support renaming across files, etc. - "rn" = { - action = "rename"; - desc = "LSP: [R]e[n]ame"; - }; - # Execute a code action, usually your cursor needs to be on top of an error - # or a suggestion from your LSP for this to activate. - "ca" = { - mode = [ "n" "x" ]; - action = "code_action"; - desc = "LSP: [C]ode [A]ction"; - }; - # WARN: This is not Goto Definition, this is Goto Declaration. - # For example, in C this would take you to the header. - "gD" = { - action = "declaration"; - desc = "LSP: [G]oto [D]eclaration"; - }; - }; - }; - - # LSP servers and clients are able to communicate to each other what features they support. - # By default, Neovim doesn't support everything that is in the LSP specification. - # When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. - # So, we create new capabilities with nvim cmp, and then broadcast that to the servers. - # NOTE: This is done automatically by Nixvim when enabling cmp-nvim-lsp below is an example if you did want to add new capabilities - #capabilities = '' - # capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) - #''; - - # This function gets run when an LSP attaches to a particular buffer. - # That is to say, every time a new file is opened that is associated with - # an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this - # function will be executred to configure the current buffer - # NOTE: This is an example of an attribute that takes raw lua - onAttach = '' - -- NOTE: Remember that Lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - local map = function(keys, func, desc) - vim.keymap.set('n', keys, func, { buffer = bufnr, desc = 'LSP: ' .. desc }) - end - - -- The following two autocommands are used to highlight references of the - -- word under the cursor when your cursor rests there for a little while. - -- See `:help CursorHold` for information about when this is executed - -- - -- When you move your cursor, the highlights will be cleared (the second autocommand). - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then - local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) - vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - buffer = bufnr, - group = highlight_augroup, - callback = vim.lsp.buf.document_highlight, - }) - - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - buffer = bufnr, - group = highlight_augroup, - callback = vim.lsp.buf.clear_references, - }) - - vim.api.nvim_create_autocmd('LspDetach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), - callback = function(event2) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } - end, - }) - end - - -- The following autocommand is used to enable inlay hints in your - -- code, if the language server you are using supports them - -- - -- This may be unwanted, since they displace some of your code - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then - map('th', function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) - end, '[T]oggle Inlay [H]ints') - end - ''; - }; - }; -} diff --git a/home-manager/kickstart.nixvim/plugins/lualine.nix b/home-manager/kickstart.nixvim/plugins/lualine.nix deleted file mode 100755 index 73302aa..0000000 --- a/home-manager/kickstart.nixvim/plugins/lualine.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ - programs.nixvim = { - plugins.lualine = { - enable = true; - }; - }; -} diff --git a/home-manager/kickstart.nixvim/plugins/number-toggle.nix b/home-manager/kickstart.nixvim/plugins/number-toggle.nix deleted file mode 100755 index f2fc032..0000000 --- a/home-manager/kickstart.nixvim/plugins/number-toggle.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ - programs.nixvim = { - plugins.numbertoggle = { - enable = true; - }; - }; -} diff --git a/home-manager/kickstart.nixvim/plugins/nvim-cmp.nix b/home-manager/kickstart.nixvim/plugins/nvim-cmp.nix deleted file mode 100755 index 091bacc..0000000 --- a/home-manager/kickstart.nixvim/plugins/nvim-cmp.nix +++ /dev/null @@ -1,129 +0,0 @@ -{ - programs.nixvim = { - # `friendly-snippets` contains a variety of premade snippets - # See the README about individual language/framework/plugin snippets: - # https://github.com/rafamadriz/friendly-snippets - # https://nix-community.github.io/nixvim/plugins/friendly-snippets.html - # plugins.friendly-snippets = { - # enable = true; - # }; - - plugins.lazydev.enable = true; # autoEnableSources not enough - plugins.luasnip.enable = true; # autoEnableSources not enough - - # Autocompletion - # See `:help cmp` - # https://nix-community.github.io/nixvim/plugins/cmp/index.html - plugins.cmp = { - enable = true; - - settings = { - snippet = { - expand = '' - function(args) - require('luasnip').lsp_expand(args.body) - end - ''; - }; - - completion = { - completeopt = "menu,menuone,noinsert"; - }; - - # For an understanding of why these mappings were - # chosen, you will need to read `:help ins-completion` - # - # No, but seriously. Please read `:help ins-completion`, it is really good! - mapping = { - # Select the [n]ext item - "" = "cmp.mapping.select_next_item()"; - # Select the [p]revious item - "" = "cmp.mapping.select_prev_item()"; - - # Scroll the documentation window [b]ack / [f]orward - "" = "cmp.mapping.scroll_docs(-4)"; - "" = "cmp.mapping.scroll_docs(4)"; - - # Accept ([y]es) the completion. - # This will auto-import if your LSP supports it. - # This will expand snippets if the LSP sent a snippet. - "" = "cmp.mapping.confirm { select = true }"; - - # If you prefer more traditional completion keymaps, - # you can uncomment the following lines. - # "" = "cmp.mapping.confirm { select = true }"; - # "" = "cmp.mapping.select_next_item()"; - # "" = "cmp.mapping.select_prev_item()"; - - # Manually trigger a completion from nvim-cmp. - # Generally you don't need this, because nvim-cmp will display - # completions whenever it has completion options available. - "" = "cmp.mapping.complete {}"; - - # Think of as moving to the right of your snippet expansion. - # So if you have a snippet that's like: - # function $name($args) - # $body - # end - # - # will move you to the right of each of the expansion locations. - # is similar, except moving you backwards. - "" = '' - cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - end - end, { 'i', 's' }) - ''; - "" = '' - cmp.mapping(function() - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - end - end, { 'i', 's' }) - ''; - - # For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: - # https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps - }; - - # Dependencies - # - # WARNING: If plugins.cmp.autoEnableSources Nixivm will automatically enable the - # corresponding source plugins. This will work only when this option is set to a list. - # If you use a raw lua string, you will need to explicitly enable the relevant source - # plugins in your nixvim configuration. - # See list of most cmp source plugins that are autoloaded by defining the source: - # https://github.com/nix-community/nixvim/blob/main/plugins/cmp/sources/default.nix - sources = [ - # https://nix-community.github.io/nixvim/plugins/lazydev/index.html - { - name = "lazydev"; - # set group index to 0 to skip loading LuaLS completions as lazydev recommends it - group_index = 0; - } - # Adds other completion capabilites. - # nvim-cmp does not ship with all sources by default. They are split - # into multiple repos for maintenance purposes. - # https://nix-community.github.io/nixvim/plugins/cmp-nvim-lsp.html - { - name = "nvim_lsp"; - } - # Snippet Engine & its associated nvim-cmp source - # https://nix-community.github.io/nixvim/plugins/luasnip/index.html - { - name = "luasnip"; - } - # https://nix-community.github.io/nixvim/plugins/cmp-path.html - { - name = "path"; - } - # https://nix-community.github.io/nixvim/plugins/cmp-nvim-lsp-signature-help.html - { - name = "nvim_lsp_signature_help"; - } - ]; - }; - }; - }; -} diff --git a/home-manager/kickstart.nixvim/plugins/nvim-surround.nix b/home-manager/kickstart.nixvim/plugins/nvim-surround.nix deleted file mode 100755 index da9b1a0..0000000 --- a/home-manager/kickstart.nixvim/plugins/nvim-surround.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ - programs.nixvim = { - plugins.nvim-surround = { - enable = true; - }; - }; -} diff --git a/home-manager/kickstart.nixvim/plugins/rustaceanvim.nix b/home-manager/kickstart.nixvim/plugins/rustaceanvim.nix deleted file mode 100755 index 9f0169c..0000000 --- a/home-manager/kickstart.nixvim/plugins/rustaceanvim.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ - programs.nixvim = { - plugins.rustaceanvim = { - enable = true; - }; - }; -} diff --git a/home-manager/kickstart.nixvim/plugins/telescope.nix b/home-manager/kickstart.nixvim/plugins/telescope.nix deleted file mode 100755 index 2009665..0000000 --- a/home-manager/kickstart.nixvim/plugins/telescope.nix +++ /dev/null @@ -1,171 +0,0 @@ -{ - programs.nixvim = { - # Fuzzy Finder (files, lsp, etc) - # https://nix-community.github.io/nixvim/plugins/telescope/index.html - plugins.telescope = { - # Telescope is a fuzzy finder that comes with a lot of different things that - # it can fuzzy find! It's more than just a "file finder", it can search - # many different aspects of Neovim, your workspace, LSP, and more! - # - # The easiest way to use Telescope, is to start by doing something like: - # :Telescope help_tags - # - # After running this command, a window will open up and you're able to - # type in the prompt window. You'll see a list of `help_tags` options and - # a corresponding preview of the help. - # - # Two important keymaps to use while in Telescope are: - # - Insert mode: - # - Normal mode: ? - # - # This opens a window that shows you all of the keymaps for the current - # Telescope picker. This is really useful to discover what Telescope can - # do as well as how to actually do it! - # - # [[ Configure Telescope ]] - # See `:help telescope` and `:help telescope.setup()` - enable = true; - - # Enable Telescope extensions - extensions = { - # https://github.com/nvim-telescope/telescope-fzf-native.nvim - fzf-native.enable = true; - # https://github.com/nvim-telescope/telescope-ui-select.nvim - ui-select.enable = true; - }; - - # You can put your default mappings / updates / etc. in here - # See `:help telescope.builtin` - 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 current [W]ord"; - }; - }; - "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() } }"; - }; - }; - - # https://nix-community.github.io/nixvim/keymaps/index.html - keymaps = [ - # Slightly advanced example of overriding default behavior and theme - { - mode = "n"; - key = "/"; - # You can pass additional configuration to Telescope to change the theme, layout, etc. - action.__raw = '' - function() - require('telescope.builtin').current_buffer_fuzzy_find( - require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false - } - ) - end - ''; - options = { - desc = "[/] Fuzzily search in current buffer"; - }; - } - { - mode = "n"; - key = "s/"; - # It's also possible to pass additional configuration options. - # See `:help telescope.builtin.live_grep()` for information about particular keys - action.__raw = '' - function() - require('telescope.builtin').live_grep { - grep_open_files = true, - prompt_title = 'Live Grep in Open Files' - } - end - ''; - options = { - desc = "[S]earch [/] in Open Files"; - }; - } - # Shortcut for searching your Neovim configuration files - { - mode = "n"; - key = "sn"; - action.__raw = '' - function() - require('telescope.builtin').find_files { - cwd = vim.fn.stdpath 'config' - } - end - ''; - options = { - desc = "[S]earch [N]eovim files"; - }; - } - ]; - }; -} diff --git a/home-manager/kickstart.nixvim/plugins/todo-comments.nix b/home-manager/kickstart.nixvim/plugins/todo-comments.nix deleted file mode 100755 index e6b09fe..0000000 --- a/home-manager/kickstart.nixvim/plugins/todo-comments.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ - programs.nixvim = { - # Highlight todo, notes, etc in comments - # https://nix-community.github.io/nixvim/plugins/todo-comments/index.html - plugins.todo-comments = { - enable = true; - settings = { - signs = true; - }; - }; - }; -} diff --git a/home-manager/kickstart.nixvim/plugins/treesitter.nix b/home-manager/kickstart.nixvim/plugins/treesitter.nix deleted file mode 100755 index 9ac5c7f..0000000 --- a/home-manager/kickstart.nixvim/plugins/treesitter.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ - programs.nixvim = { - # Highlight, edit, and navigate code - # https://nix-community.github.io/nixvim/plugins/treesitter/index.html - plugins.treesitter = { - enable = true; - - settings = { - - highlight = { - enable = true; - - # Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. - additional_vim_regex_highlighting = true; - }; - - indent = { - enable = true; - disable = [ - "ruby" - ]; - }; - - # There are additional nvim-treesitter modules that you can use to interact - # with nvim-treesitter. You should go explore a few and see what interests you: - # - # - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - # - Show your current context: https://nix-community.github.io/nixvim/plugins/treesitter-context/index.html - # - Treesitter + textobjects: https://nix-community.github.io/nixvim/plugins/treesitter-textobjects/index.html - }; - }; - }; -} diff --git a/home-manager/kickstart.nixvim/plugins/which-key.nix b/home-manager/kickstart.nixvim/plugins/which-key.nix deleted file mode 100755 index 4beff64..0000000 --- a/home-manager/kickstart.nixvim/plugins/which-key.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ - programs.nixvim = { - # Useful plugin to show you pending keybinds. - # https://nix-community.github.io/nixvim/plugins/which-key/index.html - plugins.which-key = { - enable = true; - - # Document existing key chains - settings = { - spec = [ - { - __unkeyed-1 = "c"; - group = "[C]ode"; - } - { - __unkeyed-1 = "d"; - group = "[D]ocument"; - } - { - __unkeyed-1 = "r"; - group = "[R]ename"; - } - { - __unkeyed-1 = "s"; - group = "[S]earch"; - } - { - __unkeyed-1 = "w"; - group = "[W]orkspace"; - } - { - __unkeyed-1 = "t"; - group = "[T]oggle"; - } - { - __unkeyed-1 = "h"; - group = "Git [H]unk"; - mode = [ - "n" - "v" - ]; - } - ]; - }; - }; - }; -} diff --git a/home-manager/nixvim/config/conform.nix b/home-manager/nixvim/config/conform.nix new file mode 100644 index 0000000..a8a0c90 --- /dev/null +++ b/home-manager/nixvim/config/conform.nix @@ -0,0 +1,55 @@ +{ pkgs, ... }: { + extraPackages = with pkgs; [ + codespell + go + mdformat + ruff + rustfmt + shellcheck + shfmt + stylua + yamlfmt + ]; + + # https://nix-community.github.io/nixvim/plugins/conform-nvim.html + plugins.conform-nvim = { + enable = true; + settings = { + notify_on_error = false; + formatters_by_ft = { + bash = [ + "shfmt" + "shellcheck" + ]; + c = [ "clang_format" ]; + cpp = [ "clang_format" ]; + go = [ "gofmt" ]; + lua = [ "stylua" ]; + markdown = [ "mdformat" ]; + python = [ "ruff_format" ]; + rust = [ "rustfmt" ]; + sh = [ "shfmt" "shellcheck" ]; + yaml = [ "yamlfmt" ]; + + # "*" filetype to run formatters on all filetypes. + "*" = [ "codespell" ]; + }; + }; + }; + + # https://nix-community.github.io/nixvim/keymaps/index.html + keymaps = [ + { + mode = ""; + key = "f"; + action.__raw = '' + function() + require('conform').format { async = true, lsp_fallback = true } + end + ''; + options = { + desc = "[F]ormat buffer"; + }; + } + ]; +} diff --git a/home-manager/nixvim/config/default.nix b/home-manager/nixvim/config/default.nix new file mode 100644 index 0000000..346b883 --- /dev/null +++ b/home-manager/nixvim/config/default.nix @@ -0,0 +1,354 @@ +{ pkgs, ... }: { + imports = [ + ./conform.nix + ./gitsigns.nix + ./lsp.nix + ./lualine.nix + ./number-toggle.nix + ./nvim-cmp.nix + ./nvim-surround.nix + ./rustaceanvim.nix + # We disable this while the plugin is far behind current version and + # doesn't support e.g. Picker. + # ./snacks.nvim.nix + ./todo-comments.nix + ./treesitter.nix + ./which-key.nix + + ]; + + # You can easily change to a different colorscheme. + # Add your colorscheme here and enable it. + # Don't forget to disable the colorschemes you arent using + # + # If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. + colorschemes = { + # https://nix-community.github.io/nixvim/colorschemes/tokyonight/index.html + catppuccin = { + enable = false; + settings = { + flavour = "frappe"; + integrations = { + cmp = true; + gitsigns = true; + treesitter = true; + }; + }; + }; + gruvbox = { + enable = false; + }; + tokyonight = { + enable = false; + }; + }; + + # https://nix-community.github.io/nixvim/NeovimOptions/index.html?highlight=globals#globals + globals = { + # Set as the leader key + # See `:help mapleader` + mapleader = " "; + maplocalleader = " "; + + # Set to true if you have a Nerd Font installed and selected in the terminal + have_nerd_font = true; + }; + + # See `:help 'clipboard'` + clipboard = { + providers = { + wl-copy.enable = true; # For Wayland + xsel.enable = true; # For X11 + }; + + # Sync clipboard between OS and Neovim + # Remove this option if you want your OS clipboard to remain independent. + register = "unnamedplus"; + }; + + # [[ Setting options ]] + # See `:help vim.opt` + # NOTE: You can change these options as you wish! + # For more options, you can see `:help option-list` + # https://nix-community.github.io/nixvim/NeovimOptions/index.html?highlight=globals#opts + opts = { + # Show line numbers + number = true; + # You can also add relative line numbers, to help with jumping. + # Experiment for yourself to see if you like it! + relativenumber = true; + + # Enable mouse mode, can be useful for resizing splits for example! + mouse = "a"; + + # Don't show the mode, since it's already in the statusline + showmode = false; + + # Enable break indent + breakindent = true; + + # Save undo history + undofile = true; + + # Case-insensitive searching UNLESS \C or one or more capital letters in the search term + ignorecase = true; + smartcase = true; + + # Keep signcolumn on by default + signcolumn = "yes"; + + # Decrease update time + updatetime = 250; + + # Decrease mapped sequence wait time + # Displays which-key popup sooner + timeoutlen = 300; + + # Configure how new splits should be opened + splitright = true; + splitbelow = true; + + # Sets how neovim will display certain whitespace characters in the editor + # See `:help 'list'` + # and `:help 'listchars'` + list = true; + # NOTE: .__raw here means that this field is raw lua code + listchars.__raw = "{ tab = '» ', trail = '·', nbsp = '␣' }"; + + # Preview substitutions live, as you type! + inccommand = "split"; + + # Show which line your cursor is on + cursorline = true; + + # Minimal number of screen lines to keep above and below the cursor. + scrolloff = 10; + + # if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), + # instead raise a dialog asking if you wish to save the current file(s) + # See `:help 'confirm'` + confirm = true; + + # See `:help hlsearch` + hlsearch = true; + }; + + # [[ Basic Keymaps ]] + # See `:help vim.keymap.set()` + # https://nix-community.github.io/nixvim/keymaps/index.html + keymaps = [ + # Clear highlights on search when pressing in normal mode + { + mode = "n"; + key = ""; + action = "nohlsearch"; + } + # Exit terminal mode in the builtin terminal with a shortcut that is a bit easier + # for people to discover. Otherwise, you normally need to press , which + # is not what someone will guess without a bit more experience. + # + # NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping + # or just use to exit terminal mode + { + mode = "t"; + key = ""; + action = ""; + options = { + desc = "Exit terminal mode"; + }; + } + # TIP: Disable arrow keys in normal mode + /* + { + mode = "n"; + key = ""; + action = "echo 'Use h to move!!'"; + } + { + mode = "n"; + key = ""; + action = "echo 'Use l to move!!'"; + } + { + mode = "n"; + key = ""; + action = "echo 'Use k to move!!'"; + } + { + mode = "n"; + key = ""; + action = "echo 'Use j to move!!'"; + } + */ + # Keybinds to make split navigation easier. + # Use CTRL+ to switch between windows + # + # See `:help wincmd` for a list of all window commands + { + 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"; + }; + } + ]; + + # https://nix-community.github.io/nixvim/NeovimOptions/autoGroups/index.html + autoGroups = { + kickstart-highlight-yank = { + clear = true; + }; + }; + + # [[ Basic Autocommands ]] + # See `:help lua-guide-autocommands` + # https://nix-community.github.io/nixvim/NeovimOptions/autoCmd/index.html + autoCmd = [ + # Highlight when yanking (copying) text + # Try it with `yap` in normal mode + # See `:help vim.highlight.on_yank()` + { + event = [ "TextYankPost" ]; + desc = "Highlight when yanking (copying) text"; + group = "kickstart-highlight-yank"; + callback.__raw = '' + function() + vim.highlight.on_yank() + end + ''; + } + ]; + + plugins = { + # Adds icons for plugins to utilize in ui + web-devicons.enable = true; + + # Detect tabstop and shiftwidth automatically + # https://nix-community.github.io/nixvim/plugins/sleuth/index.html + sleuth = { + enable = true; + }; + }; + + extraPackages = with pkgs; [ + # These are for snacks primarily + ripgrep + fd + ]; + + # https://nix-community.github.io/nixvim/NeovimOptions/index.html?highlight=extraplugins#extraplugins + extraPlugins = with pkgs.vimPlugins; [ + gruvbox-material + snacks-nvim + ]; + + # https://nix-community.github.io/nixvim/NeovimOptions/index.html?highlight=extraplugins#extraconfiglua + extraConfigLua = '' + vim.g.gruvbox_material_background = "medium" + vim.g.gruvbox_material_diagnostic_virtual_text = "colored" + vim.g.gruvbox_material_better_performance = 1 + vim.cmd.colorscheme('gruvbox-material') + + -- snacks + require('snacks').setup({ + bigfile = { enabled = true }, + dim = { enabled = true }, + explorer = { enabled = false }, + indent = { enabled = true }, + picker = { enabled = true }, + }) + + -- Keymappings + vim.keymap.set('n', 'z', function() require('snacks').zen() end, { desc = 'Toggle Zen Mode' }) + vim.keymap.set('n', 'Z', function() require('snacks').zen.zoom() end, { desc = 'Toggle Zoom' }) + vim.keymap.set('n', '', function() require('snacks').picker.smart() end, { desc = 'Smart Find Files' }) + vim.keymap.set('n', ',', function() require('snacks').picker.buffers() end, { desc = 'Buffers' }) + vim.keymap.set('n', '/', function() require('snacks').picker.grep() end, { desc = 'Grep' }) + vim.keymap.set('n', ':', function() require('snacks').picker.command_history() end, { desc = 'Command History' }) + vim.keymap.set('n', 'n', function() require('snacks').picker.notifications() end, { desc = 'Notification History' }) + vim.keymap.set('n', 'e', function() require('snacks').explorer() end, { desc = 'File Explorer' }) + vim.keymap.set('n', 'fb', function() require('snacks').picker.buffers() end, { desc = 'Buffers' }) + vim.keymap.set('n', 'fc', function() require('snacks').picker.files({ cwd = vim.fn.stdpath('config') }) end, { desc = 'Find Config File' }) + vim.keymap.set('n', 'ff', function() require('snacks').picker.files() end, { desc = 'Find Files' }) + vim.keymap.set('n', 'fg', function() require('snacks').picker.git_files() end, { desc = 'Find Git Files' }) + vim.keymap.set('n', 'fp', function() require('snacks').picker.projects() end, { desc = 'Projects' }) + vim.keymap.set('n', 'fr', function() require('snacks').picker.recent() end, { desc = 'Recent' }) + vim.keymap.set('n', 'gb', function() require('snacks').picker.git_branches() end, { desc = 'Git Branches' }) + vim.keymap.set('n', 'gl', function() require('snacks').picker.git_log() end, { desc = 'Git Log' }) + vim.keymap.set('n', 'gL', function() require('snacks').picker.git_log_line() end, { desc = 'Git Log Line' }) + vim.keymap.set('n', 'gs', function() require('snacks').picker.git_status() end, { desc = 'Git Status' }) + vim.keymap.set('n', 'gS', function() require('snacks').picker.git_stash() end, { desc = 'Git Stash' }) + vim.keymap.set('n', 'gd', function() require('snacks').picker.git_diff() end, { desc = 'Git Diff (Hunks)' }) + vim.keymap.set('n', 'gf', function() require('snacks').picker.git_log_file() end, { desc = 'Git Log File' }) + vim.keymap.set('n', 'sb', function() require('snacks').picker.lines() end, { desc = 'Buffer Lines' }) + vim.keymap.set('n', 'sB', function() require('snacks').picker.grep_buffers() end, { desc = 'Grep Open Buffers' }) + vim.keymap.set('n', 'sg', function() require('snacks').picker.grep() end, { desc = 'Grep' }) + vim.keymap.set({ 'n', 'x' }, 'sw', function() require('snacks').picker.grep_word() end, { desc = 'Visual selection or word' }) + vim.keymap.set('n', 's"', function() require('snacks').picker.registers() end, { desc = 'Registers' }) + vim.keymap.set('n', 's/', function() require('snacks').picker.search_history() end, { desc = 'Search History' }) + vim.keymap.set('n', 'sa', function() require('snacks').picker.autocmds() end, { desc = 'Autocmds' }) + vim.keymap.set('n', 'sc', function() require('snacks').picker.command_history() end, { desc = 'Command History' }) + vim.keymap.set('n', 'sC', function() require('snacks').picker.commands() end, { desc = 'Commands' }) + vim.keymap.set('n', 'sd', function() require('snacks').picker.diagnostics() end, { desc = 'Diagnostics' }) + vim.keymap.set('n', 'sD', function() require('snacks').picker.diagnostics_buffer() end, { desc = 'Buffer Diagnostics' }) + vim.keymap.set('n', 'sh', function() require('snacks').picker.help() end, { desc = 'Help Pages' }) + vim.keymap.set('n', 'sH', function() require('snacks').picker.highlights() end, { desc = 'Highlights' }) + vim.keymap.set('n', 'si', function() require('snacks').picker.icons() end, { desc = 'Icons' }) + vim.keymap.set('n', 'sj', function() require('snacks').picker.jumps() end, { desc = 'Jumps' }) + vim.keymap.set('n', 'sk', function() require('snacks').picker.keymaps() end, { desc = 'Keymaps' }) + vim.keymap.set('n', 'sl', function() require('snacks').picker.loclist() end, { desc = 'Location List' }) + vim.keymap.set('n', 'sm', function() require('snacks').picker.marks() end, { desc = 'Marks' }) + vim.keymap.set('n', 'sM', function() require('snacks').picker.man() end, { desc = 'Man Pages' }) + vim.keymap.set('n', 'sp', function() require('snacks').picker.lazy() end, { desc = 'Search for Plugin Spec' }) + vim.keymap.set('n', 'sq', function() require('snacks').picker.qflist() end, { desc = 'Quickfix List' }) + vim.keymap.set('n', 'sR', function() require('snacks').picker.resume() end, { desc = 'Resume' }) + vim.keymap.set('n', 'su', function() require('snacks').picker.undo() end, { desc = 'Undo History' }) + vim.keymap.set('n', 'uC', function() require('snacks').picker.colorschemes() end, { desc = 'Colorschemes' }) + vim.keymap.set('n', 'gd', function() require('snacks').picker.lsp_definitions() end, { desc = 'Goto Definition' }) + vim.keymap.set('n', 'gD', function() require('snacks').picker.lsp_declarations() end, { desc = 'Goto Declaration' }) + vim.keymap.set('n', 'gr', function() require('snacks').picker.lsp_references() end, { nowait = true, desc = 'References' }) + vim.keymap.set('n', 'gI', function() require('snacks').picker.lsp_implementations() end, { desc = 'Goto Implementation' }) + vim.keymap.set('n', 'gy', function() require('snacks').picker.lsp_type_definitions() end, { desc = 'Goto T[y]pe Definition' }) + vim.keymap.set('n', 'ss', function() require('snacks').picker.lsp_symbols() end, { desc = 'LSP Symbols' }) + vim.keymap.set('n', 'sS', function() require('snacks').picker.lsp_workspace_symbols() end, { desc = 'LSP Workspace Symbols' }) + + -- Toggle keymaps + require('snacks').toggle.option('spell', { name = 'Spelling' }):map('us') + require('snacks').toggle.option('wrap', { name = 'Wrap' }):map('uw') + require('snacks').toggle.option('relativenumber', { name = 'Relative Number' }):map('uL') + require('snacks').toggle.diagnostics():map('ud') + require('snacks').toggle.line_number():map('ul') + require('snacks').toggle.option('conceallevel', { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }):map('uc') + require('snacks').toggle.treesitter():map('uT') + require('snacks').toggle.option('background', { off = 'light', on = 'dark', name = 'Dark Background' }):map('ub') + require('snacks').toggle.inlay_hints():map('uh') + require('snacks').toggle.indent():map('ug') + require('snacks').toggle.dim():map('uD') + + ''; +} diff --git a/home-manager/nixvim/config/gitsigns.nix b/home-manager/nixvim/config/gitsigns.nix new file mode 100644 index 0000000..eede269 --- /dev/null +++ b/home-manager/nixvim/config/gitsigns.nix @@ -0,0 +1,220 @@ +{ + # Adds git related signs to the gutter, as well as utilities for managing changes + # See `:help gitsigns` to understand what the configuration keys do + # https://nix-community.github.io/nixvim/plugins/gitsigns/index.html + plugins.gitsigns = { + enable = true; + settings = { + signs = { + add = { text = "+"; }; + change = { text = "~"; }; + delete = { text = "_"; }; + topdelete = { text = "‾"; }; + changedelete = { text = "~"; }; + }; + }; + }; + + # NOTE: add gitsigns recommended keymaps if you are interested + # https://nix-community.github.io/nixvim/keymaps/index.html + keymaps = [ + # Navigation + { + mode = "n"; + key = "]c"; + action.__raw = '' + function() + if vim.wo.diff then + vim.cmd.normal { ']c', bang = true } + else + require('gitsigns').nav_hunk 'next' + end + end + ''; + options = { + desc = "Jump to next git [c]hange"; + }; + } + { + mode = "n"; + key = "[c"; + action.__raw = '' + function() + if vim.wo.diff then + vim.cmd.normal { '[c', bang = true } + else + require('gitsigns').nav_hunk 'prev' + end + end + ''; + options = { + desc = "Jump to previous git [c]hange"; + }; + } + + # Actions + # visual mode + { + mode = "v"; + key = "hs"; + action.__raw = '' + function() + require('gitsigns').stage_hunk { vim.fn.line '.', vim.fn.line 'v' } + end + ''; + options = { + desc = "git [s]tage hunk"; + }; + } + { + mode = "v"; + key = "hr"; + action.__raw = '' + function() + require('gitsigns').reset_hunk { vim.fn.line '.', vim.fn.line 'v' } + end + ''; + options = { + desc = "git [r]eset hunk"; + }; + } + # normal mode + { + mode = "n"; + key = "hs"; + action.__raw = '' + function() + require('gitsigns').stage_hunk() + end + ''; + options = { + desc = "git [s]tage hunk"; + }; + } + { + mode = "n"; + key = "hr"; + action.__raw = '' + function() + require('gitsigns').reset_hunk() + end + ''; + options = { + desc = "git [r]eset hunk"; + }; + } + { + mode = "n"; + key = "hS"; + action.__raw = '' + function() + require('gitsigns').stage_buffer() + end + ''; + options = { + desc = "git [S]tage buffer"; + }; + } + { + mode = "n"; + key = "hu"; + # `undo_stage_hunk` is deprecated. See https://github.com/nvim-lua/kickstart.nvim/issues/1319 + # Replacement `stage_hunk` was accidentally merged. See https://github.com/nvim-lua/kickstart.nvim/pull/1321#issuecomment-2664265962 + action.__raw = '' + function() + require('gitsigns').undo_stage_hunk() + end + ''; + options = { + desc = "git [u]ndo stage hunk"; + }; + } + { + mode = "n"; + key = "hR"; + action.__raw = '' + function() + require('gitsigns').reset_buffer() + end + ''; + options = { + desc = "git [R]eset buffer"; + }; + } + { + mode = "n"; + key = "hp"; + action.__raw = '' + function() + require('gitsigns').preview_hunk() + end + ''; + options = { + desc = "git [p]review hunk"; + }; + } + { + mode = "n"; + key = "hb"; + action.__raw = '' + function() + require('gitsigns').blame_line() + end + ''; + options = { + desc = "git [b]lame line"; + }; + } + { + mode = "n"; + key = "hd"; + action.__raw = '' + function() + require('gitsigns').diffthis() + end + ''; + options = { + desc = "git [d]iff against index"; + }; + } + { + mode = "n"; + key = "hD"; + action.__raw = '' + function() + require('gitsigns').diffthis '@' + end + ''; + options = { + desc = "git [D]iff against last commit"; + }; + } + # Toggles + { + mode = "n"; + key = "tb"; + action.__raw = '' + function() + require('gitsigns').toggle_current_line_blame() + end + ''; + options = { + desc = "[T]oggle git show [b]lame line"; + }; + } + { + mode = "n"; + key = "tD"; + # `toggle_deleted` is deprecated. See https://github.com/nvim-lua/kickstart.nvim/issues/1319 + # Replacement `preview_hunk_inline` was accidentally merged. See https://github.com/nvim-lua/kickstart.nvim/pull/1321#issuecomment-2664265962 + action.__raw = '' + function() + require('gitsigns').toggle_deleted() + end + ''; + options = { + desc = "[T]oggle git show [D]eleted"; + }; + } + ]; +} diff --git a/home-manager/nixvim/config/lsp.nix b/home-manager/nixvim/config/lsp.nix new file mode 100644 index 0000000..059f09e --- /dev/null +++ b/home-manager/nixvim/config/lsp.nix @@ -0,0 +1,82 @@ +{ pkgs, ... }: { + extraPackages = with pkgs; [ + basedpyright + clang-tools + cmake-language-server + fish-lsp + gitlint + isort + lua-language-server + nil + nodePackages.jsonlint + ruff + stylua + typos + typos-lsp + ]; + + plugins.cmp-nvim-lsp.enable = true; + plugins.cmp-cmdline.enable = true; + plugins.cmp-nvim-lsp-signature-help.enable = true; + + # Useful status updates for LSP. + # https://nix-community.github.io/nixvim/plugins/fidget/index.html + plugins.fidget = { + enable = true; + }; + + # https://nix-community.github.io/nixvim/plugins/lsp/index.html + plugins.lsp = { + enable = true; + inlayHints = true; + + # Enable the following language servers + # Feel free to add/remove any LSPs that you want here. They will automatically be installed. + # + # Add any additional override configuration in the following tables. Available keys are: + # - cmd: Override the default command used to start the server + # - filetypes: Override the default list of associated filetypes for the server + # - capabilities: Override fields in capabilities. Can be used to disable certain LSP features. + # - settings: Override the default settings passed when initializing the server. + # For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + servers = { + basedpyright = { + enable = true; + }; + clangd = { + enable = true; + }; + cmake = { + enable = true; + }; + fish_lsp = { + enable = true; + }; + gopls = { + enable = true; + }; + lua_ls = { + enable = true; + settings = { + completion = { + callSnippet = "Replace"; + }; + }; + }; + nil_ls = { + enable = true; + }; + ruff = { + enable = true; + }; + # typos_lsp = { + # enable = true; + # settings = { + # diagnosticSeverity = "Hint"; + # }; + # }; + }; + + keymaps = { }; + }; +} diff --git a/home-manager/nixvim/config/lualine.nix b/home-manager/nixvim/config/lualine.nix new file mode 100644 index 0000000..6413900 --- /dev/null +++ b/home-manager/nixvim/config/lualine.nix @@ -0,0 +1,6 @@ +{ + plugins.lualine = { + enable = true; + }; + plugins.web-devicons.enable = true; +} diff --git a/home-manager/nixvim/config/number-toggle.nix b/home-manager/nixvim/config/number-toggle.nix new file mode 100644 index 0000000..4b359fb --- /dev/null +++ b/home-manager/nixvim/config/number-toggle.nix @@ -0,0 +1,5 @@ +{ + plugins.numbertoggle = { + enable = true; + }; +} diff --git a/home-manager/nixvim/config/nvim-cmp.nix b/home-manager/nixvim/config/nvim-cmp.nix new file mode 100644 index 0000000..3aa82bb --- /dev/null +++ b/home-manager/nixvim/config/nvim-cmp.nix @@ -0,0 +1,127 @@ +{ + # `friendly-snippets` contains a variety of premade snippets + # See the README about individual language/framework/plugin snippets: + # https://github.com/rafamadriz/friendly-snippets + # https://nix-community.github.io/nixvim/plugins/friendly-snippets.html + plugins.friendly-snippets = { + enable = true; + }; + + plugins.lazydev.enable = true; # autoEnableSources not enough + plugins.luasnip.enable = true; # autoEnableSources not enough + + # Autocompletion + # See `:help cmp` + # https://nix-community.github.io/nixvim/plugins/cmp/index.html + plugins.cmp = { + enable = true; + + settings = { + snippet = { + expand = '' + function(args) + require('luasnip').lsp_expand(args.body) + end + ''; + }; + + completion = { + completeopt = "menu,menuone,noinsert"; + }; + + # For an understanding of why these mappings were + # chosen, you will need to read `:help ins-completion` + # + # No, but seriously. Please read `:help ins-completion`, it is really good! + mapping = { + # Select the [n]ext item + "" = "cmp.mapping.select_next_item()"; + # Select the [p]revious item + "" = "cmp.mapping.select_prev_item()"; + + # Scroll the documentation window [b]ack / [f]orward + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.scroll_docs(4)"; + + # Accept ([y]es) the completion. + # This will auto-import if your LSP supports it. + # This will expand snippets if the LSP sent a snippet. + "" = "cmp.mapping.confirm { select = true }"; + + # If you prefer more traditional completion keymaps, + # you can uncomment the following lines. + # "" = "cmp.mapping.confirm { select = true }"; + # "" = "cmp.mapping.select_next_item()"; + # "" = "cmp.mapping.select_prev_item()"; + + # Manually trigger a completion from nvim-cmp. + # Generally you don't need this, because nvim-cmp will display + # completions whenever it has completion options available. + "" = "cmp.mapping.complete {}"; + + # Think of as moving to the right of your snippet expansion. + # So if you have a snippet that's like: + # function $name($args) + # $body + # end + # + # will move you to the right of each of the expansion locations. + # is similar, except moving you backwards. + "" = '' + cmp.mapping(function() + if luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + end + end, { 'i', 's' }) + ''; + "" = '' + cmp.mapping(function() + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + end + end, { 'i', 's' }) + ''; + + # For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: + # https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps + }; + + # Dependencies + # + # WARNING: If plugins.cmp.autoEnableSources Nixivm will automatically enable the + # corresponding source plugins. This will work only when this option is set to a list. + # If you use a raw lua string, you will need to explicitly enable the relevant source + # plugins in your nixvim configuration. + # See list of most cmp source plugins that are autoloaded by defining the source: + # https://github.com/nix-community/nixvim/blob/main/plugins/cmp/sources/default.nix + sources = [ + # https://nix-community.github.io/nixvim/plugins/lazydev/index.html + { + name = "lazydev"; + # set group index to 0 to skip loading LuaLS completions as lazydev recommends it + group_index = 0; + } + # Adds other completion capabilites. + # nvim-cmp does not ship with all sources by default. They are split + # into multiple repos for maintenance purposes. + # https://nix-community.github.io/nixvim/plugins/cmp-nvim-lsp.html + { + name = "nvim_lsp"; + } + # Snippet Engine & its associated nvim-cmp source + # https://nix-community.github.io/nixvim/plugins/luasnip/index.html + { + name = "luasnip"; + } + # https://nix-community.github.io/nixvim/plugins/cmp-path.html + { + name = "path"; + } + # https://nix-community.github.io/nixvim/plugins/cmp-nvim-lsp-signature-help.html + { + name = "nvim_lsp_signature_help"; + } + ]; + }; + }; +} diff --git a/home-manager/nixvim/config/nvim-surround.nix b/home-manager/nixvim/config/nvim-surround.nix new file mode 100644 index 0000000..b240582 --- /dev/null +++ b/home-manager/nixvim/config/nvim-surround.nix @@ -0,0 +1,5 @@ +{ + plugins.nvim-surround = { + enable = true; + }; +} diff --git a/home-manager/nixvim/config/rustaceanvim.nix b/home-manager/nixvim/config/rustaceanvim.nix new file mode 100644 index 0000000..2d96e4a --- /dev/null +++ b/home-manager/nixvim/config/rustaceanvim.nix @@ -0,0 +1,6 @@ +{ + # See https://nix-community.github.io/nixvim/plugins/rustaceanvim/index.html + plugins.rustaceanvim = { + enable = true; + }; +} diff --git a/home-manager/nixvim/config/snacks.nvim.nix b/home-manager/nixvim/config/snacks.nvim.nix new file mode 100644 index 0000000..0359881 --- /dev/null +++ b/home-manager/nixvim/config/snacks.nvim.nix @@ -0,0 +1,417 @@ +{ + plugins.snacks = { + enable = false; + settings = { + bigfile = { enabled = true; }; + dim = { enabled = true; }; + explorer = { enabled = true; }; + indent = { enabled = true; }; + picker = { enabled = true; }; + }; + }; + + keymaps = [ + # Zen Mode + { + key = "z"; + action = ''lua Snacks.zen()''; + options = { desc = "Toggle Zen Mode"; }; + mode = "n"; + } + { + key = "Z"; + action = ''lua Snacks.zen.zoom()''; + options = { desc = "Toggle Zoom"; }; + mode = "n"; + } + # Top Pickers & Explorer + { + key = ""; + action = ''lua Snacks.picker.smart()''; + options = { desc = "Smart Find Files"; }; + mode = "n"; + } + { + key = ","; + action = ''lua Snacks.picker.buffers()''; + options = { desc = "Buffers"; }; + mode = "n"; + } + { + key = "/"; + action = ''lua Snacks.picker.grep()''; + options = { desc = "Grep"; }; + mode = "n"; + } + { + key = ":"; + action = ''lua Snacks.picker.command_history()''; + options = { desc = "Command History"; }; + mode = "n"; + } + { + key = "n"; + action = ''lua Snacks.picker.notifications()''; + options = { desc = "Notification History"; }; + mode = "n"; + } + { + key = "e"; + action = ''lua Snacks.explorer()''; + options = { desc = "File Explorer"; }; + mode = "n"; + } + # Find + { + key = "fb"; + action = ''lua Snacks.picker.buffers()''; + options = { desc = "Buffers"; }; + mode = "n"; + } + { + key = "fc"; + action = ''lua Snacks.picker.files({ cwd = vim.fn.stdpath("config") })''; + options = { desc = "Find Config File"; }; + mode = "n"; + } + { + key = "ff"; + action = ''lua Snacks.picker.files()''; + options = { desc = "Find Files"; }; + mode = "n"; + } + { + key = "fg"; + action = ''lua Snacks.picker.git_files()''; + options = { desc = "Find Git Files"; }; + mode = "n"; + } + { + key = "fp"; + action = ''lua Snacks.picker.projects()''; + options = { desc = "Projects"; }; + mode = "n"; + } + { + key = "fr"; + action = ''lua Snacks.picker.recent()''; + options = { desc = "Recent"; }; + mode = "n"; + } + # Git + { + key = "gb"; + action = ''lua Snacks.picker.git_branches()''; + options = { desc = "Git Branches"; }; + mode = "n"; + } + { + key = "gl"; + action = ''lua Snacks.picker.git_log()''; + options = { desc = "Git Log"; }; + mode = "n"; + } + { + key = "gL"; + action = ''lua Snacks.picker.git_log_line()''; + options = { desc = "Git Log Line"; }; + mode = "n"; + } + { + key = "gs"; + action = ''lua Snacks.picker.git_status()''; + options = { desc = "Git Status"; }; + mode = "n"; + } + { + key = "gS"; + action = ''lua Snacks.picker.git_stash()''; + options = { desc = "Git Stash"; }; + mode = "n"; + } + { + key = "gd"; + action = ''lua Snacks.picker.git_diff()''; + options = { desc = "Git Diff (Hunks)"; }; + mode = "n"; + } + { + key = "gf"; + action = ''lua Snacks.picker.git_log_file()''; + options = { desc = "Git Log File"; }; + mode = "n"; + } + # Grep + { + key = "sb"; + action = ''lua Snacks.picker.lines()''; + options = { desc = "Buffer Lines"; }; + mode = "n"; + } + { + key = "sB"; + action = ''lua Snacks.picker.grep_buffers()''; + options = { desc = "Grep Open Buffers"; }; + mode = "n"; + } + { + key = "sg"; + action = ''lua Snacks.picker.grep()''; + options = { desc = "Grep"; }; + mode = "n"; + } + { + key = "sw"; + action = ''lua Snacks.picker.grep_word()''; + options = { desc = "Visual selection or word"; }; + mode = [ "n" "x" ]; + } + # Search + { + key = "s\""; + action = ''lua Snacks.picker.registers()''; + options = { desc = "Registers"; }; + mode = "n"; + } + { + key = "s/"; + action = ''lua Snacks.picker.search_history()''; + options = { desc = "Search History"; }; + mode = "n"; + } + { + key = "sa"; + action = ''lua Snacks.picker.autocmds()''; + options = { desc = "Autocmds"; }; + mode = "n"; + } + { + key = "sc"; + action = ''lua Snacks.picker.command_history()''; + options = { desc = "Command History"; }; + mode = "n"; + } + { + key = "sC"; + action = ''lua Snacks.picker.commands()''; + options = { desc = "Commands"; }; + mode = "n"; + } + { + key = "sd"; + action = ''lua Snacks.picker.diagnostics()''; + options = { desc = "Diagnostics"; }; + mode = "n"; + } + { + key = "sD"; + action = ''lua Snacks.picker.diagnostics_buffer()''; + options = { desc = "Buffer Diagnostics"; }; + mode = "n"; + } + { + key = "sh"; + action = ''lua Snacks.picker.help()''; + options = { desc = "Help Pages"; }; + mode = "n"; + } + { + key = "sH"; + action = ''lua Snacks.picker.highlights()''; + options = { desc = "Highlights"; }; + mode = "n"; + } + { + key = "si"; + action = ''lua Snacks.picker.icons()''; + options = { desc = "Icons"; }; + mode = "n"; + } + { + key = "sj"; + action = ''lua Snacks.picker.jumps()''; + options = { desc = "Jumps"; }; + mode = "n"; + } + { + key = "sk"; + action = ''lua Snacks.picker.keymaps()''; + options = { desc = "Keymaps"; }; + mode = "n"; + } + { + key = "sl"; + action = ''lua Snacks.picker.loclist()''; + options = { desc = "Location List"; }; + mode = "n"; + } + { + key = "sm"; + action = ''lua Snacks.picker.marks()''; + options = { desc = "Marks"; }; + mode = "n"; + } + { + key = "sM"; + action = ''lua Snacks.picker.man()''; + options = { desc = "Man Pages"; }; + mode = "n"; + } + { + key = "sp"; + action = ''lua Snacks.picker.lazy()''; + options = { desc = "Search for Plugin Spec"; }; + mode = "n"; + } + { + key = "sq"; + action = ''lua Snacks.picker.qflist()''; + options = { desc = "Quickfix List"; }; + mode = "n"; + } + { + key = "sR"; + action = ''lua Snacks.picker.resume()''; + options = { desc = "Resume"; }; + mode = "n"; + } + { + key = "su"; + action = ''lua Snacks.picker.undo()''; + options = { desc = "Undo History"; }; + mode = "n"; + } + { + key = "uC"; + action = ''lua Snacks.picker.colorschemes()''; + options = { desc = "Colorschemes"; }; + mode = "n"; + } + # LSP + { + key = "gd"; + action = ''lua Snacks.picker.lsp_definitions()''; + options = { desc = "Goto Definition"; }; + mode = "n"; + } + { + key = "gD"; + action = ''lua Snacks.picker.lsp_declarations()''; + options = { desc = "Goto Declaration"; }; + mode = "n"; + } + { + key = "gr"; + action = ''lua Snacks.picker.lsp_references()''; + options = { desc = "References"; nowait = true; }; + mode = "n"; + } + { + key = "gI"; + action = ''lua Snacks.picker.lsp_implementations()''; + options = { desc = "Goto Implementation"; }; + mode = "n"; + } + { + key = "gy"; + action = ''lua Snacks.picker.lsp_type_definitions()''; + options = { desc = "Goto T[y]pe Definition"; }; + mode = "n"; + } + { + key = "ss"; + action = ''lua Snacks.picker.lsp_symbols()''; + options = { desc = "LSP Symbols"; }; + mode = "n"; + } + { + key = "sS"; + action = ''lua Snacks.picker.lsp_workspace_symbols()''; + options = { desc = "LSP Workspace Symbols"; }; + mode = "n"; + } + # Toggle Mappings from init + { + key = "us"; + action = ''lua Snacks.toggle.option("spell", { name = "Spelling" })()''; + options = { desc = "Toggle Spelling"; }; + mode = "n"; + } + { + key = "uw"; + action = ''lua Snacks.toggle.option("wrap", { name = "Wrap" })()''; + options = { desc = "Toggle Wrap"; }; + mode = "n"; + } + { + key = "uL"; + action = ''lua Snacks.toggle.option("relativenumber", { name = "Relative Number" })()''; + options = { desc = "Toggle Relative Number"; }; + mode = "n"; + } + { + key = "ud"; + action = ''lua Snacks.toggle.diagnostics()''; + options = { desc = "Toggle Diagnostics"; }; + mode = "n"; + } + { + key = "ul"; + action = ''lua Snacks.toggle.line_number()''; + options = { desc = "Toggle Line Number"; }; + mode = "n"; + } + { + key = "uc"; + action = ''lua Snacks.toggle.option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 })()''; + options = { desc = "Toggle Conceallevel"; }; + mode = "n"; + } + { + key = "uT"; + action = ''lua Snacks.toggle.treesitter()''; + options = { desc = "Toggle Treesitter"; }; + mode = "n"; + } + { + key = "ub"; + action = ''lua Snacks.toggle.option("background", { off = "light", on = "dark", name = "Dark Background" })()''; + options = { desc = "Toggle Dark Background"; }; + mode = "n"; + } + { + key = "uh"; + action = ''lua Snacks.toggle.inlay_hints()''; + options = { desc = "Toggle Inlay Hints"; }; + mode = "n"; + } + { + key = "ug"; + action = ''lua Snacks.toggle.indent()''; + options = { desc = "Toggle Indent"; }; + mode = "n"; + } + { + key = "uD"; + action = ''lua Snacks.toggle.dim()''; + options = { desc = "Toggle Dim"; }; + mode = "n"; + } + ]; + + extraConfigLua = '' + vim.api.nvim_create_autocmd("User", { + pattern = "VeryLazy", + callback = function() + -- Setup some globals for debugging (lazy-loaded) + _G.dd = function(...) + Snacks.debug.inspect(...) + end + _G.bt = function() + Snacks.debug.backtrace() + end + vim.print = _G.dd -- Override print to use snacks for `:=` command + end, + }) + ''; +} diff --git a/home-manager/nixvim/config/todo-comments.nix b/home-manager/nixvim/config/todo-comments.nix new file mode 100644 index 0000000..a38bb6c --- /dev/null +++ b/home-manager/nixvim/config/todo-comments.nix @@ -0,0 +1,10 @@ +{ + # Highlight todo, notes, etc in comments + # https://nix-community.github.io/nixvim/plugins/todo-comments/index.html + plugins.todo-comments = { + enable = true; + settings = { + signs = true; + }; + }; +} diff --git a/home-manager/nixvim/config/treesitter.nix b/home-manager/nixvim/config/treesitter.nix new file mode 100644 index 0000000..1860970 --- /dev/null +++ b/home-manager/nixvim/config/treesitter.nix @@ -0,0 +1,31 @@ +{ + # Highlight, edit, and navigate code + # https://nix-community.github.io/nixvim/plugins/treesitter/index.html + plugins.treesitter = { + enable = true; + + settings = { + + highlight = { + enable = true; + + # Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. + additional_vim_regex_highlighting = true; + }; + + indent = { + enable = true; + disable = [ + "ruby" + ]; + }; + + # There are additional nvim-treesitter modules that you can use to interact + # with nvim-treesitter. You should go explore a few and see what interests you: + # + # - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` + # - Show your current context: https://nix-community.github.io/nixvim/plugins/treesitter-context/index.html + # - Treesitter + textobjects: https://nix-community.github.io/nixvim/plugins/treesitter-textobjects/index.html + }; + }; +} diff --git a/home-manager/nixvim/config/which-key.nix b/home-manager/nixvim/config/which-key.nix new file mode 100644 index 0000000..8a7f41b --- /dev/null +++ b/home-manager/nixvim/config/which-key.nix @@ -0,0 +1,45 @@ +{ + # Useful plugin to show you pending keybinds. + # https://nix-community.github.io/nixvim/plugins/which-key/index.html + plugins.which-key = { + enable = true; + + # Document existing key chains + settings = { + spec = [ + { + __unkeyed-1 = "c"; + group = "[C]ode"; + } + { + __unkeyed-1 = "d"; + group = "[D]ocument"; + } + { + __unkeyed-1 = "r"; + group = "[R]ename"; + } + { + __unkeyed-1 = "s"; + group = "[S]earch"; + } + { + __unkeyed-1 = "w"; + group = "[W]orkspace"; + } + { + __unkeyed-1 = "t"; + group = "[T]oggle"; + } + { + __unkeyed-1 = "h"; + group = "Git [H]unk"; + mode = [ + "n" + "v" + ]; + } + ]; + }; + }; +} diff --git a/home-manager/nixvim/flake.lock b/home-manager/nixvim/flake.lock new file mode 100644 index 0000000..f2ef78f --- /dev/null +++ b/home-manager/nixvim/flake.lock @@ -0,0 +1,203 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "ixx": { + "inputs": { + "flake-utils": [ + "nixvim", + "nuschtosSearch", + "flake-utils" + ], + "nixpkgs": [ + "nixvim", + "nuschtosSearch", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1729958008, + "narHash": "sha256-EiOq8jF4Z/zQe0QYVc3+qSKxRK//CFHMB84aYrYGwEs=", + "owner": "NuschtOS", + "repo": "ixx", + "rev": "9fd01aad037f345350eab2cd45e1946cc66da4eb", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "ref": "v0.0.6", + "repo": "ixx", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1743296961, + "narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1744157173, + "narHash": "sha256-bWSjxDwq7iVePrhmA7tY2dyMWHuNJo8knkO4y+q4ZkY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6a39c6e495eefabc935d8ddf66aa45d85b85fa3f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixvim": { + "inputs": { + "flake-parts": "flake-parts_2", + "nixpkgs": "nixpkgs_2", + "nuschtosSearch": "nuschtosSearch" + }, + "locked": { + "lastModified": 1744874965, + "narHash": "sha256-eOnMgAWsjqOhGRoY9smkKlNQcCz9R89mgiKwLrCIYBE=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "500b56f023e0f095ffee2d4f79e58aa09e6b0719", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "nuschtosSearch": { + "inputs": { + "flake-utils": "flake-utils", + "ixx": "ixx", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1743683223, + "narHash": "sha256-LdXtHFvhEC3S64dphap1pkkzwjErbW65eH1VRerCUT0=", + "owner": "NuschtOS", + "repo": "search", + "rev": "56a49ffef2908dad1e9a8adef1f18802bc760962", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "repo": "search", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "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" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/home-manager/nixvim/flake.nix b/home-manager/nixvim/flake.nix new file mode 100644 index 0000000..1613e3e --- /dev/null +++ b/home-manager/nixvim/flake.nix @@ -0,0 +1,50 @@ +{ + description = "A nixvim configuration"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + nixvim.url = "github:nix-community/nixvim"; + flake-parts.url = "github:hercules-ci/flake-parts"; + }; + + outputs = + { nixvim, flake-parts, ... }@inputs: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + + perSystem = + { pkgs, system, ... }: + let + nixvimLib = nixvim.lib.${system}; + nixvim' = nixvim.legacyPackages.${system}; + nixvimModule = { + inherit system; # or alternatively, set `pkgs` + module = import ./config; # import the module directly + # You can use `extraSpecialArgs` to pass additional arguments to your module files + extraSpecialArgs = { + # inherit (inputs) foo; + }; + }; + nvim = nixvim'.makeNixvimWithModule nixvimModule; + in + { + checks = { + # Run `nix flake check .` to verify that your config is not broken + default = nixvimLib.check.mkTestDerivationFromNixvimModule nixvimModule; + }; + + packages = { + # Lets you run `nix run .` to start nixvim + default = nvim; + }; + + formatter = pkgs.nixpkgs-fmt; + }; + }; + +} diff --git a/justfile b/justfile index d08289a..3d7a8c7 100644 --- a/justfile +++ b/justfile @@ -1,3 +1,5 @@ +nixos_rebuild_args := if arch() != "x86_64" { "" } else { "--build-on-remote" } + [private] default: just --list @@ -5,7 +7,7 @@ default: # Deploy [group('deploy')] deploy hostname: - nix-shell -p nixos-anywhere --run "nixos-anywhere --flake .#nixos {{hostname}}" + nix-shell -p nixos-anywhere --run "nixos-anywhere --flake .#nixos {{hostname}} {{nixos_rebuild_args}}" # Update configuration remotely [group('rebuild')]