diff options
author | Chris Lucas <chris@chrisjlucas.com> | 2016-10-29 17:04:13 -0700 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2016-12-28 14:57:38 -0500 |
commit | 99a8cd3be0509e97b649edc1599bfb74bf2b4802 (patch) | |
tree | 77ef2a023d458ef97b044354c742269617874e58 | |
parent | d4671048162be61096cfcf6beef917166afa5267 (diff) | |
download | rneovim-99a8cd3be0509e97b649edc1599bfb74bf2b4802.tar.gz rneovim-99a8cd3be0509e97b649edc1599bfb74bf2b4802.tar.bz2 rneovim-99a8cd3be0509e97b649edc1599bfb74bf2b4802.zip |
vim-patch:7.4.2201
Problem: The sign column disappears when the last sign is deleted.
Solution: Add the 'signcolumn' option. (Christian Brabandt)
https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
-rw-r--r-- | runtime/doc/options.txt | 16 | ||||
-rw-r--r-- | runtime/optwin.vim | 3 | ||||
-rw-r--r-- | src/nvim/buffer_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/edit.c | 2 | ||||
-rw-r--r-- | src/nvim/move.c | 3 | ||||
-rw-r--r-- | src/nvim/option.c | 23 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 1 | ||||
-rw-r--r-- | src/nvim/options.lua | 8 | ||||
-rw-r--r-- | src/nvim/screen.c | 17 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
10 files changed, 55 insertions, 22 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 7cfc55ed79..20d46a9f0c 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -246,10 +246,10 @@ global value, which is used for new buffers. With ":set" both the local and global value is changed. With "setlocal" only the local value is changed, thus this value is not used when editing a new buffer. -When editing a buffer that has been edited before, the last used window -options are used again. If this buffer has been edited in this window, the -values from back then are used. Otherwise the values from the window where -the buffer was edited last are used. +When editing a buffer that has been edited before, the options from the window +that was last closed are used again. If this buffer has been edited in this +window, the values from back then are used. Otherwise the values from the +last closed window where the buffer was edited last are used. It's possible to set a local window option specifically for a type of buffer. When you edit another buffer in the same window, you don't want to keep @@ -5624,10 +5624,16 @@ A jump table for the options with a short description can be found at |Q_op|. Example: Try this together with 'sidescroll' and 'listchars' as in the following example to never allow the cursor to move - onto the "extends" character: + onto the "extends" character: > :set nowrap sidescroll=1 listchars=extends:>,precedes:< :set sidescrolloff=1 +< + *'signcolumn'* *'scl'* +'signcolumn' 'scl' string (default "auto") + local to window + Whether or not to draw the signcolumn. "auto" means it will only be + drawn when there is a sign to display. *'smartcase'* *'scs'* *'nosmartcase'* *'noscs'* diff --git a/runtime/optwin.vim b/runtime/optwin.vim index 3d585267d7..b8a2636d4d 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -1250,6 +1250,9 @@ call append("$", "\t(local to buffer)") call <SID>BinOptionL("bl") call append("$", "debug\tset to \"msg\" to see all error messages") call append("$", " \tset debug=" . &debug) +call append("$", "signcolumn\twhether to show the signcolumn") +call append("$", "\t(local to window)") +call <SID>OptionL("scl") set cpo&vim diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 0418a737eb..fda906fc59 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -237,6 +237,8 @@ typedef struct { # define w_p_crb w_onebuf_opt.wo_crb /* 'cursorbind' */ int wo_crb_save; /* 'cursorbind' state saved for diff mode*/ # define w_p_crb_save w_onebuf_opt.wo_crb_save + char_u *wo_scl; +# define w_p_scl w_onebuf_opt.wo_scl /* 'signcolumn' */ int wo_scriptID[WV_COUNT]; /* SIDs for window-local options */ # define w_p_scriptID w_onebuf_opt.wo_scriptID diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 7e917336e5..bb946337b5 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -5708,7 +5708,7 @@ comp_textwidth ( textwidth -= 1; textwidth -= curwin->w_p_fdc; - if (curwin->w_buffer->b_signlist != NULL) { + if (signcolumn_on(curwin)) { textwidth -= 1; } diff --git a/src/nvim/move.c b/src/nvim/move.c index 4c814f3ae0..4e7fe86adc 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -24,6 +24,7 @@ #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/misc1.h" +#include "nvim/option.h" #include "nvim/popupmnu.h" #include "nvim/screen.h" #include "nvim/strings.h" @@ -669,7 +670,7 @@ int win_col_off(win_T *wp) return ((wp->w_p_nu || wp->w_p_rnu) ? number_width(wp) + 1 : 0) + (cmdwin_type == 0 || wp != curwin ? 0 : 1) + (int)wp->w_p_fdc - + (wp->w_buffer->b_signlist != NULL ? 2 : 0) + + (signcolumn_on(wp) ? 2 : 0) ; } diff --git a/src/nvim/option.c b/src/nvim/option.c index 797dd1dfe7..2249ef6e95 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -289,6 +289,7 @@ static char *(p_fcl_values[]) = { "all", NULL }; static char *(p_cot_values[]) = { "menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL }; static char *(p_icm_values[]) = { "nosplit", "split", NULL }; +static char *(p_scl_values[]) = { "yes", "no", "auto", NULL }; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "option.c.generated.h" @@ -3008,6 +3009,12 @@ did_set_string_option ( completeopt_was_set(); } } + /* 'signcolumn' */ + else if (varp == &curwin->w_p_scl) { + if (check_opt_strings(*varp, p_scl_values, false) != OK) { + errmsg = e_invarg; + } + } /* 'pastetoggle': translate key codes like in a mapping */ else if (varp == &p_pt) { if (*p_pt) { @@ -4782,7 +4789,6 @@ static int find_key_option(const char_u *arg) return find_key_option_len(arg, STRLEN(arg)); } - /* * if 'all' == 0: show changed options * if 'all' == 1: show all normal options @@ -5428,6 +5434,7 @@ static char_u *get_varp(vimoption_T *p) case PV_UDF: return (char_u *)&(curbuf->b_p_udf); case PV_WM: return (char_u *)&(curbuf->b_p_wm); case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); + case PV_SCL: return (char_u *)&(curwin->w_p_scl); default: EMSG(_("E356: get_varp ERROR")); } /* always return a valid pointer to avoid a crash! */ @@ -5505,6 +5512,7 @@ void copy_winopt(winopt_T *from, winopt_T *to) to->wo_fde = vim_strsave(from->wo_fde); to->wo_fdt = vim_strsave(from->wo_fdt); to->wo_fmr = vim_strsave(from->wo_fmr); + to->wo_scl = vim_strsave(from->wo_scl); check_winopt(to); /* don't want NULL pointers */ } @@ -5528,6 +5536,7 @@ static void check_winopt(winopt_T *wop) check_string_option(&wop->wo_fde); check_string_option(&wop->wo_fdt); check_string_option(&wop->wo_fmr); + check_string_option(&wop->wo_scl); check_string_option(&wop->wo_rlc); check_string_option(&wop->wo_stl); check_string_option(&wop->wo_cc); @@ -5546,6 +5555,7 @@ void clear_winopt(winopt_T *wop) clear_string_option(&wop->wo_fde); clear_string_option(&wop->wo_fdt); clear_string_option(&wop->wo_fmr); + clear_string_option(&wop->wo_scl); clear_string_option(&wop->wo_rlc); clear_string_option(&wop->wo_stl); clear_string_option(&wop->wo_cc); @@ -6902,3 +6912,14 @@ int csh_like_shell(void) return strstr((char *)path_tail(p_sh), "csh") != NULL; } +/// Return true when window "wp" has a column to draw signs in. +bool signcolumn_on(win_T *wp) +{ + if (*wp->w_p_scl == 'n') { + return false; + } + if (*wp->w_p_scl == 'y') { + return true; + } + return wp->w_buffer->b_signlist != NULL; +} diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 6e89a093c8..82c618cf6f 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -799,6 +799,7 @@ enum { , WV_WFH , WV_WFW , WV_WRAP + , WV_SCL , WV_COUNT /* must be the last one */ }; diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 14707aaa6c..70d1f73cf4 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -2170,6 +2170,14 @@ return { defaults={if_true={vi=0}} }, { + full_name='signcolumn', abbreviation='scl', + type='string', scope={'window'}, + vi_def=true, + alloced=true, + redraw={'current_window'}, + defaults={if_true={vi="auto"}} + }, + { full_name='smartcase', abbreviation='scs', type='bool', scope={'global'}, vi_def=true, diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 50517d2829..72549f1f21 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -576,15 +576,6 @@ void update_debug_sign(buf_T *buf, linenr_T lnum) } /* - * Return TRUE when window "wp" has a column to draw signs in. - */ -static int draw_signcolumn(win_T *wp) -{ - return (wp->w_buffer->b_signlist != NULL); -} - - -/* * Update a single window. * * This may cause the windows below it also to be redrawn (when clearing the @@ -1598,7 +1589,7 @@ static void win_draw_end(win_T *wp, int c1, int c2, int row, int endrow, hlf_T h ' ', ' ', hl_attr(HLF_FC)); } - if (draw_signcolumn(wp)) { + if (signcolumn_on(wp)) { int nn = n + 2; /* draw the sign column left of the fold column */ @@ -1639,7 +1630,7 @@ static void win_draw_end(win_T *wp, int c1, int c2, int row, int endrow, hlf_T h n = nn; } - if (draw_signcolumn(wp)) + if (signcolumn_on(wp)) { int nn = n + 2; @@ -1753,7 +1744,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T RL_MEMSET(col, hl_attr(HLF_FL), wp->w_width - col); /* If signs are being displayed, add two spaces. */ - if (draw_signcolumn(wp)) { + if (signcolumn_on(wp)) { len = wp->w_width - col; if (len > 0) { if (len > 2) { @@ -2701,7 +2692,7 @@ win_line ( draw_state = WL_SIGN; /* Show the sign column when there are any signs in this * buffer or when using Netbeans. */ - if (draw_signcolumn(wp)) { + if (signcolumn_on(wp)) { int text_sign; /* Draw two cells with the sign value or blank. */ c_extra = ' '; diff --git a/src/nvim/version.c b/src/nvim/version.c index d146d8ff67..e89bc49210 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -239,7 +239,7 @@ static int included_patches[] = { // 2204, // 2203 NA // 2202 NA - // 2201, + 2201, // 2200, // 2199 NA // 2198, |