Treesitter refactoring
- treesitter smart select "v<CR>" and <Tab> - treesitter swap func params with ~ - map ,tf to set TS to fold methodmain
parent
bbaa133a34
commit
0684ba9657
@ -1,79 +0,0 @@
|
||||
local present, treesitter = pcall(require, "nvim-treesitter.configs")
|
||||
|
||||
if not present then
|
||||
return
|
||||
end
|
||||
|
||||
local options = {
|
||||
|
||||
-- treesitter config (not textobjects)
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "gnn",
|
||||
node_incremental = "grn",
|
||||
scope_incremental = "grc",
|
||||
node_decremental = "grm",
|
||||
}
|
||||
},
|
||||
|
||||
textobjects = {
|
||||
enable = true,
|
||||
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true,
|
||||
keymaps = {
|
||||
-- You can use the capture groups defined in 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",
|
||||
}
|
||||
},
|
||||
|
||||
move = {
|
||||
enable = true,
|
||||
set_jumps = true, -- whether to set jumps in the jumplist
|
||||
goto_next_start = {
|
||||
["]m"] = "@function.outer",
|
||||
["]]"] = "@class.outer"
|
||||
},
|
||||
goto_next_end = {
|
||||
["]M"] = "@function.outer",
|
||||
["]["] = "@class.outer"
|
||||
},
|
||||
goto_previous_start = {
|
||||
["[m"] = "@function.outer",
|
||||
["[["] = "@class.outer"
|
||||
},
|
||||
goto_previous_end = {
|
||||
["[M"] = "@function.outer",
|
||||
["[]"] = "@class.outer"
|
||||
}
|
||||
},
|
||||
|
||||
swap = {
|
||||
enable = true,
|
||||
swap_next = {
|
||||
["<leader>sw"] = "@parameter.inner"
|
||||
},
|
||||
swap_previous = {
|
||||
["<leader>sW"] = "@parameter.inner"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
treesitter.setup(options)
|
@ -0,0 +1,101 @@
|
||||
return {
|
||||
ensure_installed = {
|
||||
"lua",
|
||||
"go",
|
||||
"rust",
|
||||
"fish",
|
||||
"bash",
|
||||
"python",
|
||||
"c",
|
||||
"haskell",
|
||||
"javascript",
|
||||
"html",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"make",
|
||||
"sql",
|
||||
"yaml",
|
||||
"toml",
|
||||
"vue",
|
||||
},
|
||||
|
||||
incremental_selection = {
|
||||
enable = false,
|
||||
keymaps = {
|
||||
init_selection = "<CR>",
|
||||
node_incremental = "<Tab>",
|
||||
scope_incremental = "<CR>",
|
||||
node_decremental = "<S-Tab>",
|
||||
}
|
||||
},
|
||||
|
||||
textsubjects = {
|
||||
enable = true,
|
||||
prev_selection = "<Tab>",
|
||||
keymaps = {
|
||||
["<CR>"] = "textsubjects-smart", -- works in visual mode
|
||||
}
|
||||
},
|
||||
|
||||
rainbow = {
|
||||
enable = true,
|
||||
extended_mode = true,
|
||||
},
|
||||
|
||||
textobjects = {
|
||||
enable = true,
|
||||
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true,
|
||||
keymaps = {
|
||||
-- You can use the capture groups defined in 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",
|
||||
}
|
||||
},
|
||||
|
||||
move = {
|
||||
enable = true,
|
||||
set_jumps = true, -- whether to set jumps in the jumplist
|
||||
|
||||
goto_next_start = {
|
||||
["]]"] = "@function.outer",
|
||||
["]m"] = "@class.outer"
|
||||
},
|
||||
|
||||
goto_next_end = {
|
||||
["]["] = "@function.outer",
|
||||
["]M"] = "@class.outer"
|
||||
},
|
||||
goto_previous_start = {
|
||||
["[["] = "@function.outer",
|
||||
["[m"] = "@class.outer"
|
||||
},
|
||||
goto_previous_end = {
|
||||
["[]"] = "@function.outer",
|
||||
["[M"] = "@class.outer"
|
||||
}
|
||||
},
|
||||
|
||||
swap = {
|
||||
enable = true,
|
||||
swap_next = {
|
||||
["~"] = "@parameter.inner"
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue