Skip to content

fix(todo_comments): handle nil parser from get_parser on nvim 0.12#338

Merged
jfly merged 1 commit intonvimtools:mainfrom
r-vdp:fix/todo-comments-nil-parser
Apr 19, 2026
Merged

fix(todo_comments): handle nil parser from get_parser on nvim 0.12#338
jfly merged 1 commit intonvimtools:mainfrom
r-vdp:fix/todo-comments-nil-parser

Conversation

@r-vdp
Copy link
Copy Markdown
Contributor

@r-vdp r-vdp commented Apr 17, 2026

What does this PR do?

Since neovim/neovim#37276 (released in 0.12), vim.treesitter.get_parser() returns nil instead of throwing when no parser is installed for the language. The pcall in todo_comments therefore succeeds with parser == nil, and the subsequent parser:parse() errors with

attempt to index local 'parser' (a nil value)

on any buffer whose filetype has no treesitter grammar installed.

This PR makes the existing guard also bail out when parser is nil.

Checklist

  • If I'm adding a new builtin (linter, formatter, code action, etc.), I
    understand it should be contributed to
    nvimtools/none-ls-extras.nvim
    instead — N/A, bugfix to existing builtin
  • I've written tests for these changes — one-line nil guard, no test infra for this builtin

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 17, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e84960de-65d8-49e2-9a6d-3cf1308d4c04

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread lua/null-ls/builtins/diagnostics/todo_comments.lua Outdated
Since neovim/neovim#37276 (released in 0.12), vim.treesitter.get_parser()
returns nil instead of throwing when no parser is installed for the
language. The pcall therefore succeeded with parser == nil, and the
subsequent parser:parse() errored with "attempt to index local 'parser'
(a nil value)" on any buffer whose filetype has no treesitter grammar.

Drop the pcall and check the return value directly. Pass
`{ error = false }` so 0.11 also returns nil instead of throwing, on
0.12+ the option is ignored.
@r-vdp r-vdp force-pushed the fix/todo-comments-nil-parser branch from 30bced9 to 4f8d399 Compare April 18, 2026 17:45
Copy link
Copy Markdown
Collaborator

@jfly jfly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this locally with both neovim v0.11.6 and v0.12.0-nightly+1d776d9. Works great, thanks!

The CI failure is unrelated: #331

@jfly jfly merged commit e135361 into nvimtools:main Apr 19, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants