Guest User

Untitled

a guest
Apr 25th, 2018
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. "
  2. " Navigate quicklist and location list windows conveniently
  3. "
  4. " I want a key, say, F4, that does :lnext or :cnext depending on whether the
  5. " location list window associated with the current buffer is open or not
  6. "
  7. " Written by Marius Gedminas <marius@gedmin.as>
  8. "
  9.  
  10. function! LocListOpen()
  11. let curwinnr = winnr()
  12. let mylist = getloclist(curwinnr)
  13. if mylist == []
  14. return 0
  15. endif
  16. for winnr in range(1, winnr('$'))
  17. if winnr != curwinnr
  18. \ && winbufnr(winnr) != -1
  19. \ && getwinvar(winnr, '&buftype') == 'quickfix'
  20. \ && getloclist(winnr) == mylist
  21. return 1
  22. endif
  23. endfor
  24. return 0
  25. endf
  26.  
  27. function! ErrorUnderCursor()
  28. if LocListOpen()
  29. let mylist = getloclist(0)
  30. else
  31. let mylist = getqflist()
  32. endif
  33. let curbufnr = bufnr("")
  34. let curlnum = line(".")
  35. for d in mylist
  36. if d.bufnr == curbufnr && d.lnum == curlnum
  37. " force a redraw, or our echo will get cleared
  38. redraw
  39. echo d.text
  40. return
  41. endif
  42. endfor
  43. endf
  44.  
  45. command! -bar ErrorUnderCursor :call ErrorUnderCursor()
  46.  
  47. command! -bar NextInList :if LocListOpen() <bar> :lnext <bar> else <bar> :cn <bar> endif <bar> ErrorUnderCursor
  48. command! -bar PrevInList :if LocListOpen() <bar> :lprev <bar> else <bar> :cp <bar> endif <bar> ErrorUnderCursor
  49. command! -bar CurInList :if LocListOpen() <bar> :ll <bar> else <bar> :cc <bar> endif <bar> ErrorUnderCursor
Add Comment
Please, Sign In to add comment