You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Comment.nvim throws [Comment.nvim] nil when using vim.pack #530
I am using Neovim's built-in vim.pack to install and load Comment.nvim.
The default gcc mapping works correctly, including for Zsh files. However, when I configure custom keymaps through toggler, opleader, or vim.keymap.set(), commenting fails with:
opleader = {
line = "<C-\\>",
block = "<leader>\\",
},
})
The default mapping:
gcc
works correctly on the same Zsh file.
I also verified that the Zsh filetype and commentstring are correct:
:set filetype?
filetype=zsh
:set commentstring?
commentstring=# %s
I tried configuring the Zsh commentstring explicitly:
local ft = require("Comment.ft")
ft.set("zsh", "#%s")
but this does not resolve the error.
I also tried creating the mapping manually with vim.keymap.set() and encountered the same:
[Comment.nvim] nil
Therefore, the issue does not appear to be related to the Zsh filetype or its commentstring. The default gcc mapping works, while custom mappings consistently trigger the error.
Custom mappings configured through toggler, opleader, or vim.keymap.set() should work in the same way as the default gcc mapping.
Is there a known compatibility issue with custom mappings when Comment.nvim is loaded using Neovim's vim.pack? What is the recommended configuration or workaround?
I ran into the same issue in tmux config file. Looks like this repo isn't maintained anymore, so I spent some time trying out a few alternatives, figured I'd share this in case it helps you:
Just drop the plugin, since Neovim now has built-in line commenting (e.g. gc, gcc) and also supports treesitter-based commentstring parsing. I tried it out and it works realy great -- only downside is it doesn't support block comments (e.g. gb, gbc), and it skips empty lines when commenting. See :help commenting
Use mini.comment -- pretty much the same as Neovim's bulit-in, but it can comment out empty lines. However, no block comment support either.
Use celeste_comment.nvim, supports both gc, gb and it's actively maintained.
Activity
0xEFFF commentedon Sep 5, 2026
I ran into the same issue in tmux config file. Looks like this repo isn't maintained anymore, so I spent some time trying out a few alternatives, figured I'd share this in case it helps you:
nilreturned byget_parser#518:gc,gcc) and also supports treesitter-basedcommentstringparsing. I tried it out and it works realy great -- only downside is it doesn't support block comments (e.g.gb,gbc), and it skips empty lines when commenting. See:help commentingmini.comment-- pretty much the same as Neovim's bulit-in, but it can comment out empty lines. However, no block comment support either.celeste_comment.nvim, supports bothgc,gband it's actively maintained.