diff options
Diffstat (limited to 'public/nvim/.nvim/lua/plugins/core/treesitter.lua')
-rw-r--r-- | public/nvim/.nvim/lua/plugins/core/treesitter.lua | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/public/nvim/.nvim/lua/plugins/core/treesitter.lua b/public/nvim/.nvim/lua/plugins/core/treesitter.lua new file mode 100644 index 0000000..3818555 --- /dev/null +++ b/public/nvim/.nvim/lua/plugins/core/treesitter.lua @@ -0,0 +1,54 @@ +---@param tbl table +---@return table +local tbl_uniq = function(tbl) + ---@type table<string, boolean> + local added = {} + local res = {} + res = vim.tbl_filter(function(k) + if added[k] then + return false + end + added[k] = true + return true + end, tbl) + + return res +end + +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + cmd = { "TSUpdateSync" }, + event = { "BufReadPost", "BufNewFile" }, + init = function() + vim.o.foldmethod = "expr" + vim.o.foldexpr = "nvim_treesitter#foldexpr()" + end, + opts = { + ensure_installed = { "query" }, + ignore_install = {}, + highlight = { + enable = true, + }, + query_linter = { + enable = true, + use_virtual_text = true, + lint_events = { "BufWrite", "CursorHold" }, + }, + }, + config = function(_, opts) + if type(opts.ensure_installed) == "table" then + opts.ensure_installed = tbl_uniq(opts.ensure_installed) + end + require("nvim-treesitter.configs").setup(opts) + end, + }, + + { + "nvim-treesitter/playground", + build = ":TSInstall query", + dependencies = { "nvim-treesitter" }, + cmd = { "TSPlaygroundToggle" }, + }, +} |