Something went wrong. Try again.
Just some noodlings with tree sitter... somewhat useful but also ideas!
Something went wrong. Try again.
Files
- Emacs Lisp 100%
README.md
# Tree-sitter help for coders
This is some work in progress, but hopefully usable, tree-sitter based tools.
In JS mode and C mode:
* short cut key based lexical variable completion
In C mode additionally:
* internal and included functions are discovered and eldoc style info offered
* identifiers show their matching declaration from this source file
The README menu:
* [Using `nic-tsm`](#using_nic-tsm_with_C)
* [Configuring tree sitter](#configuring_tree-sitter)
* [Configuring `nic-tsm` for repeated use](#using_nic-tsm_a_lot)
<div id="using_nic-tsm_with_C"></div>
## Using nic-tsm with C
Once you have tree-sitter configured you can just load the `try-treesitter-stuff.el` file into Emacs:
```emacs-lisp
(load-file "try-treesitter-stuff.el")
```
Then open a C file and:
```
M-x nic-tsm-mode
```
You now have 3 tree-sitter enabled programming tools.
### Function declarations
If you place your cursor on a function call (of your own, this does
not work yet for built-in functions, like `malloc` or `strcmp`) then
`nic-tsm` will show you the function declaration for that function in
the echo area.
This is intended to be similar to the built-in Emacs `eldoc`.
### Identifier declarations
If you place your cursor on an indentifier that refers to a file
declaration, `nic-tsm` will find the declaration and show you in the
echo area.
Additionally it will record the position of the declaration so that
you can press `C-c g` to go to the definition. When you use the goto
definition, `nic-tsm` will `push-mark` so you can return to your
original position in the usual way (`C-u SPC`).
### Lexical identifier insertion
When inside a function, `nic-tsm` will read the lexically declared
variables and present a list of the nearest 9 of them them with an
associated short cut key to allow insertion of the identifier.
Thus, in the following code:
```c
int
func(int len, char *string) {
int twice_len = len * 2;
}
```
If you position the cursor on the blank line, `nic-tsm` will use the echo area to make 3 options ava…