mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-15 18:00:07 -04:00
Expose internal api.
- add `exposed_state` to expose 'current_node' and 'cursor_pos' for a current buffer to the user. - add `get_buf_state` and `get_node_api` for users. - add documentation about api functions. - remove `node_movement` module which should be done in user side.
This commit is contained in:
parent
5a66c38b9f
commit
8be2dc64a2
7 changed files with 108 additions and 108 deletions
25
README.md
25
README.md
|
|
@ -102,16 +102,6 @@ require'nvim-treesitter.configs'.setup {
|
|||
scope_decremental = "grm", -- decrement to the previous scope
|
||||
}
|
||||
},
|
||||
node_movement = { -- allows cursor movement in node hierarchy
|
||||
enable = true,
|
||||
disable = { 'cpp', 'rust' },
|
||||
keymaps = { -- mappings for scope movement (normal mappings)
|
||||
parent_scope = "<a-k>", -- default is to move with alt key hold
|
||||
child_scope = "<a-j>",
|
||||
next_scope = "<a-h>",
|
||||
previous_scope = "<a-l>",
|
||||
}
|
||||
},
|
||||
ensure_installed = 'all' -- one of 'all', 'language', or a list of languages
|
||||
}
|
||||
EOF
|
||||
|
|
@ -136,12 +126,25 @@ Some of these features are :
|
|||
- [x] Incremental selection
|
||||
- [ ] Syntax based code folding
|
||||
- [x] Consistent syntax highlighting (the api is not quite stable yet)
|
||||
- [x] Cursor movement in scope hierachy
|
||||
- [x] Statusline indicator (`require'nvim-treesitter'.statusline(size)`)
|
||||
|
||||
You can find the roadmap [here](https://github.com/nvim-treesitter/nvim-treesitter/projects/1).
|
||||
The roadmap and all features of this plugin are open to change, and any suggestion will be highly appreciated!
|
||||
|
||||
## Api
|
||||
|
||||
Nvim-treesitter exposes an api to extend node capabilites. You can retrieve the api like this:
|
||||
```lua
|
||||
local ts_node_api = require 'nvim-treesitter'.get_node_api()
|
||||
```
|
||||
|
||||
You can also retrieve the current state of the current buffer with:
|
||||
```lua
|
||||
local buf_state = require'nvim-treesitter'.get_buf_state()
|
||||
```
|
||||
|
||||
More information is available in neovim documentation (`:help nvim-treesitter-api`).
|
||||
|
||||
## Supported Languages
|
||||
|
||||
For treesitter to work, we need to use query files such as those you can find in `queries/{lang}/{locals,highlights}.scm`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue