Undefined variable error for g:vim_json_warnings #30

Closed
chdiza opened this Issue May 22, 2014 · 4 comments

Projects

None yet

2 participants

@chdiza
chdiza commented May 22, 2014

I think the json.vim syntax file should be usable all by itself, and not require the other files in this repo. Currently it isn't usable like that, because on line 49 (and later on 114) there is this: if (g:vim_json_warnings == 1).

If the user hasn't predefined g:vim_json_warnings, then this causes an error message to appear. That variable is predefined in the ftplugin, but not in the syntax file itself.

I think what's needed is if exists("g:vim_json_warnings") && g:vim_json_warnings==1

@chdiza
chdiza commented May 23, 2014

PR in #32 :)

@elzr
Owner
elzr commented May 23, 2014

Hmm... that's a good point @chdiza. I only just added that g:vim_json_warnings check 2 days ago. I wonder though if it shouldn't be if (!exists("g:vim_json_warnings") || g:vim_json_warnings==1, so that in the standalone mode you mention (json.vim syntax file only) displaying warnings is the default. What do you think?

@chdiza
chdiza commented May 23, 2014

Well, that's totally up to you. Notice that under your most recent suggestion, there's no reason to set the variable to 1 in the ftplugin; warnings would be on unless the user explicitly unsets them.

@elzr
Owner
elzr commented May 24, 2014

Thanks for the attention to detail. :) I ended up defaulting to displaying warnings because I think it's half the point of the plugin (the other half being the concealing). I'm still setting the variable to 1 in the ftplugin, for consistency & clarity, even if logically unnecessary.

@elzr elzr closed this May 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment