Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'%' not working #271

Open
davidmaxwaterman opened this issue Nov 1, 2022 · 12 comments
Open

'%' not working #271

davidmaxwaterman opened this issue Nov 1, 2022 · 12 comments

Comments

@davidmaxwaterman
Copy link
Contributor

I have ~recently switched to Mac from Linux and was looking for a config that 'just works' and so I picked this setup.

After having used it for some time, I'm finding that the '%' key doesn't work...it's supposed to do 'matchpairs' - ie if it is on a '[' it should jump to the matching ']'.

If I 'set matchpairs' is shows matchpairs=(:),{:},[:] which looks correct.

Am I missing something special in maximum-awesome that means '%' isn't the same as regular vi?

@SalvatoreT
Copy link
Collaborator

Hey @davidmaxwaterman, I never new about the % key for jumping matchpairs, but I just tried it on the Rakefile and it seems to work fine for me.

match-pairs.mov

@SalvatoreT
Copy link
Collaborator

Here are the versions I tried it on.

maximum-awesome on  master
❯ vi -version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Sep 30 2022 03:10:57)
Garbage after option argument: "-version"
More info with: "vim -h"
maximum-awesome on  master
❯ vim -version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar  8 2021 07:21:32)
Garbage after option argument: "-version"
More info with: "vim -h"

@davidmaxwaterman
Copy link
Contributor Author

davidmaxwaterman commented Nov 3, 2022

Ah, so it is supposed to work...that's good to know at least. You video, I think, shows it working, as you say. I normally use % to jump between the beginning/end of blocks in code, so I had to try it on function params too...and it doesn't work.

So, I'm wondering how to debug this further.

One thing I noticed with your video is that it appear to be the terminal version rather than the GUI version....and, indeed, if I just invoke using vim on the cli, % does actually work....so it is just the gui version....hrm, in the gui version, in my code, it doesn't work....but if I open a new tab, and try there, it does work.
So, it's not even just a difference between the cli/gui, but something to do with the actual files I'm editing....
Yes, so if I :n tmp.js, then insert:

(
)
{
}

and try to jump between those two...it doesn't work. [EDIT - I should add that this test also applies in the terminal, so totally nothing to do with vim/mvim]

So, something to do with javascript files?

What to try next?

[EDIT] I added a video of my own, showing it working in tmp.txt but not tmp.js
https://user-images.githubusercontent.com/975698/199706743-091520ac-fd8d-42d2-9abd-175699f664a3.mp4

@davidmaxwaterman
Copy link
Contributor Author

I had a suggestion from:
https://www.reddit.com/r/vim/comments/y7x4to/comment/iv1xd97/?context=3
that suggested it was a mapping, and :set map does seem to show some suspects that might be the culprit:

o  %           * v:<C-U>call <SNR>80_Match_wrapper('',1,'o') <CR>
v  %           * :<C-U>call <SNR>80_Match_wrapper('',1,'v') <CR>m'gv``
n  %           * :<C-U>call <SNR>80_Match_wrapper('',1,'n') <CR>

Another observation that came out of that experiment is that the '%' key does actually work the very first time...but not subsequent times.

I wonder if there's any way I can further investigate this issue to move towards a fix. Suggestions welcome.

@davidmaxwaterman
Copy link
Contributor Author

Any more thoughts on this? I find that ']}' and '[{' are good enough, but I do miss '%'.

@SalvatoreT
Copy link
Collaborator

Unfortunately, I don't know what's causing it, nor can I reproduce it. ☹️

@davidmaxwaterman
Copy link
Contributor Author

Oh, I didn't realise that. You mean % works for you even on a js file?

@SalvatoreT
Copy link
Collaborator

SalvatoreT commented Nov 18, 2022

Ah, sorry I missed that. 🤦🏼
Yep, I reproduced it on a JavaScript file. 👍🏼

I'm wondering if there's something wrong with JSHint. I went to open React's dangerfile.js as an example, and I got this error.

"dangerfile.js" 267L, 7915B
Error detected while processing BufEnter Autocommands for "<buffer=1>"..function <S
NR>106_JSHint:
line   41:
could not invoke JSHint:
/Users/sal/Development/maximum-awesome/vim/bundle/jshint.vim/ftplugin/javascript/js
hint/runner.js:78^@      puts( [error.line - offset, error.character, error.reason]
.join(':') );^@      ^^@^@TypeError: puts is not a function^@    at ReadStream.<ano
nymous> (/Users/sal/Development/maximum-awesome/vim/bundle/jshint.vim/ftplugin/java
script/jshint/runner.js:78:7)^@    at ReadStream.emit (node:events:390:28)^@    at
endReadableNT (node:internal/streams/readable:1343:12)^@    at processTicksAndRejec
tions (node:internal/process/task_queues:83:21)^@
line   84:
E927: Invalid action: ''
Press ENTER or type command to continue

Look like commenting out wookiehangover/jshint.vim fixes that.

diff --git a/vimrc.bundles b/vimrc.bundles
index 104b587..f2eb343 100644
--- a/vimrc.bundles
+++ b/vimrc.bundles
@@ -19,7 +19,7 @@ Plugin 'tomtom/tlib_vim'
 Plugin 'nathanaelkane/vim-indent-guides'
 Plugin 'nono/vim-handlebars'
 Plugin 'pangloss/vim-javascript'
-Plugin 'wookiehangover/jshint.vim'
+" Plugin 'wookiehangover/jshint.vim'
 Plugin 'scrooloose/nerdtree'
 Plugin 'scrooloose/syntastic'
 Plugin 'slim-template/vim-slim'

With that I can now use % exactly once as you described!

Screenshot 2022-11-18 at 12 12 42 PM

@davidmaxwaterman
Copy link
Contributor Author

davidmaxwaterman commented Nov 19, 2022

Oddly enough, in my ~/.vimrc.bundles file, that line is already commented out....as is the syntastic line.

I was curious how you managed to get that error output. I tried running vim -D tmp.js and it complains about line 6 in /opt/homebrew/Cellar/macvim/9.0.472_1/MacVim.app/Contents/Resources/vim/vimrc, which is set nocompatible.

Any thoughts?

@davidmaxwaterman
Copy link
Contributor Author

Any more thoughts on this?

@SalvatoreT
Copy link
Collaborator

Unfortunately, I don't. I tried debugging this earlier and ran out of patience with it. Because it seems minor (to me), I haven't been able to push myself to work on this in my free time. I know this isn't the answer you're hoping for, but I wanted to give you an update.

@davidmaxwaterman
Copy link
Contributor Author

LOL, indeed, fair enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants