diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 22:39:54 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 22:39:54 +0000 |
commit | 21cb7d04c387e4198ca8098a884c78b56ffcf4c2 (patch) | |
tree | 84fe5690df1551f0bb2bdfe1a13aacd29ebc1de7 /runtime/lua/vim/vimhelp.lua | |
parent | d9c904f85a23a496df4eb6be42aa43f007b22d50 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-colorcolchar.tar.gz rneovim-colorcolchar.tar.bz2 rneovim-colorcolchar.zip |
Merge remote-tracking branch 'upstream/master' into colorcolcharcolorcolchar
Diffstat (limited to 'runtime/lua/vim/vimhelp.lua')
-rw-r--r-- | runtime/lua/vim/vimhelp.lua | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/runtime/lua/vim/vimhelp.lua b/runtime/lua/vim/vimhelp.lua new file mode 100644 index 0000000000..a4d6a50b12 --- /dev/null +++ b/runtime/lua/vim/vimhelp.lua @@ -0,0 +1,31 @@ +-- Extra functionality for displaying Vim help. + +local M = {} + +-- Called when editing the doc/syntax.txt file +function M.highlight_groups() + local save_cursor = vim.fn.getcurpos() + + local start_lnum = vim.fn.search([[\*highlight-groups\*]], 'c') + if start_lnum == 0 then + return + end + local end_lnum = vim.fn.search('^======') + if end_lnum == 0 then + return + end + + local ns = vim.api.nvim_create_namespace('vimhelp') + vim.api.nvim_buf_clear_namespace(0, ns, 0, -1) + + for lnum = start_lnum, end_lnum do + local word = vim.api.nvim_buf_get_lines(0, lnum - 1, lnum, true)[1]:match('^(%w+)\t') + if vim.fn.hlexists(word) ~= 0 then + vim.api.nvim_buf_set_extmark(0, ns, lnum - 1, 0, { end_col = #word, hl_group = word }) + end + end + + vim.fn.setpos('.', save_cursor) +end + +return M |