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

Turn off conceal completely if requested #13

Merged
merged 1 commit into from
Aug 27, 2013

Conversation

docwhat
Copy link

@docwhat docwhat commented Aug 26, 2013

It can be confusing if g:vim_json_syntax_conceal is set to 0 but conceal
is set to a non-zero value (e.g. 1 in my case) by the user's .vimrc.

This sets conceal to 0 if g:vim_json_syntax_conceal is set to 0.

It can be confusing if `g:vim_json_syntax_conceal` is set to `0`
but `conceal` is set to a non-zero value (e.g. `1` in my case) by
the user's `.vimrc`.

This sets `conceal` to `0` if `g:vim_json_syntax_conceal` is set
to `0`.
@docwhat
Copy link
Author

docwhat commented Aug 26, 2013

FYI: I like the concealing of the " characters when viewing JSON. But when editing, it gets really confusing because I can't see why things turn red (e.g. I mistype a " or delete one by mistake).

My default conceal level is 1 so setting g:vim_json_syntax_conceal causes the " characters to still be hidden, but they take up a space.

I'm not sure what would be needed to make the " hiding work better. Maybe only hide the " characters when they are legit JSON? e.g. if things would highlight "red" then don't hide the "? I'm not familiar with how conceal works, to be honest.

elzr added a commit that referenced this pull request Aug 27, 2013
Turn off conceal completely if requested (locally)
@elzr elzr merged commit a4daea6 into elzr:master Aug 27, 2013
@elzr
Copy link
Owner

elzr commented Aug 27, 2013

Thanks for the tweak docwhat. I agree that conceal can make things tricky to edit at a glance but that's why when you move your cursor to a line, the conceals turn off automatically (if it doesn't, check your concealcursor setting).

Yes, ideally, the " hiding would be smarter, but it's tricky to detect when a " is not legit JSON. Say, in a line such as "id": "file", if we take out the last or second-to-last ", things work nicely: you get a warning and the uncompleted " remains unconcealed. But if you take out the first or the second ", the other "s are paired incorrectly and thus concealing gets messed up for that line. I don't see an elegant regex way to deal with this...

Anyway, frankly I don't see this as a big deal. It seems to me viewing is by far the most common activity and when editing you just need to move yourself to the line to turn off the concealing. :)

@docwhat docwhat deleted the turn-off-conceal branch August 27, 2013 22:27
@docwhat
Copy link
Author

docwhat commented Aug 27, 2013

@elzr

Wait, what?

The " characters are supposed to re-appear when my cursor is on the line? That's not happening for me...

You can see it in this demo.

Ah-hah! I see, concealcursor is being set to inc by indentLine. When I set let g:indentLine_noConcealCursor = 1 in my ~/.vimrc then I get the behavior you describe.

Hah!

May I humbly suggest that you set concealcursor as well? Possibly with an option to turn it off?

No wonder I was having such a hard time with the conceal mode for JSON! Now it's working much better!

Ciao!

@elzr
Copy link
Owner

elzr commented Aug 28, 2013

@docwhat LOL at your stream-of-thought comment. I'm happy we were able to communicate. This misbehaviour of concealing is one of those simple things that are hard to put into words... and that seriously affected the usefulness of this plugin. I agree with your suggestion, concealcursor is now being set by default to blank and I added a new section of Common Problems to try to help the next person who runs into this.

PS: The indentLine plugin sounds cool, I might try it. Being a syntax highlighting junky my solution so far has been some makeshift background highlighting:
Syntax Highlighting indent!

@docwhat
Copy link
Author

docwhat commented Aug 28, 2013

Cool! Thanks. conceal was a feature I didn't even really know about.

Nice reading list: I'd like to suggest Dawkin's "The Selfish Gene". It really helps understanding not just genes, but memes and other popular ideas as well. It's a really different way to think about how things change. It works for coding too.

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

Successfully merging this pull request may close these issues.

2 participants