Skip to content

fix(parser): nil check before calling parse on treesitter parser#493

Closed
bumaociyuan wants to merge 1 commit intoOXY2DEV:mainfrom
bumaociyuan:fix-parser-nil-check
Closed

fix(parser): nil check before calling parse on treesitter parser#493
bumaociyuan wants to merge 1 commit intoOXY2DEV:mainfrom
bumaociyuan:fix-parser-nil-check

Conversation

@bumaociyuan
Copy link
Copy Markdown
Contributor

Summary

  • Add nil check for get_parser() result before calling :parse()
  • Fixes "attempt to index a nil value" error at parser.lua:153

Root Cause

When vim.treesitter.get_parser(buffer) returns nil, the code was still calling :parse(true) on the nil value, causing the crash.

Fix

Store the parser result in a variable, check for nil, then call :parse() only if parser exists.

Related Issue

Fixes #488

🤖 Generated with Claude Code

When get_parser returns nil, attempting to call :parse() on it causes
"attempt to index a nil value" error. This fixes issue OXY2DEV#488.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@OXY2DEV
Copy link
Copy Markdown
Owner

OXY2DEV commented Apr 18, 2026

The issue has been resolved, see e27dee8.

@OXY2DEV OXY2DEV closed this Apr 18, 2026
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.

🐞 Bug: Crashing with nvim v0.12.1

2 participants