local puk = require 'std.puk' local auto = require 'std.auto' local ignored = require 'std.ignored' local table = require 'std.table' require 'bugabinga.health'.add_dependency { name_of_executable = 'zig' } { name = 'TreeSitter CLI', name_of_executable = 'tree-sitter' } { name_of_executable = 'tar' } { name_of_executable = 'curl' } local treesitter = puk 'nvim-treesitter' treesitter.setup {} auto 'look_for_treesitter_parser' { description = 'Try loading a treesitter parser, if available.', events = 'FileType', pattern = '*', command = function(data) local match = data.match if table.contains(ignored.filetypes, match) then vim.notify('Ignore ' .. match .. ' for treesitter.', vim.log.levels.TRACE) return end -- try highlights local ok, err = pcall(vim.treesitter.start) if not ok then local available = require 'nvim-treesitter.parsers' local potential_parser = available[match] if potential_parser then vim.notify('Found potential treesitter parser for current filetype. Trying to install it. ' .. match) vim.cmd.TSInstall(match) require 'nvim-treesitter.install'.install(match, { force = false }, function() vim.treesitter.start() -- vim.cmd.edit() end) else vim.notify(err, vim.log.levels.ERROR) end return end -- indents vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" -- folds, even though i do not care... vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' end, }