Treesitter
This configuration uses the new nvim-treesitter API, where syntax highlighting is enabled per filetype using ftplugin.
Treesitter is not started globally. Instead, it is explicitly activated when a buffer with a supported filetype is opened.
Adding a new language (parser)
To add support for a new Treesitter language parser:
-
Open the following file:
./lua/okivim/plugins/treesitter.lua -
Add the language name to the
treesitter.install({ ... })list.Example:
treesitter.install({
-- ...
"go",
}) -
Install or update the parsers:
- Run
:TSUpdate, or - Restart Neovim if your setup installs parsers automatically.
- Run
You can find the full list of officially supported Treesitter languages here:
https://github.com/nvim-treesitter/nvim-treesitter/blob/main/SUPPORTED_LANGUAGES.md
Enabling Treesitter for a filetype (ftplugin)
Treesitter is activated per filetype using Neovim’s ftplugin mechanism.
To enable Treesitter for a given filetype, create a file at:
./ftplugin/<filetype>.lua
Example:
./ftplugin/go.lua
With the following minimal content:
vim.treesitter.start()
Common examples
./ftplugin/typescriptreact.lua(for.tsxfiles)./ftplugin/javascriptreact.lua(for.jsxfiles)./ftplugin/python.lua
You can use any existing file in ftplugin/ as a template.
Simply duplicate it and rename the file to match the new filetype you want to support.
Verifying the filetype
To check which filetype Neovim is using for the current buffer, run:
:set ft?
The returned value (for example, typescriptreact) must match the filename used in ftplugin/.
Summary
To add support for a new language in Treesitter:
- Add the language to
treesitter.install()in:./lua/okivim/plugins/treesitter.lua - Create a matching
ftplugin/<filetype>.luafile. - Call
vim.treesitter.start()inside that file.
This keeps the configuration simple, explicit, and aligned with modern Neovim practices.