Skip to content

fix(#52): lazy setup tree-sitter related features#55

Merged
AbaoFromCUG merged 1 commit intomasterfrom
abao/fix_ts_setup_issue
Apr 20, 2026
Merged

fix(#52): lazy setup tree-sitter related features#55
AbaoFromCUG merged 1 commit intomasterfrom
abao/fix_ts_setup_issue

Conversation

@AbaoFromCUG
Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings April 20, 2026 14:50
@AbaoFromCUG AbaoFromCUG added the bug Something isn't working label Apr 20, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts Neopyter’s initialization flow to lazily set up tree-sitter-dependent functionality, aiming to avoid doing parser/query setup until a matching buffer is opened.

Changes:

  • Delay tree-sitter parser/query setup (and highlight/textobject/injection setup) until the first matching BufReadPost.
  • Expand :checkhealth neopyter tree-sitter reporting to include query setup status.
  • Update the repro example to explicitly load/configure nvim-treesitter before Neopyter.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
lua/neopyter.lua Moves tree-sitter-related setup behind a new delay_setup() invoked on first matching buffer read.
lua/neopyter/health.lua Updates health messages and adds checks for whether Neopyter tree-sitter queries are set up.
example/repro.lua Adjusts Lazy.nvim repro spec to ensure nvim-treesitter is loaded/configured ahead of Neopyter.
example/main.ju.py Minor example output text change.

Comment thread lua/neopyter/health.lua Outdated
Comment thread lua/neopyter.lua Outdated
Comment thread lua/neopyter.lua
Comment on lines +117 to +126
function neopyter.delay_setup()
if neopyter.delay_setuped then
return
end
neopyter.load_parser()
highlight.setup()
textobject.setup()
injection.setup()
neopyter.delay_setuped = true
end
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

neopyter.delay_setup() is now exported as part of the module API (it’s a non-local function on the returned table). If this is intended to be internal-only, mark it ---@nodoc and/or make it local to avoid committing to it as a supported public API surface.

Copilot uses AI. Check for mistakes.
Comment thread example/repro.lua
priority = 1001, -- make sure `nvim-treesitter` is loaded before `neopyter`
lazy = false,
config = function()
require('nvim-treesitter.configs').setup {
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

This file uses Stylua with quote_style = "AutoPreferDouble", but the new require('nvim-treesitter.configs') line introduces single quotes. Switch to double quotes to match the repo’s formatting settings and avoid unnecessary churn when running Stylua.

Suggested change
require('nvim-treesitter.configs').setup {
require("nvim-treesitter.configs").setup {

Copilot uses AI. Check for mistakes.
Comment thread lua/neopyter/health.lua Outdated
Comment on lines +30 to +33
if neopyter.parser[lang] then
health.ok(string.format("tree-sitter query: %s is set up", lang))
else
health.warn(string.format("tree-sitter query: %s is not set up; please setup neopyter after loading tree-sitter's parser", lang))
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

neopyter.parser is now initialized in delay_setup(), so it can be nil when users run :checkhealth neopyter before opening a matching buffer. Accessing neopyter.parser[lang] will then throw an error. Guard against neopyter.parser == nil (or call neopyter.delay_setup() before this check) so checkhealth never crashes.

Copilot uses AI. Check for mistakes.
@AbaoFromCUG AbaoFromCUG force-pushed the abao/fix_ts_setup_issue branch from 88938ce to d13c399 Compare April 20, 2026 14:59
@AbaoFromCUG AbaoFromCUG merged commit b95390d into master Apr 20, 2026
8 checks passed
@AbaoFromCUG AbaoFromCUG deleted the abao/fix_ts_setup_issue branch April 20, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants