Git Product home page Git Product logo

Comments (3)

sonph avatar sonph commented on May 23, 2024

Hi @SevereOverfl0w, setting background only works if the color scheme uses the same foreground colors for both light and dark, i.e. solarized, which doesn't give the desired contrast for readability. Onehalf uses lighter foreground colors for dark theme and darker foreground colors for light theme.

You can think of this as white on black (dark) and black on white (light), versus gray on white or gray on black.

If you want to achieve similar functionality to the plugin, I think it's simply a matter of replacing set background=(light|dark) with colorscheme (onehalflight|onehalfdark).

from onehalf.

BlueDrink9 avatar BlueDrink9 commented on May 23, 2024

As a workaround, I wrote this to automatically switch the scheme when '&background' changes:

augroup myColourschemes
    autocmd!
augroup end

autocmd myColourschemes colorscheme * let colorSch =
            \ get(g:, 'colors_name', 'default')

Plug 'sonph/onehalf', {'rtp': 'vim/'}
function! s:onehalfSwapLightDark()
  if g:colorSch =~? "dark"
    colorscheme onehalflight
  else
    colorscheme onehalfdark
  endif
endfunction
function! s:setOnehalfColourSwapAutocmd()
  au myColourschemes OptionSet background if g:colorSch =~? "onehalf" | call <sid>onehalfSwapLightDark() | endif
endfunction
" When using onehalf, set up an autocmd to change colourscheme when
" 'background' option is set (e.g. with `yob`)
au myColourschemes ColorScheme onehalf* call <sid>setOnehalfColourSwapAutocmd() | au! myColourschemes ColorScheme onehalf*

from onehalf.

Slotos avatar Slotos commented on May 23, 2024

Hi @SevereOverfl0w, setting background only works if the color scheme uses the same foreground colors for both light and dark

I apologize for necroposting, but that is simply not true. Could be that it was true at some point, but I couldn't find when that point was.

To quote help pages for background option:

This option does NOT change the background color, it tells Nvim what
the "inherited" (terminal/GUI) background looks like.

Moreover:

When a color scheme is loaded (the "g:colors_name" variable is set)
setting 'background' will cause the color scheme to be reloaded. If
the color scheme adjusts to the value of 'background' this will work.

Basically, colorscheme needs to read &background and uses the corresponding palette to just work.

from onehalf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.