Skip to content

Conversation

@Starslayerx
Copy link
Contributor

This update modernizes the plugin SUSTech-data/wildfire.nvim to ensure full compatibility with the latest nvim-treesitter, following its migration from the deprecated master branch to the new main branch and the removal of the ts_utils module.

🔧 Changes

  • Removed dependency on the deprecated nvim-treesitter.ts_utils module
  • Replaced ts_utils.get_node_at_cursor() with vim.treesitter.get_node()
  • Replaced ts_utils.get_vim_range() with vim.treesitter.get_node_range()
  • Replaced ts_utils.get_node_text() with vim.treesitter.get_node_text()
  • Added proper coordinate conversion from 0-based to 1-based indexing
  • Ensured compatibility with modern nvim-treesitter and Neovim 0.10+

The legacy master branch remains available for users on older Neovim or nvim-treesitter versions.
This main branch provides an updated, forward-compatible version for users who have migrated to the latest ecosystem.


💡 Suggestion for Maintainers — Create a main Branch

Since nvim-treesitter itself has transitioned to a main branch and deprecated legacy helpers, it would be helpful if this repository also provided a main branch for updated code.
This would allow:

  • master → legacy users (older Treesitter / Neovim)
  • main → modern Treesitter API users

Maintainers can create a new main branch directly on GitHub using the "Branch" button, or via Git locally if preferred.

Once the branch exists, this PR can be retargeted from mastermain before merging.


📦 Temporary Installation for Users

Until the main branch 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.

- 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
@fecet fecet requested a review from Copilot October 11, 2025 01:13
Copy link

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 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_utils functions 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.

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)
Copy link

Copilot AI Oct 11, 2025

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.

Suggested change
local node = require("nvim-treesitter.ts_utils").get_node_at_pos(0)
local node = vim.treesitter.get_node({ bufnr = 0 })

Copilot uses AI. Check for mistakes.
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
@fecet fecet self-requested a review October 14, 2025 10:03
@fecet
Copy link
Member

fecet commented Oct 14, 2025

Thanks!

@fecet fecet merged commit 918a187 into SUSTech-data:master Oct 14, 2025
3 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