nix-configs

Personal NixOS and home-manager configuration files
Log | Files | Refs

commit 64fd9d756b0b49340d9e64ad189bb24be1aa26fe
parent 5c9dc4fe0435e30fb4b1c683cb2fc147119edfc8
Author: Peter <peter@minskio.co.uk>
Date:   Tue, 23 Dec 2025 17:31:23 +0000

Neovim improvements

We don't need NixSortIncludes now we're including everything for every module.
Also include vim-nix plugin for proper indentation

Diffstat:
Mhome/neovim.nix | 39+++++----------------------------------
1 file changed, 5 insertions(+), 34 deletions(-)

diff --git a/home/neovim.nix b/home/neovim.nix @@ -1,7 +1,10 @@ -{...}: { +{ pkgs, ... }: { programs.neovim = { enable = true; defaultEditor = true; + plugins = with pkgs.vimPlugins; [ + vim-nix + ]; extraConfig = '' set smartcase set nocompatible @@ -31,39 +34,7 @@ :iab <expr> _stamp strftime("%F\T%H:%M:00") autocmd BufWritePre * %s/\s\+$//e autocmd BufWritepre * %s/\n\+\%$//e - autocmd FileType nix setlocal tabstop=2 shiftwidth=2 expandtab - autocmd BufWritePre *.nix %s/\s\+$//e | retab - autocmd BufWritePost *.nix silent! execute '!alejandra -qq %' | edit - ''; - extraLuaConfig = '' - -- Define and register :NixSortIncludes to sort selected Nix includes - vim.api.nvim_create_user_command('NixSortIncludes', function() - -- Get the start and end lines of the visual selection - local start_line = vim.fn.line("'<") - 1 - local end_line = vim.fn.line("'>") - - -- Get the lines from the current buffer - local lines = vim.api.nvim_buf_get_lines(0, start_line, end_line, false) - - -- Function to extract path for sorting - local function extract_path(line) - local cleaned = line - cleaned = cleaned:gsub("^%s*%(", "") -- remove leading '(' - cleaned = cleaned:gsub("^import%s+", "") -- remove 'import' - cleaned = cleaned:gsub("%s+%b{}", "") -- remove '{...}' - cleaned = cleaned:gsub("^%s+", "") -- trim leading spaces - cleaned = cleaned:gsub("%)+%s*$", "") -- remove trailing ')' - return cleaned - end - - -- Sort lines using the extracted path - table.sort(lines, function(a, b) - return extract_path(a) < extract_path(b) - end) - - -- Replace lines in the buffer - vim.api.nvim_buf_set_lines(0, start_line, end_line, false, lines) - end, { range = true }) + lua << EOF ''; }; }