Mercurial > dotfiles
comparison .chezmoitemplates/init.lua @ 616:08bb1c92e5e5
Add cleaner quickfix
author | zegervdv <zegervdv@me.com> |
---|---|
date | Sun, 24 Jul 2022 14:48:01 +0200 |
parents | 0cace1b99e77 |
children | d130c5c8b4e9 |
comparison
equal
deleted
inserted
replaced
615:0cace1b99e77 | 616:08bb1c92e5e5 |
---|---|
528 provider = function(self) return self.warnings > 0 and self.warnings .. ' ' end, | 528 provider = function(self) return self.warnings > 0 and self.warnings .. ' ' end, |
529 }, | 529 }, |
530 hl = { fg = 'diag_warn' }, | 530 hl = { fg = 'diag_warn' }, |
531 on_click = { | 531 on_click = { |
532 callback = function() | 532 callback = function() |
533 vim.diagnostic.setqflist { severity = vim.diagnostic.severity.WARN } | 533 vim.diagnostic.setqflist { severity = { min = vim.diagnostic.severity.WARN } } |
534 vim.cmd.copen { mods = { split = 'botright' } } | 534 vim.cmd.copen { mods = { split = 'botright' } } |
535 end, | 535 end, |
536 name = 'heirline_diagnostics', | 536 name = 'heirline_diagnostics', |
537 }, | 537 }, |
538 } | 538 } |
754 n = true, -- Normal mode | 754 n = true, -- Normal mode |
755 i = true, -- Insert mode | 755 i = true, -- Insert mode |
756 c = true, -- Commandline mode | 756 c = true, -- Commandline mode |
757 } | 757 } |
758 | 758 |
759 opt.fillchars = { | 759 opt.fillchars:append { |
760 diff = '╱', | 760 diff = '╱', |
761 } | 761 } |
762 | 762 |
763 opt.foldmethod = 'expr' | 763 opt.foldmethod = 'expr' |
764 opt.foldexpr = 'nvim_treesitter#foldexpr()' | 764 opt.foldexpr = 'nvim_treesitter#foldexpr()' |
765 opt.foldnestmax = 3 | 765 opt.foldnestmax = 3 |
766 opt.foldminlines = 1 | 766 opt.foldminlines = 1 |
767 opt.foldtext = | 767 opt.foldtext = |
768 [[substitute(getline(v:foldstart),'\\t',repeat('\ ',&tabstop),'g').'...'.trim(getline(v:foldend)) . ' (' . (v:foldend - v:foldstart + 1) . ' lines)']] | 768 [[substitute(getline(v:foldstart),'\\t',repeat('\ ',&tabstop),'g').'...'.trim(getline(v:foldend)) . ' (' . (v:foldend - v:foldstart + 1) . ' lines)']] |
769 opt.foldenable = false | 769 opt.foldenable = false |
770 | |
771 function _G.qftf(info) | |
772 local items | |
773 local ret = {} | |
774 if info.quickfix == 1 then | |
775 items = fn.getqflist({ id = info.id, items = 0 }).items | |
776 else | |
777 items = fn.getloclist(info.winid, { id = info.id, items = 0 }).items | |
778 end | |
779 local limit = 31 | |
780 local fnameFmt1, fnameFmt2 = '%-' .. limit .. 's', '…%.' .. (limit - 1) .. 's' | |
781 local validFmt = '%s │%5d:%-3d│%s %s' | |
782 for i = info.start_idx, info.end_idx do | |
783 local e = items[i] | |
784 local fname = '' | |
785 local str | |
786 if e.valid == 1 then | |
787 if e.bufnr > 0 then | |
788 fname = fn.bufname(e.bufnr) | |
789 if fname == '' then | |
790 fname = '[No Name]' | |
791 else | |
792 fname = fname:gsub('^' .. vim.env.HOME, '~') | |
793 end | |
794 -- char in fname may occur more than 1 width, ignore this issue in order to keep performance | |
795 if #fname <= limit then | |
796 fname = fnameFmt1:format(fname) | |
797 else | |
798 fname = fnameFmt2:format(fname:sub(1 - limit)) | |
799 end | |
800 end | |
801 local lnum = e.lnum > 99999 and -1 or e.lnum | |
802 local col = e.col > 999 and -1 or e.col | |
803 local qtype = e.type == '' and '' or ' ' .. e.type:sub(1, 1):upper() | |
804 str = validFmt:format(fname, lnum, col, qtype, e.text) | |
805 else | |
806 str = e.text | |
807 end | |
808 table.insert(ret, str) | |
809 end | |
810 return ret | |
811 end | |
812 | |
813 vim.o.qftf = '{info -> v:lua._G.qftf(info)}' | |
770 | 814 |
771 -- Clean up terminal codes from strings | 815 -- Clean up terminal codes from strings |
772 local t = function(str) return vim.api.nvim_replace_termcodes(str, true, true, true) end | 816 local t = function(str) return vim.api.nvim_replace_termcodes(str, true, true, true) end |
773 | 817 |
774 -- General keymaps | 818 -- General keymaps |