faerryn / fey_neovim

MIT License
23 stars 0 forks source link

Source configuration from within vim #2

Closed kkharji closed 4 years ago

kkharji commented 4 years ago

Hi there, I'm hacking on fey to create my own configuration (Thanks a lot), which I wouldn't be doing if fey had not choice to be a distribution like doom and spacevim (please consider changing fey to a "framework" targeted towards current hard-core users to configure neovim with lua, rather than as a distribution for new user looking to have a outofbox IDE with neovim (which theres tone of out here), if this something could be further discussed, open an issue "Fey as high-level framework" and tag me).

Source configuration from within vim problem I'm used to editing my configuration, adding new plugin and source $MYVIMRC, and depending on external shell script isn't something practical for me. So I create the following command

vim.cmd"command! Sync let g:batch=1 | source ~/repos/fnvim/init.vim | lua minpac.update()"

After running it or sourcing in general, I get the following error

/home/tami/refs/vim/fey_neovim/config.lua:91: Vim(lua):
E5108: Error executing lua [string ":lua"]:1: attempt to index field 'ui_status_line' (a nil value)

However, with the command I defined above I defined, fzf and lightline brings additional errors when activated

When trying to open fzf:->

E5108: Error executing lua [string ":lua"]:1: attempt to call field 'files' (a nil value)  

When exiting from goyo and lightline:->

Error detected while processing ColorScheme Autocommands for "*":   
E5108: Error executing lua [string ":lua"]:1: attempt to call field 'lightline' 
(a nil value)                                               ā”‚

Thanks

kkharji commented 4 years ago

Maybe relevant? https://stackoverflow.com/questions/55856614/lua-attempt-to-call-method-len-a-nil-value

faerryn commented 4 years ago

What (I think) is happening is this:

  1. There is a global table called fey where I put all of the globally available functions and variables. e.g. fey.ui_status_line.status_line.lightline is a function for setting syncing lightline's colorscheme to the global colorscheme.
  2. Now when you let g:batch = 1 and source init.vim, the line fey = {} is run, which clears out the table. It is not repopulated with anything from any config.lua, since g:batch == 1.
  3. The old commands and mappings are not cleared (since they are not reset in init.vim) so they still refer to these functions inside an effectively empty fey table.
faerryn commented 4 years ago

One thing of note is that whenever you modify and write to config.lua file that was previously active (in your init.lua), that file is immediately loaded. So :Sync would only be needed if you install new packages/plugins/whatever they are called. That should hopefully happen rarely enough that exiting out of vim and doing a fey sync wouldn't be too uncomfortable.

faerryn commented 4 years ago

I have tried to fix it. g:batch is renamed to g:fey_load_packages btw.

kkharji commented 4 years ago

Thanks a lot šŸ™, and yes shall script makes sense now

kkharji commented 4 years ago

@faerryn I see you've changed the readme description of fey to configurations framework? do u really mean it, I have few thoughts on what will make the next great conf framework for neovim, wouls you like to open a new issue?