Skip to content

Commit f7bcd72

Browse files
committed
use coclist for diagnostics
1 parent 469b630 commit f7bcd72

File tree

2 files changed

+5
-72
lines changed

2 files changed

+5
-72
lines changed

dot_config/nvim/init.vim

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -437,18 +437,6 @@ vim.keymap.set('n', 'll', function() vim.cmd(":Telescope tmux-awesome-manager li
437437

438438
tmux_term = require('tmux-awesome-manager.src.term')
439439

440-
require("trouble").setup {
441-
position = "bottom",
442-
padding = false,
443-
height = 5,
444-
icons = true,
445-
auto_open = false,
446-
auto_close = false,
447-
auto_preview = false,
448-
auto_jump = {},
449-
mode = "loclist"
450-
}
451-
452440
EOF
453441

454442
autocmd FileType octo inoremap<buffer><silent> @ @<C-x><C-o>

dot_vimrc

Lines changed: 5 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ Plug 'kevinhwang91/nvim-hlslens', has('nvim') ? {} : { 'on': [] }
147147
Plug 'petertriho/nvim-scrollbar', has('nvim') ? {} : { 'on': [] }
148148
Plug 'otavioschwanck/tmux-awesome-manager.nvim', has('nvim') ? {} : { 'on': [] }
149149
Plug 'chrisgrieser/nvim-early-retirement', has('nvim') ? {} : { 'on': [] }
150-
Plug 'folke/trouble.nvim', has('nvim') ? { 'tag': 'v2.10.0' } : { 'on': [] }
151150

152151
if exists('$OPENAI_API_KEY')
153152
Plug 'dpayne/CodeGPT.nvim', has('nvim') ? {} : { 'on': [] }
@@ -382,10 +381,10 @@ else
382381
inoremap <silent><expr> <c-@> coc#refresh()
383382
endif
384383

385-
" Use `[g` and `]g` to navigate diagnostics
384+
" Use `g[` and `g]` to navigate diagnostics
386385
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
387-
nmap <silent> [g <Plug>(coc-diagnostic-prev)
388-
nmap <silent> ]g <Plug>(coc-diagnostic-next)
386+
nmap <silent> g[ <Plug>(coc-diagnostic-prev)
387+
nmap <silent> g] <Plug>(coc-diagnostic-next)
389388

390389
" GoTo code navigation.
391390
nmap <silent> gd <Plug>(coc-definition)
@@ -507,39 +506,11 @@ let g:diagnostic_window_size = 3
507506
xmap <silent> <space>d :call ToggleDiagnostics()<CR>
508507
nmap <silent> <space>d :call ToggleDiagnostics()<CR>
509508

510-
if has('nvim')
511-
let g:auto_diagnostic_window = 0
512-
endif
513-
514509
function! ToggleDiagnostics() abort
515-
if !has('nvim')
516-
if get(getloclist(0, {'winid':0}), 'winid', 0)
517-
" the location window is open
518-
windo lcl\|ccl
519-
else
520-
" the location window is closed
521-
if empty(&l:buftype)
522-
if (&filetype !=# 'floaterm') && (&buftype !=# 'terminal')
523-
execute 'CocDiagnostics ' . g:diagnostic_window_size
524-
execute 'botright lwindow'
525-
execute 'wincmd p'
526-
endif
527-
endif
528-
endif
529-
else
530-
if g:auto_diagnostic_window
531-
call v:lua.notify('LSP Diagnostics Window', 'Disabling auto-open', 'info')
532-
let g:auto_diagnostic_window = 0
533-
endif
534-
if empty(&l:buftype)
535-
call coc#rpc#request('fillDiagnostics', [bufnr('%')])
536-
execute 'TroubleToggle'
537-
execute 'wincmd p'
538-
endif
539-
endif
510+
execute 'CocList --height=5 diagnostics --buffer'
540511
endfunction
541512

542-
augroup coc_diag
513+
augroup coc_nvim
543514
" shutdown coc on exit
544515
autocmd VimLeavePre * :call coc#rpc#kill()
545516
" auto close outline if it's the last window
@@ -558,32 +529,6 @@ augroup coc_diag
558529
endif
559530
endif
560531
endfunction
561-
562-
function! s:RefreshDiagnostics() abort
563-
if empty(&l:buftype)
564-
if has('nvim')
565-
let l:trouble_open = bufwinnr('^Trouble$') != -1
566-
if g:auto_diagnostic_window
567-
call coc#rpc#request('fillDiagnostics', [bufnr('')])
568-
if len(getloclist(0)) > 0
569-
if l:trouble_open
570-
execute 'TroubleRefresh'
571-
else
572-
execute 'Trouble loclist'
573-
execute 'wincmd p'
574-
endif
575-
else
576-
execute 'TroubleClose'
577-
endif
578-
elseif l:trouble_open
579-
execute 'TroubleRefresh'
580-
endif
581-
endif
582-
endif
583-
endfunction
584-
585-
autocmd User CocDiagnosticChange call timer_start(0, {-> s:RefreshDiagnostics()})
586-
587532
augroup end
588533

589534
" Remove plugins not explicitly defined in g:coc_global_extensions

0 commit comments

Comments
 (0)