equivalent of get() for a string ?

10 views
Skip to first unread message

Marc Chantreux

unread,
Jun 24, 2021, 3:49:32 PM6/24/21
to vim...@googlegroups.com
hello people,

I would like this

if exists('g:purescript_update_path')
if g:purescript_update_path
call PurescriptUpdatePath()
endif
endif

To be something like

if get('g:purescript_update_path',v:false)
call PurescriptUpdatePath()
endif

but get() doesn't work with strings and i don't find something close.
did i miss something from the doc ?

regards,
marc



Salman Halim

unread,
Jun 24, 2021, 3:53:09 PM6/24/21
to Vim Users
Shameless plug: my GetVar script (https://www.vim.org/scripts/script.php?script_id=353) does this.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/YNTfT1yVXYWRHawY%40prometheus.u-strasbg.fr.


--
 
Salman

I, too, shall something make and glory in the making.

Marc Chantreux

unread,
Jun 24, 2021, 4:50:09 PM6/24/21
to vim...@googlegroups.com
hello Salman,

> Shameless plug: my GetVar script (
> https://www.vim.org/scripts/script.php?script_id=353) does this.

thanks for noticing but i can't add such a dependency as i'm trying to
fix an existing package and would like to push my code upstream at
some point.

regards,
marc


bfrg

unread,
Jun 26, 2021, 3:06:59 AM6/26/21
to vim...@googlegroups.com
Marc,

try this here:

if get(g:, 'purescript_update_path')
call PurescriptUpdatePath()
endif

You can omit the v:false in get(), see `:help get()` for more details.
g:, w: and b: return the global, window-local, and buffer-local dictionary,
respectively. See `:help g:` for more details. For example, if you run `:echo g:`
in the command-line it will print all the global variables as a dictionary. When
we pass g:, b: or w: to get(), we essentially use the following overload:
get({dict}, {key} [, {default}])
Reply all
Reply to author
Forward
0 new messages