commit 5067d0f5e4d48f39e5e4b46cb0ab78d1b1aa5850
parent a435601e2d0dcbc44f068136598247e64c3dcb38
Author: Tomas Nemec <nemi@skaut.cz>
Date: Tue, 25 Jan 2022 14:02:23 +0100
update
Diffstat:
3 files changed, 68 insertions(+), 1 deletion(-)
diff --git a/plugin/grep.lua b/plugin/grep.lua
@@ -8,7 +8,7 @@ function! GrepOperator(type)
return
endif
- silent execute "grep! " . shellescape(@@) . " ."
+ silent execute "grep! -e " . shellescape(@@) . " ."
copen
endfunction
]]
diff --git a/plugin/qftf.lua b/plugin/qftf.lua
@@ -0,0 +1,44 @@
+function _G.qftf(info)
+ local items
+ local ret = {}
+ if info.quickfix == 1 then
+ items = vim.fn.getqflist({id = info.id, items = 0}).items
+ else
+ items = vim.fn.getloclist(info.winid, {id = info.id, items = 0}).items
+ end
+ local limit = 31
+ local fname_fmt1, fname_fmt2 = '%-' .. limit .. 's', '…%.' .. (limit - 1) .. 's'
+ local valid_fmt = '%s │%4d:%-3d│%s %s'
+ for i = info.start_idx, info.end_idx do
+ local e = items[i]
+ local fname = ''
+ local str
+ if e.valid == 1 then
+ if e.bufnr > 0 then
+ fname = vim.fn.bufname(e.bufnr)
+ if fname == '' then
+ fname = '[No Name]'
+ else
+ fname = fname:gsub('^' .. vim.env.HOME, '~')
+ end
+ -- char in fname may occur more than 1 width, ignore this issue in order to keep performance
+ if #fname <= limit then
+ fname = fname_fmt1:format(fname)
+ else
+ fname = fname_fmt2:format(fname:sub(1 - limit))
+ end
+ end
+ local lnum = e.lnum > 99999 and -1 or e.lnum
+ local col = e.col > 999 and -1 or e.col
+ local qtype = e.type == '' and '' or ' ' .. e.type:sub(1, 1):upper()
+ local text = e.text:gsub('^%s*(.-)%s*$', '%1')
+ str = valid_fmt:format(fname, lnum, col, qtype, text)
+ else
+ str = e.text
+ end
+ table.insert(ret, str)
+ end
+ return ret
+end
+
+vim.o.qftf = '{info -> v:lua._G.qftf(info)}'
diff --git a/syntax/qf.vim b/syntax/qf.vim
@@ -0,0 +1,23 @@
+if exists("b:current_syntax")
+ finish
+endif
+
+syn match qfFileName /^[^│]*/ nextgroup=qfSeparatorLeft
+syn match qfSeparatorLeft /│/ contained nextgroup=qfLineNr
+syn match qfLineNr /[^│]*/ contained nextgroup=qfSeparatorRight
+syn match qfSeparatorRight '│' contained nextgroup=qfError,qfWarning,qfInfo,qfNote
+syn match qfError / E .*$/ contained
+syn match qfWarning / W .*$/ contained
+syn match qfInfo / I .*$/ contained
+syn match qfNote / [NH] .*$/ contained
+
+hi def link qfFileName Directory
+hi def link qfSeparatorLeft Delimiter
+hi def link qfSeparatorRight Delimiter
+hi def link qfLineNr LineNr
+hi def link qfError CocErrorSign
+hi def link qfWarning CocWarningSign
+hi def link qfInfo CocInfoSign
+hi def link qfNote CocHintSign
+
+let b:current_syntax = 'qf'