Skip to content

Have parse! rely on non-nil returned parser to determine success#772

Open
seamusriordan wants to merge 2 commits intoOlical:mainfrom
seamusriordan:validate-ts-parse-bugfix
Open

Have parse! rely on non-nil returned parser to determine success#772
seamusriordan wants to merge 2 commits intoOlical:mainfrom
seamusriordan:validate-ts-parse-bugfix

Conversation

@seamusriordan
Copy link
Copy Markdown
Contributor

@seamusriordan seamusriordan commented May 5, 2026

I found the underlying vim.treesitter.get_parser function in tree-sitter.parse! was always returning true in the first return value even in failure. e.g.

true, nil 

with error (which is the final return value)

Parser could not be created for buffer 3 and language "DiffviewFiles"

When the call is successful I get something like

true, table: 0x010165a190

with returned error message of nil.

I was able to trigger the failure with the diffview plugin by editing a lisp file in a git repo, closing neovim and opening it without arguments (i.e. without opening any files), then invoking :DiffviewOpen. I believe in this scenario conjure is invoked because it is associated with one of the buffers, but it is trying to call parse! all buffers, one of which does not have a treesitter language registered.

This will have a followup PR for the tree-sitter completions to guard around failed parsing. I pulled this out separately as we've done general bug fixes like this in their own PRs.

@seamusriordan seamusriordan marked this pull request as ready for review May 5, 2026 09:23
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.

1 participant