Giter Site home page Giter Site logo

tree-sitter.kak's Introduction

tree-sitter.kak

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.

Highlighting Demo

asciicast

Usage

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
}

Configuration

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.

Supported Languages

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.

TODO

  • 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 and set_language commands, and send language along with buffer information for parse_buffer. if the buffer doesn't exist, it should just be created. this will simplify the request logic and make it more robust.

tree-sitter.kak's People

Contributors

enricozb avatar

Stargazers

Florian Gaeremynck avatar  avatar Michael P. Manti avatar Ivan Oleynikov avatar  avatar Rosario Pulella avatar  avatar Carlo Jeske avatar Gianni Chiappetta avatar Andy Shevchenko avatar  avatar Evan Relf avatar Jujo avatar LordCasser avatar  avatar Daniel Lewan avatar Vladimir Bauer avatar Taupiqueur avatar Cem Aksoylar avatar

Watchers

 avatar Rosario Pulella avatar Jujo avatar

Forkers

gepau gnull

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.