@@ -19,71 +19,6 @@ local function get_highlight_query(lang)
1919 end
2020end
2121
22- --- @param bufnr integer
23- --- @param lnum integer
24- --- @return quicker.TSHighlight[]
25- function M .buf_get_ts_highlights (bufnr , lnum )
26- local filetype = vim .bo [bufnr ].filetype
27- if not filetype or filetype == " " then
28- filetype = vim .filetype .match ({ buf = bufnr }) or " "
29- end
30- local lang = vim .treesitter .language .get_lang (filetype ) or filetype
31- if lang == " " then
32- return {}
33- end
34- local ok , parser = pcall (vim .treesitter .get_parser , bufnr , lang )
35- if not ok or not parser then
36- return {}
37- end
38-
39- local row = lnum - 1
40- if not parser :is_valid () then
41- parser :parse (true )
42- end
43-
44- local highlights = {}
45- parser :for_each_tree (function (tstree , tree )
46- if not tstree then
47- return
48- end
49-
50- local root_node = tstree :root ()
51- local root_start_row , _ , root_end_row , _ = root_node :range ()
52-
53- -- Only worry about trees within the line range
54- if root_start_row > row or root_end_row < row then
55- return
56- end
57-
58- local query = get_highlight_query (tree :lang ())
59-
60- -- Some injected languages may not have highlight queries.
61- if not query then
62- return
63- end
64-
65- for capture , node , metadata in query :iter_captures (root_node , bufnr , row , root_end_row + 1 ) do
66- if capture == nil then
67- break
68- end
69-
70- local range = vim .treesitter .get_range (node , bufnr , metadata [capture ])
71- local start_row , start_col , _ , end_row , end_col , _ = unpack (range )
72- if start_row > row then
73- break
74- end
75- local capture_name = query .captures [capture ]
76- local hl = string.format (" @%s.%s" , capture_name , tree :lang ())
77- if end_row > start_row then
78- end_col = - 1
79- end
80- table.insert (highlights , { start_col , end_col , hl })
81- end
82- end )
83-
84- return highlights
85- end
86-
8722--- @class quicker.LSPHighlight
8823--- @field [ 1] integer start_col
8924--- @field [ 2] integer end_col
@@ -157,50 +92,6 @@ function M.buf_get_lsp_highlights(bufnr, lnum)
15792 return lsp_highlights
15893end
15994
160- --- @param item QuickFixItem
161- --- @param line string
162- --- @return quicker.TSHighlight[]
163- M .get_heuristic_ts_highlights = function (item , line )
164- local filetype = vim .filetype .match ({ buf = item .bufnr })
165- if not filetype then
166- return {}
167- end
168-
169- local lang = vim .treesitter .language .get_lang (filetype )
170- if not lang then
171- return {}
172- end
173-
174- local has_parser , parser = pcall (vim .treesitter .get_string_parser , line , lang )
175- if not has_parser then
176- return {}
177- end
178-
179- local root = parser :parse (true )[1 ]:root ()
180- local query = vim .treesitter .query .get (lang , " highlights" )
181- if not query then
182- return {}
183- end
184-
185- local highlights = {}
186- for capture , node , metadata in query :iter_captures (root , line ) do
187- if capture == nil then
188- break
189- end
190-
191- local range = vim .treesitter .get_range (node , line , metadata [capture ])
192- local start_row , start_col , _ , end_row , end_col , _ = unpack (range )
193- local capture_name = query .captures [capture ]
194- local hl = string.format (" @%s.%s" , capture_name , lang )
195- if end_row > start_row then
196- end_col = - 1
197- end
198- table.insert (highlights , { start_col , end_col , hl })
199- end
200-
201- return highlights
202- end
203-
20495function M .set_highlight_groups ()
20596 if vim .tbl_isempty (vim .api .nvim_get_hl (0 , { name = " QuickFixHeaderHard" })) then
20697 vim .api .nvim_set_hl (0 , " QuickFixHeaderHard" , { link = " Delimiter" , default = true })
0 commit comments