Skip to content

The init.lua file

Tree-sitter is a parsing tool/library that improves syntax highlighting in Neovim.

Tree-sitter comes built-in with Neovim, and is relatively easy to configure.

Configuring Tree-sitter

Add the following code to your configuration, e.g. in your init.lua or in lua/treesitter=setup.lua:

-- .config/nvim/lua/plugins/treesitter-setup.lua
require("nvim-treesitter.configs").setup({
-- A list of parser names, or "all" (the five listed parsers should always be installed)
ensure_installed = { "c", "lua", "vim", "vimdoc", "query" },
-- enable syntax highlighting
highlight = {
enable = true
}
})

Replace the languages in ensure_installed with the relevant languages you need. The full list of languages and additional configuration options are available here.

Tree-sitter and Colorschemes

When picking a Neovim colorscheme, ensure that it’s tree-sitter supported/compatible — Awesome Neovim provides a list of themes which you can use.

There is more information on setting up themes in the colorscheme section.