From 290b0872d042ee4d3ce7e46555b0c731a6e2e704 Mon Sep 17 00:00:00 2001 From: Reed Esau Date: Mon, 7 Sep 2015 00:19:42 -0600 Subject: [PATCH] Added 'auto' mode indicator to fix #18 An indicator to show that Vim's autoformat is activated while in HardPencil mode. --- README.markdown | 14 ++++++++++++-- plugin/pencil.vim | 10 +++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index 7c04bf0..ae900a0 100644 --- a/README.markdown +++ b/README.markdown @@ -375,12 +375,22 @@ or if using [bling/vim-airline][va]: let g:airline_section_x = '%{PencilMode()}' ``` -If you don’t like the default indicators, you can specify different ones: +The default indicators now include ‘auto’ for when Vim’s autoformat is +activated in hard line break mode. ```vim -let g:pencil#mode_indicators = {'hard': '␍', 'soft': '⤸', 'off': '',} +let g:pencil#mode_indicators = {'hard': 'H', 'auto': 'A', 'soft': 'S', 'off': '',} ``` +If Unicode is detected, the default indicators are: + +```vim +let g:pencil#mode_indicators = {'hard': '␍', 'auto': 'ª', 'soft': '⤸', 'off': '',} +``` + +If you don’t like the default indicators, you can specify your own in +your `.vimrc`. + Note that `PencilMode()` will return blank for buffers in which _pencil_ has not been initialized. diff --git a/plugin/pencil.vim b/plugin/pencil.vim index 14d3378..235a78c 100644 --- a/plugin/pencil.vim +++ b/plugin/pencil.vim @@ -31,7 +31,11 @@ fun! PencilMode() if b:pencil_wrap_mode ==# s:WRAP_MODE_SOFT return get(g:pencil#mode_indicators, 'soft', 'S') elsei b:pencil_wrap_mode ==# s:WRAP_MODE_HARD - return get(g:pencil#mode_indicators, 'hard', 'H') + if &fo =~ 'a' + return get(g:pencil#mode_indicators, 'auto', 'A') + el + return get(g:pencil#mode_indicators, 'hard', 'H') + en el return get(g:pencil#mode_indicators, 'off', '') en @@ -135,9 +139,9 @@ en if !exists('g:pencil#mode_indicators') " used to set PencilMode() for statusline if s:unicode_enabled() - let g:pencil#mode_indicators = {'hard': '␍', 'soft': '⤸', 'off': '',} + let g:pencil#mode_indicators = {'hard': '␍', 'auto': 'ª', 'soft': '⤸', 'off': '',} el - let g:pencil#mode_indicators = {'hard': 'H', 'soft': 'S', 'off': '',} + let g:pencil#mode_indicators = {'hard': 'H', 'auto': 'A', 'soft': 'S', 'off': '',} en en