This is a complete implementation of the current C3 grammar for tree-sitter, usable for syntax highlighting, indentation, folding, code analysis, header/doc generation, and more.
The latest version supports C3 0.7.1 and is not compatible with C3 < 0.7.0.
Check out the tree-sitter-c3 playground here: https://c3lang.github.io/tree-sitter-c3/
- In some cases, this grammar is less strict than the compiler.
- Tree structure and node naming is still subject to change.
https://github.com/c3lang/c3-ts-mode
- Install the nvim-treesitter plugin from the
main
branch - Run
:TSInstall c3
Right now there is a proposal for adding c3 language support, but there is still no support. To get started with c3 in helix editor:
- Add this to
languages.toml
:
[[grammar]]
name = "c3"
[grammar.source]
git = "https://github.com/c3lang/tree-sitter-c3.git"
rev = "main"
[[language]]
name = "c3"
scope = "source.c3"
file-types = ["c3", "c3i"]
roots = ["project.json"]
comment-token = "//"
language-servers = ["c3-lsp"] #if you want LSP support
[language.block-comment-tokens]
end = "*/"
start = "/*"
#LSP support
[language-server.c3-lsp]
command = "c3lsp"
- Run
hx -g fetch
, which will fetch all the grammars (you can exclude grammars withuse-grammars.only
oruse-grammars.except
inlanguages.toml
). - Run
hx -g build
(you need to havegcc
/clang
installed on your system and possiblygnumake
). - Add queries from
$XDG_CONFIG_HOME/helix/runtime/grammars/sources/c3/queries
to$XDG_CONFIG_HOME/helix/runtime/queries/c3
:
mkdir $XDG_CONFIG_HOME/helix/runtime/queries
cp -r $XDG_CONFIG_HOME/helix/runtime/grammars/sources/c3/queries $XDG_CONFIG_HOME/helix/runtime/queries/c3
- Now you can write
c3
in Helix Editor with highlighting and LSP support!