mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
chore: remove lua heredocs in documentation and readme
This commit is contained in:
parent
708b4e4cac
commit
2e67eace75
2 changed files with 8 additions and 38 deletions
32
README.md
32
README.md
|
|
@ -100,8 +100,7 @@ Each module provides a distinct tree-sitter-based feature such as [highlighting]
|
||||||
|
|
||||||
All modules are disabled by default and need to be activated explicitly in your `init.vim`, e.g., via
|
All modules are disabled by default and need to be activated explicitly in your `init.vim`, e.g., via
|
||||||
|
|
||||||
```vim
|
```lua
|
||||||
lua <<EOF
|
|
||||||
require'nvim-treesitter.configs'.setup {
|
require'nvim-treesitter.configs'.setup {
|
||||||
-- One of "all", "maintained" (parsers with maintainers), or a list of languages
|
-- One of "all", "maintained" (parsers with maintainers), or a list of languages
|
||||||
ensure_installed = "maintained",
|
ensure_installed = "maintained",
|
||||||
|
|
@ -126,7 +125,6 @@ require'nvim-treesitter.configs'.setup {
|
||||||
additional_vim_regex_highlighting = false,
|
additional_vim_regex_highlighting = false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
EOF
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Each module can also be enabled or disabled interactively through the following commands:
|
Each module can also be enabled or disabled interactively through the following commands:
|
||||||
|
|
@ -268,8 +266,7 @@ Additional modules can be provided as [external plugins](https://github.com/nvim
|
||||||
|
|
||||||
Consistent syntax highlighting.
|
Consistent syntax highlighting.
|
||||||
|
|
||||||
```vim
|
```lua
|
||||||
lua <<EOF
|
|
||||||
require'nvim-treesitter.configs'.setup {
|
require'nvim-treesitter.configs'.setup {
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true,
|
enable = true,
|
||||||
|
|
@ -284,15 +281,13 @@ require'nvim-treesitter.configs'.setup {
|
||||||
additional_vim_regex_highlighting = false,
|
additional_vim_regex_highlighting = false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
EOF
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Incremental selection
|
#### Incremental selection
|
||||||
|
|
||||||
Incremental selection based on the named nodes from the grammar.
|
Incremental selection based on the named nodes from the grammar.
|
||||||
|
|
||||||
```vim
|
```lua
|
||||||
lua <<EOF
|
|
||||||
require'nvim-treesitter.configs'.setup {
|
require'nvim-treesitter.configs'.setup {
|
||||||
incremental_selection = {
|
incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
|
|
@ -304,7 +299,6 @@ require'nvim-treesitter.configs'.setup {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
EOF
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Indentation
|
#### Indentation
|
||||||
|
|
@ -312,14 +306,12 @@ EOF
|
||||||
Indentation based on treesitter for the `=` operator.
|
Indentation based on treesitter for the `=` operator.
|
||||||
**NOTE: This is an experimental feature**.
|
**NOTE: This is an experimental feature**.
|
||||||
|
|
||||||
```vim
|
```lua
|
||||||
lua <<EOF
|
|
||||||
require'nvim-treesitter.configs'.setup {
|
require'nvim-treesitter.configs'.setup {
|
||||||
indent = {
|
indent = {
|
||||||
enable = true
|
enable = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOF
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Folding
|
#### Folding
|
||||||
|
|
@ -343,8 +335,7 @@ If you have a parser that is not on the list of supported languages (either as a
|
||||||
2. Run `tree-sitter generate` in this directory (followed by `tree-sitter test` for good measure).
|
2. Run `tree-sitter generate` in this directory (followed by `tree-sitter test` for good measure).
|
||||||
3. Add the following snippet to your `init.vim`:
|
3. Add the following snippet to your `init.vim`:
|
||||||
|
|
||||||
```vim
|
```lua
|
||||||
lua <<EOF
|
|
||||||
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
|
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
|
||||||
parser_config.zimbu = {
|
parser_config.zimbu = {
|
||||||
install_info = {
|
install_info = {
|
||||||
|
|
@ -357,16 +348,13 @@ parser_config.zimbu = {
|
||||||
},
|
},
|
||||||
filetype = "zu", -- if filetype does not match the parser name
|
filetype = "zu", -- if filetype does not match the parser name
|
||||||
}
|
}
|
||||||
EOF
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If you wish to set a specific parser for a filetype, you should extend the `filetype_to_parsername` table:
|
If you wish to set a specific parser for a filetype, you should extend the `filetype_to_parsername` table:
|
||||||
|
|
||||||
```vim
|
```lua
|
||||||
lua <<EOF
|
|
||||||
local ft_to_parser = require"nvim-treesitter.parsers".filetype_to_parsername
|
local ft_to_parser = require"nvim-treesitter.parsers".filetype_to_parsername
|
||||||
ft_to_parser.someft = "python" -- the someft filetype will use the python parser and queries.
|
ft_to_parser.someft = "python" -- the someft filetype will use the python parser and queries.
|
||||||
EOF
|
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Start `nvim` and `:TSInstall zimbu`.
|
4. Start `nvim` and `:TSInstall zimbu`.
|
||||||
|
|
@ -398,10 +386,8 @@ but if you want to extend a query use the `after/queries/` directory.
|
||||||
If you want to completely override a query, you can use `:h set_query()`.
|
If you want to completely override a query, you can use `:h set_query()`.
|
||||||
For example, to override the `injections` queries from `c` with your own:
|
For example, to override the `injections` queries from `c` with your own:
|
||||||
|
|
||||||
```vim
|
```lua
|
||||||
lua <<EOF
|
|
||||||
require("vim.treesitter.query").set_query("c", "injections", "(comment) @comment")
|
require("vim.treesitter.query").set_query("c", "injections", "(comment) @comment")
|
||||||
EOF
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Note: when using `set_query`, all queries in the runtime directories will be ignored.
|
Note: when using `set_query`, all queries in the runtime directories will be ignored.
|
||||||
|
|
@ -416,8 +402,7 @@ If you wish you write your own module, you need to support
|
||||||
|
|
||||||
At the top level, you can use the `define_modules` function to define one or more modules or module groups:
|
At the top level, you can use the `define_modules` function to define one or more modules or module groups:
|
||||||
|
|
||||||
```vim
|
```lua
|
||||||
lua <<EOF
|
|
||||||
require'nvim-treesitter'.define_modules {
|
require'nvim-treesitter'.define_modules {
|
||||||
my_cool_plugin = {
|
my_cool_plugin = {
|
||||||
attach = function(bufnr, lang)
|
attach = function(bufnr, lang)
|
||||||
|
|
@ -431,7 +416,6 @@ require'nvim-treesitter'.define_modules {
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOF
|
|
||||||
```
|
```
|
||||||
|
|
||||||
with the following properties:
|
with the following properties:
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ By default, everything is disabled.
|
||||||
To enable supported features, put this in your `init.vim` file:
|
To enable supported features, put this in your `init.vim` file:
|
||||||
|
|
||||||
>
|
>
|
||||||
lua <<EOF
|
|
||||||
require'nvim-treesitter.configs'.setup {
|
require'nvim-treesitter.configs'.setup {
|
||||||
-- One of "all", "maintained" (parsers with maintainers), or a list of languages
|
-- One of "all", "maintained" (parsers with maintainers), or a list of languages
|
||||||
ensure_installed = "maintained",
|
ensure_installed = "maintained",
|
||||||
|
|
@ -63,7 +62,6 @@ To enable supported features, put this in your `init.vim` file:
|
||||||
additional_vim_regex_highlighting = false,
|
additional_vim_regex_highlighting = false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
EOF
|
|
||||||
<
|
<
|
||||||
|
|
||||||
See |nvim-treesitter-modules| for a list of all available modules and its options.
|
See |nvim-treesitter-modules| for a list of all available modules and its options.
|
||||||
|
|
@ -80,14 +78,12 @@ Each module corresponds to an entry in the dictionary passed to the
|
||||||
`nvim-treesitter.configs.setup` function, this should be in your `init.vim` file.
|
`nvim-treesitter.configs.setup` function, this should be in your `init.vim` file.
|
||||||
|
|
||||||
>
|
>
|
||||||
lua <<EOF
|
|
||||||
require'nvim-treesitter.configs'.setup {
|
require'nvim-treesitter.configs'.setup {
|
||||||
-- Modules and its options go here
|
-- Modules and its options go here
|
||||||
highlight = { enable = true },
|
highlight = { enable = true },
|
||||||
incremental_selection = { enable = true },
|
incremental_selection = { enable = true },
|
||||||
textobjects = { enable = true },
|
textobjects = { enable = true },
|
||||||
}
|
}
|
||||||
EOF
|
|
||||||
<
|
<
|
||||||
|
|
||||||
All modules share some common options, like `enable` and `disable`.
|
All modules share some common options, like `enable` and `disable`.
|
||||||
|
|
@ -95,14 +91,12 @@ When `enable` is `true` this will enable the module for all supported languages,
|
||||||
if you want to disable the module for some languages you can pass a list to the `disable` option.
|
if you want to disable the module for some languages you can pass a list to the `disable` option.
|
||||||
|
|
||||||
>
|
>
|
||||||
lua <<EOF
|
|
||||||
require'nvim-treesitter.configs'.setup {
|
require'nvim-treesitter.configs'.setup {
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true,
|
enable = true,
|
||||||
disable = { "cpp", "lua" },
|
disable = { "cpp", "lua" },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
EOF
|
|
||||||
<
|
<
|
||||||
|
|
||||||
For more fine-grained control, `disable` can also take a function and
|
For more fine-grained control, `disable` can also take a function and
|
||||||
|
|
@ -111,7 +105,6 @@ The function is called once when a module starts in a buffer and receives the
|
||||||
language and buffer number as arguments:
|
language and buffer number as arguments:
|
||||||
|
|
||||||
>
|
>
|
||||||
lua <<EOF
|
|
||||||
require'nvim-treesitter.configs'.setup {
|
require'nvim-treesitter.configs'.setup {
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true,
|
enable = true,
|
||||||
|
|
@ -120,7 +113,6 @@ language and buffer number as arguments:
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
EOF
|
|
||||||
<
|
<
|
||||||
|
|
||||||
Options that define or accept a keymap use the same format you use to define
|
Options that define or accept a keymap use the same format you use to define
|
||||||
|
|
@ -150,7 +142,6 @@ Supported options:
|
||||||
Defaults to `false`.
|
Defaults to `false`.
|
||||||
|
|
||||||
>
|
>
|
||||||
lua <<EOF
|
|
||||||
require'nvim-treesitter.configs'.setup {
|
require'nvim-treesitter.configs'.setup {
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true,
|
enable = true,
|
||||||
|
|
@ -162,7 +153,6 @@ Supported options:
|
||||||
additional_vim_regex_highlighting = false,
|
additional_vim_regex_highlighting = false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
EOF
|
|
||||||
<
|
<
|
||||||
Note: The api is not stable yet.
|
Note: The api is not stable yet.
|
||||||
|
|
||||||
|
|
@ -186,7 +176,6 @@ Supported options:
|
||||||
Defaults to `grm`.
|
Defaults to `grm`.
|
||||||
|
|
||||||
>
|
>
|
||||||
lua <<EOF
|
|
||||||
require'nvim-treesitter.configs'.setup {
|
require'nvim-treesitter.configs'.setup {
|
||||||
incremental_selection = {
|
incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
|
|
@ -198,7 +187,6 @@ Supported options:
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
EOF
|
|
||||||
<
|
<
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
@ -212,13 +200,11 @@ Supported options:
|
||||||
- enable: `true` or `false`.
|
- enable: `true` or `false`.
|
||||||
- disable: list of languages.
|
- disable: list of languages.
|
||||||
>
|
>
|
||||||
lua <<EOF
|
|
||||||
require'nvim-treesitter.configs'.setup {
|
require'nvim-treesitter.configs'.setup {
|
||||||
indent = {
|
indent = {
|
||||||
enable = true
|
enable = true
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
EOF
|
|
||||||
<
|
<
|
||||||
==============================================================================
|
==============================================================================
|
||||||
COMMANDS *nvim-treesitter-commands*
|
COMMANDS *nvim-treesitter-commands*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue