├── README.md ├── autoload ├── splatoon_color.vim ├── vital.vim └── vital │ ├── _splatoon_color.vim │ ├── _splatoon_color │ ├── Bitwise.vim │ ├── Random.vim │ └── Random │ │ └── Xor128.vim │ └── splatoon_color.vital ├── colors ├── splatoon-1on1.vim ├── splatoon-random.vim └── splatoon.vim └── splatoon.png /README.md: -------------------------------------------------------------------------------- 1 | ![vim-color-splatoon](splatoon.png) 2 | =================================== 3 | 4 | This is a Vim color scheme heavily inspired by [Splatoon](http://www.nintendo.co.jp/wiiu/agmj/). 5 | 6 | Colors are selected randomly on `:colorscheme`! This color scheme is now only for gVim. 7 | 8 | ## Usage 9 | 10 | Simply use `:colorscheme` 11 | 12 | ```vim 13 | colorscheme splatoon 14 | ``` 15 | 16 | ## Colorschemes 17 | 18 | ### `splatoon` color scheme 19 | 20 | Regular Splatoon color scheme. Uses preset Splatoon colors. 21 | 22 | ![regular](https://raw.githubusercontent.com/rhysd/ss/master/vim-color-splatoon/color-splatoon.gif) 23 | 24 | ### `splatoon-1on1` 25 | 26 | Only 2 colors are selected randomly from like battle in Splatoon. 27 | 28 | ![1-on-1](https://raw.githubusercontent.com/rhysd/ss/master/vim-color-splatoon/color-splatoon-1on1.gif) 29 | 30 | ### `splatoon-random` 31 | 32 | Generate random Splatoon-like colors. 33 | 34 | ![totally random](https://raw.githubusercontent.com/rhysd/ss/master/vim-color-splatoon/color-splatoon-random.gif) 35 | 36 | ## License 37 | 38 | Distributed under [the MIT license](http://opensource.org/licenses/MIT) except for [splatoon.png](splatoon.png). 39 | 40 | Copyright (c) 2015 rhysd 41 | 42 | -------------------------------------------------------------------------------- /autoload/splatoon_color.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | 3 | let s:save_cpo = &cpo 4 | set cpo&vim 5 | 6 | let s:Random = vital#of('splatoon_color').import('Random') 7 | 8 | " Preset Colors {{{ 9 | " オレンジ 10 | " オレンジ2 11 | " オレンジ(薄い) 12 | 13 | " 薄いピンク 14 | " ピンク 15 | " 濃いピンク 16 | 17 | " シアン 18 | " 薄いシアン 19 | 20 | " 黄色 21 | " 若干濃い黄色 22 | 23 | " 青 24 | " 濃い青 25 | " 濃い青2 26 | " 濃い水色 27 | 28 | " 黄緑 29 | " 濃い黄緑 30 | " 濃い黄緑(緑寄り) 31 | " 濃い黄緑(黄寄り) 32 | " 緑 33 | 34 | " うすい紫 35 | " 紫 36 | " 濃い紫 37 | 38 | " 赤 39 | 40 | let s:PRESET_COLORS = [ 41 | \ ["#ff8c27", "#ff8c27", "#ff9934"], 42 | \ ["#fd6495", "#fd2a95", "#fd2a95"], 43 | \ ["#00ffff", "#26e3dc"], 44 | \ ["#ffff00", "#fac800"], 45 | \ ["#3232ff", "#323296", "#3232c8", "#3fa9d9"], 46 | \ ["#aac800", "#7ac943", "#75d31e", "#c2e329", "#0bd67d"], 47 | \ ["#961e86", "#ad00bc", "#6400e6"], 48 | \ ["#c82828"], 49 | \ ] 50 | " }}} 51 | 52 | if !exists('s:rng') 53 | let s:rng = s:Random.new('Xor128') 54 | endif 55 | 56 | " random generator {{{ 57 | function! splatoon_color#get_random_generator() abort 58 | let gen = {"base" : s:rng.shuffle([0, 1, 2])} 59 | 60 | function! gen.generate_one() dict abort 61 | 62 | let colors = [0, 0, 0] 63 | let base = self.base[0] 64 | 65 | let i = base 66 | let colors[i] = s:rng.sample([255, 200, 180, 150]) 67 | 68 | let n = s:rng.range(2) 69 | let i = (base + n + 1) % 3 70 | let colors[i] = s:rng.sample([255, 200, 180, 150, 100, 50, 40]) 71 | 72 | let i = (base + 2 - n) % 3 73 | let colors[i] = s:rng.sample([60, 40, 30, 0]) 74 | 75 | unlet self.base[0] 76 | if len(self.base) ==# 0 77 | let self.base = s:rng.shuffle([0, 1, 2]) 78 | endif 79 | 80 | return '#' . join(map(colors, 'printf("%.2x", v:val)'), '') 81 | endfunction 82 | 83 | function! gen.gen_fg() dict abort 84 | return ["guifg=" . self.generate_one(), ""] 85 | endfunction 86 | 87 | function! gen.gen_bg() dict abort 88 | return ["", "guibg=" . self.generate_one()] 89 | endfunction 90 | 91 | function! gen.gen_pair() dict abort 92 | return ["guifg=" . self.generate_one(), "guibg=" . self.generate_one()] 93 | endfunction 94 | 95 | return gen 96 | endfunction 97 | " }}} 98 | 99 | " regular generator {{{ 100 | function! splatoon_color#get_regular_generator() abort 101 | let gen = { 102 | \ "colors" : s:rng.shuffle(deepcopy(s:PRESET_COLORS)), 103 | \ "idx" : 0, 104 | \ } 105 | 106 | function! gen.choose_one() dict abort 107 | let i = s:rng.range(len(self.colors)) 108 | let group = self.colors[i] 109 | let j = s:rng.range(len(group)) 110 | let color = group[j] 111 | unlet group[j] 112 | 113 | if len(group) == 0 114 | unlet self.colors[i] 115 | endif 116 | 117 | if len(self.colors) ==# 0 118 | let self.colors = s:rng.shuffle(deepcopy(s:PRESET_COLORS)) 119 | let self.idx = 0 120 | else 121 | let self.idx = (self.idx + 1) % len(self.colors) 122 | endif 123 | 124 | return color 125 | endfunction 126 | 127 | function! gen.gen_fg() dict abort 128 | return ["guifg=" . self.choose_one(), ""] 129 | endfunction 130 | 131 | function! gen.gen_bg() dict abort 132 | return ["", "guibg=" . self.choose_one()] 133 | endfunction 134 | 135 | function! gen.gen_pair() dict abort 136 | return ["guifg=" . self.choose_one(), "guibg=" . self.choose_one()] 137 | endfunction 138 | 139 | return gen 140 | endfunction 141 | " }}} 142 | 143 | " 1 on 1 color generator {{{ 144 | function! s:choose_color(arr) 145 | let i = s:rng.range(len(a:arr)) 146 | let group = a:arr[i] 147 | let len = len(group) 148 | if len == 1 149 | let color = group[0] 150 | else 151 | let color = group[s:rng.range(len)] 152 | endif 153 | return [color, i] 154 | endfunction 155 | 156 | function! splatoon_color#get_1_on_1_generator() abort 157 | let colors = deepcopy(s:PRESET_COLORS) 158 | 159 | let [first, i] = s:choose_color(colors) 160 | unlet colors[i] 161 | let [second, _] = s:choose_color(colors) 162 | 163 | let gen = {"pair" : [first, second]} 164 | 165 | function! gen.gen_fg() dict abort 166 | return ["guifg=" . self.pair[s:rng.range(2)], ""] 167 | endfunction 168 | 169 | function! gen.gen_bg() dict abort 170 | return ["", "guibg=" . self.pair[s:rng.range(2)]] 171 | endfunction 172 | 173 | function! gen.gen_pair() dict abort 174 | let n = s:rng.range(2) 175 | return ["guifg=" . self.pair[n], "guibg=" . self.pair[xor(n, 1)]] 176 | endfunction 177 | 178 | return gen 179 | endfunction 180 | " }}} 181 | 182 | " {{{colorize() 183 | function! s:hi(group, colors, ...) abort 184 | if a:0 == 1 185 | execute 'hi' a:group a:colors[0] a:colors[1] "gui=" . a:1 186 | else 187 | execute 'hi' a:group a:colors[0] a:colors[1] 188 | endif 189 | endfunction 190 | 191 | function! splatoon_color#colorize(generator_name) abort 192 | if !has('gui_running') 193 | echohl ErrorMsg | echomsg "'splatoon' colorscheme is only for gVim!" | echohl None 194 | endif 195 | 196 | let g = splatoon_color#get_{a:generator_name}_generator() 197 | 198 | call s:hi("Bold" , ["", ""], "bold") 199 | call s:hi("Debug" , g.gen_fg()) 200 | call s:hi("Directory" , g.gen_fg()) 201 | call s:hi("ErrorMsg" , g.gen_pair()) 202 | call s:hi("Exception" , g.gen_fg()) 203 | call s:hi("FoldColumn" , g.gen_fg()) 204 | call s:hi("Folded" , g.gen_pair()) 205 | call s:hi("IncSearch" , g.gen_pair(), "none") 206 | call s:hi("Italic" , ["", ""], "none") 207 | call s:hi("Macro" , g.gen_fg()) 208 | call s:hi("MatchParen" , g.gen_pair()) 209 | call s:hi("ModeMsg" , g.gen_fg()) 210 | call s:hi("MoreMsg" , g.gen_fg()) 211 | call s:hi("Question" , g.gen_fg()) 212 | call s:hi("Search" , g.gen_pair()) 213 | call s:hi("SpecialKey" , g.gen_fg()) 214 | call s:hi("TooLong" , g.gen_fg()) 215 | call s:hi("Underlined" , g.gen_fg()) 216 | call s:hi("Visual" , g.gen_bg()) 217 | call s:hi("VisualNOS" , g.gen_fg()) 218 | call s:hi("WarningMsg" , g.gen_fg()) 219 | call s:hi("WildMenu" , g.gen_fg()) 220 | call s:hi("Title" , g.gen_fg(), "none") 221 | call s:hi("Conceal" , g.gen_fg()) 222 | call s:hi("Cursor" , g.gen_bg()) 223 | call s:hi("NonText" , g.gen_fg()) 224 | call s:hi("Normal" , ["guifg=#e0e0e0", "guibg=#303030"]) 225 | call s:hi("LineNr" , g.gen_fg()) 226 | call s:hi("SignColumn" , g.gen_pair()) 227 | call s:hi("SpecialKey" , g.gen_fg()) 228 | call s:hi("StatusLine" , g.gen_pair(), "none") 229 | call s:hi("StatusLineNC" , g.gen_pair(), "none") 230 | call s:hi("VertSplit" , g.gen_pair(), "none") 231 | call s:hi("ColorColumn" , g.gen_bg(), "none") 232 | call s:hi("CursorColumn" , g.gen_bg(), "none") 233 | call s:hi("CursorLine" , g.gen_bg(), "none") 234 | call s:hi("CursorLineNr" , g.gen_pair()) 235 | call s:hi("PMenu" , g.gen_bg(), "none") 236 | call s:hi("PMenuSel" , g.gen_fg()) 237 | call s:hi("TabLine" , g.gen_pair(), "none") 238 | call s:hi("TabLineFill" , g.gen_pair(), "none") 239 | call s:hi("TabLineSel" , g.gen_pair(), "none") 240 | 241 | " Standard syntax highlighting 242 | call s:hi("Boolean" , g.gen_fg()) 243 | call s:hi("Character" , g.gen_fg()) 244 | call s:hi("Comment" , g.gen_fg()) 245 | call s:hi("Conditional" , g.gen_fg()) 246 | call s:hi("Constant" , g.gen_fg()) 247 | call s:hi("Define" , g.gen_fg(), "none") 248 | call s:hi("Delimiter" , g.gen_fg()) 249 | call s:hi("Float" , g.gen_fg()) 250 | call s:hi("Function" , g.gen_fg()) 251 | call s:hi("Identifier" , g.gen_fg(), "none") 252 | call s:hi("Include" , g.gen_fg()) 253 | call s:hi("Keyword" , g.gen_fg()) 254 | call s:hi("Label" , g.gen_fg()) 255 | call s:hi("Number" , g.gen_fg()) 256 | call s:hi("Operator" , g.gen_fg(), "none") 257 | call s:hi("PreProc" , g.gen_fg()) 258 | call s:hi("Repeat" , g.gen_fg()) 259 | call s:hi("Special" , g.gen_fg()) 260 | call s:hi("SpecialChar" , g.gen_fg()) 261 | call s:hi("Statement" , g.gen_fg()) 262 | call s:hi("StorageClass" , g.gen_fg()) 263 | call s:hi("String" , g.gen_fg()) 264 | call s:hi("Structure" , g.gen_fg()) 265 | call s:hi("Tag" , g.gen_fg()) 266 | call s:hi("Todo" , g.gen_pair()) 267 | call s:hi("Type" , g.gen_fg(), "none") 268 | call s:hi("Typedef" , g.gen_fg()) 269 | 270 | " Spelling highlighting 271 | call s:hi("SpellBad" , g.gen_bg(), "undercurl") 272 | call s:hi("SpellLocal" , g.gen_bg(), "undercurl") 273 | call s:hi("SpellCap" , g.gen_bg(), "undercurl") 274 | call s:hi("SpellRare" , g.gen_bg(), "undercurl") 275 | 276 | endfunction 277 | " }}} 278 | 279 | let &cpo = s:save_cpo 280 | unlet s:save_cpo 281 | -------------------------------------------------------------------------------- /autoload/vital.vim: -------------------------------------------------------------------------------- 1 | function! vital#of(name) abort 2 | let files = globpath(&runtimepath, 'autoload/vital/' . a:name . '.vital') 3 | let file = split(files, "\n") 4 | if empty(file) 5 | throw 'vital: version file not found: ' . a:name 6 | endif 7 | let ver = readfile(file[0], 'b') 8 | if empty(ver) 9 | throw 'vital: invalid version file: ' . a:name 10 | endif 11 | return vital#_{substitute(ver[0], '\W', '', 'g')}#new() 12 | endfunction 13 | -------------------------------------------------------------------------------- /autoload/vital/_splatoon_color.vim: -------------------------------------------------------------------------------- 1 | let s:self_version = expand(':t:r') 2 | let s:self_file = expand('') 3 | 4 | " Note: The extra argument to globpath() was added in Patch 7.2.051. 5 | let s:globpath_third_arg = v:version > 702 || v:version == 702 && has('patch51') 6 | 7 | let s:loaded = {} 8 | let s:cache_module_path = {} 9 | let s:cache_sid = {} 10 | 11 | let s:_vital_files_cache_runtimepath = '' 12 | let s:_vital_files_cache = [] 13 | let s:_unify_path_cache = {} 14 | 15 | function! s:import(name, ...) abort 16 | let target = {} 17 | let functions = [] 18 | for a in a:000 19 | if type(a) == type({}) 20 | let target = a 21 | elseif type(a) == type([]) 22 | let functions = a 23 | endif 24 | unlet a 25 | endfor 26 | let module = s:_import(a:name) 27 | if empty(functions) 28 | call extend(target, module, 'keep') 29 | else 30 | for f in functions 31 | if has_key(module, f) && !has_key(target, f) 32 | let target[f] = module[f] 33 | endif 34 | endfor 35 | endif 36 | return target 37 | endfunction 38 | 39 | function! s:load(...) dict abort 40 | for arg in a:000 41 | let [name; as] = type(arg) == type([]) ? arg[: 1] : [arg, arg] 42 | let target = split(join(as, ''), '\W\+') 43 | let dict = self 44 | let dict_type = type({}) 45 | while !empty(target) 46 | let ns = remove(target, 0) 47 | if !has_key(dict, ns) 48 | let dict[ns] = {} 49 | endif 50 | if type(dict[ns]) == dict_type 51 | let dict = dict[ns] 52 | else 53 | unlet dict 54 | break 55 | endif 56 | endwhile 57 | 58 | if exists('dict') 59 | call extend(dict, s:_import(name)) 60 | endif 61 | unlet arg 62 | endfor 63 | return self 64 | endfunction 65 | 66 | function! s:unload() abort 67 | let s:loaded = {} 68 | let s:cache_sid = {} 69 | let s:cache_module_path = {} 70 | endfunction 71 | 72 | function! s:exists(name) abort 73 | return s:_get_module_path(a:name) !=# '' 74 | endfunction 75 | 76 | function! s:search(pattern) abort 77 | let paths = s:_vital_files(a:pattern) 78 | let modules = sort(map(paths, 's:_file2module(v:val)')) 79 | return s:_uniq(modules) 80 | endfunction 81 | 82 | function! s:expand_modules(entry, all) abort 83 | if type(a:entry) == type([]) 84 | let candidates = s:_concat(map(copy(a:entry), 's:search(v:val)')) 85 | if empty(candidates) 86 | throw printf('vital: Any of module %s is not found', string(a:entry)) 87 | endif 88 | if eval(join(map(copy(candidates), 'has_key(a:all, v:val)'), '+')) 89 | let modules = [] 90 | else 91 | let modules = [candidates[0]] 92 | endif 93 | else 94 | let modules = s:search(a:entry) 95 | if empty(modules) 96 | throw printf('vital: Module %s is not found', a:entry) 97 | endif 98 | endif 99 | call filter(modules, '!has_key(a:all, v:val)') 100 | for module in modules 101 | let a:all[module] = 1 102 | endfor 103 | return modules 104 | endfunction 105 | 106 | function! s:_import(name) abort 107 | if type(a:name) == type(0) 108 | return s:_build_module(a:name) 109 | endif 110 | let path = s:_get_module_path(a:name) 111 | if path ==# '' 112 | throw 'vital: module not found: ' . a:name 113 | endif 114 | let sid = s:_get_sid_by_script(path) 115 | if !sid 116 | try 117 | execute 'source' fnameescape(path) 118 | catch /^Vim\%((\a\+)\)\?:E484/ 119 | throw 'vital: module not found: ' . a:name 120 | catch /^Vim\%((\a\+)\)\?:E127/ 121 | " Ignore. 122 | endtry 123 | 124 | let sid = s:_get_sid_by_script(path) 125 | endif 126 | return s:_build_module(sid) 127 | endfunction 128 | 129 | function! s:_get_module_path(name) abort 130 | let key = a:name . '_' 131 | if has_key(s:cache_module_path, key) 132 | return s:cache_module_path[key] 133 | endif 134 | if s:_is_absolute_path(a:name) && filereadable(a:name) 135 | return a:name 136 | endif 137 | if a:name ==# '' 138 | let paths = [s:self_file] 139 | elseif a:name =~# '\v^\u\w*%(\.\u\w*)*$' 140 | let paths = s:_vital_files(a:name) 141 | else 142 | throw 'vital: Invalid module name: ' . a:name 143 | endif 144 | 145 | call filter(paths, 'filereadable(expand(v:val, 1))') 146 | let path = get(paths, 0, '') 147 | let s:cache_module_path[key] = path 148 | return path 149 | endfunction 150 | 151 | function! s:_get_sid_by_script(path) abort 152 | if has_key(s:cache_sid, a:path) 153 | return s:cache_sid[a:path] 154 | endif 155 | 156 | let path = s:_unify_path(a:path) 157 | for line in filter(split(s:_redir('scriptnames'), "\n"), 158 | \ 'stridx(v:val, s:self_version) > 0') 159 | let list = matchlist(line, '^\s*\(\d\+\):\s\+\(.\+\)\s*$') 160 | if !empty(list) && s:_unify_path(list[2]) ==# path 161 | let s:cache_sid[a:path] = list[1] - 0 162 | return s:cache_sid[a:path] 163 | endif 164 | endfor 165 | return 0 166 | endfunction 167 | 168 | function! s:_file2module(file) abort 169 | let filename = fnamemodify(a:file, ':p:gs?[\\/]?/?') 170 | let tail = matchstr(filename, 'autoload/vital/_\w\+/\zs.*\ze\.vim$') 171 | return join(split(tail, '[\\/]\+'), '.') 172 | endfunction 173 | 174 | if filereadable(expand(':r') . '.VIM') 175 | " resolve() is slow, so we cache results. 176 | " Note: On windows, vim can't expand path names from 8.3 formats. 177 | " So if getting full path via and $HOME was set as 8.3 format, 178 | " vital load duplicated scripts. Below's :~ avoid this issue. 179 | function! s:_unify_path(path) abort 180 | if has_key(s:_unify_path_cache, a:path) 181 | return s:_unify_path_cache[a:path] 182 | endif 183 | let value = tolower(fnamemodify(resolve(fnamemodify( 184 | \ a:path, ':p')), ':~:gs?[\\/]?/?')) 185 | let s:_unify_path_cache[a:path] = value 186 | return value 187 | endfunction 188 | else 189 | function! s:_unify_path(path) abort 190 | return resolve(fnamemodify(a:path, ':p:gs?[\\/]?/?')) 191 | endfunction 192 | endif 193 | 194 | if s:globpath_third_arg 195 | function! s:_runtime_files(path) abort 196 | return split(globpath(&runtimepath, a:path, 1), "\n") 197 | endfunction 198 | else 199 | function! s:_runtime_files(path) abort 200 | return split(globpath(&runtimepath, a:path), "\n") 201 | endfunction 202 | endif 203 | 204 | function! s:_vital_files(pattern) abort 205 | if s:_vital_files_cache_runtimepath !=# &runtimepath 206 | let path = printf('autoload/vital/%s/**/*.vim', s:self_version) 207 | let s:_vital_files_cache = s:_runtime_files(path) 208 | let mod = ':p:gs?[\\/]\+?/?' 209 | call map(s:_vital_files_cache, 'fnamemodify(v:val, mod)') 210 | let s:_vital_files_cache_runtimepath = &runtimepath 211 | endif 212 | let target = substitute(a:pattern, '\.', '/', 'g') 213 | let target = substitute(target, '\*', '[^/]*', 'g') 214 | let regexp = printf('autoload/vital/%s/%s.vim', s:self_version, target) 215 | return filter(copy(s:_vital_files_cache), 'v:val =~# regexp') 216 | endfunction 217 | 218 | " Copy from System.Filepath 219 | if has('win16') || has('win32') || has('win64') 220 | function! s:_is_absolute_path(path) abort 221 | return a:path =~? '^[a-z]:[/\\]' 222 | endfunction 223 | else 224 | function! s:_is_absolute_path(path) abort 225 | return a:path[0] ==# '/' 226 | endfunction 227 | endif 228 | 229 | function! s:_build_module(sid) abort 230 | if has_key(s:loaded, a:sid) 231 | return copy(s:loaded[a:sid]) 232 | endif 233 | let functions = s:_get_functions(a:sid) 234 | 235 | let prefix = '' . a:sid . '_' 236 | let module = {} 237 | for func in functions 238 | let module[func] = function(prefix . func) 239 | endfor 240 | if has_key(module, '_vital_loaded') 241 | let V = vital#{s:self_version}#new() 242 | if has_key(module, '_vital_depends') 243 | let all = {} 244 | let modules = 245 | \ s:_concat(map(module._vital_depends(), 246 | \ 's:expand_modules(v:val, all)')) 247 | call call(V.load, modules, V) 248 | endif 249 | try 250 | call module._vital_loaded(V) 251 | catch 252 | " FIXME: Show an error message for debug. 253 | endtry 254 | endif 255 | if !get(g:, 'vital_debug', 0) 256 | call filter(module, 'v:key =~# "^\\a"') 257 | endif 258 | let s:loaded[a:sid] = module 259 | return copy(module) 260 | endfunction 261 | 262 | if exists('+regexpengine') 263 | function! s:_get_functions(sid) abort 264 | let funcs = s:_redir(printf("function /\\%%#=2^\%d_", a:sid)) 265 | let map_pat = '' . a:sid . '_\zs\w\+' 266 | return map(split(funcs, "\n"), 'matchstr(v:val, map_pat)') 267 | endfunction 268 | else 269 | function! s:_get_functions(sid) abort 270 | let prefix = '' . a:sid . '_' 271 | let funcs = s:_redir('function') 272 | let filter_pat = '^\s*function ' . prefix 273 | let map_pat = prefix . '\zs\w\+' 274 | return map(filter(split(funcs, "\n"), 275 | \ 'stridx(v:val, prefix) > 0 && v:val =~# filter_pat'), 276 | \ 'matchstr(v:val, map_pat)') 277 | endfunction 278 | endif 279 | 280 | if exists('*uniq') 281 | function! s:_uniq(list) abort 282 | return uniq(a:list) 283 | endfunction 284 | else 285 | function! s:_uniq(list) abort 286 | let i = len(a:list) - 1 287 | while 0 < i 288 | if a:list[i] ==# a:list[i - 1] 289 | call remove(a:list, i) 290 | let i -= 2 291 | else 292 | let i -= 1 293 | endif 294 | endwhile 295 | return a:list 296 | endfunction 297 | endif 298 | 299 | function! s:_concat(lists) abort 300 | let result_list = [] 301 | for list in a:lists 302 | let result_list += list 303 | endfor 304 | return result_list 305 | endfunction 306 | 307 | function! s:_redir(cmd) abort 308 | let [save_verbose, save_verbosefile] = [&verbose, &verbosefile] 309 | set verbose=0 verbosefile= 310 | redir => res 311 | silent! execute a:cmd 312 | redir END 313 | let [&verbose, &verbosefile] = [save_verbose, save_verbosefile] 314 | return res 315 | endfunction 316 | 317 | function! vital#{s:self_version}#new() abort 318 | return s:_import('') 319 | endfunction 320 | -------------------------------------------------------------------------------- /autoload/vital/_splatoon_color/Bitwise.vim: -------------------------------------------------------------------------------- 1 | " bitwise operators 2 | " moved from github.com/ynkdir/vim-funlib 3 | 4 | let s:save_cpo = &cpo 5 | set cpo&vim 6 | 7 | " compare as unsigned int 8 | function! s:compare(a, b) abort 9 | if (a:a >= 0 && a:b >= 0) || (a:a < 0 && a:b < 0) 10 | return a:a < a:b ? -1 : a:a > a:b ? 1 : 0 11 | else 12 | return a:a < 0 ? 1 : -1 13 | endif 14 | endfunction 15 | 16 | function! s:lshift(a, n) abort 17 | return a:a * s:pow2[s:and(a:n, 0x1F)] 18 | endfunction 19 | 20 | function! s:rshift(a, n) abort 21 | let n = s:and(a:n, 0x1F) 22 | return n == 0 ? a:a : 23 | \ a:a < 0 ? (a:a - 0x80000000) / s:pow2[n] + 0x40000000 / s:pow2[n - 1] 24 | \ : a:a / s:pow2[n] 25 | endfunction 26 | 27 | let s:pow2 = [ 28 | \ 0x1, 0x2, 0x4, 0x8, 29 | \ 0x10, 0x20, 0x40, 0x80, 30 | \ 0x100, 0x200, 0x400, 0x800, 31 | \ 0x1000, 0x2000, 0x4000, 0x8000, 32 | \ 0x10000, 0x20000, 0x40000, 0x80000, 33 | \ 0x100000, 0x200000, 0x400000, 0x800000, 34 | \ 0x1000000, 0x2000000, 0x4000000, 0x8000000, 35 | \ 0x10000000, 0x20000000, 0x40000000, 0x80000000, 36 | \ ] 37 | 38 | if exists('*and') 39 | function! s:_vital_loaded(V) dict abort 40 | for op in ['and', 'or', 'xor', 'invert'] 41 | let self[op] = function(op) 42 | let s:[op] = self[op] 43 | endfor 44 | endfunction 45 | finish 46 | endif 47 | 48 | 49 | function! s:invert(a) abort 50 | return -a:a - 1 51 | endfunction 52 | 53 | function! s:and(a, b) abort 54 | let a = a:a < 0 ? a:a - 0x80000000 : a:a 55 | let b = a:b < 0 ? a:b - 0x80000000 : a:b 56 | let r = 0 57 | let n = 1 58 | while a && b 59 | let r += s:and[a % 0x10][b % 0x10] * n 60 | let a = a / 0x10 61 | let b = b / 0x10 62 | let n = n * 0x10 63 | endwhile 64 | if (a:a < 0) && (a:b < 0) 65 | let r += 0x80000000 66 | endif 67 | return r 68 | endfunction 69 | 70 | function! s:or(a, b) abort 71 | let a = a:a < 0 ? a:a - 0x80000000 : a:a 72 | let b = a:b < 0 ? a:b - 0x80000000 : a:b 73 | let r = 0 74 | let n = 1 75 | while a || b 76 | let r += s:or[a % 0x10][b % 0x10] * n 77 | let a = a / 0x10 78 | let b = b / 0x10 79 | let n = n * 0x10 80 | endwhile 81 | if (a:a < 0) || (a:b < 0) 82 | let r += 0x80000000 83 | endif 84 | return r 85 | endfunction 86 | 87 | function! s:xor(a, b) abort 88 | let a = a:a < 0 ? a:a - 0x80000000 : a:a 89 | let b = a:b < 0 ? a:b - 0x80000000 : a:b 90 | let r = 0 91 | let n = 1 92 | while a || b 93 | let r += s:xor[a % 0x10][b % 0x10] * n 94 | let a = a / 0x10 95 | let b = b / 0x10 96 | let n = n * 0x10 97 | endwhile 98 | if (a:a < 0) != (a:b < 0) 99 | let r += 0x80000000 100 | endif 101 | return r 102 | endfunction 103 | 104 | let s:and = [ 105 | \ [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0], 106 | \ [0x0, 0x1, 0x0, 0x1, 0x0, 0x1, 0x0, 0x1,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im:set et ts=2 sts=2 sw=2 tw=0: 165 | -------------------------------------------------------------------------------- /autoload/vital/_splatoon_color/Random.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpo 2 | set cpo&vim 3 | 4 | function! s:_vital_loaded(V) abort 5 | let s:V = a:V 6 | let s:Bitwise = s:V.import('Bitwise') 7 | endfunction 8 | 9 | function! s:_vital_depends() abort 10 | return [['Random.*'], 'Bitwise'] 11 | endfunction 12 | 13 | let s:loaded_generator_modules = {} 14 | 15 | let s:Random = {} 16 | 17 | function! s:Random.next(...) abort 18 | if a:0 19 | return map(range(a:1), 'self._generator.next()') 20 | endif 21 | return self._generator.next() 22 | endfunction 23 | 24 | function! s:Random.seed(seed) abort 25 | let seed = type(a:seed) == type([]) ? a:seed : [a:seed] 26 | return self._generator.seed(seed) 27 | endfunction 28 | 29 | function! s:Random.generate_canonical() abort 30 | let b = 32 31 | let min = self._generator.min() + 0.0 32 | let r = (self._generator.max() + 0.0) - min + 1.0 33 | let log2r = float2nr(log(r) / log(2.0)) 34 | let k = max([1, (b + log2r - 1) / log2r]) 35 | let sum = 0.0 36 | let tmp = 1.0 37 | while k != 0 38 | let sum += (self._generator.next() - min) * tmp 39 | let tmp = tmp * r 40 | let k -= 1 41 | endwhile 42 | return sum / tmp 43 | endfunction 44 | 45 | function! s:Random.range(from, ...) abort 46 | let [from, to] = a:0 ? [a:from, a:1] : [0, a:from] 47 | let range = to - from 48 | let base = self.generate_canonical() * range 49 | return (type(range) == type(0.0) ? base : float2nr(base)) + from 50 | endfunction 51 | 52 | function! s:Random.bool() abort 53 | return self.range(2) 54 | endfunction 55 | 56 | function! s:Random.sample(list, ...) abort 57 | if a:0 == 0 58 | return a:list[self.range(len(a:list))] 59 | endif 60 | let list = copy(a:list) 61 | let result = [] 62 | for _ in range(a:1) 63 | let result += [remove(list, self.range(len(list)))] 64 | endfor 65 | return result 66 | endfunction 67 | 68 | function! s:Random.shuffle(list) abort 69 | let pos = len(a:list) 70 | while 1 < pos 71 | let n = self.range(pos) 72 | let pos -= 1 73 | if n != pos 74 | let temp = a:list[n] 75 | let a:list[n] = a:list[pos] 76 | let a:list[pos] = temp 77 | endif 78 | endwhile 79 | return a:list 80 | endfunction 81 | 82 | 83 | function! s:make_seed() abort 84 | let seed = localtime() 85 | if has('reltime') 86 | let time = split(reltimestr(reltime()), '\.') 87 | for n in time 88 | let seed = s:Bitwise.xor(seed, str2nr(n)) 89 | endfor 90 | endif 91 | if exists('*getpid') 92 | let seed = s:Bitwise.xor(seed, getpid()) 93 | endif 94 | let seed = s:_seed_from_string(seed, expand('~')) 95 | return seed 96 | endfunction 97 | 98 | function! s:_seed_from_string(seed, str) abort 99 | let seed = a:seed 100 | for n in range(len(a:str)) 101 | let seed = s:Bitwise.xor(seed, s:Bitwise.lshift(a:str[n], n % 4)) 102 | endfor 103 | return seed 104 | endfunction 105 | 106 | function! s:new(...) abort 107 | let generator = a:0 ? a:1 : '' 108 | let seed = 2 <= a:0 ? a:2 : s:next() 109 | let random = deepcopy(s:Random) 110 | let random._generator = s:_get_generator(generator) 111 | call random.seed(seed) 112 | return random 113 | endfunction 114 | 115 | function! s:_get_generator(arg) abort 116 | let arg = 117 | \ empty(a:arg) 118 | \ ? matchstr(get(s:V.search('Random.*'), 0, ''), 'Random\.\zs.*$') 119 | \ : a:arg 120 | if type(arg) == type('') 121 | if !has_key(s:loaded_generator_modules, arg) 122 | let module_name = 'Random.' . arg 123 | if !s:V.exists(module_name) 124 | throw printf('vital: Random: the generator "%s" does not exist.', arg) 125 | endif 126 | let module = s:V.import(module_name) 127 | let s:loaded_generator_modules[arg] = module 128 | endif 129 | let gen = s:loaded_generator_modules[arg].new_generator() 130 | return gen 131 | endif 132 | if type(arg) == type({}) 133 | return arg 134 | endif 135 | throw printf('vital: Random: Invalid generator: %s', string(a:arg)) 136 | endfunction 137 | 138 | function! s:_common() abort 139 | if !exists('s:common_random') 140 | let s:common_random = s:new('', s:make_seed()) 141 | endif 142 | return s:common_random 143 | endfunction 144 | let s:func_type = type(function('type')) 145 | for s:func in keys(filter(copy(s:Random), 'type(v:val) == s:func_type')) 146 | execute join([ 147 | \ 'function! s:' . s:func . '(...) abort', 148 | \ ' let r = s:_common()', 149 | \ ' return call(r.' . s:func . ', a:000, r)', 150 | \ 'endfunction', 151 | \ ], "\n") 152 | endfor 153 | 154 | let &cpo = s:save_cpo 155 | unlet s:save_cpo 156 | -------------------------------------------------------------------------------- /autoload/vital/_splatoon_color/Random/Xor128.vim: -------------------------------------------------------------------------------- 1 | " random number generator using xorshift128 2 | " http://www.jstatsoft.org/v08/i14/paper 3 | 4 | let s:save_cpo = &cpo 5 | set cpo&vim 6 | 7 | 8 | function! s:_vital_loaded(V) abort 9 | let s:B = a:V.import('Bitwise') 10 | endfunction 11 | 12 | function! s:_vital_depends() abort 13 | return ['Bitwise'] 14 | endfunction 15 | 16 | 17 | let s:Generator = {} 18 | 19 | function! s:Generator.next() abort 20 | let t = s:B.xor(self._x, s:B.lshift(self._x, 11)) 21 | let w = self._w 22 | let self._x = self._y 23 | let self._y = self._z 24 | let self._z = self._w 25 | let self._w = s:B.xor(s:B.xor(w, s:B.rshift(w, 19)), s:B.xor(t, s:B.rshift(t, 8))) 26 | return self._w 27 | endfunction 28 | 29 | function! s:Generator.min() abort 30 | return 0x80000000 31 | endfunction 32 | 33 | function! s:Generator.max() abort 34 | return 0x7FFFFFFF 35 | endfunction 36 | 37 | function! s:Generator.seed(seeds) abort 38 | if 4 < len(a:seeds) 39 | throw 'vital: Random.Xor128: too many seed parameters' 40 | endif 41 | let [self._x, self._y, self._z, self._w] = 42 | \ a:seeds + [123456789, 362436069, 521288629, 88675123][len(a:seeds) :] 43 | endfunction 44 | 45 | function! s:new_generator() abort 46 | let gen = deepcopy(s:Generator) 47 | call gen.seed([]) 48 | return gen 49 | endfunction 50 | 51 | 52 | let s:common_generator = s:new_generator() 53 | function! s:srand(...) abort 54 | if a:0 == 0 55 | let x = has('reltime') ? reltime()[1] : localtime() 56 | elseif a:0 == 1 57 | let x = a:1 58 | else 59 | throw 'vital: Random.Xor128.srand(): too many arguments' 60 | endif 61 | call s:common_generator.seed([x]) 62 | endfunction 63 | 64 | function! s:rand() abort 65 | return s:common_generator.next() 66 | endfunction 67 | 68 | 69 | let &cpo = s:save_cpo 70 | unlet s:save_cpo 71 | 72 | " vim:set et ts=2 sts=2 sw=2 tw=0: 73 | -------------------------------------------------------------------------------- /autoload/vital/splatoon_color.vital: -------------------------------------------------------------------------------- 1 | splatoon_color 2 | 1dbb388 3 | 4 | Random 5 | Random.Xor128 6 | -------------------------------------------------------------------------------- /colors/splatoon-1on1.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpo 2 | set cpo&vim 3 | 4 | hi clear 5 | syntax reset 6 | set bg=dark 7 | let g:colors_name = "splatoon-1on1" 8 | call splatoon_color#colorize('1_on_1') 9 | 10 | let &cpo = s:save_cpo 11 | unlet s:save_cpo 12 | -------------------------------------------------------------------------------- /colors/splatoon-random.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpo 2 | set cpo&vim 3 | 4 | hi clear 5 | syntax reset 6 | set bg=dark 7 | let g:colors_name = "splatoon-random" 8 | call splatoon_color#colorize('random') 9 | 10 | let &cpo = s:save_cpo 11 | unlet s:save_cpo 12 | -------------------------------------------------------------------------------- /colors/splatoon.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpo 2 | set cpo&vim 3 | 4 | hi clear 5 | syntax reset 6 | set bg=dark 7 | let g:colors_name = "splatoon" 8 | call splatoon_color#colorize('regular') 9 | 10 | let &cpo = s:save_cpo 11 | unlet s:save_cpo 12 | -------------------------------------------------------------------------------- /splatoon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhysd/vim-color-splatoon/0eb784254a7db93c0cc3404336635b5283916029/splatoon.png --------------------------------------------------------------------------------