diff --git a/.tmux.conf b/.tmux.conf index 033012b..ff50ab8 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -29,6 +29,6 @@ bind-key l select-pane -R set -g @plugin 'tmux-plugins/tpm' set -g @plugin 'tmux-plugins/tmux-sensible' #catpuccin theme -run ~/.config/tmux/plugins/catppuccin/tmux/catppuccin.tmux +run ~/.config/tmux/plugins/catppuccin/catppuccin.tmux run '~/.tmux/plugins/tpm/tpm' diff --git a/lua/plugins/plugin.lua b/lua/plugins/plugin.lua index 9222345..874b682 100644 --- a/lua/plugins/plugin.lua +++ b/lua/plugins/plugin.lua @@ -350,35 +350,41 @@ return { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", config = function() - require("nvim-treesitter.configs").setup({ - ensure_installed = { - -- Existing - "lua", "vim", "vimdoc", "bash", - -- Web - "javascript", "typescript", "tsx", "json", "yaml", "html", "css", "prisma", "graphql", - -- Rust - "rust", "toml", - -- Python - "python", - -- C/C++ - "c", "cpp", - -- Markdown - "markdown", "markdown_inline", - -- Tools - "sql", "http", - }, - highlight = { enable = true }, - indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - node_incremental = "", - scope_incremental = false, - node_decremental = "", - }, - }, + -- Install parsers + local ensure_installed = { + "lua", "vim", "vimdoc", "bash", + "javascript", "typescript", "tsx", "json", "yaml", "html", "css", "graphql", + "rust", "toml", + "python", + "c", "cpp", + "markdown", "markdown_inline", + "sql", + } + + -- Auto-install missing parsers + vim.api.nvim_create_autocmd("FileType", { + callback = function() + local ft = vim.bo.filetype + local lang = vim.treesitter.language.get_lang(ft) or ft + if vim.tbl_contains(ensure_installed, lang) then + pcall(vim.treesitter.start) + end + end, }) + + -- Enable treesitter highlighting globally + vim.treesitter.start = vim.treesitter.start or function() end + + -- Run TSUpdate to ensure parsers are installed + vim.defer_fn(function() + for _, lang in ipairs(ensure_installed) do + pcall(function() + if not pcall(vim.treesitter.language.inspect, lang) then + vim.cmd("TSInstall " .. lang) + end + end) + end + end, 100) end, },