How to add unsupported language to kak-tree-sitter?

I’m trying out kak-tree-sitter, which works great with the languages it supports. However I wanted to add support for an unsupported language, QML. So, I followed the readme and tried adding the qml grammar and queries to my ~/.config/kak-tree-sitter/config.toml:

[language.qml.grammar]
source = { url = "https://github.com/yuja/tree-sitter-qmljs", pin = "master" }
path = "src"
compile = "npm install && cargo build --release"
link = ""

[language.qml.queries]
path = "queries"

However, when I do ktsctl sync qml, it says “no configuration for language qml”. What am I doing wrong?

i dont know if this will help, but i remember when i tried to add a tree-sitter grammar for luau (GitHub - tree-sitter-grammars/tree-sitter-luau: luau grammar for tree-sitter) and actually managed to get a successful result with the following snippet:

# luau
[language.luau.grammar.source.git]
url = "https://github.com/tree-sitter-grammars/tree-sitter-luau"
pin = "5b088fac748f2666a315cafd1638a214388eb23e"

[language.luau.grammar]
path = "src"
compile = "cc"
compile_args = ["-c", "-fpic", "../scanner.c", "../parser.c", "-I", ".."]
compile_flags = ["-O3"]
link = "cc"
link_args = ["-shared", "-fpic", "scanner.o", "parser.o", "-o", "luau.so"]
link_flags = ["-O3"]

[language.luau.queries.source.git]
url = "https://github.com/tree-sitter-grammars/tree-sitter-luau"
pin = "5b088fac748f2666a315cafd1638a214388eb23e"

[language.luau.queries]
path = "queries"

take this configuration with a grain of salt, as it was made >6 months ago and might be relying on some outdated constructs, but it seems to have a lot of elements that you are missing, so try and add a few options and see how it goes!

but remember, its always better to consult documentation! (~hadronized/kak-tree-sitter (master): docs/man/ - sourcehut git)

good luck with future work!

1 Like

Ah, I needed to add link_args = [], and my source needs to be nested in a git key. It seems that if the config is invalid it won’t recognize the language. The docs were a little unclear to me but I guess I should’ve looked at the default config more thoroughly. Anyway, thanks!

1 Like

I’ll update the docs, it should be clear to people why something is not working as expected. Also, the error message should be clearer.

Feel free to send a patch to add QML to the default config once you have something that works!