Skip to content

Commit

Permalink
(mini.pick) FEATURE: Update builtin.help() to use tree-sitter highl…
Browse files Browse the repository at this point in the history
…ighting.
  • Loading branch information
echasnovski committed Dec 29, 2023
1 parent e587e75 commit eb5754a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ vim.keymap.set('i', '<C-z>', '<C-g>u<Esc>[s1z=`]a<C-g>u', { desc = 'Correct late
## mini.pick

- FEATURE: Implement `window.prompt_cursor` and `window.prompt_prefix` config options.
- FEATURE: Update `builtin.help()` to use tree-sitter highlighting (if there is any).

## mini.sessions

Expand Down
4 changes: 3 additions & 1 deletion lua/mini/pick.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,9 @@ MiniPick.builtin.help = function(local_opts, opts)
-- Take advantage of `taglist` output on how to open tag
vim.api.nvim_buf_call(buf_id, function()
vim.cmd('noautocmd edit ' .. vim.fn.fnameescape(item.filename))
vim.bo.buftype, vim.bo.buflisted, vim.bo.bufhidden, vim.bo.syntax = 'nofile', false, 'wipe', 'help'
vim.bo.buftype, vim.bo.buflisted, vim.bo.bufhidden = 'nofile', false, 'wipe'
local has_ts = pcall(vim.treesitter.start, 0)
if not has_ts then vim.bo.syntax = 'help' end

local cache_hlsearch = vim.v.hlsearch
-- Make a "very nomagic" search to account for special characters in tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
04|11111111111111111111111111111111111111111111111111111111111111111111111111111111
05|23222222222222222222222222222222222222222222222222211111111111111111111111111111
06|24444444444444444444444444444444444444444444444444211111111111111111111111111111
07|25666666666666666644444445555555666666665555555555211111111111111111111111111111
07|25555555555555555544444445555555666666665555555555211111111111111111111111111111
08|24444444444444444444444445555555566666666555555555211111111111111111111111111111
09|25555555555555555555555555555555555555555555555555211111111111111111111111111111
10|24444444444444444444444444444444444444444444444444211111111111111111111111111111
11|25566666666444444444444445555555666666655555555555211111111111111111111111111111
11|25555555555444444444444445555555555555555555555555211111111111111111111111111111
12|24444444444444444444444446666666655555555555555555211111111111111111111111111111
13|25555555555555555555555555555555555555555555555555211111111111111111111111111111
14|22222222222222222222222222222222222222222222222222211111111111111111111111111111
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
03|11111111111111111111111111111111111111111111111111111111111111111111111111111111
04|11111111111111111111111111111111111111111111111111111111111111111111111111111111
05|23333333322222222222222222222222222222222222222222211111111111111111111111111111
06|24444445444444454444444666666666666666666666666666211111111111111111111111111111
07|26666666666666666555555555555555555557777777755555211111111111111111111111111111
08|26666666666666666555555555555555555555555555555555211111111111111111111111111111
09|25555555555555555555555555555555555555555555555555211111111111111111111111111111
10|24444445444444444466666666666666666666666666666666211111111111111111111111111111
11|26666666666666666555555555555555555555555555555555211111111111111111111111111111
12|26666666666666666555555544444455555555555555555555211111111111111111111111111111
13|26666666666666666555555555555555555555555555555555211111111111111111111111111111
06|24444444555555545555555666666666666666666666666666211111111111111111111111111111
07|26666666666666666444444444444444444447777777744444211111111111111111111111111111
08|26666666666666666444444444444444444444444444444444211111111111111111111111111111
09|24444444444444444444444444444444444444444444444444211111111111111111111111111111
10|24444444555555555566666666666666666666666666666666211111111111111111111111111111
11|26666666666666666444444444444444444444444444444444211111111111111111111111111111
12|26666666666666666444444488888844444444444444444444211111111111111111111111111111
13|26666666666666666444444444444444444444444444444444211111111111111111111111111111
14|22222222222222222222222222222222222222222222222222211111111111111111111111111111
15|00000000000000000000000000000000000000000000000000000000000000000000000000000000
3 changes: 2 additions & 1 deletion tests/test_pick.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2733,7 +2733,8 @@ T['builtin.help()']['has proper preview'] = function()
type_keys('<Tab>')
child.expect_screenshot()
eq(child.bo.buftype, 'nofile')
eq(child.bo.syntax, 'help')
-- Neovim<0.8 should use built-in syntax, while Neovim>=0.8 - tree-sitter
if child.fn.has('nvim-0.8') == 0 then eq(child.bo.syntax, 'help') end

eq(child.v.hlsearch, 0)
eq(child.fn.getreg('/'), 'aa')
Expand Down

0 comments on commit eb5754a

Please sign in to comment.