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
Error message "[Comment.nvim] nil" when plugin is used with vim.pack #517
I am experimenting with moving from Lazy to the new vim.pack plugin manager in Neovim nightly. Looks mostly OK, but I may be configuring Comment.nvim incorrectly. When using key bindings like gcc, all I get is the error message "[Comment.nvim] nil", which is not too helpful in itself.
How does one correctly configure this plugin for vim.pack? The following does not seem to work:
Oh. I did not consider that this might be an issue with the nightly Neovim build in general. I experienced the problem for the first time after I started my vim.pack tests.
Reacted by Michele Esposito Marzino (a.k.a. alexolegovich) and Johann Chang (Jhang)
I also started getting this after I upgraded to Nvim 0.12. I don't think #518 is a good solution, as it just avoids using tree-sitter for the commenting logic, which is not ideal. The real problem (in my case at least) was that tree-sitter broke when I upgraded from 0.11 to 0.12.
To fix tree-sitter, I had to move the nvim-treesitter plugin from the master branch to the main branch. The code in master is compatible with Nvim < 0.12 only, and the code in main is for 0.12. Unfortunately the configuration for the main branch changed in an incompatible way. This is what I found to work for me:
In addition, the version in main requires a fairly recent version of the tree-sitter-cli tool to be installed. I took care of this by running:
cargo install --locked tree-sitter-cli
With this, comments started to work again, including the trickier cases like jsx/tsx files, which rely on tree-sitter contextual information to provide the correct commenting style.
In my previous configuration I relied on the auto_install feature to ensure there was always a tree-sitter parser available. It does not appear to be a similar option for the most recent version of the plugin, so it is important to make sure all the languages that you need are explicitly loaded.
Sadly, the nvim-treesitter repository has been archived just a couple of days ago, and I'm not sure what to do about that. But for the time being everything seems to work.
I hope this helps others with the same issue!
Reacted by L1Q, Adiel Emilson, Cyber Falcon, Antonio Gutierrez, Michele Esposito Marzino (a.k.a. alexolegovich) and Ernesto Chavez Sanchez
Reacted by L1Q, Adiel Emilson, Cyber Falcon, Antonio Gutierrez, mlorenc227 and Khalid H. Ahmed
I don't think #518 is a good solution, as it just avoids using tree-sitter for the commenting logic, which is not ideal
Saying something is not a good solution just because it doesn't solve your particular problem is a bit rough, don't you think? Comment.nvim supports not only languages that are supported by tree-sitter. There is a ton of languages which do not have a tree-sitter parser. That "not good solution" makes it work in such cases.
@faergeek I wouldn't worry about the "not a good solution" comment. Your fix resolved my immediate issue, which is undoubtedly a good thing. I also believe in the old adage that perfect should not be allowed to stand in the way of good.
@faergeek apologies, my choice of words was terrible, and I had no intention to offend anyone. Your solution is good, as it is the only way to make things work when you do not have a tree-sitter grammar installed for your language.
@LongYinStudio Now I have to ask: Did you even read the comments in this issue? The reason behind this problem is quite clear, and @faergeek made a fix available three weeks ago. I can see no mystery here.
I have nvim 0.12.3 it doesn't work. I have lazy with zero config just basic setup. It just gives a warning "nil" with nothing else. I think it used to work on nvim 0.12 until recently. Either upgrading this plugin or going from 0.12 to 0.12.3 broke something but nothing works on my side.
I have treesitter main branch with proper config, reinstalled every treesitter parser etc.
I have some languages configured with this plugin:
language
works
elixir
nil
erlang
nil
gleam
nil
go
yes
javascript
nil
lua
nil
python
nil
rust
nil
sh
nil
typescript
nil
yaml
nil
The plugin doesn't load automatically when nvim starts, to start the plugin I run:
:lua require('Comment').setup()
Once the plugin is loaded I can use it with .go files, but the rest of my configuration doesn't work.
Here's my full configuration:
require('Comment').setup(
{
---Add a space b/w comment and the linepadding=true,
---Whether the cursor should stay at its positionsticky=true,
---Lines to be ignored while (un)commentignore=nil,
---LHS of toggle mappings in NORMAL modetoggler= {
---Line-comment toggle keymapline='<leader>c',
---Block-comment toggle keymapblock='<leader>C',
},
---LHS of operator-pending mappings in NORMAL and VISUAL modeopleader= {
---Line-comment keymapline='<leader>c',
---Block-comment keymapblock='<leader>C',
},
---LHS of extra mappingsextra= {
---Add comment on the line aboveabove='gcO',
---Add comment on the line belowbelow='gco',
---Add comment at the end of lineeol='gcA',
},
---Enable keybindings---NOTE: If given `false` then the plugin won't create any mappingsmappings= {
---Operator-pending mapping; `gcc` `gbc` `gc[count]{motion}` `gb[count]{motion}`basic=true,
---Extra mapping; `gco`, `gcO`, `gcA`extra=true,
},
---Function to call before (un)commentpre_hook=nil,
---Function to call after (un)commentpost_hook=nil,
}
)
localft=require('Comment.ft')
ft.go= {'//%s', '//%s'}
ft.javascript= {'//%s', '/*%s*/'}
ft.yaml='#%s'ft.rust= {'//%s', '/*%s*/'}
ft.typescript= {'//%s', '/*%s*/'}
ft.elixir= {'#%s', '#%s'}
ft.erlang= {'%% %s', '%% %s'}
ft.gleam= {'//%s', '//%s'}
ft.lua= {'--%s', '--[[%s]]'}
ft.sh= {'#%s', '#%s'}
ft.python= {'#%s', '#%s'}
ft.haskell= {'--%s', '{-%s-}'}
I installed this plugin using the new package manager from nvim 0.12
Activity
babelfish commentedon Mar 20, 2026
I'm seeing the same thing while using lazy in neovim nightly.
rseichter commentedon Mar 20, 2026
Oh. I did not consider that this might be an issue with the nightly Neovim build in general. I experienced the problem for the first time after I started my vim.pack tests.
faergeek commentedon Mar 21, 2026
Seems like it's caused by this change in neovim: neovim/neovim@fd1e019
fix: take into account a `nil` returned by `get_parser`
rseichter commentedon Mar 21, 2026
@faergeek Thanks for the fix, it works for me.
miguelgrinberg commentedon Apr 5, 2026
I also started getting this after I upgraded to Nvim 0.12. I don't think #518 is a good solution, as it just avoids using tree-sitter for the commenting logic, which is not ideal. The real problem (in my case at least) was that tree-sitter broke when I upgraded from 0.11 to 0.12.
To fix tree-sitter, I had to move the nvim-treesitter plugin from the
masterbranch to themainbranch. The code inmasteris compatible with Nvim < 0.12 only, and the code inmainis for 0.12. Unfortunately the configuration for themainbranch changed in an incompatible way. This is what I found to work for me:{ 'nvim-treesitter/nvim-treesitter', lazy = false, branch = "main", build = ":TSUpdate", init = function() require('nvim-treesitter').install({ 'python', 'javascript', 'typescript', 'jsx', 'tsx', 'go', 'rust', 'html', 'css', 'lua', 'vim' }) end, },In addition, the version in
mainrequires a fairly recent version of thetree-sitter-clitool to be installed. I took care of this by running:With this, comments started to work again, including the trickier cases like jsx/tsx files, which rely on tree-sitter contextual information to provide the correct commenting style.
In my previous configuration I relied on the
auto_installfeature to ensure there was always a tree-sitter parser available. It does not appear to be a similar option for the most recent version of the plugin, so it is important to make sure all the languages that you need are explicitly loaded.Sadly, the nvim-treesitter repository has been archived just a couple of days ago, and I'm not sure what to do about that. But for the time being everything seems to work.
I hope this helps others with the same issue!
faergeek commentedon Apr 6, 2026
Saying something is not a good solution just because it doesn't solve your particular problem is a bit rough, don't you think? Comment.nvim supports not only languages that are supported by tree-sitter. There is a ton of languages which do not have a tree-sitter parser. That "not good solution" makes it work in such cases.
rseichter commentedon Apr 6, 2026
@faergeek I wouldn't worry about the "not a good solution" comment. Your fix resolved my immediate issue, which is undoubtedly a good thing. I also believe in the old adage that perfect should not be allowed to stand in the way of good.
miguelgrinberg commentedon Apr 6, 2026
@faergeek apologies, my choice of words was terrible, and I had no intention to offend anyone. Your solution is good, as it is the only way to make things work when you do not have a tree-sitter grammar installed for your language.
feat(comments): disabled Comment.nvim in favor of mini.comment
rseichter commentedon May 6, 2026
@LongYinStudio Downgrading to Neovim 0.11 is not an option, what with
vim.packonly being available in versions 0.12.0 and later. 😉rseichter commentedon May 6, 2026
@LongYinStudio Now I have to ask: Did you even read the comments in this issue? The reason behind this problem is quite clear, and @faergeek made a fix available three weeks ago. I can see no mystery here.
vijay-git-hub3 commentedon May 18, 2026
@faergeek Is there a way you can also add fix for block commenting? Its still returning nil.
Its the only reason I haven't switched to mini.comment
faergeek commentedon May 18, 2026
@vijay-git-hub3 I've switched to mini.comment and I'm not really interested in fixing something I don't use anymore.
ilan-schemoul commentedon Jun 16, 2026
I have nvim 0.12.3 it doesn't work. I have lazy with zero config just basic setup. It just gives a warning "nil" with nothing else. I think it used to work on nvim 0.12 until recently. Either upgrading this plugin or going from 0.12 to 0.12.3 broke something but nothing works on my side.
I have treesitter main branch with proper config, reinstalled every treesitter parser etc.
4k1k0 commentedon Jul 4, 2026
My setup: nvim 0.12.3
I have some languages configured with this plugin:
The plugin doesn't load automatically when nvim starts, to start the plugin I run:
Once the plugin is loaded I can use it with .go files, but the rest of my configuration doesn't work.
Here's my full configuration:
I installed this plugin using the new package manager from nvim 0.12
Note: I already tried changing the timeoutlen setting.
Jouo commentedon Jul 19, 2026
@miguelgrinberg nvim-treesitter got unarchived yesterday, is the fix that you described part of a PR or something?
redvedev commentedon Jul 27, 2026
It works for lua files, but for python I get the error
darianmorat commentedon Aug 17, 2026
Found a workaround: using
load = function()in thevim.packspec and callingrequire("Comment").setup()there fixes the[Comment.nvim] nilerrorfix(nvim): fix Comment.nvim breaking on Neovim 0.12
ayoubelmhamdi commentedon Aug 23, 2026
A temporary solution is for any plugin fixed in the
PRand not merged yet: use forke repo and setting branchfrom PR pages:
{ "faergeek/Comment.nvim", branch = "nvim-0.12-compatibility", opts = {}, }lua: migrate to mini.comment
fix: take into account a `nil` returned by `get_parser`
fix(nvim): fix Comment.nvim breaking on Neovim 0.12
fix: take into account a `nil` returned by `get_parser`