summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorelianiva <dicha.arkana03@gmail.com>2021-01-30 23:34:05 +0700
committerGitHub <noreply@github.com>2021-01-30 23:34:05 +0700
commitb1fb172b7f56f92c954e5dc3f62b21dd6a4fbe3d (patch)
treec6512cb7aa1f5e832a95d86bd7713096f297e9dc /lua
parent2a5db2f4f1b72b5e8f565773395efe4e4569728c (diff)
fix: no TS highlight if it gets loaded after Telescope (#479)
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/previewers/utils.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/lua/telescope/previewers/utils.lua b/lua/telescope/previewers/utils.lua
index 67fded8..ac5ce86 100644
--- a/lua/telescope/previewers/utils.lua
+++ b/lua/telescope/previewers/utils.lua
@@ -72,6 +72,14 @@ end
-- Attach ts highlighter
utils.ts_highlighter = function(bufnr, ft)
+ if not has_ts then
+ has_ts, _ = pcall(require, 'nvim-treesitter')
+ if has_ts then
+ _, ts_highlight = pcall(require, 'nvim-treesitter.highlight')
+ _, ts_parsers = pcall(require, 'nvim-treesitter.parsers')
+ end
+ end
+
if has_ts and has_filetype(ft) then
local lang = ts_parsers.ft_to_lang(ft);
if ts_parsers.has_parser(lang) then