2022-12-30 17:30:52 +01:00
|
|
|
return {
|
2023-07-20 17:16:13 -04:00
|
|
|
-- Treesitter is a new parser generator tool that we can
|
|
|
|
-- use in Neovim to power faster and more accurate
|
|
|
|
-- syntax highlighting.
|
2022-12-30 17:30:52 +01:00
|
|
|
{
|
|
|
|
"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-10-04 10:45:10 +02:00
|
|
|
event = { "LazyFile", "VeryLazy" },
|
2023-02-16 20:12:54 +01:00
|
|
|
dependencies = {
|
|
|
|
{
|
|
|
|
"nvim-treesitter/nvim-treesitter-textobjects",
|
2023-10-04 21:00:32 +02:00
|
|
|
config = function()
|
2023-10-07 15:06:13 +02:00
|
|
|
-- When in diff mode, we want to use the default
|
|
|
|
-- vim text objects c & C instead of the treesitter ones.
|
|
|
|
local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)>
|
|
|
|
local configs = require("nvim-treesitter.configs")
|
|
|
|
for name, fn in pairs(move) do
|
|
|
|
if name:find("goto") == 1 then
|
|
|
|
move[name] = function(q, ...)
|
|
|
|
if vim.wo.diff then
|
|
|
|
local config = configs.get_module("textobjects.move")[name] ---@type table<string,string>
|
|
|
|
for key, query in pairs(config or {}) do
|
|
|
|
if q == query and key:find("[%]%[][cC]") then
|
|
|
|
vim.cmd("normal! " .. key)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
2023-10-04 21:00:32 +02:00
|
|
|
end
|
2023-10-07 15:06:13 +02:00
|
|
|
return fn(q, ...)
|
2023-10-04 21:00:32 +02:00
|
|
|
end
|
2023-10-07 15:06:13 +02:00
|
|
|
end
|
|
|
|
end
|
2023-10-04 21:00:32 +02:00
|
|
|
end,
|
2023-02-16 20:12:54 +01:00
|
|
|
},
|
|
|
|
},
|
2023-10-10 11:07:58 +02:00
|
|
|
cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" },
|
2023-01-16 21:17:04 +01:00
|
|
|
keys = {
|
|
|
|
{ "<c-space>", desc = "Increment selection" },
|
2023-03-04 02:40:37 -05:00
|
|
|
{ "<bs>", desc = "Decrement selection", mode = "x" },
|
2023-01-16 21:17:04 +01:00
|
|
|
},
|
2023-01-08 15:05:34 +01:00
|
|
|
---@type TSConfig
|
2023-10-08 15:17:50 +02:00
|
|
|
---@diagnostic disable-next-line: missing-fields
|
2023-01-08 15:05:34 +01:00
|
|
|
opts = {
|
|
|
|
highlight = { enable = true },
|
2023-03-25 04:42:57 -04:00
|
|
|
indent = { enable = true },
|
2023-01-08 15:05:34 +01:00
|
|
|
ensure_installed = {
|
|
|
|
"bash",
|
2023-02-27 19:38:23 +01:00
|
|
|
"c",
|
2023-10-08 12:37:59 +02:00
|
|
|
"diff",
|
2023-01-08 15:05:34 +01:00
|
|
|
"html",
|
|
|
|
"javascript",
|
2023-07-30 16:10:45 +07:00
|
|
|
"jsdoc",
|
2023-01-08 15:05:34 +01:00
|
|
|
"json",
|
2023-10-08 12:37:59 +02:00
|
|
|
"jsonc",
|
2023-01-08 15:05:34 +01:00
|
|
|
"lua",
|
2023-03-21 02:27:13 -04:00
|
|
|
"luadoc",
|
2023-03-05 03:08:51 -05:00
|
|
|
"luap",
|
2023-01-08 15:05:34 +01:00
|
|
|
"markdown",
|
|
|
|
"markdown_inline",
|
|
|
|
"python",
|
|
|
|
"query",
|
|
|
|
"regex",
|
2023-10-08 12:37:59 +02:00
|
|
|
"toml",
|
2023-01-08 15:05:34 +01:00
|
|
|
"tsx",
|
|
|
|
"typescript",
|
|
|
|
"vim",
|
2023-04-15 17:11:29 -04:00
|
|
|
"vimdoc",
|
2023-01-08 15:05:34 +01:00
|
|
|
"yaml",
|
|
|
|
},
|
2023-01-16 21:17:04 +01:00
|
|
|
incremental_selection = {
|
|
|
|
enable = true,
|
|
|
|
keymaps = {
|
|
|
|
init_selection = "<C-space>",
|
|
|
|
node_incremental = "<C-space>",
|
2023-04-21 02:21:34 -05:00
|
|
|
scope_incremental = false,
|
2023-01-17 14:44:45 +01:00
|
|
|
node_decremental = "<bs>",
|
2023-01-16 21:17:04 +01:00
|
|
|
},
|
|
|
|
},
|
2023-10-04 00:12:32 +02:00
|
|
|
textobjects = {
|
|
|
|
move = {
|
|
|
|
enable = true,
|
|
|
|
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" },
|
|
|
|
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" },
|
|
|
|
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" },
|
|
|
|
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" },
|
|
|
|
},
|
|
|
|
},
|
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-04-19 16:44:57 +02:00
|
|
|
if type(opts.ensure_installed) == "table" then
|
|
|
|
---@type table<string, boolean>
|
|
|
|
local added = {}
|
|
|
|
opts.ensure_installed = vim.tbl_filter(function(lang)
|
|
|
|
if added[lang] then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
added[lang] = true
|
|
|
|
return true
|
|
|
|
end, opts.ensure_installed)
|
|
|
|
end
|
2023-01-08 15:05:34 +01:00
|
|
|
require("nvim-treesitter.configs").setup(opts)
|
2022-12-30 17:30:52 +01:00
|
|
|
end,
|
|
|
|
},
|
2023-10-12 00:11:12 +02:00
|
|
|
|
|
|
|
-- Show context of the current function
|
|
|
|
{
|
|
|
|
"nvim-treesitter/nvim-treesitter-context",
|
|
|
|
event = "LazyFile",
|
|
|
|
enabled = true,
|
|
|
|
opts = { mode = "cursor" },
|
|
|
|
},
|
|
|
|
|
2023-10-11 22:39:24 +02:00
|
|
|
-- Automatically add closing tags for HTML and JSX
|
|
|
|
{
|
|
|
|
"windwp/nvim-ts-autotag",
|
|
|
|
event = "InsertEnter",
|
|
|
|
opts = {},
|
|
|
|
},
|
2022-12-30 17:30:52 +01:00
|
|
|
}
|