Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Commit c0a32b6

Browse files
committed
add prev cycle cmd
1 parent ab3cb0a commit c0a32b6

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

lua/jumpLoc.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ function M.jumpNextLocationCycle()
8282
end
8383
end
8484

85+
function M.jumpPrevLocationCycle()
86+
local prev_i = M.get_prev_loc()
87+
if prev_i > 0 then
88+
jumpToLocation(prev_i)
89+
elseif M.get_next_loc() >= 0 then
90+
jumpToLocation(#M.location)
91+
else
92+
return api.nvim_command("echohl WarningMsg | echo 'No diagnostics found' | echohl None")
93+
end
94+
end
95+
8596
-- Open line diagnostics when jump
8697
-- Don't do anything if diagnostic_auto_popup_while_jump == 0
8798
-- NOTE need to delay a certain amount of time to show correctly

plugin/diagnostic.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ let s:save_cpo = &cpo
44
set cpo&vim
55

66
command! PrevDiagnostic lua require'jumpLoc'.jumpPrevLocation()
7+
command! PrevDiagnosticCycle lua require'jumpLoc'.jumpPrevLocationCycle()
78
command! NextDiagnostic lua require'jumpLoc'.jumpNextLocation()
89
command! NextDiagnosticCycle lua require'jumpLoc'.jumpNextLocationCycle()
910
command! OpenDiagnostic lua require'jumpLoc'.openDiagnostics()

0 commit comments

Comments
 (0)