Neovim
Back to Development
NeovimIntermediate13 min

Neovim Treesitter: Syntax Highlighting, Code Folding, and Text Objects

Treesitter: The Syntax Engine

Replace regex-based highlighting with Treesitter's incremental parsing. Set up smart code folding, structural text objects, and context-aware navigation.

Neovim's Lua API means your editor config is a real program — not a pile of Vimscript variables. You get functions, loops, conditionals, and lazy loading for free.

By the end of this 13 min guide, you'll have a working Neovim setup and practical Neovim workflows you can use immediately.

Installing Parsers with :TSInstall

Install Neovim:

brew install neovim ripgrep
Tip: Verify the installation with neovim --version or neovim -V after installing.

Syntax Highlighting Configuration

Structure your config into modular files under lua/. Each file handles one concern: options, keymaps, plugins, autocmds.

Here's a foundational configuration to start with:

-- keymaps.lua
vim.keymap.set("n", "w", ":w", { desc = "Save" })
vim.keymap.set("n", "q", ":q", { desc = "Quit" })
vim.keymap.set("n", "e", ":NvimTreeToggle", { desc = "Toggle file tree" })

Code Folding & Indentation

With Neovim configured, these Neovim-specific workflows will save you time every day:

Pro tip: Don't try to adopt everything at once. Start with <leader>ff find files with Telescope and add more as it becomes habit.

Text Objects & Selection

Once you're comfortable with Neovim basics, these advanced techniques will transform your Neovim workflow:

Parser Issues & Missing Queries

Here are the most common Neovim issues and how to fix them:

Treesitter Mastery

Congratulations — you now have a solid Neovim foundation. Here's where to go next:

← PreviousObsidian Canvas: Visual Thinking with Infinite WhiteboardsNext →Neovim Snippets and Autopairs: Code Faster with Smart Expansion