qf.vim 973 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. " Vim filetype plugin file
  2. " Language: Vim's quickfix window
  3. " Maintainer: Lech Lorens <Lech.Lorens@gmail.com>
  4. " Last Change: 2019 Jul 15
  5. if exists("b:did_ftplugin")
  6. finish
  7. endif
  8. " Don't load another plugin for this buffer
  9. let b:did_ftplugin = 1
  10. if !get(g:, 'qf_disable_statusline')
  11. let b:undo_ftplugin = "set stl<"
  12. " Display the command that produced the list in the quickfix window:
  13. setlocal stl=%t%{exists('w:quickfix_title')?\ '\ '.w:quickfix_title\ :\ ''}\ %=%-15(%l,%c%V%)\ %P
  14. endif
  15. function! s:setup_toc() abort
  16. if get(w:, 'quickfix_title') !~# '\<TOC$' || &syntax != 'qf'
  17. return
  18. endif
  19. let list = getloclist(0)
  20. if empty(list)
  21. return
  22. endif
  23. let bufnr = list[0].bufnr
  24. setlocal modifiable
  25. silent %delete _
  26. call setline(1, map(list, 'v:val.text'))
  27. setlocal nomodifiable nomodified
  28. let &syntax = getbufvar(bufnr, '&syntax')
  29. endfunction
  30. augroup qf_toc
  31. autocmd!
  32. autocmd Syntax <buffer> call s:setup_toc()
  33. augroup END