├── README.md ├── doc └── keeppad.txt └── plugin └── keeppad.vim /README.md: -------------------------------------------------------------------------------- 1 | :tea: vim-keeppad 2 | ================= 3 | 4 | Keep padding! If you `:set nonumber`, you can find that there is no space at 5 | the left side of window and you might think it's not beautiful. vim-keeppad 6 | solves this problem. vim-keeppad adds padding only when 'number' option is 7 | turned off (:set nonumber) by default. 8 | 9 | ![](https://i.gyazo.com/2a6962e7ecc6f024a0fc26dbfbe21536.png) 10 | 11 | 12 | #### Without vim-keeppad 13 | 14 | There is no padding... 15 | 16 | ![](https://i.gyazo.com/e5512f89ed55c498506ecaca4687ac83.png) 17 | 18 | :package: Installation :package: 19 | -------------------------------- 20 | 21 | Install with your favorite plugin managers like 22 | [Neobundle](https://github.com/Shougo/neobundle.vim) / 23 | [Vundle](https://github.com/gmarik/Vundle.vim) / 24 | [vim-plug](https://github.com/junegunn/vim-plug) 25 | 26 | ```vim 27 | NeoBundle 'haya14busa/vim-keeppad' 28 | Plugin 'haya14busa/vim-keeppad' 29 | Plug 'haya14busa/vim-keeppad' 30 | ``` 31 | 32 | :bird: Author :bird: 33 | -------------------- 34 | haya14busa (https://github.com/haya14busa) 35 | 36 | :orange_book: Documentation :orange_book: 37 | ----------------------------------------- 38 | 39 | [**:h keeppad.txt**](./doc/keeppad.txt) 40 | -------------------------------------------------------------------------------- /doc/keeppad.txt: -------------------------------------------------------------------------------- 1 | *keeppad.txt* add padding 2 | 3 | Author : haya14busa 4 | Version : 0.9.0 5 | License : MIT license {{{ 6 | 7 | Copyright (c) 2016 haya14busa 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining 10 | a copy of this software and associated documentation files (the 11 | "Software"), to deal in the Software without restriction, including 12 | without limitation the rights to use, copy, modify, merge, publish, 13 | distribute, sublicense, and/or sell copies of the Software, and to 14 | permit persons to whom the Software is furnished to do so, subject to 15 | the following conditions: 16 | The above copyright notice and this permission notice shall be 17 | included in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | 27 | }}} 28 | 29 | ============================================================================== 30 | CONTENTS *keeppad-contents* 31 | 32 | INTRODUCTION |keeppad-introduction| 33 | INSTALLATION |keeppad-installation| 34 | INTERFACE |keeppad-interface| 35 | COMMANDS |keeppad-commands| 36 | VARIABLES |keeppad-variables| 37 | Changelog |keeppad-changelog| 38 | 39 | ============================================================================== 40 | INTRODUCTION *keeppad-introduction* 41 | 42 | *vim-keeppad* (*keeppad.vim* ) add padding. If you `:set nonumber`, you can 43 | find that there is no space at the left side of window and you might think 44 | it's not beautiful. vim-keeppad solves this problem. 45 | 46 | ============================================================================== 47 | INSTALLATION *keeppad-installation* 48 | 49 | Install with your favorite plugin managers like NeoBundle/Plugin/Plug 50 | > 51 | NeoBundle 'haya14busa/vim-keeppad' 52 | Plugin 'haya14busa/vim-keeppad' 53 | Plug 'haya14busa/vim-keeppad' 54 | 55 | ============================================================================== 56 | INTERFACE *keeppad-interface* 57 | ------------------------------------------------------------------------------ 58 | COMMAND *keeppad-commands* 59 | 60 | :KeeppadOn *:KeeppadOn* 61 | Turn on keeppad. 62 | 63 | :KeeppadOff *:KeeppadOff* 64 | Turn off keeppad. 65 | 66 | ------------------------------------------------------------------------------ 67 | VARIABLES *keeppad-variables* 68 | 69 | g:keeppad_autopadding *g:keeppad_autopadding* 70 | Turn on keeppad automatically if this variable is 1. 71 | Default: 1 72 | 73 | g:keeppad_no_hl *g:keeppad_no_hl* 74 | Clear highlight of the padding(|hl-SignColumn|) if this variable is 1. 75 | Default: 1 76 | 77 | g:keeppad_hook_number_option *g:keeppad_hook_number_option* 78 | Toggle keeppad with the update of the 'number' option. 79 | Default: 1 80 | 81 | ============================================================================== 82 | CHANGELOG *keeppad-changelog* 83 | 84 | 0.9.0 2016-01-13 85 | - Init. 86 | 87 | ============================================================================== 88 | vim:tw=78:ts=8:ft=help:norl:noet:fen:fdl=0:fdm=marker: 89 | -------------------------------------------------------------------------------- /plugin/keeppad.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " FILE: plugin/keeppad.vim 3 | " AUTHOR: haya14busa 4 | " DESCRIPTION: Keep left padding by always showing sign column. It works well 5 | " with :set nonumber. See :h SignColumn for sign column. 6 | " License: MIT license 7 | "============================================================================= 8 | scriptencoding utf-8 9 | if expand('%:p') ==# expand(':p') 10 | unlet! g:loaded_keeppad 11 | endif 12 | if exists('g:loaded_keeppad') 13 | finish 14 | endif 15 | let g:loaded_keeppad = 1 16 | let s:save_cpo = &cpo 17 | set cpo&vim 18 | 19 | " function! s:id(name) abort 20 | " return eval(join(map(split(a:name, '\zs'), 'char2nr(v:val)'), '+')) 21 | " endfunction 22 | " echo s:id('keeppad') 23 | " => 1148 24 | let s:ID = get(g:, 'keeppad_id', 1148) 25 | 26 | sign define keeppad 27 | 28 | let g:keeppad_autopadding = get(g:, 'keeppad_autopadding', 1) 29 | let g:keeppad_no_hl = get(g:, 'keeppad_no_hl', 1) 30 | let g:keeppad_hook_number_option = get(g:, 'keeppad_hook_number_option', 1) 31 | 32 | let s:ON = g:keeppad_autopadding 33 | 34 | command! KeeppadOn call s:on() 35 | command! KeeppadOff call s:off() 36 | 37 | if g:keeppad_autopadding 38 | augroup plugin-keeppad-dummysign 39 | autocmd! 40 | autocmd BufWinEnter * if !g:keeppad_hook_number_option || !&number | call dummysign() | endif 41 | autocmd VimEnter * call clear_auto() 42 | if g:keeppad_hook_number_option 43 | autocmd OptionSet * call s:optionset() 44 | endif 45 | augroup END 46 | 47 | 48 | function! s:optionset() abort 49 | if s:ON && expand('') is# 'number' 50 | if v:option_new 51 | call s:dummysign_off() 52 | else 53 | call s:clear_enable_auto() 54 | call s:dummysign() 55 | endif 56 | endif 57 | endfunction 58 | endif 59 | 60 | function! s:dummysign() abort 61 | execute printf('sign place %d line=%d name=keeppad buffer=%d', s:ID, 1, bufnr('%')) 62 | endfunction 63 | 64 | function! s:dummysign_off() abort 65 | execute printf('sign unplace %d buffer=%d', s:ID, bufnr('%')) 66 | endfunction 67 | 68 | function! s:clear_auto() abort 69 | if g:keeppad_no_hl 70 | call s:clear_hi() 71 | call s:clear_enable_auto() 72 | endif 73 | endfunction 74 | 75 | function! s:clear_enable_auto() abort 76 | augroup plugin-keeppad-clear-hi 77 | autocmd! 78 | autocmd ColorScheme * call clear_hi() 79 | augroup END 80 | endfunction 81 | 82 | function! s:clear_hi() abort 83 | highlight SignColumn ctermbg=None 84 | endfunction 85 | 86 | function! s:clear_hi_off() abort 87 | autocmd! plugin-keeppad-clear-hi 88 | if g:keeppad_no_hl 89 | let colors_name = get(g:, 'colors_name', '') 90 | if colors_name isnot# '' 91 | try 92 | execute 'colorscheme ' . colors_name 93 | endtry 94 | endif 95 | endif 96 | endfunction 97 | 98 | function! s:on() abort 99 | let s:ON = 1 100 | call s:clear_auto() 101 | call s:dummysign() 102 | endfunction 103 | 104 | function! s:off() abort 105 | let s:ON = 0 106 | call s:dummysign_off() 107 | call s:clear_hi_off() 108 | endfunction 109 | 110 | let &cpo = s:save_cpo 111 | unlet s:save_cpo 112 | " __END__ 113 | " vim: expandtab softtabstop=2 shiftwidth=2 foldmethod=marker 114 | --------------------------------------------------------------------------------