Ⅰ. 插件描述
vim themes across the spectrumⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'nightsense/vimspectr'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'nightsense/vimspectr'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'nightsense/vimspectr'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/nightsense/vimspectr
Ⅳ. 文档说明
Note: this repository is archived. If I continue developing the vimspectr concept in future, it will probably be in the form of a new repository with the themes rebuilt from scratch. In the meantime, you might want to check out my current active vim theme, snow.
.
.
.
<h1 id="vimspectr">vimspectr</h1>
<p>vimspectr is a set of 26 vim themes, consisting of a dark/light pair for each of the following hues:</p>
| - | 0° | 30° | 60° | 90° | 120° | 150° | 180° | 210° | 240° | 270° | 300° | 330° |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| grey | red | orange | yellow | lawn green |
green | sea green |
aqua | sky blue |
blue | purple | pink | rose |
<p>» click here for the vimspectr theme previewer «</p>
<h2 id="setup">setup</h2>
<h3 id="installation">installation</h3>
<p>If you don’t have a preferred plugin helper, consider trying vim-plug, which can be installed with:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">curl -fLo ~/.vim/autoload/plug.vim --create-dirs \</pre></div></div>
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
<p>To install vimspectr using vim-plug, add the following to the top of your vimrc:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">call plug#begin('~/.vim/plugged')</pre></div></div>
Plug 'nightsense/vimspectr'
call plug#end()
<p>Then restart vim and run PlugUpdate (from the vim command line).</p>
<p>Finally, if you want vimspectr to work in the terminal (for the shell and/or terminal vim), create a symlink at ~/.vimspectr-shell pointing to your vimspectr/shell directory. The path to this directory will vary depending on your plugin helper. For vim-plug users, the following command will create the required symlink:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">ln -s ~/.vim/plugged/vimspectr/shell ~/.vimspectr-shell</pre></div></div>
<h3 id="activation">activation</h3>
<p>To activate a vimspectr theme, add the following line to your vimrc:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">colorscheme vimspectrH-B</pre></div></div>
<p>…replacing H with hue (e.g. 60) and B with background setting (i.e. dark or light).</p>
<p>For example:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">colorscheme vimspectr60-light</pre></div></div>
<p>View the list of theme files to see all possible values for colorscheme.</p>
<h3 id="randomization">randomization</h3>
<p>To load a random vimspectr theme on vim startup:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">let vimspectr_themes = [</pre></div></div>
'vimspectr0-dark' , 'vimspectr0-light' ,
'vimspectr30-dark' , 'vimspectr30-light' ,
'vimspectr60-dark' , 'vimspectr60-light' ,
'vimspectr90-dark' , 'vimspectr90-light' ,
'vimspectr120-dark' , 'vimspectr120-light' ,
'vimspectr150-dark' , 'vimspectr150-light' ,
'vimspectr180-dark' , 'vimspectr180-light' ,
'vimspectr210-dark' , 'vimspectr210-light' ,
'vimspectr240-dark' , 'vimspectr240-light' ,
'vimspectr270-dark' , 'vimspectr270-light' ,
'vimspectr300-dark' , 'vimspectr300-light' ,
'vimspectr330-dark' , 'vimspectr330-light' ,
'vimspectrgrey-dark', 'vimspectrgrey-light',
]
exe 'colorscheme '.vimspectr_themes[localtime() % len(vimspectr_themes)]
<p>To load a random dark theme during the night, random light theme during the day:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">if strftime("%H") < 7 || strftime("%H") >= 19
let themes = [
\ 'vimspectr0-dark' , 'vimspectr0-dark' , 'vimspectr30-dark' ,
\ 'vimspectr60-dark' , 'vimspectr90-dark' , 'vimspectr120-dark' ,
\ 'vimspectr150-dark' , 'vimspectr180-dark' , 'vimspectr210-dark' ,
\ 'vimspectr240-dark' , 'vimspectr270-dark' , 'vimspectr300-dark' ,
\ 'vimspectr330-dark' , 'vimspectrgrey-dark'
\ ]else
let themes = [
\ 'vimspectr0-light' , 'vimspectr0-light' , 'vimspectr30-light' ,
\ 'vimspectr60-light' , 'vimspectr90-light' , 'vimspectr120-light',
\ 'vimspectr150-light', 'vimspectr180-light' , 'vimspectr210-light',
\ 'vimspectr240-light', 'vimspectr270-light' , 'vimspectr300-light',
\ 'vimspectr330-light', 'vimspectrgrey-light'
\ ]endif
exe 'colorscheme '.themes[localtime() % len(themes)]
</pre></div></div>
<h3 id="options">options</h3>
<p>Options can be triggered by adding the corresponding code (before the line that sets colorscheme) in your vimrc.</p>
| option | vimrc code |
|---|---|
| disable highlighted current line number | let g:vimspectrCursorLineNr = 'off' |
| enable muted line numbers | let g:vimspectrMuteLineNr = 'on' |
| disable line number background | let g:vimspectrLineNr = 'off' |
| enable muted statusline | let g:vimspectrMuteStatusLine = 'on' |
| enable italicized comments | let g:vimspectrItalicComment = 'on' |
<h2 id="terminal">terminal</h2>
<p>vimspectr includes support for the Linux console and various terminal emulators, including alacritty, gnome-terminal, roxterm, st, terminator, tilda, tilix, urxvt, xfce4-terminal, and xterm. Terminal vim and neovim are supported, as are screen and tmux.</p>
<p>If colours aren’t displaying properly, the issue is probably related to 256-colour support. Be sure your terminal (and multiplexer, if applicable) supports 256 colours and is properly configured.</p>
<h3 id="shell-configuration">shell configuration</h3>
<p>This step configures your shell to load a vimspectr terminal theme on startup (not required for terminal vim).</p>
<p>Don’t forget to enable vimspectr terminal support by creating the required symlink.</p>
<p>For bash/zsh, add the following to ~/.bashrc or ~/.zshrc…</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">[ -n "$PS1" ] && sh ~/.vimspectr-shell/THEME</pre></div></div>
<p>…replacing THEME with the desired colourscheme (e.g. sh ~/.vimspectr-shell/vimspectr210-dark).</p>
<p>On macOS, where~/.bashrcis not sourced automatically, you can add this line to~/.bash_profileinstead.</p>
<p>For fish, add the following to ~/.config/fish/config.fish:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">if status --is-interactive; sh ~/.vimspectr-shell/THEME; end</pre></div></div>
<h3 id="randomization-1">randomization</h3>
<p>To load a random vimspectr theme on bash/zsh startup, add the following to ~/.bashrc:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">vimspectr_theme=$(ls ~/.vimspectr-shell/ | grep vimspectr | shuf -n1)</pre></div></div>
[ -n "$PS1" ] && sh ~/.vimspectr-shell/$vimspectr_theme
<p>To load a random vimspectr theme on fish startup, add the following to ~/.config/fish/config.fish:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">set vimspectr_theme (ls ~/.vimspectr-shell/ | grep vimspectr | shuf -n1)</pre></div></div>
if status --is-interactive; sh ~/.vimspectr-shell/$vimspectr_theme; end
<h3 id="restoring-shell-theme-on-vim-exit">restoring shell theme on vim exit</h3>
<p>If different themes are used for the shell and terminal vim, the latter theme will persist in the terminal after vim is closed. In order to restore the original shell theme, you can wrap the vim command in a shell function:</p>
<p>For bash/zsh, add the following to ~/.bashrc or ~/.zshrc…</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">vim(){ sh -c "vim $*"; sh ~/.vimspectr-shell/THEME; clear; }</pre></div></div>
<p>…replacing THEME with the colourscheme (e.g. sh ~/.nightshell/vimspectr210-dark) to restore upon exiting vim.</p>
<p>For fish, add the following to ~/.config/fish/config.fish:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">function vim; sh -c "vim $argv"; sh ~/.vimspectr-shell/THEME; clear; end</pre></div></div>
<h2 id="optional-steps">optional steps</h2>
<h3 id="dircolors">dircolors</h3>
<p>Don’t forget to enable vimspectr terminal support by creating the required symlink.</p>
<p>dircolors is basically a theme for the ls command, defining the colours used to distinguish filetypes. To activate the vimspectr version of dircolors:</p>
<p>bash/zsh: add the following to ~/.bashrc or ~/.zshrc:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">eval </pre></div></div>dircolors ~/.vimspectr-shell/dircolors
<p>fish: add the following to ~/.config/fish/config.fish:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">eval (dircolors -c ~/.vimspectr-shell/dircolors)</pre></div></div>
<h3 id="fish-shell-theme">fish shell theme</h3>
<p>Don’t forget to enable vimspectr terminal support by creating the required symlink.</p>
<p>The custom nightshell fish theme can be activated by adding the following to ~/.config/fish/config.fish:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">source ~/.vimspectr-shell/fish</pre></div></div>
<h3 id="base16-shell-integration">base16-shell integration</h3>
<p>Don’t forget to enable vimspectr terminal support by creating the required symlink.</p>
<p>If you already use Base16 Shell, you can make it aware of vimspectr themes with the following command:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">bash -c 'for f in ~/.vimspectr-shell/-; do</pre></div></div>
ln -s $f $(echo $f.sh | sed "s#vimspectr-shell/#config/base16-shell/scripts/base16-#")
done'
<p>To undo the above command:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight">bash -c 'for f in ~/.config/base16-shell/scripts/vimspectr; do rm $f; done'</pre></div></div>
<h2 id="troubleshooting">troubleshooting</h2>
<p>If colours aren’t displaying correctly…</p>
- …in neovim, ensure your configuration does not contain
set termguicolors - …in tmux, try launching tmux with
tmux -2
<p>
</p>
<h2 id="production-notes">production notes</h2>
<p>
</p>
<h3 id="palette-construction">palette construction</h3> <p>Each vimspectr theme consists of 6 theme-specific base colours and 8 fixed accent colours.</p> <p>Base colours were determined by:</p>
- selecting contrast ratios such that values of base colours of the greyscale theme align with 1/24 intervals
- adding saturation to base colours of remaining themes, also observing 1/24 intervals
- saturation rises as value falls
</li> ul><p>Accent colours were determined by:</p>
- selecting pure hues (“pure red” etc.) at the scale of 1/12 colour wheel intervals
- fine-tuning these hues by 1/48 intervals
- clockwise: red and purple (1 interval), pink (2)
- counterclockwise: orange and teal (1 interval), yellow (2)
</li> <li>selecting saturations and values at the scale of 1/24 intervals <ul> <li>saturation rises as hue transitions counterclockwise from pink to green</li> <li>value rises as hue transitions clockwise from green to pink</li> </ul> </li> ul><thead>
<tr> <th style="text-align: right">greyscale base</th> <th style="text-align: left">dark accents</th> <th style="text-align: center">light accents</th> </tr></thead>
<tbody><tr> <td style="text-align: right"><img src="http://www.colorhexa.com/141414.png" height="24" width="42" /> <code class="highlighter-rouge">141414</code> </td> <td style="text-align: center"><img src="http://www.colorhexa.com/b55a4c.png" height="24" width="42" /> <code class="highlighter-rouge">b55a4c</code> </td> <td style="text-align: left"><img src="http://www.colorhexa.com/e04d38.png" height="24" width="42" /> <code class="highlighter-rouge">e04d38</code></td> </tr> <tr> <td style="text-align: right"><img src="http://www.colorhexa.com/2b2b2b.png" height="24" width="42" /> <code class="highlighter-rouge">2b2b2b</code> </td> <td style="text-align: center"><img src="http://www.colorhexa.com/b5734c.png" height="24" width="42" /> <code class="highlighter-rouge">b5734c</code> </td> <td style="text-align: left"><img src="http://www.colorhexa.com/e07638.png" height="24" width="42" /> <code class="highlighter-rouge">e07638</code></td> </tr> <tr> <td style="text-align: right"><img src="http://www.colorhexa.com/6b6b6b.png" height="24" width="42" /> <code class="highlighter-rouge">6b6b6b</code> </td> <td style="text-align: center"><img src="http://www.colorhexa.com/b59b4c.png" height="24" width="42" /> <code class="highlighter-rouge">b59b4c</code> </td> <td style="text-align: left"><img src="http://www.colorhexa.com/e0b738.png" height="24" width="42" /> <code class="highlighter-rouge">e0b738</code></td> </tr> <tr> <td style="text-align: right"><img src="http://www.colorhexa.com/8a8a8a.png" height="24" width="42" /> <code class="highlighter-rouge">8a8a8a</code> </td> <td style="text-align: center"><img src="http://www.colorhexa.com/6d8a50.png" height="24" width="42" /> <code class="highlighter-rouge">6d8a50</code> </td> <td style="text-align: left"><img src="http://www.colorhexa.com/699e34.png" height="24" width="42" /> <code class="highlighter-rouge">699e34</code></td> </tr> <tr> <td style="text-align: right"><img src="http://www.colorhexa.com/e8e8e8.png" height="24" width="42" /> <code class="highlighter-rouge">e8e8e8</code> </td> <td style="text-align: center"><img src="http://www.colorhexa.com/508a82.png" height="24" width="42" /> <code class="highlighter-rouge">508a82</code> </td> <td style="text-align: left"><img src="http://www.colorhexa.com/349e90.png" height="24" width="42" /> <code class="highlighter-rouge">349e90</code></td> </tr> <tr> <td style="text-align: right"><img src="http://www.colorhexa.com/ffffff.png" height="24" width="42" /> <code class="highlighter-rouge">ffffff</code> </td> <td style="text-align: center"><img src="http://www.colorhexa.com/6a849e.png" height="24" width="42" /> <code class="highlighter-rouge">6a849e</code> </td> <td style="text-align: left"><img src="http://www.colorhexa.com/4286c9.png" height="24" width="42" /> <code class="highlighter-rouge">4286c9</code></td> </tr> <tr> <td></td> <td style="text-align: center"><img src="http://www.colorhexa.com/8b6a9e.png" height="24" width="42" /> <code class="highlighter-rouge">8b6a9e</code> </td> <td style="text-align: left"><img src="http://www.colorhexa.com/a565c9.png" height="24" width="42" /> <code class="highlighter-rouge">a565c9</code></td> </tr> <tr> <td></td> <td style="text-align: center"><img src="http://www.colorhexa.com/b57988.png" height="24" width="42" /> <code class="highlighter-rouge">b57988</code> </td> <td style="text-align: left"><img src="http://www.colorhexa.com/e0708c.png" height="24" width="42" /> <code class="highlighter-rouge">e0708c</code></td> </tr></tbody>
</table>
</blockquote><p>
</p><h3 id="accent-colour-logic">accent colour logic</h3> <p>Red, the colour of alarm, is used for warning elements, including error messages, misspellings, and diff deletions.</p> <p>
Orange, the colour of fire, can be associated with preliminary “warmup” activity. Orange is therefore used for preliminary elements, such as preprocessor commands (which prepare data to be handled by another program), incremental searching (that is, a search term in the process of being typed), titles, and miscapitalized words.</p> <p>
Yellow, a classic highlighting colour, is applied to elements that are not warnings, yet should draw attention with high visibility. These highlighted elements include search results, task tags (
TODO,FIXME…), and diff changes.</p> <p>Green, the colour that says “go ahead, proceed with the task at hand”, is used for action elements, such as statements (if/then, while/do, case…), mode indicators (insert, visual…), vim user prompts, and diff additions.</p> <p>
Teal is named after the “common teal”, a kind of duck, thus connecting this colour with the concept of “species”, which is a means of classifying life into very specific types. Teal is therefore used for specifying object types, such as data type (boolean, integer, string…) or storage class (static, volatile…), as well as mislocalized words.</p> <p>
Blue, a colour of calm stability, is used for constants, which come in the form of boolean values, integers, floating-point numbers, characters, and strings.</p> <p>
Purple, associated with (historically) rare purple dyes produced for special works of art, is used for special text, including special characters (standalone or within syntax units), vim tags, debugging statements, and rarely-used words.</p> <p>
Pink, the colour of spring blossoms, is used for object names, including the names of variables and functions. To code is to bring countless objects blossoming into life as one types their names.</p>
<p>
</p><h3 id="dircolors-logic">dircolors logic</h3>
- directories are bold, reflecting their “expanded” role as a “file that contains files”
- normal directories use the normal text colour
- “sticky” directories are pink, like sticky bubble gum
- “other-writable” directories are orange, as though warmed by the heat of writing activity
- directories that are both “sticky” and “other-writable” are orange and underlined: the orange is writing-warmth, while the underline is a “stick”
</li> <li><strong>links</strong> are underlined, like hyperlinks on the internet <ul> <li>this applies to both <strong>multi-hardlinked files</strong> and <strong>symlinks</strong></li> <li>links use the normal text colour except for <strong>orphan links</strong> (symlinks that point to non-existent files), which are <strong>red</strong> (the colour of warning)</li> </ul> </li> <li><strong>device driver files</strong> are <strong>highlighted</strong> with the normal text colour; since this colour is grey (or greyish), these highlighted blocks of texts resemble the grey, boxy form taken by many technological devices</li> <li><strong>IPC files</strong> are <strong>blue-highlighted</strong>, since they enable information to flow between processes like water</li> <li><strong>setuid files</strong> (u+s) are <strong>purple-highlighted</strong>: p<strong>u</strong>rple = <strong>u</strong>ser</li> <li><strong>setgid files</strong> (g+s) are <strong>green-highlighted</strong>: <strong>g</strong>reen = <strong>g</strong>roup</li> <li>files that use <strong>capabilities</strong> are <strong>red-highlighted</strong>: red = red-blooded = capable</li> <li><strong>executable files</strong> are <strong>green</strong>, since green = “go ahead, proceed with action”</li> <li><strong>archive files</strong> are <strong>purple</strong>, since purple is the colour of famous dyes made from sea snails, which are packed (like archives) into shells</li> <li><strong>multimedia files</strong> are <strong>blue</strong>, since blue conveys calm, enduring stability (like the sea and sky), just like the great works of art (images, music, video) we can rely on</li>