Warning This currently just a proof-of-concept, and isn't stable yet.
A Tree-sitter server that keeps parsed ASTs in memory. This is useful for generalizing plugins that want to query the AST. Highlighting and structural selections are two main motivating examples.
The package does not install a configuration file automatically. So you must put one wherever you like and tell the plugin where that configuration file is:
set-option global tree_sitter_config <path_to_your_config>
Then, in buffers where you want to use tree-sitter.kak
, call tree-sitter-enable-buffer
. Furthermore,
if you want to enable highlighting, you should remove the default highlighters. For example, for rust:
hook buffer BufSetOption filetype=rust %{
rmhl window/rust
tree-sitter-enable-buffer
}
The configuration file currently only controls highlights, and maps tree-sitter captures to kakoune's faces.
For example, from config/config.toml
:
[language.rust.faces]
attribute = "meta"
comment = "comment"
function = "function"
keyword = "keyword"
operator = "operator"
string = "string"
type = "type"
type-builtin = "type"
constructor = "value"
constant = "value"
constant-builtin = "value"
The captures are defined in the languages query file, which are currently shipped with the library instead of being configurable.
Currently, only rust is supported. Other languages are easy to add though, adding them as a dependency
in the Cargo.toml
file and matching against them in languages/mod.rs
.
- add more languages
- make the query files configurable
- autoload the default config
- add commands for querying the AST
- add documentation for commands & requests
- remove
new_buffer
andset_language
commands, and send language along with buffer information forparse_buffer
. if the buffer doesn't exist, it should just be created. this will simplify the request logic and make it more robust.