[vim] major refactoring of solarized.vim
parent
a211ae8fc9
commit
4a0e344883
102
README.md
102
README.md
|
|
@ -3,19 +3,17 @@ Solarized Colorscheme for Vim
|
||||||
|
|
||||||
Developed by Ethan Schoonover <es@ethanschoonover.com>
|
Developed by Ethan Schoonover <es@ethanschoonover.com>
|
||||||
|
|
||||||
Visit the [Solarized Homepage][Solarized]
|
Visit the [Solarized homepage]
|
||||||
-----------------------------------------
|
------------------------------
|
||||||
|
|
||||||
See the [homepage for the Solarized colorscheme][Solarized] for screenshots,
|
See the [Solarized homepage] for screenshots,
|
||||||
details and colorscheme versions for Vim, Mutt, popular terminal emulators and
|
details and colorscheme versions for Vim, Mutt, popular terminal emulators and
|
||||||
other applications.
|
other applications.
|
||||||
|
|
||||||
Screenshots
|
Screenshots
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
[
|
||||||
dark](https://github.com/altercation/solarized/raw/master/img/solarized-screen-ruby-dark-th.png)](https://github.com/altercation/solarized/raw/master/img/solarized-screen-ruby-dark.png)
|
|
||||||
[](https://github.com/altercation/solarized/raw/master/img/solarized-screen-ruby-light.png)
|
|
||||||
|
|
||||||
Downloads
|
Downloads
|
||||||
---------
|
---------
|
||||||
|
|
@ -29,7 +27,7 @@ and is for installation convenience only (with [Pathogen] or [Vundle], for
|
||||||
instance). Issues, bug reports, changelogs are centralized at the main
|
instance). Issues, bug reports, changelogs are centralized at the main
|
||||||
[Solarized repository].
|
[Solarized repository].
|
||||||
|
|
||||||
[Solarized]: http://ethanschoonover.com/solarized
|
[Solarized homepage]: http://ethanschoonover.com/solarized
|
||||||
[Solarized repository]: https://github.com/altercation/solarized
|
[Solarized repository]: https://github.com/altercation/solarized
|
||||||
[Vim-only repository]: https://github.com/altercation/vim-colors-solarized
|
[Vim-only repository]: https://github.com/altercation/vim-colors-solarized
|
||||||
[vimorg-script]: http://vim.org/script
|
[vimorg-script]: http://vim.org/script
|
||||||
|
|
@ -70,11 +68,13 @@ Installation
|
||||||
After either Option 1 or Option 2 above, put the following two lines in your
|
After either Option 1 or Option 2 above, put the following two lines in your
|
||||||
.vimrc:
|
.vimrc:
|
||||||
|
|
||||||
|
syntax enable
|
||||||
set background=dark
|
set background=dark
|
||||||
colorscheme solarized
|
colorscheme solarized
|
||||||
|
|
||||||
or, for the light background mode of Solarized:
|
or, for the light background mode of Solarized:
|
||||||
|
|
||||||
|
syntax enable
|
||||||
set background=light
|
set background=light
|
||||||
colorscheme solarized
|
colorscheme solarized
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ assignment out entirely and get the same results.
|
||||||
set background=dark
|
set background=dark
|
||||||
endif
|
endif
|
||||||
|
|
||||||
See the [Solarized homepage][Solarized] for screenshots which will help you
|
See the [Solarized homepage] for screenshots which will help you
|
||||||
select either the light or dark background.
|
select either the light or dark background.
|
||||||
|
|
||||||
### IMPORTANT NOTE FOR TERMINAL USERS:
|
### IMPORTANT NOTE FOR TERMINAL USERS:
|
||||||
|
|
@ -98,15 +98,22 @@ If you are going to use Solarized in Terminal mode (i.e. not in a GUI version
|
||||||
like gvim or macvim), **please please please** consider setting your terminal
|
like gvim or macvim), **please please please** consider setting your terminal
|
||||||
emulator's colorscheme to used the Solarized palette. I've included palettes
|
emulator's colorscheme to used the Solarized palette. I've included palettes
|
||||||
for some popular terminal emulator as well as Xdefaults in the official
|
for some popular terminal emulator as well as Xdefaults in the official
|
||||||
Solarized download available from [Solarized homepage][Solarized]. If you use
|
Solarized download available from [Solarized homepage]. If you use
|
||||||
Solarized without these colors, Solarized will by default use an approximate
|
Solarized *without* these colors, Solarized will need to be told to degrade its
|
||||||
set of 256 colors. It isn't bad looking and has been extensively tweaked, but
|
colorscheme to a set compatible with the limited 256 terminal palette (whereas
|
||||||
it's still not quite the real thing.
|
by using the terminal's 16 ansi color values, you can set the correct, specific
|
||||||
|
values for the Solarized palette).
|
||||||
|
|
||||||
If you do use the custom terminal colors, simply add the following line
|
If you do use the custom terminal colors, solarized.vim should work out of the
|
||||||
*before* the `colorschem solarized` line:
|
box for you. If you are using a terminal emulator that supports 256 colors and
|
||||||
|
don't want to use the custom Solarized terminal colors, you will need to use
|
||||||
|
the degraded 256 colorscheme. To do so, simply add the following line *before*
|
||||||
|
the `colorschem solarized` line:
|
||||||
|
|
||||||
let g:solarized_termcolors=16
|
let g:solarized_termcolors=256
|
||||||
|
|
||||||
|
Again, I recommend just changing your terminal colors to Solarized values
|
||||||
|
either manually or via one of the many terminal schemes available for import.
|
||||||
|
|
||||||
Advanced Configuration
|
Advanced Configuration
|
||||||
----------------------
|
----------------------
|
||||||
|
|
@ -118,13 +125,12 @@ Set these in your vimrc file prior to calling the colorscheme.
|
||||||
"
|
"
|
||||||
option name default optional
|
option name default optional
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
g:solarized_termcolors= 256 | 16
|
g:solarized_termcolors= 16 | 256
|
||||||
g:solarized_termtrans = 0 | 1
|
g:solarized_termtrans = 0 | 1
|
||||||
g:solarized_degrade = 0 | 1
|
g:solarized_degrade = 0 | 1
|
||||||
g:solarized_bold = 1 | 0
|
g:solarized_bold = 1 | 0
|
||||||
g:solarized_underline = 1 | 0
|
g:solarized_underline = 1 | 0
|
||||||
g:solarized_italic = 1 | 0
|
g:solarized_italic = 1 | 0
|
||||||
g:solarized_style = "dark" | "light"
|
|
||||||
g:solarized_contrast = "normal"| "high" or "low"
|
g:solarized_contrast = "normal"| "high" or "low"
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -132,19 +138,22 @@ Set these in your vimrc file prior to calling the colorscheme.
|
||||||
|
|
||||||
* g:solarized_termcolors
|
* g:solarized_termcolors
|
||||||
|
|
||||||
**The most important option** if you are using vim in terminal (non gui)
|
This is set to *16* by default, meaning that Solarized will attempt to use
|
||||||
mode! See my diatribe above regarding terminal colors. This tells Solarized
|
the standard 16 colors of your terminal emulator. You will need to set
|
||||||
to use the 256 degraded color mode if running in a 256 color capable
|
those colors to the correct Solarized values either manually or by
|
||||||
terminal. Otherwise, if set to `16` it will use the terminal emulators
|
importing one of the many colorscheme available for popular terminal
|
||||||
colorscheme (best option as long as you've set the emulators colors to the
|
emulators and Xdefaults.
|
||||||
Solarized palette).
|
|
||||||
|
|
||||||
* g:solarized_termtrans
|
* g:solarized_termtrans
|
||||||
|
|
||||||
If you use a terminal emulator with a transparent background and Solarized
|
If you use a terminal emulator with a transparent background and Solarized
|
||||||
isn't displaying the background color transparently, set this to 1 and
|
isn't displaying the background color transparently, set this to 1 and
|
||||||
Solarized will use the default (transparent) background of the terminal
|
Solarized will use the default (transparent) background of the terminal
|
||||||
emulator. *urxvt* required this in my testing; Terminal.app/iTerm2 did not.
|
emulator. *urxvt* required this in my testing; iTerm2 did not.
|
||||||
|
|
||||||
|
Note that on Mac OS X Terminal.app, solarized_termtrans is set to 1 by
|
||||||
|
default as this is almost always the best option. The only exception to
|
||||||
|
this is if the working terminfo file supports 256 colors (xterm-256color).
|
||||||
|
|
||||||
* g:solarized_degrade
|
* g:solarized_degrade
|
||||||
|
|
||||||
|
|
@ -157,50 +166,27 @@ Set these in your vimrc file prior to calling the colorscheme.
|
||||||
italicized typefaces, simply assign a zero value to the appropriate
|
italicized typefaces, simply assign a zero value to the appropriate
|
||||||
variable, for example: `let g:solarized_italic=0`
|
variable, for example: `let g:solarized_italic=0`
|
||||||
|
|
||||||
* g:solarized_style
|
|
||||||
|
|
||||||
Simply another way to force Solarized to use a dark or light background.
|
|
||||||
It's better to use `set background=dark` or `set background=light` in your
|
|
||||||
.vimrc file. This option is mostly used in scripts (quick background color
|
|
||||||
change) or for testing.
|
|
||||||
|
|
||||||
* g:solarized_contrast
|
* g:solarized_contrast
|
||||||
|
|
||||||
Stick with normal! It's been carefully tested. Setting this option to high
|
Stick with normal! It's been carefully tested. Setting this option to high
|
||||||
or low does use the same Solarized palette but simply shifts some values up
|
or low does use the same Solarized palette but simply shifts some values up
|
||||||
or down in order to expand or compress the tonal range displayed.
|
or down in order to expand or compress the tonal range displayed.
|
||||||
|
|
||||||
### **IMPORTANT NOTE FOR TERMINAL USERS**
|
|
||||||
|
|
||||||
If you are running vim in a terminal, Solarized will run in 256 color mode if
|
|
||||||
the terminal supports it, but those 256 colors are (in all 256 color terminal
|
|
||||||
emulators) limited to a "degraded" color palette. While the colors will all
|
|
||||||
approximate the specific Solarized color values, if you prefer an accurate
|
|
||||||
color palette you can set the ANSI colors in your terminal and use the 16 color
|
|
||||||
terminal mode using the g:solarized_termcolors="16" option detailed below. The
|
|
||||||
ANSI color map is specified in the table below and terminal color themes are
|
|
||||||
available for download from the web page listed at the top of this file,
|
|
||||||
including xorg defaul color values and themes for OS X Terminal.app and iTerm2.
|
|
||||||
|
|
||||||
Toggle Background Function
|
Toggle Background Function
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
Here's a quick script that toggles the background color, using F5 in this
|
Solarized comes with a Toggle Background plugin that by default will map to
|
||||||
example. You can drop this into .vimrc:
|
<F5> if that mapping is available. If it is not available you will need to
|
||||||
|
either map the function manually or change your current <F5> mapping to
|
||||||
|
something else. If you wish to map the function manually, enter the following
|
||||||
|
lines in your .vimrc:
|
||||||
|
|
||||||
function! ToggleBackground()
|
nmap <unique> <F5> <Plug>ToggleBackground
|
||||||
if (w:solarized_style=="dark")
|
imap <unique> <F5> <Plug>ToggleBackground
|
||||||
let w:solarized_style="light"
|
vmap <unique> <F5> <Plug>ToggleBackground
|
||||||
colorscheme solarized
|
|
||||||
else
|
Note that it is important to *not* use the noremap map variants. The plugin
|
||||||
let w:solarized_style="dark"
|
uses noremap internally. You may run `:help togglebg` for more information.
|
||||||
colorscheme solarized
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
command! Togbg call ToggleBackground()
|
|
||||||
nnoremap <F5> :call ToggleBackground()<CR>
|
|
||||||
inoremap <F5> <ESC>:call ToggleBackground()<CR>a
|
|
||||||
vnoremap <F5> <ESC>:call ToggleBackground()<CR>
|
|
||||||
|
|
||||||
Code Notes
|
Code Notes
|
||||||
----------
|
----------
|
||||||
|
|
|
||||||
1187
colors/solarized.vim
1187
colors/solarized.vim
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,9 @@
|
||||||
|
togbg togglebackground.txt /*togbg*
|
||||||
|
togbg-default togglebackground.txt /*togbg-default*
|
||||||
|
togbg-issues togglebackground.txt /*togbg-issues*
|
||||||
|
togbg-newmap togglebackground.txt /*togbg-newmap*
|
||||||
|
togbg-usage togglebackground.txt /*togbg-usage*
|
||||||
|
toggle-background togglebackground.txt /*toggle-background*
|
||||||
|
togglebackground togglebackground.txt /*togglebackground*
|
||||||
|
togglebackground.txt togglebackground.txt /*togglebackground.txt*
|
||||||
|
togglebg togglebackground.txt /*togglebg*
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
*togglebackground.txt* For Vim version 7.3. or newer Last change: 2011 Apr 7
|
||||||
|
|
||||||
|
|
||||||
|
TOGGLE BACKGROUND PLUGIN by Ethan Schoonover ~
|
||||||
|
|
||||||
|
Toggle Background *toggle-background*
|
||||||
|
*togglebackground*
|
||||||
|
*togglebg* *togbg*
|
||||||
|
|
||||||
|
Toggle Background is a simple plugin to switch between light and dark
|
||||||
|
background modes and reset the colorscheme. This is most useful for
|
||||||
|
colorschemes that support both light and dark modes and in terminals or gui
|
||||||
|
vim windows where the background will be properly set.
|
||||||
|
|
||||||
|
0. Usage |togbg-usage|
|
||||||
|
1. Default Mapping |togbg-default|
|
||||||
|
2. Changing the Mapping |togbg-newmap|
|
||||||
|
3. Issues |togbg-issues|
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
0. Usage *togbg-usage*
|
||||||
|
|
||||||
|
Press your map key(s) to activate Toggle Background, or select "Toggle
|
||||||
|
Background" from the 'Window' menu while in gui mode.
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
1. Default Mapping *togbg-default*
|
||||||
|
|
||||||
|
Toggle Background starts with a default mapping to function key <F5>. If you
|
||||||
|
are already using this in a mapping, Toggle Background will not map itself to
|
||||||
|
a default and you will have to map it manually in your .vimrc file, or
|
||||||
|
remove/change your existing <F5> mapping to another value.
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
2. Changing the Mapping *togbg-newmap*
|
||||||
|
|
||||||
|
To set your own mapping in your .vimrc file, simply add the following three
|
||||||
|
lines to support normal, insert and visual mode usage:
|
||||||
|
|
||||||
|
nmap <unique> <F5> <Plug>ToggleBackground
|
||||||
|
imap <unique> <F5> <Plug>ToggleBackground
|
||||||
|
vmap <unique> <F5> <Plug>ToggleBackground
|
||||||
|
|
||||||
|
Note that it is important to NOT use the noremap map variants. The plugin uses
|
||||||
|
noremap internally.
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
3. Issues *togbg-issues*
|
||||||
|
|
||||||
|
When using the plugin during insert mode, there should be no interruption in
|
||||||
|
workflow. However, if you activate the plugin during REPLACE mode, you will
|
||||||
|
switch to insert mode.
|
||||||
|
|
||||||
|
vim:tw=78:noet:ts=8:ft=help:norl:
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
" Toggle background
|
||||||
|
" Last Change: April 7, 2011
|
||||||
|
" Maintainer: Ethan Schoonover
|
||||||
|
" License: OSI approved MIT license
|
||||||
|
|
||||||
|
if exists("g:loaded_ToggleBackground")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let g:loaded_ToggleBackground = 1
|
||||||
|
|
||||||
|
if !exists("no_plugin_maps") && !hasmapto('<Plug>ToggleBackground')
|
||||||
|
" map alone won't work here as it doesn't
|
||||||
|
try
|
||||||
|
silent! nmap <unique> <F5> <Plug>ToggleBackground
|
||||||
|
silent! imap <unique> <F5> <Plug>ToggleBackground
|
||||||
|
silent! vmap <unique> <F5> <Plug>ToggleBackground
|
||||||
|
finally
|
||||||
|
let g:test_val = "checked"
|
||||||
|
endtry
|
||||||
|
endif
|
||||||
|
|
||||||
|
" noremap is a bit misleading here if you are unused to vim mapping.
|
||||||
|
" in fact, there is remapping, but only of script locally defined remaps, in
|
||||||
|
" this case <SID>TogBG. The <script> argument modifies the noremap scope in
|
||||||
|
" this regard (and the noremenu below).
|
||||||
|
nnoremap <unique> <script> <Plug>ToggleBackground <SID>TogBG
|
||||||
|
inoremap <unique> <script> <Plug>ToggleBackground <ESC><SID>TogBG<ESC>a
|
||||||
|
vnoremap <unique> <script> <Plug>ToggleBackground <ESC><SID>TogBG<ESC>gv
|
||||||
|
nnoremenu <script> Window.Toggle\ Background <SID>TogBG
|
||||||
|
inoremenu <script> Window.Toggle\ Background <ESC><SID>TogBG<ESC>a
|
||||||
|
vnoremenu <script> Window.Toggle\ Background <ESC><SID>TogBG<ESC>gv
|
||||||
|
noremap <SID>TogBG :call <SID>TogBG()<CR>
|
||||||
|
|
||||||
|
function! s:TogBG()
|
||||||
|
let &background = ( &background == "dark"? "light" : "dark" ) | exe "colorscheme " . g:colors_name
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
if !exists(":ToggleBG")
|
||||||
|
command ToggleBG :call s:TogBG()
|
||||||
|
endif
|
||||||
|
|
||||||
|
function! ToggleBackground()
|
||||||
|
echo "Please update your ToggleBackground mapping. ':help togglebg' for information."
|
||||||
|
endfunction
|
||||||
|
|
||||||
Loading…
Reference in New Issue