├── doc ├── tags └── startscreen.txt ├── README.markdown ├── LICENSE └── plugin └── startscreen.vim /doc/tags: -------------------------------------------------------------------------------- 1 | g:Startscreen_function startscreen.txt /*g:Startscreen_function* 2 | startscreen startscreen.txt /*startscreen* 3 | startscreen-options startscreen.txt /*startscreen-options* 4 | startscreen.txt startscreen.txt /*startscreen.txt* 5 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | [![This project is considered stable](https://img.shields.io/badge/Status-stable-green.svg)](https://arp242.net/status/stable) 2 | 3 | Customize Vim's start screen. 4 | 5 | This is a much simpler version of [vim-startify](https://github.com/mhinz/vim-startify). 6 | 7 | By default it displays a random `fortune(6)`, but this can be configured. Many 8 | Linux systems don't ship with `fortune(6)` by default any more (shame on them!) 9 | so you may get errors if you don't have it installed. 10 | 11 | Set `g:Startscreen_function` to your prefered function to run on startup. 12 | 13 | See `:help startscreen` for the full documentation. 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2016 Martin Tournoij 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to 7 | deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9 | sell copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | The software is provided "as is", without warranty of any kind, express or 16 | implied, including but not limited to the warranties of merchantability, 17 | fitness for a particular purpose and noninfringement. In no event shall the 18 | authors or copyright holders be liable for any claim, damages or other 19 | liability, whether in an action of contract, tort or otherwise, arising 20 | from, out of or in connection with the software or the use or other dealings 21 | in the software. 22 | -------------------------------------------------------------------------------- /doc/startscreen.txt: -------------------------------------------------------------------------------- 1 | *startscreen.txt* Customize Vim's start screen. 2 | 3 | ============================================================================== 4 | INTRODUCTION *startscreen* 5 | 6 | Customize Vim's start screen. 7 | 8 | This is a much simpler version of vim-startify (which has a lot more 9 | features): https://github.com/mhinz/vim-startify 10 | 11 | By default it displays a random fortune(6), but this can be configured. Many 12 | Linux systems don't ship with fortune(6) by default any more (shame on them!) 13 | so you may get errors if you don't have it installed. 14 | 15 | ============================================================================== 16 | OPTIONS *startscreen-options* 17 | 18 | *g:Startscreen_function* (Funcref, default: `startscreen#fortune`) 19 | 20 | The function to run; this expects a |Funcref|. Note the capital S (which is 21 | required by Vim)! 22 | 23 | Example: 24 | > 25 | function! T() 26 | " Read on our TODO file 27 | read ~/TODO 28 | 29 | " Some margin for readability 30 | :silent %>> 31 | 32 | " Go to line 1 33 | :1 34 | endfun 35 | let g:Startscreen_function = function('T') 36 | < 37 | 38 | vim:tw=78:ts=8:ft=help:norl:expandtab 39 | -------------------------------------------------------------------------------- /plugin/startscreen.vim: -------------------------------------------------------------------------------- 1 | " start_screen.vim: show any text as a "start screen". 2 | " 3 | " http://code.arp242.net/startscreen.vim 4 | " 5 | " See the bottom of this file for copyright & license information. 6 | 7 | 8 | "########################################################## 9 | " Initialize some stuff 10 | scriptencoding utf-8 11 | if exists('g:loaded_startscreen') | finish | endif 12 | let g:loaded_startscreen = 1 13 | let s:save_cpo = &cpo 14 | set cpo&vim 15 | 16 | 17 | "########################################################## 18 | " Options 19 | 20 | " The default function; show a fortune 21 | fun! startscreen#fortune() 22 | let l:fortune = systemlist('fortune -a') 23 | call append('0', ['', ''] + map(l:fortune, '" " . v:val')) 24 | :1 25 | redraw! 26 | 27 | " Moar fortunes! :-) 28 | nnoremap :enew:call startscreen#start() 29 | endfun 30 | 31 | if !exists('g:Startscreen_function') 32 | let g:Startscreen_function = function('startscreen#fortune') 33 | endif 34 | 35 | 36 | " Set a fancy start screen 37 | fun! startscreen#start() 38 | " Don't run if: 39 | " - there are commandline arguments; 40 | " - the buffer isn't empty (e.g. cmd | vi -); 41 | " - we're not invoked as vim or gvim; 42 | " - we're starting in insert mode. 43 | if argc() || line2byte('$') != -1 || v:progname !~? '^[-gmnq]\=vim\=x\=\%[\.exe]$' || &insertmode 44 | return 45 | endif 46 | 47 | " Start a new buffer... 48 | enew 49 | 50 | " ...and set some options for it 51 | setlocal 52 | \ bufhidden=wipe 53 | \ buftype=nofile 54 | \ nobuflisted 55 | \ nocursorcolumn 56 | \ nocursorline 57 | \ nolist 58 | \ nonumber 59 | \ noswapfile 60 | \ norelativenumber 61 | 62 | " Now we can just write to the buffer whatever you want. 63 | call g:Startscreen_function() 64 | 65 | " No modifications to this buffer 66 | setlocal nomodifiable nomodified 67 | 68 | " When we go to insert mode start a new buffer, and start insert 69 | nnoremap e :enew 70 | nnoremap i :enew startinsert 71 | nnoremap o :enew startinsert 72 | nnoremap p :enewp 73 | nnoremap P :enewP 74 | " TODO: Map more keys. e.g. I often start Vim to paste something from the OS 75 | " clipboard (p), but I have to clear this startscreen first :-/ 76 | endfun 77 | 78 | 79 | "########################################################## 80 | " Auto command 81 | augroup startscreen 82 | autocmd! 83 | autocmd VimEnter * call startscreen#start() 84 | augroup end 85 | 86 | 87 | let &cpo = s:save_cpo 88 | unlet s:save_cpo 89 | 90 | 91 | " The MIT License (MIT) 92 | " 93 | " Copyright © 2016 Martin Tournoij 94 | " 95 | " Permission is hereby granted, free of charge, to any person obtaining a copy 96 | " of this software and associated documentation files (the "Software"), to 97 | " deal in the Software without restriction, including without limitation the 98 | " rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 99 | " sell copies of the Software, and to permit persons to whom the Software is 100 | " furnished to do so, subject to the following conditions: 101 | " 102 | " The above copyright notice and this permission notice shall be included in 103 | " all copies or substantial portions of the Software. 104 | " 105 | " The software is provided "as is", without warranty of any kind, express or 106 | " implied, including but not limited to the warranties of merchantability, 107 | " fitness for a particular purpose and noninfringement. In no event shall the 108 | " authors or copyright holders be liable for any claim, damages or other 109 | " liability, whether in an action of contract, tort or otherwise, arising 110 | " from, out of or in connection with the software or the use or other dealings 111 | " in the software. 112 | --------------------------------------------------------------------------------