All Projects → nightsense → Vimspectr

nightsense / Vimspectr

Licence: gpl-3.0
vim themes across the spectrum

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.

.

.

.

vimspectr

vimspectr is a set of 26 vim themes, consisting of a dark/light pair for each of the following hues:

- 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

» click here for the vimspectr theme previewer «

setup

installation

If you don’t have a preferred plugin helper, consider trying vim-plug, which can be installed with:

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

To install vimspectr using vim-plug, add the following to the top of your vimrc:

call plug#begin('~/.vim/plugged')
Plug 'nightsense/vimspectr'
call plug#end()

Then restart vim and run PlugUpdate (from the vim command line).

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:

ln -s ~/.vim/plugged/vimspectr/shell ~/.vimspectr-shell

activation

To activate a vimspectr theme, add the following line to your vimrc:

colorscheme vimspectrH-B

…replacing H with hue (e.g. 60) and B with background setting (i.e. dark or light).

For example:

colorscheme vimspectr60-light

View the list of theme files to see all possible values for colorscheme.

randomization

To load a random vimspectr theme on vim startup:

let vimspectr_themes = [
 \ '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)]

To load a random dark theme during the night, random light theme during the day:

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)]

options

Options can be triggered by adding the corresponding code (before the line that sets colorscheme) in your vimrc.

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'

terminal

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.

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.

shell configuration

This step configures your shell to load a vimspectr terminal theme on startup (not required for terminal vim).

Don’t forget to enable vimspectr terminal support by creating the required symlink.

For bash/zsh, add the following to ~/.bashrc or ~/.zshrc

[ -n "$PS1" ] && sh ~/.vimspectr-shell/THEME

…replacing THEME with the desired colourscheme (e.g. sh ~/.vimspectr-shell/vimspectr210-dark).

On macOS, where ~/.bashrc is not sourced automatically, you can add this line to ~/.bash_profile instead.

For fish, add the following to ~/.config/fish/config.fish:

if status --is-interactive; sh ~/.vimspectr-shell/THEME; end

randomization

To load a random vimspectr theme on bash/zsh startup, add the following to ~/.bashrc:

vimspectr_theme=$(ls ~/.vimspectr-shell/ | grep vimspectr | shuf -n1)
[ -n "$PS1" ] && sh ~/.vimspectr-shell/$vimspectr_theme

To load a random vimspectr theme on fish startup, add the following to ~/.config/fish/config.fish:

set vimspectr_theme (ls ~/.vimspectr-shell/ | grep vimspectr | shuf -n1)
if status --is-interactive; sh ~/.vimspectr-shell/$vimspectr_theme; end

restoring shell theme on vim exit

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:

For bash/zsh, add the following to ~/.bashrc or ~/.zshrc

vim(){ sh -c "vim $*"; sh ~/.vimspectr-shell/THEME; clear; }

…replacing THEME with the colourscheme (e.g. sh ~/.nightshell/vimspectr210-dark) to restore upon exiting vim.

For fish, add the following to ~/.config/fish/config.fish:

function vim; sh -c "vim $argv"; sh ~/.vimspectr-shell/THEME; clear; end

optional steps

dircolors

Don’t forget to enable vimspectr terminal support by creating the required symlink.

dircolors is basically a theme for the ls command, defining the colours used to distinguish filetypes. To activate the vimspectr version of dircolors:

bash/zsh: add the following to ~/.bashrc or ~/.zshrc:

eval `dircolors ~/.vimspectr-shell/dircolors`

fish: add the following to ~/.config/fish/config.fish:

eval (dircolors -c ~/.vimspectr-shell/dircolors)

fish shell theme

Don’t forget to enable vimspectr terminal support by creating the required symlink.

The custom nightshell fish theme can be activated by adding the following to ~/.config/fish/config.fish:

source ~/.vimspectr-shell/fish

base16-shell integration

Don’t forget to enable vimspectr terminal support by creating the required symlink.

If you already use Base16 Shell, you can make it aware of vimspectr themes with the following command:

bash -c 'for f in ~/.vimspectr-shell/*-*; do
  ln -s $f $(echo $f.sh | sed "s#vimspectr-shell/#config/base16-shell/scripts/base16-#")
done'

To undo the above command:

bash -c 'for f in ~/.config/base16-shell/scripts/*vimspectr*; do rm $f; done'

troubleshooting

If colours aren’t displaying correctly…

  • …in neovim, ensure your configuration does not contain set termguicolors
  • …in tmux, try launching tmux with tmux -2


production notes


palette construction

Each vimspectr theme consists of 6 theme-specific base colours and 8 fixed accent colours.

Base colours were determined by:

  • 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

Accent colours were determined by:

  • 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)
  • selecting saturations and values at the scale of 1/24 intervals
    • saturation rises as hue transitions counterclockwise from pink to green
    • value rises as hue transitions clockwise from green to pink
greyscale base dark accents light accents
141414 b55a4c e04d38
2b2b2b b5734c e07638
6b6b6b b59b4c e0b738
8a8a8a 6d8a50 699e34
e8e8e8 508a82 349e90
ffffff 6a849e 4286c9
8b6a9e a565c9
b57988 e0708c


accent colour logic

Red, the colour of alarm, is used for warning elements, including error messages, misspellings, and diff deletions.

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.

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.

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.

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.

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.

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.

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.


dircolors logic

  • 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”
  • links are underlined, like hyperlinks on the internet
    • this applies to both multi-hardlinked files and symlinks
    • links use the normal text colour except for orphan links (symlinks that point to non-existent files), which are red (the colour of warning)
  • device driver files are highlighted 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
  • IPC files are blue-highlighted, since they enable information to flow between processes like water
  • setuid files (u+s) are purple-highlighted: purple = user
  • setgid files (g+s) are green-highlighted: green = group
  • files that use capabilities are red-highlighted: red = red-blooded = capable
  • executable files are green, since green = “go ahead, proceed with action”
  • archive files are purple, since purple is the colour of famous dyes made from sea snails, which are packed (like archives) into shells
  • multimedia files are blue, 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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].