Skip to content

Replace nvim-treesitter with Neovim 0.12 native Tree-sitter support#5

Merged
vmarlier merged 2 commits into
mainfrom
copilot/replace-nvim-treesitter-with-native-support
May 11, 2026
Merged

Replace nvim-treesitter with Neovim 0.12 native Tree-sitter support#5
vmarlier merged 2 commits into
mainfrom
copilot/replace-nvim-treesitter-with-native-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 11, 2026

nvim-treesitter is archived and was causing config breakage. Neovim 0.12 ships Tree-sitter natively, making the plugin redundant.

Changes

  • nvim/lua/plugins/core.lua — removed the entire nvim-treesitter plugin block
  • nvim/lua/config/treesitter.lua (new) — native Tree-sitter setup:
    • Auto-installs all 19 parsers on first run via vim.treesitter.language.install() (fires on VimEnter, non-blocking)
    • Enables highlighting per-buffer via FileType autocmd using vim.treesitter.start(); silently falls back to regex when no parser is available
    • Restores incremental selection keymaps (<C-space> expand, <bs> shrink) using vim.treesitter.incremental_selection
  • nvim/lua/config/index.lua — loads the new config.treesitter module
  • README.md — documents Neovim 0.12+ as minimum requirement; notes automatic parser installation

flash.nvim's flash.treesitter() continues to work unchanged — it calls Neovim's built-in Tree-sitter API directly.

-- Auto-installs missing parsers on first VimEnter
local function install_missing_parsers()
  for _, lang in ipairs(ensure_installed) do
    local already_loaded = pcall(vim.treesitter.language.require_language, lang, nil, true)
    if not already_loaded then
      pcall(vim.treesitter.language.install, lang)
    end
  end
end
Original prompt

Replace the archived nvim-treesitter plugin with Neovim 0.12's native Tree-sitter support. The migration should include:

Current Tree-sitter Setup

  • Plugin: nvim-treesitter v0.10.0 (archived, causing configuration issues)
  • Location: nvim/lua/plugins/core.lua (lines 272-346)
  • Features enabled: Syntax highlighting, indentation, incremental selection
  • Languages/Parsers: bash, diff, dockerfile, go, gomod, gosum, gowork, hcl, helm, json, lua, markdown, regex, terraform, yaml, typescript, tsx, javascript, dart, sql, json5

Required Changes

  1. Remove nvim-treesitter plugin from nvim/lua/plugins/core.lua

  2. Create native Tree-sitter configuration with auto-installation:

    • Automatically install all required parsers on first run
    • Support both initial setup and migration to another machine
    • No manual :TSInstall commands needed
  3. Migrate Tree-sitter features:

    • Syntax highlighting (already works natively)
    • Indentation support (already works natively)
    • Incremental selection keymaps (<C-space> and <bs>)
  4. Update dependent plugins:

    • flash.nvim uses Tree-sitter for navigation (line 35 in motion.lua) - ensure compatibility
    • Verify nvim-ufo, nvim-cmp, and lualine work with native Tree-sitter
  5. Update README.md to reflect:

    • Neovim version 0.12.0+ requirement
    • Remove nvim-treesitter from plugins list
    • Document native Tree-sitter usage

Goals

  • ✅ Automatic parser installation on first run
  • ✅ No manual setup required when migrating to another laptop
  • ✅ Drop-in replacement for nvim-treesitter
  • ✅ Maintain all current Tree-sitter functionality
  • ✅ Update Neovim version in README to 0.12.0

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: I am currently using nvim-treesitter in my neovim configuration. However, there was some changes lately, the nvim-treesitter plugin has been archived and it messed up my configuration.

I heard that neovim 0.12 is now shipping treesitter as a native feature, I want to adapt my current configuration to replace nvim-treesitter.
Can you describe what I need to do ?

@vmarlier/dotfiles/files/nvim

Assistant: I'll analyze your current nvim configuration to understand how you're using nvim-treesitter and help you migrate to Neovim's native treesitter support.

Assistant: Let me fetch the directory contents to explore your nvim configuration:

Assistant: Based on my analysis of your neovim configuration, here's what you need to do to migrate from nvim-treesitter to Neovim 0.12's native Tree-sitter support:

Migration Strategy

1. Update Your Neovim Version

First, ensure you're on Neovim 0.12 or later. You're currently using 0.11.0 according to your README, so upgrade via ASDF:

asdf install neovim 0.12.0  # or latest
asdf global neovim 0.12.0

2. Remove nvim-treesitter Plugin

In your nvim/lua/plugins/core.lua (lines 272-346), you need to remove the entire nvim-treesitter plugin block. This plugin becomes unnecessary with native Tree-sitter support.

3. Move Tree-sitter Configuration to init.lua

Create a native Tree-sitter configuration. Add this to your nvim/lua/config/options.lua or create a new config file:

-- Tree-sitter configuration for Neovim 0.12+
vim.treesitter.language.register('markdown', 'mdx')  -- If needed
vim.treesitter.language.register('bash', 'sh')       -- Alias bash to sh

-- Highlight configuration
if vim.treesitter.highlighter then
  vim.treesitter.highlighter.start()
end

4. Update TSInstall Commands

Replace nvim-treesitter's :TSInstall with Neovim's built-in approach. Tree-sitter parsers are now managed via:

-- Use this in a command or mapping
:TSInstall <language>
-- or
vim.treesitter.language.register('language', 'parser-name')

5. Replace Incremental Selection Keymaps

Your current keymaps for incremental selection (lines 286-289) depend on nvim-treesitter. Neovim 0.12+ provides native incremental selection. Update your nvim/lua/config/mappings.lua with:

vim.keymap.set("x", "<C-space>", function()
  -- Builtin incremental selection
  require('vim.treesitter.incremental_selection').init_selection_ns("")
end, { noremap = true })

vim.keymap.set("x", "<bs>", function()
  require('vim.treesitter.incremental_selection').node_decremental("")
end, { noremap = true })

6. Handle Ensure_installed Languages

Tree-sitter parsers in Neovim 0.12+ need to be pre-installed. You have two options:

Option A: Manual installation

nvim --headless "+TSInstall bash dockerfile go json lua markdown terraform yaml typescript tsx javascript sql dart" +qa

Option B: Create an auto-install utility in your config to handle it on startup.

7. Update Dependent Plugins

Check which plugins depend on nvim-treesitter and update them:

  • nvim-ufo (folding) - may need updates for native Tree-sitter
  • `nvim-c...

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Remove nvim-treesitter and integrate Neovim native Tree-sitter Replace nvim-treesitter with Neovim 0.12 native Tree-sitter support May 11, 2026
Copilot AI requested a review from vmarlier May 11, 2026 11:45
@vmarlier vmarlier marked this pull request as ready for review May 11, 2026 11:45
Copilot stopped work on behalf of vmarlier due to an error May 11, 2026 11:55
@vmarlier vmarlier merged commit 564a224 into main May 11, 2026
1 check failed
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