neovim: slice 2 plugins — which-key, gitsigns, oil, nvim-ufo, direnv (#19) #25
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-19-nixvim-slice-2-plugins"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements the slice-2 proposal from issue #19 (comment id 441) — the five plugins rpickler named, for testing. Follows #21 which merged.
New files under
users/modules/neovim/plugins/(all option names verified against the nixvim rev pinned inflake.lock,5b912bd8):which-key.nix— bare enable; auto-labels the slice-1gd/gr/<leader>ca… keymaps via theirdesc.gitsigns.nix— enable + keymaps:]c/[chunk nav,<leader>gsstage,<leader>grreset,<leader>gppreview,<leader>gbblame.current_line_blameleft off for now (on-demand blame via<leader>gb).oil.nix— oil as default file explorer (default_file_explorer = true), columnspermissions/icon/size/type/git,<leader>e→:Oil --float,<leader>E→:Oil. Plusoil-git-statusfor git markers (its module sets the requiredwin_options.signcolumn = "yes:2"default itself).nvim-ufo.nix— folds:opts.foldmethod = "expr"+foldexpr = "v:lua.vim.ufo.foldexpr()", unfolded at start (foldenable = false,foldlevel = 99,foldcolumn = "1");provider_selectorwithnix/vim = "indent"fallbacks;zR/zM/zr/zm/zpufo keymaps. Module'ssetupLspCapabilitiesstays on (wires LSP foldingRange).direnv.nix—auto = 1,silent_load = 1,edit_mode = "edit"(the by-name module wraps direnv-vim; 0/1 flags).Edits to existing files:
plugins/default.nix— imports the five new modules.plugins/snacks/default.nix—foldnav.enabled = false: snacks'zA/zo/zc/zR… keymaps overlap ufo's; ufo's README asks other fold plugins to release them.default.nix—direnvCLI added toextraPackages(the module pulls the Vim plugin but not the binary:DirenvExportneeds).Deliberately not included, per your feedback: conform/format-on-save, smear-cursor, nabla, yanky. Formatting stays manual via
<leader>cf.Note: oil's own
<C-h>insert-mode mapping is left at its default (parent-dir) — didn't override it. Not build-verified from my side (no nix here); your rebuild is the real test. Iffoldcolumn = "1"bugs you, delete that one line innvim-ufo.nix.Closes #19? No — keeping #19 open for future slices per the thread.
@ -0,0 +10,4 @@settings = {# nix has no reliable lsp/treesitter folding ranges — indent is the# plugin README's fallback for such filetypes.provider_selector.__raw = ''Something wrong with this function:
@ -0,0 +11,4 @@};keymaps = [{These first two keymaps are causing errors when starting neovim.
Lua's prefixexp grammar does not allow subscripting a table literal directly: 'return { ... }[filetype]' fails to compile ('end expected ... near ['), which is what broke init.lua (luap error at 88:3). Bind the map to a local first, then index it — the pattern from the plugin's README. Verified against the Lua 5.1 reference parser ('end expected near [' on the old form, clean compile on the new one); runtime behaviour is unchanged (nix/vim -> indent, git -> '', others -> nil).Fixed in
0e383f6— you were right, the function itself was broken.Root cause: Lua's grammar does not allow indexing a table constructor inline.
return { nix = "indent", ... }[filetype]is not a valid expression (prefixexpcan't be a{ ... }literal followed by a subscript), so the parser aborts at the[, gives up trying to close thereturn, and cascades into theexpected end/expected }errors you saw. The plugin README uses a bound local for exactly this reason; my one-liner shortcut was the bug.Fix (matches the README pattern):
Verified: compiled both forms against the Lua 5.1 reference parser — the old form fails with
'end' expected (to close 'function') near '['(same failure as your init.lua error), the new form compiles clean. Runtime behaviour is unchanged:nix/vim→"indent",git→"", other filetypes →nil(ufo falls through to its default providers).Also swept the rest of the slice for the same pattern — the only other
__rawLua in these files are barerequire('ufo').*/require('gitsigns').*references, no inline-subscript constructs anywhere else.Closing the loop: PR is merged with both review points settled.
provider_selector(review onnvim-ufo.nix): fixed in0e383f6— the bound-localftMapform from the plugin README; merged as-is on main.]c/[ckeymaps (review ongitsigns.nix): settled by87a65911— left commented out on main (and kept commented out on the slice-3 branch in PR #28), so startup is clean and gitsigns keeps its own default nav maps.Nothing outstanding on this PR.