|
|
|
@ -1,14 +1,15 @@
|
|
|
|
|
return {
|
|
|
|
|
-- Improved syntax highlighting, text objects and more
|
|
|
|
|
--- @type LazyPluginSpec
|
|
|
|
|
{
|
|
|
|
|
"nvim-treesitter/nvim-treesitter",
|
|
|
|
|
build = ":TSUpdate",
|
|
|
|
|
init = function(plugin)
|
|
|
|
|
init = function()
|
|
|
|
|
require("nvim-treesitter.install").update({
|
|
|
|
|
with_sync = true,
|
|
|
|
|
})
|
|
|
|
|
end,
|
|
|
|
|
---@type TSConfig
|
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
|
|
|
|
--- @type TSConfig
|
|
|
|
|
opts = {
|
|
|
|
|
highlight = { enable = true },
|
|
|
|
|
indent = { enable = true },
|
|
|
|
@ -70,10 +71,10 @@ return {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
---@param opts TSConfig
|
|
|
|
|
--- @param opts TSConfig
|
|
|
|
|
config = function(_, opts)
|
|
|
|
|
if type(opts.ensure_installed) == "table" then
|
|
|
|
|
---@type table<string, boolean>
|
|
|
|
|
--- @type table<string, boolean>
|
|
|
|
|
local added = {}
|
|
|
|
|
opts.ensure_installed = vim.tbl_filter(function(lang)
|
|
|
|
|
if added[lang] then
|
|
|
|
@ -91,13 +92,15 @@ return {
|
|
|
|
|
config = function()
|
|
|
|
|
-- 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(...)>
|
|
|
|
|
--- @type table<string,fun(...)>
|
|
|
|
|
local move = require("nvim-treesitter.textobjects.move")
|
|
|
|
|
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>
|
|
|
|
|
--- @type table<string,string>
|
|
|
|
|
local config = configs.get_module("textobjects.move")[name]
|
|
|
|
|
for key, query in pairs(config or {}) do
|
|
|
|
|
if q == query and key:find("[%]%[][cC]") then
|
|
|
|
|
vim.cmd("normal! " .. key)
|
|
|
|
@ -115,8 +118,9 @@ return {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
-- Automatically add closing tags for HTML and JSX
|
|
|
|
|
--- @type LazyPluginSpec
|
|
|
|
|
{
|
|
|
|
|
"windwp/nvim-ts-autotag",
|
|
|
|
|
opts = {},
|
|
|
|
|
config = true,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|