-
Notifications
You must be signed in to change notification settings - Fork 14
Migrate from deprecated nvim-treesitter.ts_utils to built-in APIs (main branch compatibility) #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Remove dependency on nvim-treesitter.ts_utils module - Replace ts_utils.get_node_at_cursor() with vim.treesitter.get_node() - Replace ts_utils.get_vim_range() with vim.treesitter.get_node_range() - Replace ts_utils.get_node_text() with vim.treesitter.get_node_text() - Add proper coordinate conversion from 0-based to 1-based indexing - Ensure compatibility with modern nvim-treesitter versions
There was a problem hiding this 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 modernizes the wildfire.nvim plugin to be compatible with the latest nvim-treesitter by migrating away from the deprecated ts_utils module to built-in Neovim treesitter APIs.
- Replaces deprecated
ts_utilsfunctions with their built-in equivalents - Adds proper coordinate conversion from 0-based to 1-based indexing
- Updates treesitter parser access methods
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lua/wildfire/utils.lua | Migrates from ts_utils to built-in APIs and adds coordinate conversion logic |
| lua/wildfire/init.lua | Updates node selection and parser access to use modern treesitter APIs |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
lua/wildfire/init.lua
Outdated
| function M.init_selection() | ||
| count = vim.v.count1 | ||
| local node = ts_utils.get_node_at_cursor() | ||
| local node = require("nvim-treesitter.ts_utils").get_node_at_pos(0) |
Copilot
AI
Oct 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line still imports and uses the deprecated ts_utils module, contradicting the PR's goal of removing this dependency. Replace with vim.treesitter.get_node() to be consistent with the migration.
| local node = require("nvim-treesitter.ts_utils").get_node_at_pos(0) | |
| local node = vim.treesitter.get_node({ bufnr = 0 }) |
The previous migration incorrectly added +1 to end_col when converting from treesitter's 0-based exclusive indexing to vim's 1-based inclusive indexing. This caused selections to include an extra character on the right side. The correct conversion is: - start_row, start_col, end_row: 0-based -> 1-based (add +1) - end_col: 0-based exclusive == 1-based inclusive (no change needed) This fixes the bug where selecting text inside brackets/quotes would incorrectly include the closing bracket/quote character.
- Replace deprecated parsers.get_parser() with vim.treesitter.get_parser(buf) - Add buffer/column bounds validation in unsurround_coordinates() - Add cursor position clamping in update_selection() - Use pcall for safe API calls and graceful error handling - Fix E5108 crashes on blank lines and unsupported filetypes
|
Thanks! |
This update modernizes the plugin
SUSTech-data/wildfire.nvimto ensure full compatibility with the latestnvim-treesitter, following its migration from the deprecatedmasterbranch to the newmainbranch and the removal of thets_utilsmodule.🔧 Changes
nvim-treesitter.ts_utilsmodulets_utils.get_node_at_cursor()withvim.treesitter.get_node()ts_utils.get_vim_range()withvim.treesitter.get_node_range()ts_utils.get_node_text()withvim.treesitter.get_node_text()nvim-treesitterand Neovim 0.10+The legacy
masterbranch remains available for users on older Neovim ornvim-treesitterversions.This
mainbranch provides an updated, forward-compatible version for users who have migrated to the latest ecosystem.💡 Suggestion for Maintainers — Create a
mainBranchSince
nvim-treesitteritself has transitioned to amainbranch and deprecated legacy helpers, it would be helpful if this repository also provided amainbranch for updated code.This would allow:
master→ legacy users (older Treesitter / Neovim)main→ modern Treesitter API usersMaintainers can create a new
mainbranch directly on GitHub using the "Branch" button, or via Git locally if preferred.Once the branch exists, this PR can be retargeted from
master→mainbefore merging.📦 Temporary Installation for Users
Until the
mainbranch is available upstream, users can install the updated fork directly with Lazy.nvim:{ "Starslayerx/wildfire.nvim", branch = "main", event = "VeryLazy", dependencies = { "nvim-treesitter/nvim-treesitter" }, }This setup ensures both legacy and modern Neovim users can choose the version that best fits their environment — without breaking compatibility.
Thank you for maintaining
SUSTech-data/wildfire.nvim.This PR aims to simplify the transition for users upgrading to modern Treesitter while keeping backward compatibility for existing setups.