emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tree-sitter integration on feature/tree-sitter


From: Theodor Thornhill
Subject: Re: Tree-sitter integration on feature/tree-sitter
Date: Sat, 07 May 2022 11:34:18 +0200

> Thanks!
>
>> - play with it
>
> Would you please suggest how to "play with it"?  What features to turn
> on and how, what commands and displays to try, etc.  Posting such
> instructions should allow all of us get to testing this branch much
> sooner and easier.

The easiest way to play with it is to use some provided major mode that
implements it.  I've made one here for golang, for reference:
https://git.sr.ht/~theo/dotfiles/tree/master/item/emacs/.emacs.d/lisp/go-mode.el.

This can easily be modified to use 'tree-sitter-c instead

To make this work you need the definition compiled and put on some path
that emacs can see.  The suggested one is LD_LIBRARY_PATH, and I start
emacs using something like this:

```
LD_LIBRARY_PATH=/home/theo/src/tree-sitter-module/dist 
/path/to/tree-sitter-enabled-emacs/src/emacs
```

This is using the scripts provided by Yuan Fu in the tree-sitter-modules
repo.  When the major mode is enabled, you can start querying the
document by using the provided functions, such as:

```elisp
(tree-sitter-node-start
  (tree-sitter-node-at (point) (point) 'tree-sitter-go))
```

`M-x tree-sitter-inspect-mode` shows what node you are on in the mode
line.  It helps with debugging.

By 'play with it', I guess we can implement folding, highlighting,
navigation, simple rename functionality, Imenu etc etc.

Hope this helps a little!

Theodor Thornhill



reply via email to

[Prev in Thread] Current Thread [Next in Thread]