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

Commit

Permalink
feat: Add FirstDiagnostic and LastDiagnostic(#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
haorenW1025 committed May 26, 2020
1 parent 25e1b4b commit 3baf221
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lua/jumpLoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function M.get_prev_loc()
return #M.location
end

function jumpToLocation(i)
local function jumpToLocation(i)
if i >= 1 and i <= #M.location then
api.nvim_command("silent! ll"..i)
M.openLineDiagnostics()
Expand Down Expand Up @@ -92,6 +92,22 @@ function M.jumpPrevLocationCycle()
end
end

function M.jumpFirstLocation()
M.location = api.nvim_call_function('getloclist', {0})
jumpToLocation(1)
if #M.location == 0 then
return api.nvim_command("echohl WarningMsg | echo 'No diagnostics found' | echohl None")
end
end

function M.jumpLastLocation()
M.location = api.nvim_call_function('getloclist', {0})
jumpToLocation(#M.location)
if #M.location == 0 then
return api.nvim_command("echohl WarningMsg | echo 'No diagnostics found' | echohl None")
end
end

-- Open line diagnostics when jump
-- Don't do anything if diagnostic_auto_popup_while_jump == 0
-- NOTE need to delay a certain amount of time to show correctly
Expand Down
2 changes: 2 additions & 0 deletions plugin/diagnostic.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ command! PrevDiagnosticCycle lua require'jumpLoc'.jumpPrevLocationCycle()
command! NextDiagnostic lua require'jumpLoc'.jumpNextLocation()
command! NextDiagnosticCycle lua require'jumpLoc'.jumpNextLocationCycle()
command! OpenDiagnostic lua require'jumpLoc'.openDiagnostics()
command! FirstDiagnostic lua require'jumpLoc'.jumpFirstLocation()
command! LastDiagnostic lua require'jumpLoc'.jumpLastLocation()

" lua require'diagnostic'.modifyCallback()

Expand Down

0 comments on commit 3baf221

Please sign in to comment.