Gabirel / Hack-SpaceVim

🚀 Tell you how to hack SpaceVim. Be useful. Try Discussions!
MIT License
475 stars 68 forks source link

[Question] How to change layer options using init.vim #51

Closed ViiEx closed 2 years ago

ViiEx commented 2 years ago

I'm trying to configure my spacevim using init.vim instead of init.toml. I was wondering tho how can I set the layers options tho.

For example I wanted to change the shell position to be at the bottom instead at the top. With a little bit of digging into the source code of SpaceVim I tried the following:

call SpaceVim#layers#shell#set_variable(['terminal', 'bottom', 30, 1])

The above function is located at .SpaceVim/autoload/SpaceVim/layers/shell.vim at the line 138

That only resulted on opening the shell at the right side instead of the bottom.

Any ideas on how to change the my shell to open the way I intend it to and how can I set layer options on init.vim ?

Gabirel commented 2 years ago

Sorry for the late reply.

Here is the solution

Main idea: overwrite the default option manually.

call SpaceVim#layers#load('shell')

" this call function MUST STAY BELOW
" Otherwise, it will get overwritten by `call SpaceVim#layers#load('shell')`
call SpaceVim#layers#load('shell',
    \ {
    \  'default_position' : 'bottom',
    \  'default_height' : 100,
    \ }
    \ )
Check demo ![image](https://user-images.githubusercontent.com/12933851/172159423-9ec89e15-d5e9-408a-b554-12e787d52949.png)

I hope this would solve your problem. This solution works for each layer as long as SpaceVim provides that option.

Reference

https://github.com/SpaceVim/SpaceVim/pull/4545#issuecomment-1003721728

Other

I will update your question to Hack-SpaceVim documentation. Thank you for your question.

ViiEx commented 2 years ago

Works perfectly thank you a lot for the quick reply!!!!