2024-03-04 14:39:06 -05:00
|
|
|
if (vim.g.enabletreesitter == 1) then
|
|
|
|
local parser_dir
|
2024-03-01 22:30:11 -05:00
|
|
|
|
2024-03-04 14:39:06 -05:00
|
|
|
if (vim.g.treesitterparserdir == nill) then
|
|
|
|
parser_dir = "~/.config/nvim/treesitter-parsers"
|
|
|
|
else
|
|
|
|
parser_dir = vim.g.treesitterparserdir
|
|
|
|
end
|
2024-03-01 21:59:23 -05:00
|
|
|
|
2024-03-04 14:39:06 -05:00
|
|
|
vim.opt.runtimepath:append(parser_dir)
|
2024-03-01 21:59:23 -05:00
|
|
|
|
2024-03-05 13:32:39 -05:00
|
|
|
require("nvim-treesitter.configs").setup({
|
2024-03-28 21:43:00 -04:00
|
|
|
ensure_installed = { "bash", "c", "cpp", "css", "diff", "git_config", "go", "html", "java", "javascript", "json", "lua", "php", "python", "query", "rust", "scss", "toml", "typescript", "vim", "vimdoc", "vue" },
|
2024-03-28 16:25:45 -04:00
|
|
|
sync_install = true,
|
|
|
|
auto_install = true,
|
2024-03-04 14:39:06 -05:00
|
|
|
parser_install_dir = parser_dir,
|
2024-03-01 21:59:23 -05:00
|
|
|
|
2024-03-04 14:39:06 -05:00
|
|
|
highlight = {
|
|
|
|
enable = true,
|
2024-04-02 17:58:02 -04:00
|
|
|
disable = { "gitcommit", "markdown", "tmux" },
|
2024-04-03 17:22:41 -04:00
|
|
|
additional_vim_regex_highlighting = { "diff", "php", "scss" },
|
2024-03-05 12:46:26 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
textobjects = {
|
|
|
|
select = {
|
|
|
|
enable = true,
|
|
|
|
lookahead = true, -- Automatically jump forward to textobj
|
|
|
|
|
|
|
|
keymaps = {
|
2024-08-15 17:31:52 -04:00
|
|
|
[ "ap" ] = { query = "@parameter.outer", desc = "Select outer part of a parameter region" },
|
|
|
|
[ "ip" ] = { query = "@parameter.inner", desc = "Select inner part of a parameter region" },
|
2024-03-05 12:46:26 -05:00
|
|
|
[ "ac" ] = { query = "@class.outer", desc = "Select outer part of a class region" },
|
|
|
|
[ "ic" ] = { query = "@class.inner", desc = "Select inner part of a class region" },
|
|
|
|
[ "af" ] = { query = "@function.outer", desc = "Select outer part of a function region" },
|
|
|
|
[ "if" ] = { query = "@function.inner", desc = "Select inner part of a function region" },
|
|
|
|
[ "as" ] = { query = "@scope", query_group = "locals", desc = "Select language scope" },
|
|
|
|
},
|
|
|
|
|
|
|
|
selection_modes = {
|
|
|
|
[ "@parameter.outer" ] = "v",
|
|
|
|
[ "@parameter.inner" ] = "v",
|
2024-08-15 17:31:52 -04:00
|
|
|
[ "@class.inner" ] = "v",
|
|
|
|
[ "@class.outer" ] = "v",
|
|
|
|
[ "@function.outer" ] = "v",
|
|
|
|
[ "@function.inner" ] = "v",
|
2024-03-05 12:46:26 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
include_surrounding_whitespace = false,
|
|
|
|
},
|
|
|
|
|
|
|
|
move = {
|
|
|
|
enable = true,
|
|
|
|
set_jumps = true, -- whether to set jumps in the jumplist
|
|
|
|
|
|
|
|
goto_next_start = {
|
2024-08-15 17:31:52 -04:00
|
|
|
[ "]p" ] = { query = "@parameter.outer", desc = "Next parameter start" },
|
2024-03-05 12:46:26 -05:00
|
|
|
[ "]c" ] = { query = "@class.outer", desc = "Next class start" },
|
|
|
|
[ "]f" ] = { query = "@function.outer", desc = "Next function start" },
|
|
|
|
},
|
|
|
|
|
|
|
|
goto_previous_start = {
|
2024-08-15 17:31:52 -04:00
|
|
|
[ "[p" ] = { query = "@parameter.outer", desc = "Previous parameter start" },
|
|
|
|
[ "[c" ] = { query = "@class.outer", desc = "Previous class start" },
|
2024-03-05 12:46:26 -05:00
|
|
|
[ "[f" ] = { query = "@function.outer", desc = "Previous function start" },
|
|
|
|
},
|
|
|
|
|
2024-08-15 17:31:52 -04:00
|
|
|
goto_next_end = {
|
|
|
|
[ "}P" ] = { query = "@parameter.outer", desc = "Next parameter end" },
|
|
|
|
[ "}C" ] = { query = "@class.outer", desc = "Next class end" },
|
|
|
|
[ "}F" ] = { query = "@function.outer", desc = "Next function end" },
|
|
|
|
},
|
|
|
|
|
2024-03-05 12:46:26 -05:00
|
|
|
goto_previous_end = {
|
2024-08-15 17:31:52 -04:00
|
|
|
[ "{P" ] = { query = "@parameter.outer", desc = "Previous parameter end" },
|
|
|
|
[ "{C" ] = { query = "@class.outer", desc = "Previous class end" },
|
|
|
|
[ "{F" ] = { query = "@function.outer", desc = "Previous function end" },
|
2024-03-05 12:46:26 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-03-05 13:32:39 -05:00
|
|
|
})
|
2024-03-01 21:59:23 -05:00
|
|
|
end
|