local map, auto = core.misc.map, core.misc.auto local function highlight(buf) local lang = vim.bo[buf].ft if table.contains({ "diff", "tex" }, lang) then return false end -- disable in big files local ok, stats = pcall(vim.uv.fs_stat, vim.api.nvim_buf_get_name(buf)) if ok and stats and stats.size > (1024 * 100 * 10) --[[1MB]] then return false end return true end local function indent(buf) local lang = vim.bo[buf].ft -- disable indenting in php (it's more broken with than without) return not table.contains({ "php" }, lang) end return { { "nvim-treesitter/nvim-treesitter", branch = "main", config = function() vim.cmd("TSUpdate") end, load = function() local treesitter = require("nvim-treesitter") treesitter.setup {} treesitter.install({ "c", "lua", "vim", "vimdoc", "markdown", "markdown_inline", "java", "bash", "css", "html", "luadoc", "make", "zig" }, { force = false, summary = false, }) auto("FileType", { callback = function(ev) if highlight(ev.buf) then pcall(vim.treesitter.start) vim.bo[ev.buf].syntax = "ON" end if indent(ev.buf) then vim.bo[ev.buf].indentexpr = "v:lua.require('nvim-treesitter').indentexpr()" end end, }) core.misc.map("n", "t", function() treesitter.install { vim.bo[0].ft } end) end }, { "Wansmer/treesj", disable = not vim.fn.has("nvim-0.9.0"), reqs = "nvim-treesitter/nvim-treesitter", lazy = function(load) load:keymap("n", "j") load:cmd("TSJToggle") load:cmd("TSJSplit") load:cmd("TSJJoin") end, load = function() require("treesj").setup { use_default_keymaps = false, } map("n", "j", require("treesj").toggle, { desc = "fold code" }) end }, }