惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
Google DeepMind News
Google DeepMind News
博客园 - 【当耐特】
量子位
博客园 - 司徒正美
爱范儿
爱范儿
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
Jina AI
Jina AI
J
Java Code Geeks
腾讯CDC
大猫的无限游戏
大猫的无限游戏
V
Visual Studio Blog
I
InfoQ
D
Docker
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
宝玉的分享
宝玉的分享
G
Google Developers Blog
GbyAI
GbyAI
Y
Y Combinator Blog
有赞技术团队
有赞技术团队
H
Help Net Security

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How to setup tree-sitter highlighters and parsers for Neovim
Neo Sahadeo · 2026-04-27 · via DEV Community

If you're reading this, you're probably trying to figure out how to move on after the travesty that was Apr 3, 2026 for nvim-treesitter.

This post will be a walk through on how to setup syntax highlighting for tree-sitter.

Prerequisites:

  • You will need the tree-sitter cli

Setting up Queries

Queries are the languages that contain the .scm files required to tell tree-sitter how to highlight code.

  1. The easiest way to install this is to make the queries directory in you nvim path, e.g. ~/.config/nvim/queries

After which clone the nvim tree-sitter repo and move the queries folder into the nvim/queries dir.

1.1 clone --depth=1 https://github.com/nvim-treesitter/nvim-treesitter

1.2 mv nvim-treesitter/runtime/queries ~/.config/nvim/

That should be that, most syntax should immediately work.
If certain files like .svelte are not working, you can try forcing tree-sitter to start. I'll use an autocommand to attach a callback during file type loads.

~/.config/nvim/init.lua

vim.api.nvim_create_autocmd('FileType', {
    pattern = { 'svelte', 'python', 'javascript', 'typescript', 'typescriptreact', 'rust', 'go', 'c', 'c++' },
    callback = function()
        vim.treesitter.start()
    end,
})

Enter fullscreen mode Exit fullscreen mode

If its still not working, you will have to install your language parser(s). Move on to how to install parsers below.

To read more about the queries read the docs NVIM TREESITTER QUERIES.

Install a Parser

The Neovim docs say that:

Parsers are searched for as parser/{lang}.* in any 'runtimepath' directory.

but I think that's a bit messy so I'll create a tree-sitter directory to install parsers.

2.1 mkdir ~/.local/share/tree-sitter/

Let's install the tsx parser to demonstrate how this process works.

Clone this typescript-treesitter repo into that dir.

2.2 git clone --depth=1 https://github.com/tree-sitter/tree-sitter-typescript ~/.local/share/tree-sitter/tree-sitter-typescript

Next, we need to build everything. You will need the tree-sitter cli. cd into the repo.

2.3.1 make

The output looks similar to this.

Make compile output

Next since this repo contains both the tsx and typescript parser, they to need to be built separately. Since typescript is most likely working, let's build tsx

cd into tsx and run the tree-sitter builder.

2.3.2 tree-sitter build

This will generate a parser.so file. Now the hard part is done and all we have to do is add it to nvim.

2.4.1

First we need to tell nvim about our parser.

~/.config/nvim/init.lua

vim.treesitter.language.add(
    'tsx',
    { path = '/home/neosahadeo/.local/share/tree-sitter/tree-sitter-typescript/tsx/parser.so' }
)

Enter fullscreen mode Exit fullscreen mode

2.4.2

Next we need to tell nvim what highlighter we want to load into the parser.

~/.config/nvim/init.lua

vim.treesitter.language.register('tsx', { 'typescriptreact' })

Enter fullscreen mode Exit fullscreen mode

This says that nvim should associate the tsx parser with the .tsx file. (The file type name is typescriptreact, to get the name just run :echo &filetype).

After this restart neovim and everything should just work.