SpaceVim icon indicating copy to clipboard operation
SpaceVim copied to clipboard

How about exposing some internal toggle functions?

Open Kerl13 opened this issue 4 years ago • 5 comments

I'm trying to enable some features by default when I open vim such as "highlight long lines" or "show trailing whitespaces", etc. But it is a bit painful to make it work nicely with Spacevim. For instance if I want to enable trailing whitespaces I have to call these three functions:

  • EnableWhitespace
  • SpaceVim#layers#core#statusline#toggle_section('whitespace')
  • SpaceVim#layers#core#statusline#toggle_mode('whitespace')

But that that's not enough to make it work nicely with SPC-t-8 as I cannot set the s:whitespace_enable flag correctly.

It would be very convenient to be able to call Spacevim#layers#ui#toggle_whitespace directly as this function wraps up the three calls mentioned above and sets the boolean flag correctly. But if I understand correctly, the s: prefix in the definition of toggle_whitespace hides the function from outside the file.

So my questions are:

  • is there already a way to enable Spacevim trailling whitespaces/highlight-long-lines/spell-checking programmatically (with all the status bar icons and stuff)?
  • would you be okay to expose these functions so that we can call e.g. Spacevim#layers#ui#toggle_whitespaces from scripts?

Kerl13 avatar May 26 '20 14:05 Kerl13

we are going to implement cache major mode, but this is wip https://github.com/SpaceVim/SpaceVim/pull/3076

wsdjeg

I'm trying to enable some features by default when I open vim such as "highlight long lines" or "show trailing whitespaces", etc. But it is a bit painful to make it work nicely with Spacevim. For instance if I want to enable trailing whitespaces I have to call these three functions:

  • EnableWhitespace
  • SpaceVim#layers#core#statusline#toggle_section('whitespace')
  • SpaceVim#layers#core#statusline#toggle_mode('whitespace')

But that that's not enough to make it work nicely with SPC-t-8 as I cannot set the s:whitespace_enable flag correctly.

It would be very convenient to be able to call Spacevim#layers#ui#toggle_whitespace directly as this function wraps up the three calls mentioned above and sets the boolean flag correctly. But if I understand correctly, the s: prefix in the definition of toggle_whitespace hides the function from outside the file.

So my questions are:

  • is there already a way to enable Spacevim trailling whitespaces/highlight-long-lines/spell-checking programmatically (with all the status bar icons and stuff)?
  • would you be okay to expose these functions so that we can call e.g. Spacevim#layers#ui#toggle_whitespaces from scripts?

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/SpaceVim/SpaceVim/issues/3555

wsdjeg avatar May 27 '20 15:05 wsdjeg

I'd really like to be able to say the following in init.toml:

default_whitespace_toggle = true
default_column_indicator_toggle = true
default_toggle_wrap_long_lines = true

and have all of these toggles enabled by default, instead of needing to do SPC t f, SPC t w and SPC t W manually each time I open vim. Is there a workaround for this already?

edit: This is related to https://github.com/SpaceVim/SpaceVim/issues/2316 and https://github.com/SpaceVim/SpaceVim/issues/2316

lippirk avatar Nov 22 '20 21:11 lippirk

Also very interested in this.

@wsdjeg could you please advise, how #3076 should help with this?

mironnn avatar Jul 21 '21 15:07 mironnn

@mironnn if you would like a hacky workaround, this should work - put your defaults into a macro in ~/.SpaceVim/vimrc and then call the macro. for example:

let @i=' tw tf'
:normal @i

lippirk avatar Jul 21 '21 15:07 lippirk

@mironnn if you would like a hacky workaround, this should work - put your defaults into a macro in ~/.SpaceVim/vimrc and then call the macro. for example:

let @i=' tw tf'
:normal @i

@lippirk thank you for your proposal. It is a workaround, but maybe there is another solution how to define toggle values in the config

mironnn avatar Jul 22 '21 14:07 mironnn

#3076 add the cache feature for cache the result of SpaceVim#layers#core#statusline#toggle_mode, but currently it does not support SpaceVim#layers#core#statusline#toggle_section, so SPC t w does not work, but SPC t s SPC t p etc should work.

wsdjeg avatar Oct 23 '22 05:10 wsdjeg