2022-12-30 17:30:52 +01:00
|
|
|
return {
|
|
|
|
{
|
|
|
|
"nvim-treesitter/nvim-treesitter",
|
2023-01-16 23:36:01 +01:00
|
|
|
version = false, -- last release is way too old and doesn't work on Windows
|
2022-12-30 17:30:52 +01:00
|
|
|
build = ":TSUpdate",
|
2023-02-07 21:59:33 +01:00
|
|
|
event = { "BufReadPost", "BufNewFile" },
|
2023-02-16 20:12:54 +01:00
|
|
|
dependencies = {
|
|
|
|
{
|
|
|
|
"nvim-treesitter/nvim-treesitter-textobjects",
|
|
|
|
init = function()
|
|
|
|
-- PERF: no need to load the plugin, if we only need its queries for mini.ai
|
|
|
|
local plugin = require("lazy.core.config").spec.plugins["nvim-treesitter"]
|
|
|
|
local opts = require("lazy.core.plugin").values(plugin, "opts", false)
|
|
|
|
local enabled = false
|
|
|
|
if opts.textobjects then
|
|
|
|
for _, mod in ipairs({ "move", "select", "swap", "lsp_interop" }) do
|
2023-02-20 16:01:02 +01:00
|
|
|
if opts.textobjects[mod] and opts.textobjects[mod].enable then
|
2023-02-16 20:12:54 +01:00
|
|
|
enabled = true
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if not enabled then
|
|
|
|
require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects")
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
2023-01-16 21:17:04 +01:00
|
|
|
keys = {
|
|
|
|
{ "<c-space>", desc = "Increment selection" },
|
2023-01-17 14:44:45 +01:00
|
|
|
{ "<bs>", desc = "Schrink selection", mode = "x" },
|
2023-01-16 21:17:04 +01:00
|
|
|
},
|
2023-01-08 15:05:34 +01:00
|
|
|
---@type TSConfig
|
|
|
|
opts = {
|
|
|
|
highlight = { enable = true },
|
2023-02-18 13:14:47 +01:00
|
|
|
indent = { enable = true, disable = { "python" } },
|
2023-01-08 15:05:34 +01:00
|
|
|
context_commentstring = { enable = true, enable_autocmd = false },
|
|
|
|
ensure_installed = {
|
|
|
|
"bash",
|
|
|
|
"help",
|
|
|
|
"html",
|
|
|
|
"javascript",
|
|
|
|
"json",
|
|
|
|
"lua",
|
|
|
|
"markdown",
|
|
|
|
"markdown_inline",
|
|
|
|
"python",
|
|
|
|
"query",
|
|
|
|
"regex",
|
|
|
|
"tsx",
|
|
|
|
"typescript",
|
|
|
|
"vim",
|
|
|
|
"yaml",
|
|
|
|
},
|
2023-01-16 21:17:04 +01:00
|
|
|
incremental_selection = {
|
|
|
|
enable = true,
|
|
|
|
keymaps = {
|
|
|
|
init_selection = "<C-space>",
|
|
|
|
node_incremental = "<C-space>",
|
2023-01-17 14:44:45 +01:00
|
|
|
scope_incremental = "<nop>",
|
|
|
|
node_decremental = "<bs>",
|
2023-01-16 21:17:04 +01:00
|
|
|
},
|
|
|
|
},
|
2023-01-07 10:50:06 +01:00
|
|
|
},
|
2023-01-08 15:05:34 +01:00
|
|
|
---@param opts TSConfig
|
2023-01-25 09:00:19 +01:00
|
|
|
config = function(_, opts)
|
2023-01-08 15:05:34 +01:00
|
|
|
require("nvim-treesitter.configs").setup(opts)
|
2022-12-30 17:30:52 +01:00
|
|
|
end,
|
|
|
|
},
|
|
|
|
}
|