diff --git a/config/nvim/lua/core/plugins.lua b/config/nvim/lua/core/plugins.lua index 37d2dae..443338b 100644 --- a/config/nvim/lua/core/plugins.lua +++ b/config/nvim/lua/core/plugins.lua @@ -55,16 +55,26 @@ require("lazy").setup({ { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", - opts = { - ensure_installed = { + config = function() + local langs = { "lua", "bash", "yaml", "json", "toml", "dockerfile", "nix", "python", "markdown", "diff", "git_config", - }, - highlight = { enable = true }, - indent = { enable = true }, - }, - config = function(_, opts) - require("nvim-treesitter.configs").setup(opts) + } + -- old API (nvim-treesitter < 1.0, nvim 0.9.x) + local ok, configs = pcall(require, "nvim-treesitter.configs") + if ok then + configs.setup({ + ensure_installed = langs, + highlight = { enable = true }, + indent = { enable = true }, + }) + return + end + -- new API (nvim-treesitter >= 1.0, nvim 0.10+): highlight is built-in + local ts_ok, ts = pcall(require, "nvim-treesitter") + if ts_ok and ts.install then + ts.install(langs) + end end, },