diff --git a/lyrathorpe/home/editor.nix b/lyrathorpe/home/editor.nix index 8e98a69..8f84c06 100644 --- a/lyrathorpe/home/editor.nix +++ b/lyrathorpe/home/editor.nix @@ -2,7 +2,7 @@ # tree, indent guides, fugitive, tmux-navigator, Catppuccin Mocha, 2-space hard # tabs, Jenkinsfile=groovy) plus a real LSP stack in place of the inert ALE. # Wanted on every host; vi/vim/$EDITOR all launch nvim. -{ inputs, ... }: +{ inputs, pkgs, ... }: { imports = [ inputs.nixvim.homeModules.nixvim ]; @@ -16,6 +16,17 @@ # warn that its pinned nixpkgs was overridden by the input `follows`. nixpkgs.source = inputs.nixpkgs; + # Formatter binaries for conform-nvim (below), matching the repo's treefmt + # set. On nvim's PATH only. + extraPackages = with pkgs; [ + nixfmt + stylua + ruff + shfmt + prettier + gofumpt + ]; + globals.mapleader = " "; opts = { @@ -77,11 +88,52 @@ cmp = { enable = true; autoEnableSources = true; - settings.sources = [ - { name = "nvim_lsp"; } - { name = "buffer"; } - { name = "path"; } - ]; + settings = { + snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end"; + sources = [ + { name = "nvim_lsp"; } + { name = "luasnip"; } + { name = "buffer"; } + { name = "path"; } + ]; + }; + }; + + # Fuzzy finder (files / live grep / symbols); rg + fd are already on PATH. + telescope = { + enable = true; + extensions.fzf-native.enable = true; + }; + gitsigns.enable = true; # gutter signs, stage-hunk, blame + which-key.enable = true; # popup of pending keybindings (leader is Space) + trouble.enable = true; # project-wide diagnostics/quickfix list + lualine = { + enable = true; + settings.options.theme = "catppuccin"; + }; + comment.enable = true; # gc / gcc comment toggling + nvim-autopairs.enable = true; + treesitter-textobjects.enable = true; + luasnip.enable = true; # snippet engine (drives cmp's luasnip source above) + + # Format-on-save, mirroring the repo's treefmt set. Filetypes with no + # formatter here (e.g. terraform) fall back to the LSP formatter. + conform-nvim = { + enable = true; + settings = { + formatters_by_ft = { + nix = [ "nixfmt" ]; + lua = [ "stylua" ]; + python = [ "ruff_format" ]; + sh = [ "shfmt" ]; + markdown = [ "prettier" ]; + go = [ "gofumpt" ]; + }; + format_on_save = { + timeout_ms = 2000; + lsp_format = "fallback"; + }; + }; }; }; @@ -92,6 +144,30 @@ action = "NvimTreeToggle"; options.desc = "Toggle file tree"; } + { + mode = "n"; + key = "ff"; + action = "Telescope find_files"; + options.desc = "Find files"; + } + { + mode = "n"; + key = "fg"; + action = "Telescope live_grep"; + options.desc = "Live grep"; + } + { + mode = "n"; + key = "fb"; + action = "Telescope buffers"; + options.desc = "Buffers"; + } + { + mode = "n"; + key = "xx"; + action = "Trouble diagnostics toggle"; + options.desc = "Diagnostics list"; + } ]; # au BufNewFile,BufRead *Jenkinsfile setf groovy