mirror of
https://github.com/aminnairi/dotfiles.git
synced 2026-09-14 16:52:12 +02:00
added more text objects for tree sitter
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
dependencies = {
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
},
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("nvim-treesitter.configs").setup({
|
||||
@@ -50,7 +53,7 @@ return {
|
||||
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
|
||||
|
||||
indent = {
|
||||
enable = true
|
||||
enable = true,
|
||||
},
|
||||
|
||||
highlight = {
|
||||
@@ -61,6 +64,81 @@ return {
|
||||
-- Instead of true it can also be a list of languages
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
-- Configure text objects
|
||||
textobjects = {
|
||||
-- Text objects for selections like inside word (iw) or inside html tag (it)
|
||||
select = {
|
||||
-- Enable text objects selection
|
||||
enable = true,
|
||||
|
||||
-- Automatically jump forward to textobj, similar to targets.vim
|
||||
lookahead = true,
|
||||
|
||||
-- Keymaps to use for using the following selection text objects
|
||||
keymaps = {
|
||||
-- The whole function
|
||||
["af"] = { query = "@function.outer", desc = "Select the whole function" },
|
||||
-- Inside a function
|
||||
["if"] = { query = "@function.inner", desc = "Select inside a function" },
|
||||
-- Inside an assignment
|
||||
["i="] = { query = "@assignment.inner", desc = "Select inside of a statement" },
|
||||
-- Left-hand-side of a statement
|
||||
["l="] = { query = "@assignment.lhs", desc = "Select left-hand-side of a statement" },
|
||||
-- Right-hand-side of a statement
|
||||
["r="] = { query = "@assignment.rhs", desc = "Select right-hand-side of a statement" },
|
||||
-- The whole statement
|
||||
["a="] = { query = "@assignment.outer", desc = "Select the whole statement" },
|
||||
-- Inside of an attribute
|
||||
["ia"] = { query = "@attribute.inner", desc = "Select inside of an attribute" },
|
||||
-- The whole attribute
|
||||
["aa"] = { query = "@attribute.outer", desc = "Select the whole attribute" },
|
||||
-- Inside of a block
|
||||
["ib"] = { query = "@block.inner", desc = "Select inside a block" },
|
||||
-- The whole block
|
||||
["ab"] = { query = "@block.outer", desc = "Select the whole block" },
|
||||
-- Inside of a class
|
||||
["ic"] = { query = "@class.inner", desc = "Select inside of a class" },
|
||||
-- The whole class
|
||||
["ac"] = { query = "@class.outer", desc = "Select the whole class" },
|
||||
-- Inside a comment
|
||||
["iC"] = { query = "@comment.inner", desc = "Select inside of a comment" },
|
||||
-- The whole comment
|
||||
["aC"] = { query = "@comment.outer", desc = "Select the whole comment" },
|
||||
-- Inside of a conditional statement
|
||||
["ii"] = { query = "@conditional.inner", desc = "Select inside of a conditional statement" },
|
||||
-- The whole conditional statement
|
||||
["ai"] = { query = "@conditional.outer", desc = "Select the whole conditional statement" },
|
||||
-- Inside a loop
|
||||
["il"] = { query = "@loop.inner", desc = "Select inside a loop" },
|
||||
-- The whole a loop
|
||||
["al"] = { query = "@loop.outer", desc = "Select the whole loop" },
|
||||
-- Inside a number
|
||||
["in"] = { query = "@number.inner", desc = "Select inside a number" },
|
||||
-- Inside a number
|
||||
["an"] = { query = "@number.inner", desc = "Select the whole number" },
|
||||
-- Inside a parameter
|
||||
["ip"] = { query = "@parameter.inner", desc = "Select inside a parameter" },
|
||||
-- The whole parameter
|
||||
["ap"] = { query = "@parameter.outer", desc = "Select the whole parameter" },
|
||||
-- Inside of a regex
|
||||
["ir"] = { query = "@regex.inner", desc = "Select inside of a regex" },
|
||||
-- The whole regex
|
||||
["ar"] = { query = "@regex.outer", desc = "Select the whole regex" },
|
||||
-- Inside of a return statement
|
||||
["iR"] = { query = "@return.inner", desc = "Select inside of a return statement" },
|
||||
-- The whole return statement
|
||||
["aR"] = { query = "@return.outer", desc = "Select the whole return statement" },
|
||||
-- Inside of a scope
|
||||
["i{"] = { query = "@scopename.inner", desc = "Select inside of a scope" },
|
||||
-- Inside of a statement
|
||||
["iS"] = { query = "@statement.outer", desc = "Select inside of a statement" },
|
||||
-- Inside of a statement
|
||||
["aS"] = { query = "@statement.outer", desc = "Select the whole statement" },
|
||||
},
|
||||
-- Select surrounding white spaces as well as the selected text object
|
||||
include_surrounding_whitespace = true,
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user