diff --git a/plugin/40_plugins.lua b/plugin/40_plugins.lua index 8a6760d..8276f38 100644 --- a/plugin/40_plugins.lua +++ b/plugin/40_plugins.lua @@ -9,7 +9,6 @@ end) -- Treesitter Config.now_if_args(function() - vim.pack.add({ 'https://github.com/nvim-treesitter/nvim-treesitter' }) local filetypes = { 'html', 'css', 'lua', 'go', 'php', 'blade', 'sql', 'javascript', @@ -17,14 +16,14 @@ Config.now_if_args(function() 'json', 'xml', 'toml', 'sh', 'bash', 'zsh', 'just', 'gitcommit', 'diff', 'regex', 'http' } - Config.on_filetype(table.concat(filetypes, ','), function() - local buf = vim.api.nvim_get_current_buf() - if pcall(vim.treesitter.start, buf) and vim.bo[buf].filetype == 'php' then - vim.bo[buf].indentexpr = 'v:lua.require"nvim-treesitter".indentexpr()' + Config.autocmd('FileType', filetypes, function(ev) + if pcall(vim.treesitter.start, ev.buf) and vim.bo[ev.buf].filetype == 'php' then + vim.bo[ev.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end - end) + end, 'Start tree-sitter') Config.later(function() + vim.pack.add({ 'https://github.com/nvim-treesitter/nvim-treesitter' }) require('nvim-treesitter').install(vim.tbl_map(function(ft) return vim.treesitter.language.get_lang(ft) or ft end, filetypes))