├── autoload └── splash.vim ├── doc └── splash.txt ├── plugin └── splash.vim └── sample └── vimgirl.txt /autoload/splash.vim: -------------------------------------------------------------------------------- 1 | " Changes the splash of Vim as you like. 2 | " Version: 1.1 3 | " Author : thinca 4 | " License: zlib License 5 | 6 | let s:save_cpo = &cpo 7 | set cpo&vim 8 | 9 | function! splash#intro() 10 | if argc() == 0 && bufnr('$') == 1 && filereadable(g:splash#path) 11 | call splash#show(g:splash#path) 12 | endif 13 | endfunction 14 | 15 | function! splash#command(file) 16 | let file = empty(a:file) ? g:splash#path : a:file 17 | try 18 | call splash#show(file) 19 | catch /^splash:/ 20 | echohl ErrorMsg 21 | echomsg v:exception 22 | echohl None 23 | endtry 24 | endfunction 25 | 26 | function! splash#show(file) 27 | if type(a:file) == type('') 28 | if !filereadable(a:file) 29 | throw 'splash: Can not read file: ' . a:file 30 | endif 31 | let content = map(readfile(a:file), 'iconv(v:val, "utf-8", &encoding)') 32 | elseif type(a:file) == type([]) 33 | let content = a:file 34 | else 35 | throw 'splash: Invalid argument: ' . string(a:file) 36 | endif 37 | call s:clear_cmdline() 38 | let restore_command = s:open_new_buffer() 39 | call s:draw(content) 40 | redraw 41 | let char = s:getchar() 42 | silent execute restore_command 43 | call feedkeys(char) 44 | endfunction 45 | 46 | function! s:clear_cmdline() 47 | echon '' 48 | endfunction 49 | 50 | function! s:open_new_buffer() 51 | let foldenable = &l:foldenable 52 | let bufnr = bufnr('%') 53 | hide enew 54 | setlocal buftype=nofile nowrap nolist nonumber bufhidden=wipe 55 | setlocal nofoldenable 56 | let restore_command = bufnr == bufnr('%') ? 'enew' : bufnr . ' buffer' 57 | let restore_command .= ' | let &l:foldenable = ' . foldenable 58 | return restore_command 59 | endfunction 60 | 61 | function! s:getchar() 62 | let char = getchar() 63 | return type(char) == type(0) ? nr2char(char) : char 64 | endfunction 65 | 66 | function! s:draw(content) 67 | let screen_width = winwidth(0) 68 | let screen_height = winheight(0) 69 | let content_height = len(a:content) 70 | let padding_lines = repeat([''], screen_height - content_height - 1) 71 | silent put =padding_lines 72 | call cursor((screen_height - content_height) / 2, 1) 73 | silent put =s:block_centerize(a:content, screen_width) 74 | 1 75 | endfunction 76 | 77 | function! s:height_middlize(max_height, body_height) 78 | return (a:max_height - a:body_height) / 2 79 | endfunction 80 | 81 | function! s:block_centerize(lines, width) 82 | let left = s:centerize_padding(a:width, s:block_width(a:lines)) 83 | return map(a:lines, 'left . v:val') 84 | endfunction 85 | 86 | function! s:centerize_padding(max_width, body_width) 87 | return repeat(' ', (a:max_width - a:body_width) / 2) 88 | endfunction 89 | 90 | function! s:block_width(lines) 91 | return max(map(copy(a:lines), 'strwidth(v:val)')) 92 | endfunction 93 | 94 | 95 | if !exists('g:splash#path') 96 | let g:splash#path = expand(':h:h') . '/sample/vimgirl.txt' 97 | endif 98 | 99 | let &cpo = s:save_cpo 100 | unlet s:save_cpo 101 | -------------------------------------------------------------------------------- /doc/splash.txt: -------------------------------------------------------------------------------- 1 | *splash.txt* Changes the splash of Vim as you like. 2 | 3 | Version: 1.1 4 | Author : thinca 5 | License: zlib License 6 | 7 | ============================================================================== 8 | CONTENTS *splash-contents* 9 | 10 | INTRODUCTION |splash-introduction| 11 | INTERFACE |splash-interface| 12 | COMMANDS |splash-commands| 13 | FUNCTIONS |splash-functions| 14 | CUSTOMIZING |splash-customizing| 15 | SPECIAL THANKS |splash-special-thanks| 16 | CHANGELOG |splash-changelog| 17 | 18 | 19 | 20 | ============================================================================== 21 | INTRODUCTION *splash-introduction* 22 | 23 | *splash* is a Vim plugin to change the splash of Vim instead of |:intro|. 24 | 25 | Requirements: 26 | - Vim 7.3 or later 27 | 28 | Latest version: 29 | https://github.com/thinca/vim-splash 30 | 31 | 32 | 33 | ============================================================================== 34 | INTERFACE *splash-interface* 35 | 36 | ------------------------------------------------------------------------------ 37 | COMMANDS *splash-commands* 38 | 39 | :Splash [file] *:Splash* 40 | Shows the splash into the current window. [file] is a filename. 41 | If [file] is omitted, |g:splash#path| is used. 42 | 43 | 44 | ------------------------------------------------------------------------------ 45 | FUNCTIONS *splash-functions* 46 | 47 | splash#show({file}) *splash#show()* 48 | splash#show({lines}) 49 | Shows the splash into the current window. 50 | {file} is a filename. 51 | {lines} is a |List| of string. This is treated as content directly. 52 | 53 | 54 | 55 | ============================================================================== 56 | CUSTOMIZING *splash-customizing* 57 | 58 | g:splash#path *g:splash#path* 59 | The default splash file. 60 | Splash file must be written by utf-8. 61 | 62 | 63 | 64 | ============================================================================== 65 | SPECIAL THANKS *splash-special-thanks* 66 | 67 | A sample file "sample/vimgirl.txt" was created by @shiwano. 68 | He gave me the permission which includes this file in plugin. Thanks! 69 | Original: https://gist.github.com/shiwano/5276921 70 | 71 | 72 | 73 | ============================================================================== 74 | CHANGELOG *splash-changelog* 75 | 76 | 1.1 2013-04-03 77 | - Fix the folding bug. 78 | - FIx the encoding bug. 79 | 80 | 1.0 2013-04-01 81 | - Initial version. 82 | 83 | 84 | ============================================================================== 85 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 86 | -------------------------------------------------------------------------------- /plugin/splash.vim: -------------------------------------------------------------------------------- 1 | " Changes the splash of Vim as you like. 2 | " Version: 1.1 3 | " Author : thinca 4 | " License: zlib License 5 | 6 | if exists('g:loaded_splash') 7 | finish 8 | endif 9 | let g:loaded_splash = 1 10 | 11 | let s:save_cpo = &cpo 12 | set cpo&vim 13 | 14 | command! -nargs=? -complete=file Splash call splash#command() 15 | 16 | augroup plugin-splash 17 | autocmd! 18 | autocmd VimEnter * nested call splash#intro() 19 | autocmd StdinReadPre * autocmd! plugin-splash VimEnter 20 | augroup END 21 | 22 | let &cpo = s:save_cpo 23 | unlet s:save_cpo 24 | -------------------------------------------------------------------------------- /sample/vimgirl.txt: -------------------------------------------------------------------------------- 1 | メ __-─-,-- _ 2 | ,イ >:::::::::::< ヽ〟 3 | ヽ─イ /,::::,::::::::\ >─r 4 | ヾ〟//:!:::ハ::::::|:!:ヽ ,丿 5 | ソ r:リヤ ハ::::::ハ:ハ::|rヘ〟 6 | Ⅲ:|:| V―ヘ::::/-ル゙|/ ハリ\ Happy 7 | !|:ハ:|,-=〟ヽ/,-=.ソハリ H Vimming♡ 8 | !ヽriゾUソゾ "ハUソノ゙hNノソ 9 | |!ハヾヾ` `´ノlリ´ 10 | ノ:ノハ ハ 丶 クハ ____ 11 | _________(ヽ/(ヾ/ハ,:ヽ 冖 ∠||ヽ _-==|リリ!) 12 | ,-´¬¬─-─/\\ \ノ:ハ\ゝ =- ハvノリ:ヾ丿::(⊃´ イ==-──´ 13 | ((-====Ξ二二::-´\ヾ \-ヾ::``丶^ )/|:!)!:::<(___/卜-'ヾ=-―´ 14 | /ソ /ハ/ ∠/ --===( ) ⊂)ヽへ:::)==Η!ηv 》:!>====|≡≡) 15 | ! ` !/リ リ/:-=="ヽ:ヽ'" |, -リリノ |!\乂 ヾ:ル | ル=-"ヾヽ 16 | | | ハヽ-=/:リヽ::(>___|) -=='" =-v-"===ヽ》|| ハ ||ヾ)ハ 17 | ハ ! !!ヾ !:/リ/ヽ:ヽ |/ ‖ /\ Vim ヽ》 ! || リ 18 | __/ソ V ///'|ヽ:ハ) |Y ‖ /:::\ ! }‖ !|| / 19 | ‖ | |/ヽ!リ | | | / |:::|\ヽV ||| ( 20 | \\ハ|| | | | ! |:::| \(!\ リ| ` 21 | \\!| | | | | / |:::| \\\__!ノ 22 | )! | ヾ! / / ^::::^ ヘ ヾ 23 | <,/ | " / / __!--==-!__ ハ ヽ=-- __ 24 | __====>ヾ// /三二===二三!\\-- =-- __ 25 | (-== イ / ‖/ / / | | \\ \ \ \_=-| 26 | \ \,∠ ‖/ / / | | \\\\ `/ / 27 | \ / \ ル / 仝 ! \\\,/ \/ 28 | ( > //// i || | i| \\\ ) 29 | ヽ /_ // | || | | ヽヽ ゞ" 30 | ヽヽ/¬/- <" - _ | Y | || ヽヽ< 31 | ^" /" ' || 》 / __| _|| > > 32 | > > | || <_____=--_=--->_=->_=゙ 33 | ヾ_| /::ヽ_ / // ! > > 34 | |/":::::ヽ=/, // /<=-´ 35 | |:::::|:::| |===//-===/´ 36 | ヽ::::|:::|/:::::::::/ 37 | |::::|:::リ:::::/:::/ 38 | |::::|::::リ:::/:::/ 39 | --------------------------------------------------------------------------------