-
Notifications
You must be signed in to change notification settings - Fork 4
Highlighting in NeoVim
Alex LaFroscia edited this page Feb 28, 2021
·
2 revisions
This should cover how to use this package to highlight Handlebars files in NeoVim through their nvim-treesitter
project.
-
nvim-treesitter
installed as a plugin to your NeoVim installation - The
tree-sitter-glimmer
repository cloned to your computer
You can configure nvim-treesitter
with an additional grammar like so. Note that the following is Lua code; you can use Lua inside a VimScript file as shown here.
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.glimmer = {
install_info = {
url = "~/Code/tree-sitter-glimmer",
files = {
"src/parser.c",
"src/scanner.c"
}
},
filetype = "hbs",
used_by = {
"handlebars",
"html.handlebars"
}
}
Note that the url
should be a path to wherever you have the repository cloned to your computer.
nvim-treesitter
does not automatically discover highlighting configurations that are part of a manually-installed installed grammar.
The easiest option I've found is to create a queries/glimmer
directory inside your main NeoVim configuration folder (the location of your init.vim
) and then create a symlink from there to the highlights.scm
file in this repository
mkdir -p $DOTFILES/nvim/queries/glimmer
ln -s ~/Code/tree-sitter-glimmer/queries/highlights.scm $DOTFILES/nvim/queries/glimmer/
- Run
:TSUpdate glimmer
after pulling any new changes to the grammar to ensurenvim-treesitter
includes the latest changes