Files
nvim/lua/conf/plugins/treesitter.lua

82 lines
2.2 KiB
Lua

local map, auto = core.misc.map, core.misc.auto
return {
{ "nvim-treesitter/nvim-treesitter",
disable = not vim.fn.has("nvim-0.10.0"),
config = function()
vim.cmd("TSUpdate")
end,
load = function()
require("nvim-treesitter.configs").setup {
-- good default parsers
ensure_installed = { "c", "lua", "vim", "vimdoc", "markdown",
"markdown_inline", "java", "bash", "css", "html", "luadoc",
"make"
},
-- indentation
indent = {
enable = true,
disable = function(lang, _)
-- disable indenting in php (it's more broken with than without)
return table.contains(({
"php"
}), lang)
end
},
-- enable highlighting
highlight = {
enable = true,
-- use vim highlighting in addition to treesitter
additional_vim_regex_highlighting = true,
disable = function(lang, buf)
-- disable in some files where vim's builtin highlighting is better
if table.contains(({
"diff", "tex"
}), lang) then
return true
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 true
end
end
}
}
end
},
{ "Wansmer/treesj",
disable = not vim.fn.has("nvim-0.9.0"),
reqs = "nvim-treesitter/nvim-treesitter",
lazy = function(load)
load:keymap("n", "<leader>j")
load:cmd("TSJToggle")
load:cmd("TSJSplit")
load:cmd("TSJJoin")
end,
load = function()
require("treesj").setup {
use_default_keymaps = false,
}
map("n", "<leader>j", require("treesj").toggle, { desc = "fold code" })
end
},
{ "windwp/nvim-ts-autotag",
reqs = "nvim-treesitter/nvim-treesitter",
disable = not vim.fn.has("nvim-0.9.5"),
-- lazy = dep_short.auto({ "BufReadPre", "BufNewFile" }),
load = function()
require("nvim-ts-autotag").setup {}
end
}
}