As @justinmk suggetsted I am re-opening neovim/neovim#10056 here
I write rust with rls and often use quickfix window to find issues.
If you compare how similar "quickfix" window looks in Emacs you will notice that the output is
justified by columns, and overall is more readable.
I have not found any options to format the output of the quickfix window. It would be great to have
the ability to provide printf-like format a string for quickfix item, specifying column lengths, and inlucing/excluding items like column numbers, error codes etc.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
I often use quickfix commands, but I rarely use the quickfix window. I have in fact some of the following mappings for easier moving about in the quickfix list:
if exists(':map') == 2 if has('quickfix') map <F2> :cnext<CR> map <S-F2> :cprev<CR> map <F3> :cnfile<CR> map <S-F3> :cpfile<CR> map <F4> :cfirst<CR> map <S-F4> :clast<CR> endif endif
Some are more useful than others so you may want to put only some of them in your vimrc.
This said, I think that what you see is due to the history of how the quickfix feature was added to Vim: the :make command and the 'errorformat' option were added first, to help Vim decode compilers' output messages and bring up the corresponding source line. Then (IIRC) :grep, :helpgrep and :vimgrep (in that order) were added to treat the grep utility as a compiler, and then to add Vim-intrinsic capabilities for searching the helpfiles, then any files, according to Vim's own regular expresion syntax.
The format of a compiler's output is of course something over which Vim has no control. In the case of the intrinsic :helpgrep and :vimgrep commands, there are pluses and minuses to what you are requesting: among the minus points, aligning the text would IIUC require two-pass handling, one pass to determine the longest string in each column and then a second pass to output the text; then the extra spaces would mean that the visible source text would be truncated earlier than now whenever the text representing the filename, line and column would be shorter than the maximum (and therefore be padded with a certain number of spaces).
Best regards,
Tony.
This is not what you want, but in the meantime, to make the entries aligned, I use something like this in ~/.vim/after/plugin/qf.vim:
if executable('column') && executable('sed')
let s:ul_save = &l:ul
setl modifiable ul=-1
sil! exe "%!sed 's/|/\<c-a>|/1'"
sil! exe "%!sed 's/|/\<c-a>|/2'"
sil! exe "%!column -s '\<c-a>' -t"
let &l:ul = s:ul_save
unlet! s:ul_save
setl nomodifiable nomodified
endif
It requires the $ sed and $ column utilities.
And to shorten the file paths, if you have the patch 8.0.1782, you can use the 'module' property of the quickfix list to change the text which is displayed:
call setqflist([], 'r', {'items': map(getqflist(),
\ {i,v -> extend(v, {'module': substitute(fnamemodify(bufname(v.bufnr), ':t'), '.\{7}\zs.\+', '…', '')})})})
if executable('column') && executable('sed')
let s:ul_save = &l:ul
setl modifiable ul=-1
sil! exe "%!sed 's/|/\<c-a>|/1'"
sil! exe "%!sed 's/|/\<c-a>|/2'"
sil! exe "%!column -s '\<c-a>' -t"
let &l:ul = s:ul_save
unlet! s:ul_save
setl nomodifiable nomodified
endif
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.![]()
Just for reference: Neomake has an experimental/optional feature to re-format the quickfix/location list (via neomake#quickfix#enable()).
It applies formatting according to / based on the makers/linters that were used, and adds basic highlighting, e.g. for E\d+ from Python's flake8.
It also shortens / aligns columns, and only displays the buffer name if necessary (when multiple buffers are in the list), otherwise (and in general) the quickfix title is used.
lnum/cols and maker names are aligned.
With multiple buffers it adds the name to the first entry where it changes. When it would use a separate column for this, a lot of space would be wasted (since that's repeated information).
I see that this is very specific to Neomake's use case, and especially for having a single buffer therein mostly, but just wanted to share this anyway
One quick/good improvement would be to use fname:39:15 instead of fname|39 col 15|, which also makes it easier to copy'n'paste for other tools (that handle fname:lnum).
Although it should probably not use fname:col then, but maybe rather fname::col (for then there is no lnum, but only a column).
isn't it possible to make use of concealing for aligning?
—
You are receiving this because you commented.
@vim-ml how can I try this option? Is this in master?
—
You are receiving this because you were mentioned.
Just as an FYI there are plugins like vim-addon-qf-layout that alter the contents of the quickfix window. I use this simplified version.
This will of course throw off what Vim considers to be the expected syntax. So if you care about that you'll need to re-define qfFileName, qfSeparator, qfLineNr, and qfError accordingly.
—
You are receiving this because you were mentioned.
I think this is fixed by 8.2.0869 which provides the global option 'quickfixtextfunc', as well as a quickfix list attribute with the same name.
I had a look at the screenshot; you could get the desired result, or at least something close enough with this code:
vim -Nu NONE -S <(cat <<'EOF'
set qftf=QuickFixTextFunc nowrap
fu QuickFixTextFunc(info) abort
if a:info.quickfix
let size = getqflist({'size': 1}).size
let e = getqflist({'id': a:info.id, 'idx': a:info.idx, 'items': 1}).items[0]
else
let size = getloclist(0, {'size': 1}).size
let e = getloclist(0, {'id': a:info.id, 'idx': a:info.idx, 'items': 1}).items[0]
endif
if size > 1000 | return 'some text' | endif
let fname = fnamemodify(bufname(e.bufnr), ':t')
if strchars(fname, 1) <= 8
let fname = printf('%8s', fname)
else
let fname = printf('%.7s', fname)..'…'
endif
let lnum = printf('%5d', e.lnum)
let col = printf('%3d', e.col)
return fname..'|'..lnum..' col '..col..'| '..e.text
endfu
EOF
) +'helpg foobar' +copen
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
Closed #4425.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
closing then. Thanks.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()