diff options
author | kylo252 <[email protected]> | 2021-12-28 09:48:42 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-12-28 09:48:42 +0100 |
commit | 656a452909efb5b83dcf5af00455956116353a72 (patch) | |
tree | c3187ca7e10c986dbcab6b5d1ac36b5b295ee649 | |
parent | fefe78d81c9ee0fa4231b11e1c623e72960f5856 (diff) |
refactor: avoid running ts.setup in headless (#2119)
-rw-r--r-- | lua/lvim/core/treesitter.lua | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lua/lvim/core/treesitter.lua b/lua/lvim/core/treesitter.lua index 8dbbcacb..d8b0c136 100644 --- a/lua/lvim/core/treesitter.lua +++ b/lua/lvim/core/treesitter.lua @@ -74,16 +74,20 @@ M.config = function() end M.setup = function() + -- avoid running in headless mode since it's harder to detect failures + if #vim.api.nvim_list_uis() == 0 then + Log:debug "headless mode detected, skipping running setup for treesitter" + return + end + local status_ok, treesitter_configs = pcall(require, "nvim-treesitter.configs") if not status_ok then - Log:get_default().error "Failed to load nvim-treesitter.configs" + Log:error "Failed to load nvim-treesitter.configs" return end local opts = vim.deepcopy(lvim.builtin.treesitter) - -- avoid running any installers in headless mode since it's harder to detect failures - opts.ensure_installed = #vim.api.nvim_list_uis() == 0 and {} or opts.ensure_installed treesitter_configs.setup(opts) if lvim.builtin.treesitter.on_config_done then |