dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit fff1ebea7b5ce8b4cdbef19fe7f98e0f6fc7df34
parent 86d89991961afb793396ea6f8c972b0f59695572
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Tue, 25 Feb 2020 13:25:10 +0100

vim: colors and settings

Former-commit-id: bf6926ae71784448ce898bc3b4d931013c7e82ab
Diffstat:
Mscripts/colgen.rb | 40++++++++++++++++++++++++++++++++++++----
Mvim/colors/jokull.vim | 4++--
Mvim/colors/jokull.vimcolor | 36++++++++++++++++++++++++------------
Mvim/syntax/vimcolor.vim | 21+++++++++++++++------
Mvim/vimrc | 5+++++
5 files changed, 82 insertions(+), 24 deletions(-)

diff --git a/scripts/colgen.rb b/scripts/colgen.rb @@ -143,14 +143,40 @@ elsif not ARGV[0].end_with? ".vimcolor" abort "File extension should be .vimcolor" end +# Read the file +lines = File.readlines(ARGV[0]) +nlines = lines.length + +# This will hold custom user-defined color names +colornames = {} + # Read and parse the definitions from file passed as argument -File.open(ARGV[0], "r").each do |line| +cursor = 0 +while cursor < nlines + line = lines[cursor] + # Remove excess whitespace line.strip! + if line.start_with? "palette:" + loop do + cursor += 1 + line = lines[cursor] + next if line.empty? || line.start_with?("\"") + + entry = line.strip.split + if not entry[1].end_with? "." + entry[1] = entry[1].gsub ",", "" + colornames[entry[0]] = entry[1] + else + entry[1] = entry[1].gsub ".", "" + colornames[entry[0]] = entry[1] + break + end + end # Link definitions # Format: link group1[,group2..] destgroup - if line.start_with? "link" + elsif line.start_with? "link" # From-group and to-group from, to = line.split(" ")[1..-1] @@ -185,7 +211,11 @@ File.open(ARGV[0], "r").each do |line| fg, bg = colors.split(',').map { |x| x.strip } # Set background color to NONE if not defined - bg = "NONE" if bg.nil? + bg = "NONE" if (bg.nil? or bg.empty?) + + # Resolve variables to the hex value of the color + fg = colornames[fg] if (not fg.start_with? "#" and not fg == "NONE") + bg = colornames[bg] if (not bg.start_with? "#" and not bg == "NONE") # Parse the attribute, remove whitespace, join with commas (so result is e.g. 'bold,underline') attrs = (attrs.nil? ? "NONE" : attrs.split(',').map { |x| x.strip }.join(",")) @@ -193,12 +223,15 @@ File.open(ARGV[0], "r").each do |line| # Add the definition to the array primary << [group, fg, bg, attrs] end + + cursor += 1 end # Write the colorscheme file File.open("#{ENV['HOME']}/.vim/colors/#{ARGV[0].sub(/.*\//, '').sub('.vimcolor', '.vim')}", "w") do |f| # Write the preamble, along with background value f.puts <<~EOF + set background=#{background} if version > 580 highlight clear if exists("syntax_on") @@ -206,7 +239,6 @@ File.open("#{ENV['HOME']}/.vim/colors/#{ARGV[0].sub(/.*\//, '').sub('.vimcolor', endif endif let g:colors_name = "#{ARGV[0].sub(/.*\//, '').sub('.vimcolor', '')}" - set background=#{background} EOF # Write color definitions first diff --git a/vim/colors/jokull.vim b/vim/colors/jokull.vim @@ -1,3 +1,4 @@ +set background=light if version > 580 highlight clear if exists("syntax_on") @@ -5,7 +6,6 @@ if version > 580 endif endif let g:colors_name = "jokull" -set background=light hi Normal guifg=#2c2625 guibg=#e4e4e4 ctermfg=0 ctermbg=254 cterm=NONE gui=NONE hi Cursorline guifg=NONE guibg=#d0d0d0 ctermfg=NONE ctermbg=252 cterm=NONE gui=NONE hi String guifg=#009051 guibg=NONE ctermfg=29 ctermbg=NONE cterm=italic gui=italic @@ -23,7 +23,7 @@ hi Wildmenu guifg=#005493 guibg=#e5e5e5 ctermfg=24 ctermbg=7 cterm=bold gui=bold hi Linenr guifg=#9b9b4c guibg=NONE ctermfg=101 ctermbg=NONE cterm=NONE gui=NONE hi Preproc guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE cterm=NONE gui=NONE hi Vertsplit guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE cterm=NONE gui=NONE -hi Todo guifg=Blue guibg=Yellow ctermfg=0 ctermbg=0 cterm=NONE gui=NONE +hi Todo guifg=#0000FF guibg=#FFFF00 ctermfg=21 ctermbg=11 cterm=NONE gui=NONE hi Nontext guifg=#81A1C1 guibg=NONE ctermfg=109 ctermbg=NONE cterm=NONE gui=NONE hi Statusline guifg=NONE guibg=#7abecd ctermfg=NONE ctermbg=110 cterm=NONE gui=NONE hi Statuslinenc guifg=NONE guibg=#a8dbfd ctermfg=NONE ctermbg=153 cterm=NONE gui=NONE diff --git a/vim/colors/jokull.vimcolor b/vim/colors/jokull.vimcolor @@ -1,31 +1,43 @@ " This script uses the colorgen script " to create a colorscheme from something a bit more readable. " Format is 'group fg_hex, bg_hex. attrs' + +palette: + text #2c2625, + bg #e4e4e4, + darkblue #005493, + lightblue #a8dbfd, + gray #d0d0d0, + lightgreen #d7f1e0, + offwhite #e5e5e5, + justblue #0000FF, + justyellow #FFFF00. + background light -Normal #2c2625, #e4e4e4 -Cursorline NONE, #d0d0d0 +Normal text, bg +Cursorline NONE, gray String #009051. italic Identifier #112d4e Function #0096ff. bold Statement #0050a0 Include #2696bf. bold -Type #005493 -Search NONE, #d7f1e0 +Type darkblue +Search NONE, lightgreen Incsearch NONE, #b7d1b0. bold -Folded #236dff, #d0d0d0 -Tablinefill NONE, #d0d0d0 -Tablinesel NONE, #e5e5e5 -Wildmenu #005493, #e5e5e5. bold +Folded #236dff, gray +Tablinefill NONE, gray +Tablinesel NONE, offwhite +Wildmenu darkblue, offwhite. bold Linenr #9b9b4c, NONE Preproc NONE Vertsplit NONE -Todo Blue, Yellow +Todo justblue, justyellow Nontext #81A1C1 Statusline NONE, #7abecd -Statuslinenc NONE, #a8dbfd +Statuslinenc NONE, lightblue Visual NONE, #a8caff Title #225555. bold -Matchparen #d7f1e0, #a8dbfd +Matchparen lightgreen, lightblue QfFileName #0076ff Delimiter #5f5f00 Comment #5f5f5f. italic @@ -47,5 +59,5 @@ link pmenusel statusline Diffadd NONE, #a5ffa5 Diffdelete NONE, #ffa5a5 -Diffchange #2c2625, #c0beff +Diffchange text, #c0beff Difftext NONE, #a0aeff. bold diff --git a/vim/syntax/vimcolor.vim b/vim/syntax/vimcolor.vim @@ -10,29 +10,38 @@ set cpo&vim syntax clear " Define highlighting groups -syntax keyword vimcolorKeyword background +syntax keyword vimcolorKeyword background light dark syntax keyword vimcolorNone NONE -syntax keyword vimcolorAttrs italic bold dark light -syntax match vimcolorGroup "[A-Z][^ ]*" +syntax keyword vimcolorAttrs italic bold +syntax match vimcolorGroup "^[A-Z][^ ]*" +syntax match vimcolorName "[ ,]\zs[^# ][^ ]*" syntax match vimcolorColor "#[0-9a-fA-F]\+" syntax match vimcolorDelims "[,.]" containedin=vimcolorLinkSource syntax match vimcolorLinkLine "^link .*$" contains=vimcolorLink,vimcolorLinkSource,vimcolorLinkDest syntax keyword vimcolorLink contained link syntax match vimcolorLinkSource "\(link \)\@<=[a-zA-Z,]\+" contained syntax match vimcolorLinkDest "[a-zA-Z]\+$" contained -syntax region vimcolorComment start=/^"/ end="$" +syntax region vimcolorComment start=/^ *"/ end="$" +syntax region vimcolorPalette start="^palette:" end="\." contains=vimcolorPaletteKeyword,vimcolorPaletteColorName,vimcolorPaletteColorVal,vimcolorComment +syntax match vimcolorPaletteColorName "^ *\zs[^ ]\+" contained +syntax match vimcolorPaletteColorVal "#[a-fA-F0-9]\+" contained +syntax keyword vimcolorPaletteKeyword palette contained " Perform the actual highlighting -hi def link vimcolorKeyword Keyword +hi def link vimcolorKeyword Include hi def link vimcolorGroup Statement hi def link vimcolorLinkSource Statement hi def link vimcolorColor Constant hi def link vimcolorNone Include hi def link vimcolorDelims Delimiter -hi def link vimcolorAttrs Type +hi def link vimcolorAttrs String hi def link vimcolorLink Operator hi def link vimcolorLinkDest Identifier hi def link vimcolorComment Comment +hi def link vimcolorPaletteColorName Number +hi def link vimcolorPaletteColorVal Constant +hi def link vimcolorPaletteKeyword Include +hi def link vimcolorName Number let b:current_syntax = "vimcolor" let &cpo = s:cpo_save diff --git a/vim/vimrc b/vim/vimrc @@ -373,6 +373,9 @@ let g:unicoder_cancel_visual = 1 nnoremap <C-l> :call unicoder#start(0)<CR> inoremap <C-l> <Esc>:call unicoder#start(1)<CR> " }}} +" colorizer {{{ +let g:colorizer_colornames = 0 +" }}} " }}} " }}} " General {{{ @@ -491,6 +494,8 @@ set wildmode=longest:list,full " Add everything to sessions set sessionoptions=buffers,curdir,folds,globals,localoptions,options,resize,tabpages + +set updatetime=100 " }}} " Editor {{{ " In general, don't want anything concealed