fix: dont change highlights when using current_buffer_fuzzy_find (#1524)

this happens if parsers are installed but highlight is set to false.
So parsing the buffer with treesitter will automatically apply them to
the buffer but because treesitter highlighting is disabled it will
change the buffer. Its stupid and i dont know why you want parser
installed but highlighting disabled but whatever.

We just dont calculate highlights for people who have highlight set
to false
This commit is contained in:
Simon Hauser
2021-12-03 14:46:53 +01:00
committed by GitHub
parent 4e075bf924
commit 60a4ce080f

View File

@@ -487,10 +487,11 @@ files.current_buffer_fuzzy_find = function(opts)
if ts_ok then if ts_ok then
filetype = ts_parsers.ft_to_lang(filetype) filetype = ts_parsers.ft_to_lang(filetype)
end end
local _, ts_configs = pcall(require, "nvim-treesitter.configs")
local parser_ok, parser = pcall(vim.treesitter.get_parser, bufnr, filetype) local parser_ok, parser = pcall(vim.treesitter.get_parser, bufnr, filetype)
local query_ok, query = pcall(vim.treesitter.get_query, filetype, "highlights") local query_ok, query = pcall(vim.treesitter.get_query, filetype, "highlights")
if parser_ok and query_ok then if ts_configs.is_enabled("highlight", filetype, bufnr) and parser_ok and query_ok then
local root = parser:parse()[1]:root() local root = parser:parse()[1]:root()
local highlighter = vim.treesitter.highlighter.new(parser) local highlighter = vim.treesitter.highlighter.new(parser)