Comments (13)
I would not say that this is a bug: the only item is selected (in the list), and both lnext
and lprev
error out with "no next/previous".
I just wanted to propose using :ll
, but you've mentioned it yourself already.
After all, still not a bug with syntastic.
I could imagine fixing this through unimpaired, which provides [l
and ]l
to navigate the location list: it could catch the error and call :ll
automatically. What do you think?
I have reported it over there already: tpope/vim-unimpaired#7
from syntastic.
I'd suggest something like this instead:
function! <SID>LocationPrevious()
try
lprev
catch /^Vim\%((\a\+)\)\=:E553/
llast
endtry
endfunction
function! <SID>LocationNext()
try
lnext
catch /^Vim\%((\a\+)\)\=:E553/
lfirst
endtry
endfunction
nnoremap <silent> <Plug>LocationPrevious :<C-u>exe 'call <SID>LocationPrevious()'<CR>
nnoremap <silent> <Plug>LocationNext :<C-u>exe 'call <SID>LocationNext()'<CR>
nmap <silent> ,, <Plug>LocationPrevious
nmap <silent> .. <Plug>LocationNext
from syntastic.
This does appear to work as expected, doesn't it?
What do you expect for it to happen instead?
from syntastic.
Wouldn't you expect it to jump to the single location in the location list?
from syntastic.
Aren't you at the first item already? (Vim jumps there by default)
Anyway, this is Vim core functionality and therefore not an issue with syntastic in particular, as far as I can see.
from syntastic.
No I can be anywhere in the code and try to use :lnext or :lprev and I only get the No more items error. Using :ll seemed to work though. I just assumed that the location list would have been in vim long enough that it wouldn't have this blatant bugs anymore so that's why I suspected there may had been something weird with syntastic.
from syntastic.
Actually now that I know that it's just some idiosyncrasy of vim and have conditioned myself to use :ll when there's only one match I am not that bothered by this any more. It just seemed illogical.
from syntastic.
Closing this issue off as it is to do with vims standard behaviour - not syntastic
from syntastic.
I'll just post my workaround in case someone came across this issue:
function LocationListNavOrJustOne(cmd)
redir => output
silent! exec a:cmd
redir END
if match(output, "E553: No more items") >= 0
exec ':ll'
else
echom output
endif
endfunction
nmap ,, :call LocationListNavOrJustOne(":lprev")<CR>
nmap .. :call LocationListNavOrJustOne(":lnext")<CR>
Pretty straightforward: this will map ,,
(two comma) to :lprev
and ..
(two period) to :lnext
. When these two command return E553: No more items
, run :ll
to jump to the only result.
I was hoping to make :lprev
jump to the last item when it reached the first one but I'm really not an expert in vimscripting.
from syntastic.
@lcd047
Way better than mine. Thank you!
from syntastic.
Based on @lcd047's code above I made the following to not produce a ugly multi-line erorr message if there are no entries in the location list:
" Allow :lprev to work with empty location list, or at first location
function! <SID>LocationPrevious()
try
lprev
catch /:E553:/
lfirst
catch /:E42:/
echo "Location list empty"
catch /.*/
echo v:exception
endtry
endfunction
" Allow :lnext to work with empty location list, or at last location
function! <SID>LocationNext()
try
lnext
catch /:E553:/
lfirst
catch /:E42:/
echo "Location list empty"
catch /.*/
echo v:exception
endtry
endfunction
from syntastic.
Actually, this is an even better solution (but consider adding echo "List empty"
rather than an null catch.)
from syntastic.
For those stumbling on this behavior, maybe the solutions is "don't do that" - see this workflow/workaround.
from syntastic.
Related Issues (20)
- Location list flashes then disappears HOT 1
- Checkers problem HOT 2
- Assembly files of different architecture(s): how? HOT 1
- How highlight full word (not line) warning or error in code? HOT 2
- Multiple error windows opened for the same project. HOT 2
- Syntastic Not finding checker [merlin] HOT 2
- syntastic checker output: python: can''t open file HOT 2
- Garbled characters appear in the sidebar HOT 3
- plase patch please
- loc_list should be closed when 'WinLeave' is detected. HOT 4
- How can I disable Syntastic active mode if opened read-only (via "view" command) HOT 2
- Bad configuration
- Pylint comments are not disabling errors HOT 1
- Only one character is underlined, not the whole error HOT 1
- Squiggles start at the wrong place when there are tab characters before them HOT 1
- Integrate with GH workflow linter HOT 1
- Find shared/library headers HOT 1
- strange behavior of loc_list related to `g:syntastic_cpp_checkers` HOT 1
- Add new checker script for Ruff HOT 2
- syntastic: error: checker ansible/ansible_lint: can't parse version string (abnormal termination?) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from syntastic.