Adding Spell Check To The Neovim Tree-Sitter Plugin
Introduction
These are my notes for adding spell check to new sections of my tree-sitter neopolitan plugin for neovim.
The key was to do this in queries/highlights.scm
((paragraph_first_word) @spell)
((word) @spell)Where these already existed:
(paragraph_first_word) @neo_paragraph_first_word
(word) @neo_paragraph_nth_wordthe tree-sitter plugin is currently set up so that each section type has to be added individually to use spell check. I'm not going to mess with that too much since the real goal is to make an LSP for neopolitan that is more robust.
Adding A New Section
-
The project is
workshop/tree-sitter-neopolitan -
Run
start-full-gen-and-test -
Create a new test in the
corpusdirectory by copying an existing one -
Start by creating a
choiceentry for the section in thegrammar.jsfile based on the name of the section type (e.g.endnote_section) -
Add the new section function in the main body of the
grammar.jsfile.(e.g. copy
p_sectionand replace thep_tokenin it with whatever the name of the new section is) -
Add the
$.NAME_tokenentry to the list ofexternalsin thegrammar.jsfile alphabetical order. -
Add a key for the token in the
TokenTypeofsrc/scanner.cc -
Follow the directions in the comments of
find_tokenin thesrc/scanner.ccfile. -
Follow the directions in the README.neo for how to install the update.
NOTE: You might have to use VS code to read the file because nvim might fight with the plugin until it's been fully re-installed/updated.