Files
nvim/lua/stevenmm/lazy/treesitter.lua

120 lines
2.9 KiB
Lua

-- lua/plugins/treesitter.lua
-- print('treesitter.lua loaded')
return {
"nvim-treesitter/nvim-treesitter",
version = false,
build = ":TSUpdate",
-- init = function(plugin)
-- require("lazy.core.loader").add_to_rtp(plugin)
-- require("nvim-treesitter.query_predicates")
-- end,
dependencies = {
{
"nvim-treesitter/nvim-treesitter-textobjects",
"windwp/nvim-ts-autotag",
-- config = function()
-- 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]
-- for key, query in pairs(config or {}) do
-- if q == query and key:find("[%]%[][cC]") then
-- vim.cmd("normal! " .. key)
-- return
-- end
-- end
-- end
-- return fn(q, ...)
-- end
-- end
-- end
-- end,
-- },
},
},
-- cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" },
-- keys = {
-- { "<c-space>", desc = "Increment Selection" },
-- { "<bs>", desc = "Decrement Selection", mode = "x" },
-- },
opts = {
highlight = { enable = true },
indent = { enable = true },
-- autotag = {
-- enable = true,
-- -- enable_rename = true,
-- -- enable_close = true,
-- -- enable_close_on_slash = true,
-- -- filetypes = { "html", "xml" },
-- },
ensure_installed = {
"bash",
"c",
"cpp",
"go",
"diff",
"html",
"javascript",
"jsdoc",
"json",
"jsonc",
"lua",
"luadoc",
"luap",
"markdown",
"markdown_inline",
"python",
"query",
"regex",
"toml",
"tsx",
"typescript",
"vim",
"vimdoc",
"xml",
"yaml",
},
-- incremental_selection = {
-- enable = true,
-- keymaps = {
-- init_selection = "<C-space>",
-- node_incremental = "<C-space>",
-- scope_incremental = false,
-- node_decremental = "<bs>",
-- },
-- },
-- 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" },
-- },
-- },
},
config = function(_, opts)
require('nvim-ts-autotag').setup()
if type(opts.ensure_installed) == "table" then
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
require("nvim-treesitter.configs").setup(opts)
end,
-- require('nvim-treesitter.configs').setup {
-- autotag = {
-- enable = true,
-- }
-- }
}