my attempt to use the treesitter rewrite

it'd be nice to use this but it forces me to chase the cli util which isn't
reasonable whatsoever, additionally:
- It can't seem to check if something is installed before attempting to
  reinstall it
- It won't shut the fuck up with all it's messages even though it's not
  even supposed to show messages by default

I'm sure the codebase is less of a mess but the ergonomics from a user
standpoint is absolutely worse.
This commit is contained in:
Squibid 2025-12-17 22:15:45 -05:00
parent a25ca205ca
commit f095d0cbf5
Signed by: squibid
GPG key ID: BECE5684D3C4005D

View file

@ -1,58 +1,59 @@
local map = core.misc.map 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 { return {
{ "nvim-treesitter/nvim-treesitter", { "nvim-treesitter/nvim-treesitter",
branch = "main",
config = function() config = function()
vim.cmd("TSUpdate") vim.cmd("TSUpdate")
end, end,
load = function() load = function()
require("nvim-treesitter.configs").setup { local treesitter = require("nvim-treesitter")
-- good default parsers treesitter.setup {}
ensure_installed = { "c", "lua", "vim", "vimdoc", "markdown", treesitter.install({
"markdown_inline", "java", "bash", "css", "html", "luadoc", "c", "lua", "vim", "vimdoc", "markdown",
"make", "zig" "markdown_inline", "java", "bash", "css", "html", "luadoc",
}, "make", "zig"
}, {
force = false,
summary = false,
})
-- indentation auto("FileType", {
indent = { callback = function(ev)
enable = true, if highlight(ev.buf) then
pcall(vim.treesitter.start)
disable = function(lang, _) vim.bo[ev.buf].syntax = "ON"
-- disable indenting in php (it's more broken with than without)
return table.contains(({
"php"
}), lang)
end end
}, if indent(ev.buf) then
vim.bo[ev.buf].indentexpr = "v:lua.require('nvim-treesitter').indentexpr()"
-- 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
} end,
} })
core.misc.map("n", "<leader><leader>t", function() core.misc.map("n", "<leader><leader>t", function()
pcall(vim.cmd.TSInstall, vim.api.nvim_get_option_value("ft", { treesitter.install { vim.bo[0].ft }
buf = vim.api.nvim_get_current_buf()
}))
end) end)
end end
}, },