summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorDhruv Manilawala <dhruvmanila@gmail.com>2021-04-28 19:59:28 +0530
committerGitHub <noreply@github.com>2021-04-28 10:29:28 -0400
commit28ae702682ce9874f716a3258d4d1539e71bd161 (patch)
treeb94c782d6aea7a678d728cbd72d2f78ee61e3597 /lua
parent1675d370bfba182560aa526190cdf808a3a80420 (diff)
fix: use treesitter language name instead of ft if available (#801)
* fix: use treesitter language name if available This will fix the problem where the filetype is different than the treesitter lang name. Eg., filetyep -> "sh", langname -> "bash" * refactor: use treesitter only if the query object is available * refactor: ok -> parser_ok ;)
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/builtin/files.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/lua/telescope/builtin/files.lua b/lua/telescope/builtin/files.lua
index 6253545..bcdf8b6 100644
--- a/lua/telescope/builtin/files.lua
+++ b/lua/telescope/builtin/files.lua
@@ -368,10 +368,14 @@ files.current_buffer_fuzzy_find = function(opts)
})
end
- local ok, parser = pcall(vim.treesitter.get_parser, bufnr, filetype)
- if ok then
- local query = vim.treesitter.get_query(filetype, "highlights")
+ local ts_ok, ts_parsers = pcall(require, 'nvim-treesitter.parsers')
+ if ts_ok then
+ filetype = ts_parsers.ft_to_lang(filetype)
+ end
+ local parser_ok, parser = pcall(vim.treesitter.get_parser, bufnr, filetype)
+ local query_ok, query = pcall(vim.treesitter.get_query, filetype, "highlights")
+ if parser_ok and query_ok then
local root = parser:parse()[1]:root()
local highlighter = vim.treesitter.highlighter.new(parser)