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

Normalize variable declarations with a set function #237

Closed
wants to merge 1 commit into from
Closed

Normalize variable declarations with a set function #237

wants to merge 1 commit into from

Conversation

kutsan
Copy link
Contributor

@kutsan kutsan commented Mar 15, 2018

s:set() function declares variables with its default value like in built-in get() function style.

@ryanoasis
Copy link
Owner

Very nice. I've wanted to do something with those variables 😊

@kutsan
Copy link
Contributor Author

kutsan commented Mar 16, 2018

I don't know about you but I think using global variables that bountifully is not a right thing. I think options should be kept inside one global vim dictionary, like let g:devicons = {}. Obviously it's too late to do that.

@ryanoasis
Copy link
Owner

You are right but never too late to do things correctly. We could do this for 1.0.0 as a breaking change. Ref: #77

@kutsan
Copy link
Contributor Author

kutsan commented Mar 30, 2018

Oh, that's awesome. Then, I'm proposing greppers method to handle this.

https://github.com/mhinz/vim-grepper/blob/635c14284aea79117f2cc9d07c18c8f6da23d85b/plugin/grepper.vim#L11-L110

We can even categorize configs inside that dictionary. I really like the way how @mhinz handles. I think this approach should be default across plugin authors.

@mhinz
Copy link

mhinz commented Mar 30, 2018

Let me chime in for a moment.

vim-grepper was the first plugin where I tried that single dict approach. Personally I still like it, but the more keys I added, the more complicated the code for merging became. (Ignore this if most values are of the same type and there's not much nesting.) Oh well, I like VimL, and it's something I can figure out.

But users are not used to using dicts for configuration. Beginners often don't even understand how to break up a dict over multiple lines, because they simply don't know much about VimL. Global variables are probably more intuitive for those people.

So, people are often confused about the fact that let g:myplugin.foo.bar = x won't work without doing let g:myplugin.foo = {} first. That's what the merging code is for, right? But mind that the vimrc is always sourced before all other plugins. So, you have to force sourcing the plugin in the vimrc via runtime plugin/myplugin.vim before using let g:myplugin.foo.bar = x.

Then again, the more plugins use this approach, the more people will learn about it...

...you decide. ;-)

@kutsan
Copy link
Contributor Author

kutsan commented Mar 30, 2018

@mhinz Thank you so much for your comment on this. I'm going to still say this project should go for it.

@ryanoasis ryanoasis added this to the v0.11.0 milestone May 3, 2018
@ryanoasis ryanoasis closed this in 8b0fc69 Feb 4, 2019
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.

3 participants