diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/nvim/globals.h | 8 | ||||
| -rw-r--r-- | src/nvim/option.c | 76 | ||||
| -rw-r--r-- | src/nvim/options.lua | 2 | ||||
| -rw-r--r-- | src/nvim/screen.c | 6 | ||||
| -rw-r--r-- | src/nvim/testdir/setup.vim | 1 | 
5 files changed, 50 insertions, 43 deletions
| diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 3df201b6bf..1856384ffa 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -937,7 +937,7 @@ extern char_u *compiled_sys;   * directory is not a local directory, globaldir is NULL. */  EXTERN char_u   *globaldir INIT(= NULL); -/* Characters from 'listchars' option */ +// 'listchars' characters. Defaults are overridden in set_chars_option().  EXTERN int lcs_eol INIT(= '$');  EXTERN int lcs_ext INIT(= NUL);  EXTERN int lcs_prec INIT(= NUL); @@ -948,11 +948,11 @@ EXTERN int lcs_tab2 INIT(= NUL);  EXTERN int lcs_trail INIT(= NUL);  EXTERN int lcs_conceal INIT(= ' '); -/* Characters from 'fillchars' option */ +// 'fillchars' characters. Defaults are overridden in set_chars_option().  EXTERN int fill_stl INIT(= ' ');  EXTERN int fill_stlnc INIT(= ' '); -EXTERN int fill_vert INIT(= ' '); -EXTERN int fill_fold INIT(= '-'); +EXTERN int fill_vert INIT(= 9474);  // │ +EXTERN int fill_fold INIT(= 183);   // ·  EXTERN int fill_diff INIT(= '-');  /* Whether 'keymodel' contains "stopsel" and "startsel". */ diff --git a/src/nvim/option.c b/src/nvim/option.c index 2341371f65..eff436eb4d 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3381,37 +3381,38 @@ skip:    return NULL;    /* no error */  } -/* - * Handle setting 'listchars' or 'fillchars'. - * Returns error message, NULL if it's OK. - */ + +/// Handle setting 'listchars' or 'fillchars'. +/// Assume monocell characters +/// +/// @param varp either &p_lcs ('listchars') or &p_fcs ('fillchar') +/// @return error message, NULL if it's OK.  static char_u *set_chars_option(char_u **varp)  {    int round, i, len, entries;    char_u      *p, *s;    int c1, c2 = 0;    struct charstab { -    int     *cp; -    char    *name; +    int     *cp;    ///< char value +    char    *name;  ///< char id +    int     def;    ///< default value    }; -  static struct charstab filltab[] = -  { -    {&fill_stl,     "stl"}, -    {&fill_stlnc,   "stlnc"}, -    {&fill_vert,    "vert"}, -    {&fill_fold,    "fold"}, -    {&fill_diff,    "diff"}, +  static struct charstab filltab[] = { +    { &fill_stl,     "stl"  , ' '  }, +    { &fill_stlnc,   "stlnc", ' '  }, +    { &fill_vert,    "vert" , 9474 },  // │ +    { &fill_fold,    "fold" , 183  },  // · +    { &fill_diff,    "diff" , '-'  },    }; -  static struct charstab lcstab[] = -  { -    {&lcs_eol,      "eol"}, -    {&lcs_ext,      "extends"}, -    {&lcs_nbsp,     "nbsp"}, -    {&lcs_prec,     "precedes"}, -    {&lcs_space,    "space"}, -    {&lcs_tab2,     "tab"}, -    {&lcs_trail,    "trail"}, -    {&lcs_conceal,  "conceal"}, +  static struct charstab lcstab[] = { +    { &lcs_eol,      "eol",      NUL }, +    { &lcs_ext,      "extends",  NUL }, +    { &lcs_nbsp,     "nbsp",     NUL }, +    { &lcs_prec,     "precedes", NUL }, +    { &lcs_space,    "space",    NUL }, +    { &lcs_tab2,     "tab",      NUL }, +    { &lcs_trail,    "trail",    NUL }, +    { &lcs_conceal,  "conceal",  NUL },    };    struct charstab *tab; @@ -3421,20 +3422,29 @@ static char_u *set_chars_option(char_u **varp)    } else {      tab = filltab;      entries = ARRAY_SIZE(filltab); +    if (*p_ambw == 'd') { +      // XXX: If ambiwidth=double then "|" and "·" take 2 columns, which is +      // forbidden (TUI limitation?). Set old defaults. +      filltab[2].def = '|'; +      filltab[3].def = '-'; +    } else { +      filltab[2].def = 9474;  // │ +      filltab[3].def = 183;   // · +    }    } -  /* first round: check for valid value, second round: assign values */ -  for (round = 0; round <= 1; ++round) { +  // first round: check for valid value, second round: assign values +  for (round = 0; round <= 1; round++) {      if (round > 0) { -      /* After checking that the value is valid: set defaults: space for -       * 'fillchars', NUL for 'listchars' */ -      for (i = 0; i < entries; ++i) -        if (tab[i].cp != NULL) -          *(tab[i].cp) = (varp == &p_lcs ? NUL : ' '); -      if (varp == &p_lcs) +      // After checking that the value is valid: set defaults +      for (i = 0; i < entries; i++) { +        if (tab[i].cp != NULL) { +          *(tab[i].cp) = tab[i].def; +        } +      } +      if (varp == &p_lcs) {          lcs_tab1 = NUL; -      else -        fill_diff = '-'; +      }      }      p = *varp;      while (*p) { diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 6e8100594d..34ff810410 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -812,7 +812,7 @@ return {        vi_def=true,        redraw={'all_windows'},        varname='p_fcs', -      defaults={if_true={vi="vert:|,fold:-"}} +      defaults={if_true={vi=''}}      },      {        full_name='fixendofline', abbreviation='fixeol', diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 2b4317fd49..b4cdbbd824 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -7088,11 +7088,7 @@ static int fillchar_status(int *attr, win_T *wp)  static int fillchar_vsep(win_T *wp, int *attr)  {    *attr = win_hl_attr(wp, HLF_C); -  if (*attr == 0 && fill_vert == ' ') { -    return '|'; -  } else { -    return fill_vert; -  } +  return fill_vert;  }  /* diff --git a/src/nvim/testdir/setup.vim b/src/nvim/testdir/setup.vim index 87cf1f6163..7d6dd0c7ce 100644 --- a/src/nvim/testdir/setup.vim +++ b/src/nvim/testdir/setup.vim @@ -6,6 +6,7 @@ set directory^=.  set backspace=  set nohidden smarttab noautoindent noautoread complete-=i noruler noshowcmd  set listchars=eol:$ +set fillchars=vert:\|,fold:-  " Prevent Nvim log from writing to stderr.  let $NVIM_LOG_FILE = exists($NVIM_LOG_FILE) ? $NVIM_LOG_FILE : 'Xnvim.log' | 
