nvim-treesitter-context/README.md

270 lines
5.7 KiB
Markdown
Raw Permalink Normal View History

2020-10-19 11:42:47 +02:00
# nvim-treesitter-context
2021-04-03 07:56:37 +02:00
Lightweight alternative to [context.vim](https://github.com/wellle/context.vim)
2020-10-19 11:42:47 +02:00
## Requirements
Neovim >= v0.9.0
Note: if you need support for Neovim 0.6.x please use the tag `compat/0.6`.
2020-10-19 11:42:47 +02:00
## Screenshot
2020-10-19 11:45:48 +02:00
![theme](./static/demo.gif)
2020-10-19 11:42:47 +02:00
## Supported Languages
2024-06-27 16:53:25 +02:00
Note: support for specific languages is strictly community maintained and can break from time to time as parsers are updated.
<details>
<summary>click to expand</summary
2020-10-19 11:42:47 +02:00
2024-01-08 11:44:31 +01:00
- [x] `apex`
- [x] `bash`
- [x] `c`
2023-04-04 18:31:27 +02:00
- [x] `c_sharp`
2023-05-07 11:11:20 +02:00
- [x] `capnp`
- [x] `clojure`
2023-08-18 11:28:43 +02:00
- [x] `cmake`
- [x] `cpp`
2023-04-28 17:24:21 +02:00
- [x] `css`
2023-05-08 04:48:45 +02:00
- [x] `cuda`
2023-11-17 18:00:00 +01:00
- [x] `cue`
2023-05-24 15:32:16 +02:00
- [x] `d`
- [x] `dart`
- [x] `devicetree`
2023-03-13 15:04:53 +01:00
- [x] `elixir`
2024-05-15 14:54:34 +02:00
- [x] `elm`
- [x] `fennel`
2023-11-21 10:33:31 +01:00
- [x] `fish`
2023-05-11 14:45:20 +02:00
- [x] `fortran`
2024-03-20 23:22:57 +01:00
- [x] `gdscript`
2023-06-13 18:15:54 +02:00
- [x] `glimmer`
2023-03-13 15:04:53 +01:00
- [x] `go`
2023-04-29 21:12:35 +02:00
- [x] `graphql`
- [x] `groovy`
- [x] `haskell`
- [x] `html_tags`
2023-04-28 17:24:21 +02:00
- [x] `ini`
- [x] `janet` (using the "janet_simple" grammar)
2023-03-13 15:04:53 +01:00
- [x] `java`
- [x] `javascript`
- [x] `json`
2023-09-30 19:00:00 +02:00
- [x] `jsonnet`
2023-09-26 17:06:56 +02:00
- [x] `julia`
2023-03-13 15:04:53 +01:00
- [x] `latex`
2023-10-04 02:10:53 +02:00
- [x] `liquidsoap`
2023-11-21 10:33:31 +01:00
- [x] `lua`
- [x] `markdown`
2023-05-01 17:12:21 +02:00
- [x] `matlab`
2023-09-23 20:39:16 +02:00
- [x] `nim`
2023-06-02 03:02:08 +02:00
- [x] `nix`
2023-05-11 14:45:20 +02:00
- [x] `norg`
- [x] `objdump`
2023-04-28 17:24:21 +02:00
- [x] `ocaml_interface`
- [x] `ocaml`
2023-08-20 00:49:10 +02:00
- [x] `odin`
- [x] `php`
2024-02-10 15:35:05 +01:00
- [x] `php_only`
2023-04-29 20:20:06 +02:00
- [x] `prisma`
2024-07-04 14:44:25 +02:00
- [x] `proto`
2023-03-13 15:04:53 +01:00
- [x] `python`
2023-03-20 01:38:48 +01:00
- [x] `r`
2024-04-13 16:58:37 +02:00
- [x] `ruby` (and `rspec`)
2023-03-13 15:04:53 +01:00
- [x] `rust`
- [x] `scala`
2023-04-28 17:24:21 +02:00
- [x] `scss`
- [x] `smali`
2023-11-21 10:33:31 +01:00
- [x] `solidity`
- [x] `svelte`
2023-04-28 17:24:21 +02:00
- [x] `swift`
2024-05-02 16:05:30 +02:00
- [x] `tact`
2023-09-01 15:12:18 +02:00
- [x] `tcl`
- [x] `teal`
- [x] `templ`
2023-03-08 15:24:54 +01:00
- [x] `terraform`
- [x] `toml`
- [x] `tsx`
2023-03-13 15:04:53 +01:00
- [x] `typescript`
- [x] `typoscript`
- [x] `usd`
2023-03-13 15:04:53 +01:00
- [x] `verilog`
- [x] `vim`
2024-02-20 02:08:33 +01:00
- [x] `vue`
2023-11-21 10:33:31 +01:00
- [x] `xml`
2023-03-13 15:04:53 +01:00
- [x] `yaml`
2023-11-21 10:33:31 +01:00
- [x] `yang`
2023-04-28 17:24:21 +02:00
- [x] `zig`
2024-09-14 17:42:31 +02:00
- [x] `ada`
- [ ] `agda`
- [ ] `arduino`
- [ ] `astro`
- [ ] `beancount`
- [ ] `bibtex`
- [ ] `bicep`
- [ ] `blueprint`
- [ ] `chatito`
- [ ] `clojure`
- [ ] `commonlisp`
- [ ] `cooklang`
- [ ] `cpon`
- [ ] `dhall`
- [ ] `dockerfile`
- [ ] `dot`
- [ ] `ebnf`
- [ ] `ecma`
- [ ] `eex`
- [ ] `elsa`
- [ ] `elvish`
- [ ] `embedded_template`
- [ ] `erlang`
- [ ] `fennel`
- [ ] `foam`
- [ ] `fsh`
- [ ] `func`
- [ ] `fusion`
- [ ] `gdscript`
- [ ] `git_rebase`
- [ ] `gleam`
- [ ] `glsl`
- [ ] `godot_resource`
- [ ] `gomod`
- [ ] `gosum`
- [ ] `gowork`
- [ ] `hack`
- [ ] `hcl`
- [ ] `heex`
- [ ] `hjson`
- [ ] `hlsl`
- [ ] `hocon`
- [ ] `html`
- [ ] `htmldjango`
- [ ] `http`
- [ ] `jq`
- [ ] `jsdoc`
- [ ] `json5`
- [ ] `jsonc`
- [ ] `jsx`
- [ ] `kdl`
- [ ] `kotlin`
- [ ] `lalrpop`
- [ ] `ledger`
- [ ] `llvm`
- [ ] `m68k`
- [ ] `markdown_inline`
- [ ] `menhir`
- [ ] `mermaid`
- [ ] `meson`
- [ ] `nickel`
- [ ] `ocamllex`
- [ ] `pascal`
- [ ] `perl`
- [ ] `phpdoc`
- [ ] `pioasm`
- [ ] `po`
- [ ] `poe_filter`
- [ ] `prql`
- [ ] `pug`
- [ ] `ql`
- [ ] `qmldir`
- [ ] `qmljs`
- [ ] `query`
- [ ] `racket`
- [ ] `rasi`
- [ ] `rego`
- [ ] `rnoweb`
- [ ] `ron`
- [ ] `rst`
- [ ] `scheme`
- [ ] `slint`
- [ ] `smithy`
- [ ] `sparql`
- [ ] `sql`
- [ ] `starlark`
- [ ] `supercollider`
- [ ] `surface`
- [ ] `sxhkdrc`
- [ ] `t32`
- [ ] `thrift`
- [ ] `tiger`
- [ ] `tlaplus`
- [ ] `todotxt`
- [ ] `turtle`
- [ ] `twig`
- [ ] `ungrammar`
- [ ] `v`
- [ ] `vala`
- [ ] `vhs`
- [ ] `wgsl`
- [ ] `wgsl_bevy`
- [ ] `yuck`
2023-05-12 12:01:51 +02:00
2023-05-11 11:42:18 +02:00
</details>
2023-05-12 12:01:51 +02:00
## Configuration
(Default values are shown below)
Note: calling `setup()` is optional.
```lua
2021-08-01 04:07:27 +02:00
require'treesitter-context'.setup{
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit.
line_numbers = true,
multiline_threshold = 20, -- Maximum number of lines to show for a single context
trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline'
-- Separator between context and content. Should be a single character string, like '-'.
-- When separator is set, the context will only show up when there are at least 2 lines above cursorline.
separator = nil,
zindex = 20, -- The Z-index of the context window
on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching
}
```
2020-10-19 11:42:47 +02:00
## Commands
2021-05-14 00:17:20 +02:00
`TSContextEnable`, `TSContextDisable` and `TSContextToggle`.
2020-10-19 11:42:47 +02:00
## Appearance
Use the highlight group `TreesitterContext` to change the colors of the
context. Per default it links to `NormalFloat`.
Use the highlight group `TreesitterContextLineNumber` to change the colors of the
context line numbers if `line_numbers` is set. Per default it links to `LineNr`.
Use the highlight group `TreesitterContextSeparator` to change the colors of the
separator if `separator` is set. By default it links to `FloatBorder`.
Use the highlight groups `TreesitterContextBottom` and/or
`TreesitterContextLineNumberBottom` to change the highlight of the last line of
the context window. By default it links to `NONE`.
However, you can use this to create a border by applying an underline highlight, e.g,
for an underline across the screen:
2022-11-09 00:40:20 +01:00
```vim
hi TreesitterContextBottom gui=underline guisp=Grey
hi TreesitterContextLineNumberBottom gui=underline guisp=Grey
```
Or an underline below the line numbers only:
```vim
hi TreesitterContextLineNumberBottom gui=underline guisp=Grey
```
## Jumping to context (upwards)
```lua
vim.keymap.set("n", "[c", function()
require("treesitter-context").go_to_context(vim.v.count1)
end, { silent = true })
```
## Adding support for other languages
2023-05-11 11:50:42 +02:00
See [CONTRIBUTING.md](CONTRIBUTING.md)