Skip to content

Commit

Permalink
added incremental selection in treesitter.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
cjoke committed Feb 20, 2024
1 parent d5c2649 commit e27faf4
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lua/plugins/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,35 @@ return {
highlight = { enable = true },
indent = { enable = true },

incremental_selection = {
enable = true,
keymaps = {
init_selection = "<leader>ss",
node_incremental = "<leader>si",
scope_incremental = "<leader>sc",
node_decremental = "<leader>sd",
},
},
textobjects = {

select = {
enable = true,
-- Automatically jump forward to textobj, similar to targets.vim
-- automatically jump forward to textobj, similar to targets.vim
lookahead = true,

keymaps = {
-- You can use the capture groups defined in textobjects.scm
-- you can use the capture groups defined in textobjects.scm
-- these works in visualmode (charvise)
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" },
["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" },
["ic"] = { query = "@class.inner", desc = "select inner part of a class region" },
["as"] = { query = "@scope", query_group = "locals", desc = "select language scope" },
},

selection_modes = {
["@parameter.outer"] = "v", -- charwise
["@function.outer"] = "V", -- linewise
["@function.outer"] = "v", -- linewise
["@class.outer"] = "<c-v>", -- blockwise
},

Expand All @@ -54,7 +63,7 @@ return {
keymap({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move)
keymap({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_opposite)

-- Optionally, make builtin f, F, t, T also repeatable with ; and ,
-- optionally, make builtin f, f, t, t also repeatable with ; and ,
keymap({ "n", "x", "o" }, "f", ts_repeat_move.builtin_f)
keymap({ "n", "x", "o" }, "F", ts_repeat_move.builtin_F)
keymap({ "n", "x", "o" }, "t", ts_repeat_move.builtin_t)
Expand Down

0 comments on commit e27faf4

Please sign in to comment.