|
| 1 | +Solarized Colorscheme for Vim |
| 2 | +============================= |
| 3 | + |
| 4 | +Developed by Ethan Schoonover <es@ethanschoonover.com> |
| 5 | + |
| 6 | +Visit the [Solarized Homepage][solarized] |
| 7 | +----------------------------------------- |
| 8 | + |
| 9 | +See the [homepage for the Solarized colorscheme][solarized] for screenshots, |
| 10 | +details and colorscheme versions for Vim, Mutt, popular terminal emulators and |
| 11 | +other applications. |
| 12 | + |
| 13 | +Screenshots |
| 14 | +----------- |
| 15 | + |
| 16 | +[](https://github.com/altercation/solarized/raw/master/img/solarized-screen-ruby-dark.png) |
| 17 | +[](https://github.com/altercation/solarized/raw/master/img/solarized-screen-ruby-light.png) |
| 18 | + |
| 19 | +Downloads |
| 20 | +--------- |
| 21 | + |
| 22 | +If you have come across this colorscheme via the [vim-only repository on |
| 23 | +github][vim-solarized-github], or the [vim.org script page][vimorg-script] see |
| 24 | +the link above to the Solarized homepage or |
| 25 | +visit the [github repository for Solarized][solarized-github]. |
| 26 | + |
| 27 | +[solarized]: http://ethanschoonover.com/solarized |
| 28 | +[solarized-github]: https://github.com/altercation/solarized |
| 29 | +[vim-solarized-github]: https://github.com/altercation/vim-colors-solarized |
| 30 | +[vimorg-script]: http://vim.org/script |
| 31 | +[pathogen]: https://github.com/tpope/vim-pathogen |
| 32 | + |
| 33 | +Installation |
| 34 | +------------ |
| 35 | + |
| 36 | +### Option 1: Manual installation |
| 37 | + |
| 38 | +1. Move `solarized.vim` to your `.vim/colors` directory. After downloading the |
| 39 | + vim script or package: |
| 40 | + |
| 41 | + $ cd vim-colors-solarized/colors |
| 42 | + $ mv solarized.vim ~/.vim/colors/ |
| 43 | + |
| 44 | +### Option 2: Pathogen installation ***(recommended)*** |
| 45 | + |
| 46 | +1. Download and install Tim Pope's [Pathogen]. |
| 47 | + |
| 48 | +2. Next, move or clone the `vim-colors-solarized` directory so that it is |
| 49 | + a subdirectory of the `.vim/bundle` directory. |
| 50 | + |
| 51 | + a. **Clone:** |
| 52 | + |
| 53 | + $ cd ~/.vim/bundle |
| 54 | + $ git clone git://github.com/altercation/vim-colors-solarized.git |
| 55 | + |
| 56 | + b. **Move:** |
| 57 | + |
| 58 | + In the parent directory of vim-colors-solarized: |
| 59 | + |
| 60 | + $ mv vim-colors-solarized ~/.vim/bundle/ |
| 61 | + |
| 62 | +### Modify .vimrc |
| 63 | + |
| 64 | +After either Option 1 or Option 2 above, put the following two lines in your |
| 65 | +.vimrc: |
| 66 | + |
| 67 | + set background=dark |
| 68 | + colorscheme solarized |
| 69 | + |
| 70 | +or, for the light background mode of Solarized: |
| 71 | + |
| 72 | + set background=light |
| 73 | + colorscheme solarized |
| 74 | + |
| 75 | +I like to have a different background in GUI and terminal modes, so I can use |
| 76 | +the following if-then. However, I find vim's background autodetection to be |
| 77 | +pretty good and, at least with MacVim, I can leave this background value |
| 78 | +assignment out entirely and get the same results. |
| 79 | + |
| 80 | + if has('gui_running') |
| 81 | + set background=light |
| 82 | + else |
| 83 | + set background=dark |
| 84 | + endif |
| 85 | + |
| 86 | +See the [Solarized homepage][solarized] for screenshots which will help you |
| 87 | +select either the light or dark background. |
| 88 | + |
| 89 | +### IMPORTANT NOTE FOR TERMINAL USERS: |
| 90 | + |
| 91 | +If you are going to use Solarized in Terminal mode (i.e. not in a GUI version |
| 92 | +like gvim or macvim), **please please please** consider setting your terminal |
| 93 | +emulator's colorscheme to used the Solarized palette. I've included palettes |
| 94 | +for some popular terminal emulator as well as Xdefaults in the official |
| 95 | +Solarized download available from [Solarized homepage][solarized]. If you use |
| 96 | +Solarized without these colors, Solarized will by default use an approximate |
| 97 | +set of 256 colors. It isn't bad looking and has been extensively tweaked, but |
| 98 | +it's still not quite the real thing. |
| 99 | + |
| 100 | +If you do use the custom terminal colors, simply add the following line |
| 101 | +*before* the `colorschem solarized` line: |
| 102 | + |
| 103 | + let g:solarized_termcolors=16 |
| 104 | + |
| 105 | +Advanced Configuration |
| 106 | +---------------------- |
| 107 | + |
| 108 | +Solarized will work out of the box with just the two lines specified above but |
| 109 | +does include several other options that can be set in your .vimrc file. |
| 110 | + |
| 111 | +Set these in your vimrc file prior to calling the colorscheme. |
| 112 | +" |
| 113 | + option name default optional |
| 114 | + ------------------------------------------------ |
| 115 | + g:solarized_termcolors= 256 | 16 |
| 116 | + g:solarized_termtrans = 0 | 1 |
| 117 | + g:solarized_degrade = 0 | 1 |
| 118 | + g:solarized_bold = 1 | 0 |
| 119 | + g:solarized_underline = 1 | 0 |
| 120 | + g:solarized_italic = 1 | 0 |
| 121 | + g:solarized_style = "dark" | "light" |
| 122 | + g:solarized_contrast = "normal"| "high" or "low" |
| 123 | + ------------------------------------------------ |
| 124 | + |
| 125 | +### Option Details |
| 126 | + |
| 127 | +* g:solarized_termcolors |
| 128 | + |
| 129 | + **The most important option** if you are using vim in terminal (non gui) |
| 130 | + mode! See my diatribe above regarding terminal colors. This tells Solarized |
| 131 | + to use the 256 degraded color mode if running in a 256 color capable |
| 132 | + terminal. Otherwise, if set to `16` it will use the terminal emulators |
| 133 | + colorscheme (best option as long as you've set the emulators colors to the |
| 134 | + Solarized palette). |
| 135 | + |
| 136 | +* g:solarized_termtrans |
| 137 | + |
| 138 | + If you use a terminal emulator with a transparent background and Solarized |
| 139 | + isn't displaying the background color transparently, set this to 1 and |
| 140 | + Solarized will use the default (transparent) background of the terminal |
| 141 | + emulator. *urxvt* required this in my testing; Terminal.app/iTerm2 did not. |
| 142 | + |
| 143 | +* g:solarized_degrade |
| 144 | + |
| 145 | + For test purposes only; forces Solarized to use the 256 degraded color mode |
| 146 | + to test the approximate color values for accuracy. |
| 147 | + |
| 148 | +* g:solarized_bold | g:solarized_underline | g:solarized_italic |
| 149 | + |
| 150 | + If you wish to stop Solarized from displaying bold, underlined or |
| 151 | + italicized typefaces, simply assign a zero value to the appropriate |
| 152 | + variable, for example: `let g:solarized_italic=0` |
| 153 | + |
| 154 | +* g:solarized_style |
| 155 | + |
| 156 | + Simply another way to force Solarized to use a dark or light background. |
| 157 | + It's better to use `set background=dark` or `set background=light` in your |
| 158 | + .vimrc file. This option is mostly used in scripts (quick background color |
| 159 | + change) or for testing. |
| 160 | + |
| 161 | +* g:solarized_contrast |
| 162 | + |
| 163 | + Stick with normal! It's been carefully tested. Setting this option to high |
| 164 | + or low does use the same Solarized palette but simply shifts some values up |
| 165 | + or down in order to expand or compress the tonal range displayed. |
| 166 | + |
| 167 | +### **IMPORTANT NOTE FOR TERMINAL USERS** |
| 168 | + |
| 169 | +If you are running vim in a terminal, Solarized will run in 256 color mode if |
| 170 | +the terminal supports it, but those 256 colors are (in all 256 color terminal |
| 171 | +emulators) limited to a "degraded" color palette. While the colors will all |
| 172 | +approximate the specific Solarized color values, if you prefer an accurate |
| 173 | +color palette you can set the ANSI colors in your terminal and use the 16 color |
| 174 | +terminal mode using the g:solarized_termcolors="16" option detailed below. The |
| 175 | +ANSI color map is specified in the table below and terminal color themes are |
| 176 | +available for download from the web page listed at the top of this file, |
| 177 | +including xorg defaul color values and themes for OS X Terminal.app and iTerm2. |
| 178 | + |
| 179 | +Toggle Background Function |
| 180 | +-------------------------- |
| 181 | + |
| 182 | +Here's a quick script that toggles the background color, using F5 in this |
| 183 | +example. You can drop this into .vimrc: |
| 184 | + |
| 185 | + function! ToggleBackground() |
| 186 | + if (w:solarized_style=="dark") |
| 187 | + let w:solarized_style="light" |
| 188 | + colorscheme solarized |
| 189 | + else |
| 190 | + let w:solarized_style="dark" |
| 191 | + colorscheme solarized |
| 192 | + endif |
| 193 | + endfunction |
| 194 | + command! Togbg call ToggleBackground() |
| 195 | + nnoremap <F5> :call ToggleBackground()<CR> |
| 196 | + inoremap <F5> <ESC>:call ToggleBackground()<CR>a |
| 197 | + vnoremap <F5> <ESC>:call ToggleBackground()<CR> |
| 198 | + |
| 199 | +Code Notes |
| 200 | +---------- |
| 201 | + |
| 202 | +Use folding to view the `solarized.vim` script with `foldmethod=marker` turned |
| 203 | +on. |
| 204 | + |
| 205 | +I have attempted to modularize the creation of Vim colorschemes in this script |
| 206 | +and, while it could be refactored further, it should be a good foundation for |
| 207 | +the creation of any color scheme. By simply changing the sixteen values in the |
| 208 | +GUI section and testing in gvim (or mvim) you can rapidly prototype new |
| 209 | +colorschemes without diving into the weeds of line-item editing each syntax |
| 210 | +highlight declaration. |
| 211 | + |
| 212 | +License |
| 213 | +------- |
| 214 | +Copyright (c) 2011 Ethan Schoonover |
| 215 | + |
| 216 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 217 | +of this software and associated documentation files (the "Software"), to deal |
| 218 | +in the Software without restriction, including without limitation the rights |
| 219 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 220 | +copies of the Software, and to permit persons to whom the Software is |
| 221 | +furnished to do so, subject to the following conditions: |
| 222 | + |
| 223 | +The above copyright notice and this permission notice shall be included in |
| 224 | +all copies or substantial portions of the Software. |
| 225 | + |
| 226 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 227 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 228 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 229 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 230 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 231 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 232 | +THE SOFTWARE. |
| 233 | + |
0 commit comments