Skip to content

Instantly share code, notes, and snippets.

@baileythegreen
Created October 1, 2021 13:21
Show Gist options
  • Save baileythegreen/6518918129b5533fc43fb7276ab25bbc to your computer and use it in GitHub Desktop.
Save baileythegreen/6518918129b5533fc43fb7276ab25bbc to your computer and use it in GitHub Desktop.
Adding a syntax highlighting theme in vim
" not necessary for the theme file to work
set softtabstop=4
set shiftwidth=4
set expandtab
set nu
set mouse=n
" related to theme, but can be put in ~.vimrc, or run in vim as desired
syntax on
set termguicolors=on
color imprimateur
" these lines are required for (my terminal to do) italics
let &t_ZH="\e[3m"
let &t_ZR="\e[23m"
" set some default print options for use by :hardcopy
" the first line sets fonts and sizes for regular, bold, and italic text
" the second sets the number of lines in the header, turns on syntax
" highlighting, text-wrapping, line numbers, and jobsplitting (good for
" making multiple copies, apparently)
set printfont=r:courier:h8,b:courier-bold:h8,i:courier-oblique:h8
set printoptions=header:2,syntax:y,wrap:y,number:y,jobsplit:
" tell vim to recognise snakemake files; I have a separate syntax file for these
au BufNewFile,BufRead Snakefile set syntax=snakemake
au BufNewFile,BufRead *.snake set syntax=snakemake
au BufNewFile,BufRead *.smk set syntax=snakemake
" definition of an alternate :hardcopy, mostly not used
command! -nargs=* Hardcopy call DoMyPrint('<args>')
function DoMyPrint(args)
let colorsave=g:colors_name
color imprimateur
exec 'hardcopy popt=header:2,syntax:y,wrap:y,number:y,jobsplit:y,duplex:short'.a:args
exec 'color '.colorsave
endfunction

To enable this theme

In vim, run:

:color imprimateur

or add:

color imprimateur

to your ~/.vimrc, or .

Save the theme file in: ~/.vim/colors/imprimateur.vim; vim knows to look here.

Abbreviations

fg = foreground (text colour) bg = background (highlight colour)

Formatting options

term : {bold, italic, underline, standout, reverse} cterm : {bold, italic, underline, standout, reverse}

Affect colour of text in terminal

ctermfg, ctermbg : a string, such as one of {red, cyan, magenta, black, darkgreen}, or a number in the range {0..255}

Affect colour of text in gvim, only:

guifg, guibg : a string, such as one of {red, cyan, magenta, black, darkgreen}, or a hex value for the desired colour

" local syntax file - set colors on a per-machine basis:
" vim: tw=0 ts=4 sw=4
" Vim color file
" Author: Bailey Harrington <baileythegreen@gmail.com>
" Based on: koehler, by Ron Aaron <ron@ronware.org>
" Last Change: 2021 Oct 1
" save in: ~/.vim/colors/imprimateur.vim
hi clear
if exists('syntax_on')
syntax reset
endif
" this file is intended for printing, and vim :hardcopy arbitrarily changes colours
" when the background is 'dark'
if &background !=# 'light'
set background=light
endif
" creates a global variable; this is standard
let g:colors_name = 'imprimateur'
" assigns colour and formatting to categories of syntactic values
hi Normal guifg=white guibg=black ctermbg=NONE
hi Scrollbar guifg=darkcyan guibg=cyan ctermfg=magenta
hi Menu guifg=black guibg=cyan ctermfg=magenta
hi SpecialKey term=bold cterm=bold ctermfg=darkred guifg=#cc0000
hi NonText term=bold cterm=bold ctermfg=darkred gui=bold guifg=#cc0000
hi Directory term=bold cterm=bold ctermfg=brown guifg=#cc8000
hi ErrorMsg term=standout cterm=bold ctermfg=grey ctermbg=red guifg=White guibg=Red
hi Search term=reverse ctermfg=white ctermbg=red guifg=white guibg=Red
hi MoreMsg term=bold cterm=bold ctermfg=darkgreen gui=bold guifg=darkcyan
hi ModeMsg term=bold cterm=bold gui=bold guifg=White guibg=Blue
hi LineNr term=underline cterm=bold ctermfg=54 guifg=Yellow
hi Question term=standout cterm=bold ctermfg=darkgreen gui=bold guifg=Green
hi StatusLine term=bold,reverse cterm=bold ctermfg=lightblue ctermbg=white gui=bold guifg=blue guibg=white
hi StatusLineNC term=reverse ctermfg=white ctermbg=lightblue guifg=white guibg=blue
hi Title term=bold cterm=bold ctermfg=darkmagenta gui=bold guifg=Magenta
hi Visual term=reverse cterm=reverse gui=reverse
hi WarningMsg term=standout cterm=bold ctermfg=darkred guifg=Red
hi Cursor guifg=bg guibg=Green
hi Comment term=italic cterm=italic ctermfg=grey guifg=#80a0ff
hi Constant term=underline ctermfg=darkred guifg=#ffa0a0
hi Special term=bold cterm=bold ctermfg=red guifg=Orange
hi Identifier term=underline ctermfg=32 guifg=#40ffff
hi Statement term=bold cterm=bold ctermfg=17 gui=bold guifg=#ffff60
hi Number ctermfg=163
hi PreProc term=underline ctermfg=darkmagenta guifg=#ff80ff
hi Type term=underline cterm=bold ctermfg=lightgreen gui=bold guifg=#60ff60
hi Error term=reverse ctermfg=darkcyan ctermbg=black guifg=Red guibg=Black
hi Todo term=standout ctermfg=black ctermbg=darkcyan guifg=Blue guibg=Yellow
hi CursorLine term=underline guibg=#555555 cterm=underline
hi CursorColumn term=underline guibg=#555555 cterm=underline
hi MatchParen term=reverse ctermfg=blue guibg=Blue
hi TabLine term=bold,reverse cterm=bold ctermfg=lightblue ctermbg=white gui=bold guifg=blue guibg=white
hi TabLineFill term=bold,reverse cterm=bold ctermfg=lightblue ctermbg=white gui=bold guifg=blue guibg=white
hi TabLineSel term=reverse ctermfg=white ctermbg=lightblue guifg=white guibg=blue
hi Underlined term=underline cterm=bold,underline ctermfg=lightblue guifg=lightblue gui=bold,underline
hi Ignore ctermfg=black ctermbg=black guifg=black guibg=black
hi EndOfBuffer term=bold cterm=bold ctermfg=darkred guifg=#cc0000 gui=bold
hi link IncSearch Visual
hi link String Constant
hi link Character Constant
hi link Number Constant
hi link Boolean Constant
hi link Float Number
hi link Function Identifier
hi link Conditional Statement
hi link Repeat Statement
hi link Label Statement
hi link Operator Statement
hi link Keyword Statement
hi link Exception Statement
hi link Include PreProc
hi link Define PreProc
hi link Macro PreProc
hi link PreCondit PreProc
hi link StorageClass Type
hi link Structure Type
hi link Typedef Type
hi link Tag Special
hi link SpecialChar Special
hi link Delimiter Special
hi link SpecialComment Special
hi link Debug Special
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment