Vim9script introduces the fact of having to use a global to pass values between a P function, producing its values, used for example in an autocommand and a second C function consuming its data / values which would be called on a key mapping for example. The fact is that going through globals is not very elegant and forced to create a new global named different in each new case explained above. So I was looking for another way.
Nicolas
Le jeudi 20 octobre 2022 à 09:23:46 UTC+2, tommy....@gmail.com a écrit :
I don't get what you mean really, I'd use a g:global variable personally, and not think more of it.HthTommytir. 18. okt. 2022, 6:50 p.m. skrev Nicolas <niva...@gmail.com>:Hi,All written in vim9script, I wonder how sharing variable between two def vim9 functions out of declaring these funcs as this :
- the first one imported and used throught _vimrc autocommand on BufEnter
- the second one is declared inside the first one and is mapped just after in the code on event such as mouse double click.
The second one func, it needs variable dict computed by the first one on each BufEnter event.
In vimfiles/helper/autoload/helper.vim I gotexport def UnderLineHeaders(): voidvar headers: dict<string> = {}.. some stuff..def g:OpeningHeader(): voidexe 'edit ' .. headers['goodIdxHeader'] ~path to the header file.enddefnnoremap <buffer> <2-Leftmouse> :call g:OpeningHeader()<CR> <<< be carefull :)enddefIn _vimrc i got:import autoload './vimfiles/plugged/helper.vim/autoload/helper.vim' as thatautocmd BufEnter *.cpp,*.h that. UnderLineHeaders() <<< be carefull :)Out of global var, I think there is a better way to share something between first exported func and triggered on BufEnter and second one which needs variable computed of this triggered func, second one which occurs and called on mapped double click mouse event .Thank you for your helpI can share the entire vimscript if needed.Nicolas--
--
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/86cfe413-7cc8-43b1-bc2c-446398bba367n%40googlegroups.com.
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/f35fda3a-35b1-4634-848b-4b0a1d09a278n%40googlegroups.com.
No comments:
Post a Comment