Hi Tommy 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. > > Hth > > Tommy > > tir. 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 got >> export def *UnderLineHeaders*(): void >> var headers: dict<string> = {} >> .. some stuff >> .. >> >> def *g:OpeningHeader*(): void >> exe 'edit ' .. headers['goodIdxHeader'] ~path to the header file. >> enddef >> *nnoremap <buffer> <2-Leftmouse> :call **g:OpeningHeader**()<CR> **<<< >> be carefull :)* >> enddef >> >> In *_vimrc *i got: >> import autoload './vimfiles/plugged/helper.vim/autoload/helper.vim' as >> *that* >> *autocmd 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 help >> I 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 >> >> <https://groups.google.com/d/msgid/vim_use/86cfe413-7cc8-43b1-bc2c-446398bba367n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- -- 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+unsubscr...@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.