Update documentation for new modules 'refactor'/'textobjects'

This commit is contained in:
Stephan Seitz 2020-07-04 17:15:04 +02:00 committed by Thomas Vigouroux
parent 5e83307a43
commit d351c9b342
3 changed files with 72 additions and 2 deletions

View file

@ -133,6 +133,34 @@ require'nvim-treesitter.configs'.setup {
}
}
},
textobjects = { -- syntax-aware textobjects
enable = true,
disable = {},
keymaps = {
["iL"] = { -- you can define your own textobjects directly here
python = "(function_definition) @function",
cpp = "(function_definition) @function",
c = "(function_definition) @function",
java = "(method_declaration) @function"
},
-- or you use the queries from supported languages with textobjects.scm
["af"] = "@function.outer",
["if"] = "@function.inner",
["aC"] = "@class.outer",
["iC"] = "@class.inner",
["ac"] = "@conditional.outer",
["ic"] = "@conditional.inner",
["ae"] = "@block.outer",
["ie"] = "@block.inner",
["al"] = "@loop.outer",
["il"] = "@loop.inner",
["is"] = "@statement.inner",
["as"] = "@statement.outer",
["ad"] = "@comment.outer",
["am"] = "@call.outer",
["im"] = "@call.inner"
}
},
ensure_installed = 'all' -- one of 'all', 'language', or a list of languages
}
EOF
@ -171,6 +199,7 @@ The roadmap and all features of this plugin are open to change, and any suggesti
- `refactor.navigation`: Syntax based definition listing and navigation.
* List all definitions
* Go to definition
- `textobjects`: Vim textobjects defined by treesitter queries
## Defining Modules
@ -217,7 +246,7 @@ More information is available in the help file (`:help nvim-treesitter-utils`).
## Supported Languages
For treesitter to work, we need to use query files such as those you can find in
For `nvim-treesitter` to work, we need to use query files such as those you can find in
`queries/{lang}/{locals,highlights,textobjects}.scm`
We are looking for maintainers to write query files for their languages.

View file

@ -47,6 +47,48 @@ By default, everything is disabled. To enable support for features, in your `ini
node_decremental = "grm", -- decrement to the previous node
}
},
refactor = {
highlight_defintions = {
enable = true
},
smart_rename = {
enable = true,
smart_rename = "grr" -- mapping to rename reference under cursor
},
navigation = {
enable = true,
goto_definition = "gnd", -- mapping to go to definition of symbol under cursor
list_definitions = "gnD" -- mapping to list all definitions in current file
}
},
textobjects = { -- syntax-aware textobjects
enable = true,
disable = {},
keymaps = {
["iL"] = { -- you can define your own textobjects directly here
python = "(function_definition) @function",
cpp = "(function_definition) @function",
c = "(function_definition) @function",
java = "(method_declaration) @function"
},
-- or you use the queries from supported languages with textobjects.scm
["af"] = "@function.outer",
["if"] = "@function.inner",
["aC"] = "@class.outer",
["iC"] = "@class.inner",
["ac"] = "@conditional.outer",
["ic"] = "@conditional.inner",
["ae"] = "@block.outer",
["ie"] = "@block.inner",
["al"] = "@loop.outer",
["il"] = "@loop.inner",
["is"] = "@statement.inner",
["as"] = "@statement.outer",
["ad"] = "@comment.outer",
["am"] = "@call.outer",
["im"] = "@call.inner"
}
},
ensure_installed = 'all' -- one of 'all', 'language', or a list of languages
}
EOF

View file

@ -27,7 +27,6 @@ function M.select_textobject(query_string)
local root = parser:parse():root()
local start_row, _, end_row, _ = root:range()
local nested = {}
local query = ts.parse_query(lang, query_string)
for m in queries.iter_prepared_matches(query, root, bufnr, start_row, end_row) do
for _, n in pairs(m) do