Skip to content

Commit

Permalink
feat(list): support g:coc_list_preview_filetype
Browse files Browse the repository at this point in the history
Closes #4674
  • Loading branch information
chemzqm committed Sep 2, 2023
1 parent 5347239 commit 5353e87
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 8 additions & 4 deletions autoload/coc/list.vim
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,14 @@ function! s:preview_highlights(winid, bufnr, config, float) abort
call sign_unplace(sign_group, {'buffer': a:bufnr})
let lnum = get(a:config, 'lnum', 1)
if !empty(filetype)
let start = max([0, lnum - 300])
let end = min([coc#compat#buf_line_count(a:bufnr), lnum + 300])
call coc#highlight#highlight_lines(a:winid, [{'filetype': filetype, 'startLine': start, 'endLine': end}])
call coc#compat#execute(a:winid, 'syn sync fromstart')
if get(g:, 'coc_list_preview_filetype', 0)
call coc#compat#execute(a:winid, 'setf '.filetype)
else
let start = max([0, lnum - 300])
let end = min([coc#compat#buf_line_count(a:bufnr), lnum + 300])
call coc#highlight#highlight_lines(a:winid, [{'filetype': filetype, 'startLine': start, 'endLine': end}])
call coc#compat#execute(a:winid, 'syn sync fromstart')
endif
else
call coc#compat#execute(a:winid, 'filetype detect')
let ft = getbufvar(a:bufnr, '&filetype', '')
Expand Down
4 changes: 4 additions & 0 deletions doc/coc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,10 @@ g:coc_start_at_startup *g:coc_start_at_startup*

Default: 1

g:coc_list_preview_filetype *g:coc_list_preview_filetype*

Enable set filetype for buffer in the preview window of |CocList|.

g:coc_global_extensions *g:coc_global_extensions*

Global extension names to install when they aren't installed.
Expand Down

0 comments on commit 5353e87

Please sign in to comment.