this is a tree-sitter grammer for the capy language
capy is in very early development, and as such is subject to heavy changes in terms of it's syntax. This code will most likely lack behind those changes somewhat.
clone this repository
follow the instructions from the tree-sitter website to install their cli
then run
tree-sitter init-config
and edit the "parser-directories" key in ~/.config/tree-sitter/config.json
to include the directory you cloned this repository into in step 1.
to see how a file would be syntax-highligthed run
tree-sitter highlight <your file>
to see the syntax tree tree-sitter generates for a file run
tree-sitter parse <your file>
after editing the grammar make sure to run
tree-sitter generate
and pray to Allah that there are no conflicts.
The syntax highlighting queries are stored in queries/highlights.sch
.
If you want to hack on them refer to the official syntax highligthing docs.
The grammer is stored in grammar.js
.
If you want to hack on that refer to the official parser docs.
first install nvim-tree-sitter, and make sure it is enabled, then add the following into your nvim config:
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.capy = {
install_info = {
url = "https://github.com/capy-language/tree-sitter-capy", -- local path or git repo
files = {"src/parser.c"},
branch = "pandora", -- default branch
generate_requires_npm = false,
requires_generate_from_grammar = false,
},
filetype = "capy", -- if filetype does not match the parser name
}
-- add the capy filetype
vim.filetype.add({
pattern = {
['(.*).capy'] = 'capy',
},
})
then - if you haven't already - clone the repo and link the queries
directory into your nvim runtime files
ln -s $REPO_DIR/queries/ ~/.config/nvim/queries/capy
finally open nvim and run :TSInstall
- clean up the grammar
- add tests
- fix highlighting of function parameters
- add missing highlihting queries
- add support for reflection in the grammar
- add vs-code support
- add support for locals
- add missing operation types
- review all the precedences for correctness