dot

NixOS dotfiles
git clone https://git.echoz.io/dot.git
Log | Files | Refs

commit 2cd468eb23940bc421a7b57c7e6e6e18edeeef06
parent 457ba5e3fcb0ac0ae8a7b7b4cd33ff20917ebc97
Author: Chris <chris@echoz.io>
Date:   Fri, 28 Nov 2025 04:24:51 +0100

feat(neovim): add some key binds and install treesitter grammars

Diffstat:
Mmodules/neovim/cheat-sheet.txt | 2++
Mmodules/neovim/default.nix | 22++++++++++++++++++----
Mmodules/neovim/lua/code.lua | 3+++
3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/modules/neovim/cheat-sheet.txt b/modules/neovim/cheat-sheet.txt @@ -1,6 +1,8 @@ i C-x C-o Omni completion n K Hover n,v C-w d Hover diagnostics +n,v C-w a All diagnostics +n,v gqb Format buffer n,v gra Code action n gri Go to implementation n grt Go to type definition diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix @@ -4,7 +4,7 @@ ... }: let - runtime = luaRuntime // lspRuntime // ftpluginRuntime; + runtime = luaRuntime // lspRuntime // ftpluginRuntime // treesitterRuntime; initLua = generateInitLua runtime { cheat-sheet.file = ./cheat-sheet.txt; @@ -22,6 +22,7 @@ let "flake.nix" ".git" ]; + settings.nixd.formatting.command = [ (lib.getExe pkgs.nixfmt-rfc-style) ]; }; gopls = { @@ -80,6 +81,20 @@ let }; }; + treesitterRuntime = + let + grammars = pkgs.symlinkJoin { + name = "neovim-grammars"; + paths = lib.mapAttrsToList (_: grammar: pkgs.neovimUtils.grammarToPlugin grammar) ( + lib.filterAttrs (_: lib.isDerivation) pkgs.tree-sitter-grammars + ); + }; + in + { + parser.source = grammars + "/parser"; + queries.source = grammars + "/queries"; + }; + generateLspRuntime = lsps: (lib.mapAttrs' (name: config: { @@ -90,15 +105,14 @@ let "lua/lsp.lua".text = '' local M = {} function M.setup() - vim.lsp.enable(${lib.generators.toLua { indent=" "; } (builtins.attrNames lsps)}) + vim.lsp.enable(${lib.generators.toLua { indent = " "; } (builtins.attrNames lsps)}) end return M ''; }; importLuaDir = - prefix: - path: + prefix: path: lib.pipe (builtins.readDir path) [ (lib.mapAttrs' ( name: type: { diff --git a/modules/neovim/lua/code.lua b/modules/neovim/lua/code.lua @@ -12,6 +12,9 @@ function M.setup() vim.lsp.completion.enable(true, client.id, bufnr, {}) end, }) + + vim.keymap.set({ 'n', 'v' }, 'gqb', vim.lsp.buf.format) + vim.keymap.set({ 'n', 'v' }, '<C-W>a', vim.diagnostic.setloclist) end return M