Fix treesitter again

This commit is contained in:
Thomas Avé 2025-12-19 16:30:48 +01:00
parent 435d6f5822
commit 9de92b3c62
2 changed files with 16 additions and 16 deletions

View File

@ -35,9 +35,9 @@ in
wayland.windowManager.hyprland.settings = { wayland.windowManager.hyprland.settings = {
monitor = [ monitor = [
"eDP-1,2880x1800@120.00Hz,480x0,1.2,vrr,1" "eDP-1,2880x1800@120.00Hz,480x0,1.2,vrr,1"
"DP-1,1920x1080,6240x500,1"
"HDMI-A-1,3840x2160@60.00Hz,0x-2160,1" "HDMI-A-1,3840x2160@60.00Hz,0x-2160,1"
"DP-3,1920x1080,3840x-540,1" "DP-3,1920x1080,3840x-540,1"
"DP-1,1920x1080,3840x-540,1"
]; ];
bind = [ bind = [
", XF86PowerOff, exec, ${pkgs.rofi}/bin/rofi -show power-menu -modi power-menu:${ ", XF86PowerOff, exec, ${pkgs.rofi}/bin/rofi -show power-menu -modi power-menu:${

View File

@ -1,6 +1,6 @@
return { return {
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
-- branch = 'main', -- This is the default now branch = 'main',
lazy = false, lazy = false,
config = function() config = function()
-- 1. Install Parsers -- 1. Install Parsers
@ -10,28 +10,28 @@ return {
"rust", "sql", "yaml", "markdown", "markdown_inline", "nix", "bibtex" "rust", "sql", "yaml", "markdown", "markdown_inline", "nix", "bibtex"
}) })
-- 2. Enable Highlighting via Autocmd -- 2. Safe Autocmd for Highlighting & Indent
vim.api.nvim_create_autocmd('FileType', { vim.api.nvim_create_autocmd('FileType', {
callback = function(args) callback = function(args)
-- Disable logic (ini, markdown, or large files) -- Get the language associated with the filetype
local ft = vim.bo[args.buf].filetype local lang = vim.treesitter.language.get_lang(vim.bo[args.buf].filetype)
if ft == "ini" or ft == "markdown" then return end if not lang then return end
-- IGNORE specific filetypes or large files
if lang == "ini" then return end
local max_filesize = 2000 * 1024 -- 2MB local max_filesize = 2000 * 1024 -- 2MB
local ok, stats = pcall(vim.uv.fs_stat, vim.api.nvim_buf_get_name(args.buf)) local ok, stats = pcall(vim.uv.fs_stat, vim.api.nvim_buf_get_name(args.buf))
if ok and stats and stats.size > max_filesize then return end if ok and stats and stats.size > max_filesize then return end
-- Enable highlighting -- SAFEGUARD: Try to start. If it fails (e.g., 'snacks_layout_box'), 'success' will be false.
vim.treesitter.start() local success, _ = pcall(vim.treesitter.start, args.buf, lang)
end,
})
-- 3. Enable Indentation -- Only enable indentation if Treesitter actually started successfully
vim.api.nvim_create_autocmd('FileType', { if success then
pattern = '*', vim.bo[args.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
callback = function() end
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end,
end
}) })
end, end,
} }