60 lines
1.5 KiB
VimL
60 lines
1.5 KiB
VimL
scriptencoding UTF-8
|
|
|
|
""
|
|
" QuickFix custom foldtext expression.
|
|
"
|
|
" setlocal foldexpr=kutsan#ftplugin#qf#foldexpr()
|
|
""
|
|
function! qf#foldtext() abort
|
|
let l:lines = v:foldend - v:foldstart + 1
|
|
let l:file = substitute(getline(v:foldstart), '\v\c\|.+', '', '')
|
|
|
|
return printf('%s [%s]', l:file, l:lines)
|
|
endfunction
|
|
|
|
""
|
|
" QuickFix custom fold expression.
|
|
"
|
|
" setlocal foldtext=kutsan#ftplugin#qf#foldtext(v:lnum)
|
|
"
|
|
" @param {number} lnum Line number for the 'foldexpr'.
|
|
""
|
|
function! qf#foldexpr(lnum) abort
|
|
if matchstr(getline(a:lnum), '\v\c^[^|]+') ==# matchstr(getline(a:lnum + 1), '\v\c^[^|]+')
|
|
return 1
|
|
else
|
|
return '<1'
|
|
endif
|
|
endfunction
|
|
|
|
" Disable built-in ftplugin.
|
|
let b:did_ftplugin = v:true
|
|
|
|
" Disable relative numbers and use just numbers.
|
|
setlocal norelativenumber
|
|
setlocal number
|
|
|
|
" Use custom fold expression.
|
|
setlocal foldmethod=expr
|
|
setlocal foldexpr=qf#foldexpr(v:lnum)
|
|
|
|
" Use custom foldtext.
|
|
setlocal foldtext=qf#foldtext()
|
|
|
|
" Start with all folds open.
|
|
setlocal foldlevel=99
|
|
|
|
" Make quickfix buffer hidden.
|
|
setlocal nobuflisted
|
|
|
|
" Set statusline.
|
|
setlocal statusline=%{repeat('\ ',4)} " Generate space characters given number of times.
|
|
setlocal statusline+= " Show a custom list icon.
|
|
setlocal statusline+=%{repeat('\ ',1)}
|
|
setlocal statusline+=%t " File name, either [Quickfix List] or [Location List].
|
|
setlocal statusline+=%= " Align all items to right from this point on.
|
|
setlocal statusline+=%{repeat('\ ',1)}
|
|
setlocal statusline+=%l/%L " Current line number and total item count.
|
|
setlocal statusline+=%{repeat('\ ',1)}
|
|
|