vim-qf
vim-qf copied to clipboard
Create a generic command that populates the qf/loc list with the output of a list-like command
Basically, something like vim-qlist that would also work for :oldfiles, :changes, etc in a generic manner.
Scenario
:Toqf changeswould set a specificerrorformatand run:cexprwith the output of:changes.:Toloc tselect foowould set a specificerrorformatand run:cexprwith the output of:tselect foo.
Outputs from several commands
:changes
change line col text
1 148 0 \ include=^\\s*\\([^\/]\\{-\\}import[^'\"]*\\\|[^\/]\\{-\\}require\(\\)*['\"]\\zs[^'\"]*\\ze
>
:clist & :llist
1 .minivimrc:131 col 3: elseif cmdline =~ '\v\C^(cli|lli)' | return "\<CR>:silent " . repeat(cmdline[0], 2) . "\<Space>"
2 .minivimrc:132 col 3: elseif cmdline =~ '\C^changes' | set nomore | return "\<CR>:sil se more|norm! g;\<S-Left>"
3 .minivimrc:133 col 3: elseif cmdline =~ '\C^ju' | set nomore | return "\<CR>:sil se more|norm! \<C-o>\<S-Left>"
4 .minivimrc:134 col 3: elseif cmdline =~ '\C^ol' | set nomore | return "\<CR>:sil se more|e #<"
5 .minivimrc:135 col 3: elseif cmdline =~ '\C^undol' | return "\<CR>:u "
6 .minivimrc:136 col 3: elseif cmdline =~ '\C^ls' | return "\<CR>:b"
7 .minivimrc:137 col 3: elseif cmdline =~ '/#$' | return "\<CR>:"
8 .minivimrc:138 col 3: else | return "\<CR>" | endif
9 .minivimrc:139 col 2: else | return "\<CR>" | endif
:jumps
6 365 13 .vim/vimrc
5 365 13 .vim/vimrc
4 365 13 .vim/vimrc
3 130 0 if cmdline =~ '\v\C^(dli|il)' | return "\<CR>:" . cmdline[0] . "jump " . split(cmdline, " ")[1] . "\<S-Left>\<Left>"
2 148 0 \ include=^\\s*\\([^\/]\\{-\\}import[^'\"]*\\\|[^\/]\\{-\\}require\(\\)*['\"]\\zs[^'\"]*\\ze
1 1 0 " MINIVIMRC
>
:oldfiles
1: ~/.minivimrc
2: ~/.vim/vimrc
3: ~/Applications/MacVim.app/Contents/Resources/vim/runtime/doc/cmdline.txt
4: ~/Applications/MacVim.app/Contents/Resources/vim/runtime/doc/windows.txt
5: ~/Applications/MacVim.app/Contents/Resources/vim/runtime/doc/syntax.txt
6: ~/Desktop/foo.sql
7: /private/var/folders/j0/ppmv8dx13rb38ffc284r2_200000gn/T/Google Chrome - (null) 005.txt
8: ~/Applications/MacVim.app/Contents/Resources/vim/runtime/syntax/sqloracle.vim
9: ~/Applications/MacVim.app/Contents/Resources/vim/runtime/syntax/sql.vim
Substitution:
:s/^\(\d\+\):\s\(.\+\)$/\2:1:1:oldfile #\1
~/.vim/vimrc:1:1:oldfile #2
Notes:
- appears to work
- what about the cursor position?
:ls & :buffers & :files
1 %a + ".minivimrc" line 146
Substitution:
:s/^\s\+\d\+\s\([^\"]\+\)\s\+"\(.\+\)"\s\+line \(\d\+\)$/\=submatch(2) . ":" . (submatch(3) == 0 ? 1 : submatch(3)) . ":1:" . submatch(1)
.minivimrc:146:1:%a
Notes:
- works reasonably well
- but what about the column number?
- what to do with the status symbols?
- expand them to a human-readable form like
current,alternate,hidden, etc. - apply some custom highlighting?
- expand them to a human-readable form like
:number & :#
132 » » elseif cmdline =~ '\v\C^(cli|lli)' | return "\<CR>:silent " . repeat(cmdline[0], 2) . "\<Space>"
133 » » elseif cmdline =~ '\C^changes' | set nomore | return "\<CR>:sil se more|norm! g;\<S-Left>"
134 » » elseif cmdline =~ '\C^ju' | set nomore | return "\<CR>:sil se more|norm! \<C-o>\<S-Left>"
135 » » elseif cmdline =~ '\C^ol' | set nomore | return "\<CR>:sil se more|e #<"
136 » » elseif cmdline =~ '\C^undol' | return "\<CR>:u "
138 » » elseif cmdline =~ '\C^ls' | return "\<CR>:b"
139 » » elseif cmdline =~ '/#$' | return "\<CR>:"
140 » » else | return "\<CR>" | endif
141 » else | return "\<CR>" | endif
Substitution:
:s/^\s\+\(\d\+\)\s\(.\+\)$/\=expand("%") . ":" . submatch(1) . ":" . col('.') . ":" . submatch(2)
.minivimrc:140:8:» » else | return "\<CR>" | endif
Notes:
Works perfectly with the default errorformat.
:marks
mark line col file/text
' 1 0
C 394 0 ~/Sites/FullSIX-Site-Groupe/front/source/scss/modules/_groupe_v2.scss
H 11 26 ~/Sites/a.html
J 141 24 ~/Sites/FullSIX-Site-Groupe/front/source/js/modules/controller.js
O 26 8 ~/Sites/FullSIX-Site-Groupe/front/source/js/modules/contact.js
P 57 6 ~/Sites/FullSIX-Site-Groupe/symfony/src/AppBundle/Controller/AppController.php
R 399 0 ~/Desktop/foo.zob
S 36 2 ~/Sites/FullSIX-Site-Groupe/front/source/js/modules/contact.js
V 6 42 ~/.vim/bundle/custom/plugin/custom.vim
X 21 1 ~/Documents/f6-starter-kit/_scripts/js.sh
0 931 28 ~/Applications/MacVim.app/Contents/Resources/vim/runtime/doc/pattern.txt
1 5 18 ~/.inputrc
2 131 0 ~/.vim/colors/apprentice.vim
3 48 35 ~/.vim/colors/apprentice.erb
4 58 0 ~/Downloads/colorscheme_template.vim
Substitution:
:s/^\s\+\(.\)\s\+\(\d\+\)\s\+\(\d\+\)\s\(\f\+\)$/\=submatch(4) . ":" . submatch(2) . ":" . submatch(3) . ":" . submatch(1)
~/.inputrc:5:18:1
Notes:
- must get rid of the first line before applying substitution
- what to do if the mark is in the current file?
- marks need some kind of formatting
TODO
- Figure out a proper
errorformatfor each output.
Can that be further expanded to include support for the error formats of common programming languages!?
@z0xyz the idea, here, is (or was) to provide a common quickfix interface to all the built-in list-like commands like :marks, :jumps, :ls, etc. A universal parser is way out of scope. I vaguely remember someone starting to put together a comprehensive list of &efm years ago but that's really not something I would want to do, in general, or add to vim-qf, specifically.