diff --git a/autoload/coc/list.vim b/autoload/coc/list.vim index afd4952e777..19bbb910ef0 100644 --- a/autoload/coc/list.vim +++ b/autoload/coc/list.vim @@ -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', '') diff --git a/doc/coc.txt b/doc/coc.txt index 549c0200c12..701a909b3a2 100644 --- a/doc/coc.txt +++ b/doc/coc.txt @@ -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.