Data Structures | Macros | Typedefs | Enumerations | Functions
option.c File Reference
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include "nvim/vim.h"
#include "nvim/macros.h"
#include "nvim/ascii.h"
#include "nvim/edit.h"
#include "nvim/option.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/diff.h"
#include "nvim/digraph.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/getchar.h"
#include "nvim/hardcopy.h"
#include "nvim/indent_c.h"
#include "nvim/mbyte.h"
#include "nvim/memfile.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
#include "nvim/keymap.h"
#include "nvim/garray.h"
#include "nvim/cursor_shape.h"
#include "nvim/move.h"
#include "nvim/mouse.h"
#include "nvim/normal.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/spell.h"
#include "nvim/spellfile.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/api/private/helpers.h"
#include "nvim/os/input.h"
#include "nvim/os/lang.h"

Data Structures

struct  vimoption
struct  langmap_entry_T


#define IN_OPTION_C
#define PV_BOTH   0x1000
#define PV_WIN   0x2000
#define PV_BUF   0x4000
#define PV_MASK   0x0fff
#define OPT_WIN(x)   (idopt_T)(PV_WIN + (int)(x))
#define OPT_BUF(x)   (idopt_T)(PV_BUF + (int)(x))
#define OPT_BOTH(x)   (idopt_T)(PV_BOTH + (int)(x))
#define VAR_WIN   ((char_u *)-1)
#define SCRIPTID_INIT   , 0
#define VI_DEFAULT   0 /* def_val[VI_DEFAULT] is Vi default value */
#define VIM_DEFAULT   1 /* def_val[VIM_DEFAULT] is Vim default value */
#define P_BOOL   0x01U /* the option is boolean */
#define P_NUM   0x02U /* the option is numeric */
#define P_STRING   0x04U /* the option is a string */
#define P_ALLOCED
#define P_EXPAND
#define P_NODEFAULT   0x40U /* don't set to default value */
#define P_WAS_SET   0x100U /* option has been set/reset */
#define P_NO_MKRC   0x200U /* don't include in :mkvimrc output */
#define P_VI_DEF   0x400U /* Use Vi default for Vim */
#define P_VIM   0x800U /* Vim option */
#define P_RSTAT   0x1000U
 redraw status lines More...
#define P_RWIN   0x2000U
 redraw current window and recompute text More...
#define P_RBUF   0x4000U
 redraw current buffer and recompute text More...
#define P_RALL   0x6000U
 redraw all windows More...
#define P_RCLR   0x7000U
 clear and redraw all More...
#define P_COMMA   0x8000U
 comma separated list More...
#define P_ONECOMMA   0x18000U
 commas More...
#define P_NODUP   0x20000U
 don't allow duplicate strings More...
#define P_FLAGLIST   0x40000U
 list of single-char flags More...
#define P_SECURE   0x80000U
 cannot change in modeline or secure mode More...
#define P_GETTEXT   0x100000U
 expand default value with _() More...
#define P_NOGLOB   0x200000U
 do not use local value for global vimrc More...
#define P_NFNAME   0x400000U
 only normal file name chars allowed More...
#define P_INSECURE   0x800000U
 option was set from a modeline More...
#define P_PRI_MKRC   0x1000000U
 has side effects) More...
#define P_NO_ML   0x2000000U
 not allowed in modeline More...
#define P_CURSWANT   0x4000000U
 when there is a redraw flag More...
#define P_NO_DEF_EXP   0x8000000U
 Do not expand default value. More...
#define P_RWINONLY   0x10000000U
 only redraw current window More...
#define P_NDNAME   0x20000000U
 only normal dir name chars allowed More...
#define P_UI_OPTION   0x40000000U
 send option to remote ui More...
#define PARAM_COUNT   ARRAY_SIZE(options)
#define NVIM_SIZE   (sizeof("nvim") - 1)
#define SITE_SIZE   (sizeof("site") - 1)
#define AFTER_SIZE   (sizeof("after") - 1)
#define TCO_BUFFER_SIZE   8
#define INC   20
#define GAP   3
#define COL_RULER   17 /* columns needed by standard ruler */


typedef struct vimoption vimoption_T


enum  idopt_T { PV_NONE = 0, PV_MAXVAL = 0xffff }


void set_init_1 (void)
void set_number_default (char *name, long val)
void set_init_2 (bool headless)
 Initialize the options, part two: After getting Rows and Columns. More...
void set_init_3 (void)
void set_helplang_default (const char *lang)
void set_title_defaults (void)
int do_set (char_u *arg, int opt_flags)
void set_options_bin (int oldval, int newval, int opt_flags)
int get_shada_parameter (int type)
char_ufind_shada_parameter (int type)
void check_options (void)
void check_buf_options (buf_T *buf)
void free_string_option (char_u *p)
void clear_string_option (char_u **pp)
int was_set_insecurely (char_u *opt, int opt_flags)
void set_string_option_direct (char_u *name, int opt_idx, char_u *val, int opt_flags, int set_sid)
char_ucheck_colorcolumn (win_T *wp)
char_ucheck_stl_option (char_u *s)
int findoption_len (const char *const arg, const size_t len)
bool get_tty_option (char *name, char **value)
bool set_tty_option (const char *name, char *value)
int get_option_value (char_u *name, long *numval, char_u **stringval, int opt_flags)
int get_option_value_strict (char *name, int64_t *numval, char **stringval, int opt_type, void *from)
char * set_option_value (const char *const name, const long number, const char *const string, const int opt_flags) FUNC_ATTR_NONNULL_ARG(1)
int find_key_option_len (const char_u *arg, size_t len)
void ui_refresh_options (void)
 Send update to UIs with values of UI relevant options. More...
int makeset (FILE *fd, int opt_flags, int local_only)
int makefoldset (FILE *fd)
void comp_col (void)
void unset_global_local_option (char *name, void *from)
char_uget_equalprg (void)
void win_copy_options (win_T *wp_from, win_T *wp_to)
void copy_winopt (winopt_T *from, winopt_T *to)
void check_win_options (win_T *win)
void clear_winopt (winopt_T *wop)
void didset_window_options (win_T *wp)
void buf_copy_options (buf_T *buf, int flags)
void reset_modifiable (void)
void set_iminsert_global (void)
void set_imsearch_global (void)
void set_context_in_set_cmd (expand_T *xp, char_u *arg, int opt_flags)
int ExpandSettings (expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file)
void ExpandOldSetting (int *num_file, char_u ***file)
int langmap_adjust_mb (int c)
int has_format_option (int x)
bool shortmess (int x)
void vimrc_found (char_u *fname, char_u *envname)
bool option_was_set (const char *name)
void reset_option_was_set (const char *name)
bool can_bs (int what)
void save_file_ff (buf_T *buf)
bool file_ff_differs (buf_T *buf, bool ignore_empty)
int check_ff_value (char_u *p)
int get_sw_value (buf_T *buf)
int get_sts_value (void)
void find_mps_values (int *initc, int *findc, int *backwards, int switchit)
unsigned int get_bkc_value (buf_T *buf)
int get_fileformat (buf_T *buf)
 Return the current end-of-line type: EOL_DOS, EOL_UNIX or EOL_MAC. More...
int get_fileformat_force (buf_T *buf, exarg_T *eap)
int default_fileformat (void)
 Return the default fileformat from 'fileformats'. More...
void set_fileformat (int eol_style, int opt_flags)
char_uskip_to_option_part (const char_u *p)
 Skip to next part of an option argument: skip space and comma. More...
size_t copy_option_part (char_u **option, char_u *buf, size_t maxlen, char *sep_chars)
int csh_like_shell (void)
 Return TRUE when 'shell' has "csh" in the tail. More...
bool signcolumn_on (win_T *wp)
 Return true when window "wp" has a column to draw signs in. More...
dict_Tget_winbuf_options (const int bufopt) FUNC_ATTR_WARN_UNUSED_RESULT
 Get window or buffer local options. More...

Macro Definition Documentation

#define AFTER_SIZE   (sizeof("after") - 1)
#define COL_RULER   17 /* columns needed by standard ruler */
#define GAP   3
"8:SpecialKey,~:EndOfBuffer,z:TermCursor,Z:TermCursorNC,@:NonText," \
"d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr," \
"N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title," \
"v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn," \
"A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal," \
"B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel," \
"x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill," \
"!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine," \
#define IN_OPTION_C
#define INC   20
#define NVIM_SIZE   (sizeof("nvim") - 1)
#define OPT_BOTH (   x)    (idopt_T)(PV_BOTH + (int)(x))
#define OPT_BUF (   x)    (idopt_T)(PV_BUF + (int)(x))
#define OPT_WIN (   x)    (idopt_T)(PV_WIN + (int)(x))
#define P_ALLOCED
0x08U /* the string option is in allocated memory,
must use free_string_option() when
assigning new value. Not set if default is
the same. */
#define P_BOOL   0x01U /* the option is boolean */
#define P_COMMA   0x8000U

comma separated list

#define P_CURSWANT   0x4000000U

when there is a redraw flag

update curswant required; not needed

0x80U /* default value is in allocated memory, must
use free() when assigning new value */
#define P_EXPAND
0x10U /* environment expansion. NOTE: P_EXPAND can
never be used for local or hidden options */
#define P_FLAGLIST   0x40000U

list of single-char flags

#define P_GETTEXT   0x100000U

expand default value with _()

#define P_INSECURE   0x800000U

option was set from a modeline

#define P_NDNAME   0x20000000U

only normal dir name chars allowed

#define P_NFNAME   0x400000U

only normal file name chars allowed

#define P_NO_DEF_EXP   0x8000000U

Do not expand default value.

#define P_NO_MKRC   0x200U /* don't include in :mkvimrc output */
#define P_NO_ML   0x2000000U

not allowed in modeline

#define P_NODEFAULT   0x40U /* don't set to default value */
#define P_NODUP   0x20000U

don't allow duplicate strings

#define P_NOGLOB   0x200000U

do not use local value for global vimrc

#define P_NUM   0x02U /* the option is numeric */
#define P_ONECOMMA   0x18000U


P_COMMA and cannot have two consecutive

#define P_PRI_MKRC   0x1000000U

has side effects)

priority for :mkvimrc (setting option

#define P_RALL   0x6000U

redraw all windows

#define P_RBUF   0x4000U

redraw current buffer and recompute text

#define P_RCLR   0x7000U

clear and redraw all

#define P_RSTAT   0x1000U

redraw status lines

#define P_RWIN   0x2000U

redraw current window and recompute text

#define P_RWINONLY   0x10000000U

only redraw current window

#define P_SECURE   0x80000U

cannot change in modeline or secure mode

#define P_STRING   0x04U /* the option is a string */
#define P_UI_OPTION   0x40000000U

send option to remote ui

#define P_VI_DEF   0x400U /* Use Vi default for Vim */
#define P_VIM   0x800U /* Vim option */
#define P_WAS_SET   0x100U /* option has been set/reset */
#define PARAM_COUNT   ARRAY_SIZE(options)
#define PV_BOTH   0x1000
#define PV_BUF   0x4000
#define PV_MASK   0x0fff
#define PV_WIN   0x2000
#define SCRIPTID_INIT   , 0
#define SITE_SIZE   (sizeof("site") - 1)
#define TCO_BUFFER_SIZE   8
#define VAR_WIN   ((char_u *)-1)
#define VI_DEFAULT   0 /* def_val[VI_DEFAULT] is Vi default value */
#define VIM_DEFAULT   1 /* def_val[VIM_DEFAULT] is Vim default value */

Typedef Documentation

typedef struct vimoption vimoption_T

Enumeration Type Documentation

enum idopt_T

Function Documentation

void buf_copy_options ( buf_T buf,
int  flags 
bool can_bs ( int  what)
void check_buf_options ( buf_T buf)
char_u* check_colorcolumn ( win_T wp)
int check_ff_value ( char_u p)
void check_options ( void  )
char_u* check_stl_option ( char_u s)
void check_win_options ( win_T win)
void clear_string_option ( char_u **  pp)
void clear_winopt ( winopt_T wop)
void comp_col ( void  )
size_t copy_option_part ( char_u **  option,
char_u buf,
size_t  maxlen,
char *  sep_chars 

Isolate one part of a string option separated by sep_chars.

[in,out]optionadvanced to the next part
[in,out]bufcopy of the isolated part
[in]maxlenlength of buf
[in]sep_charschars that separate the option parts
length of *option
void copy_winopt ( winopt_T from,
winopt_T to 
int csh_like_shell ( void  )

Return TRUE when 'shell' has "csh" in the tail.

int default_fileformat ( void  )

Return the default fileformat from 'fileformats'.

void didset_window_options ( win_T wp)
int do_set ( char_u arg,
int  opt_flags 
void ExpandOldSetting ( int *  num_file,
char_u ***  file 
int ExpandSettings ( expand_T xp,
regmatch_T regmatch,
int *  num_file,
char_u ***  file 
bool file_ff_differs ( buf_T buf,
bool  ignore_empty 
int find_key_option_len ( const char_u arg,
size_t  len 
void find_mps_values ( int *  initc,
int *  findc,
int *  backwards,
int  switchit 
char_u* find_shada_parameter ( int  type)
int findoption_len ( const char *const  arg,
const size_t  len 

Find index for named option

[in]argOption to find index for.
[in]lenLength of the option.
Index of the option or -1 if option was not found.
void free_string_option ( char_u p)
unsigned int get_bkc_value ( buf_T buf)

Get the local or global value of 'backupcopy'.

bufThe buffer.
char_u* get_equalprg ( void  )
int get_fileformat ( buf_T buf)

Return the current end-of-line type: EOL_DOS, EOL_UNIX or EOL_MAC.

int get_fileformat_force ( buf_T buf,
exarg_T eap 

Like get_fileformat(), but override 'fileformat' with "p" for "++opt=val" argument.

eapcan be NULL!
int get_option_value ( char_u name,
long *  numval,
char_u **  stringval,
int  opt_flags 

Gets the value for an option.

: Number or Toggle option: 1, *numval gets value. String option: 0, *stringval gets allocated string. Hidden Number or Toggle option: -1. hidden String option: -2. unknown option: -3.
stringvalNULL when only checking existence
int get_option_value_strict ( char *  name,
int64_t *  numval,
char **  stringval,
int  opt_type,
void *  from 
int get_shada_parameter ( int  type)
int get_sts_value ( void  )
int get_sw_value ( buf_T buf)
bool get_tty_option ( char *  name,
char **  value 
nameTUI-related option
dict_T* get_winbuf_options ( const int  bufopt)

Get window or buffer local options.

int has_format_option ( int  x)
bool is_tty_option ( const char *  name)
int langmap_adjust_mb ( int  c)
int makefoldset ( FILE *  fd)
int makeset ( FILE *  fd,
int  opt_flags,
int  local_only 
bool option_was_set ( const char *  name)

Check whether global option has been set

[in]nameOption name.
True if it was set.
void reset_modifiable ( void  )
void reset_option_was_set ( const char *  name)

Reset the flag indicating option "name" was set.

[in]nameOption name.
void save_file_ff ( buf_T buf)
void set_context_in_set_cmd ( expand_T xp,
char_u arg,
int  opt_flags 
void set_fileformat ( int  eol_style,
int  opt_flags 

Set the current end-of-line type to EOL_UNIX, EOL_MAC, or EOL_DOS.

Sets 'fileformat'.

eol_styleEnd-of-line style.
opt_flagsOPT_LOCAL and/or OPT_GLOBAL
void set_helplang_default ( const char *  lang)
void set_iminsert_global ( void  )
void set_imsearch_global ( void  )
void set_init_1 ( void  )
void set_init_2 ( bool  headless)

Initialize the options, part two: After getting Rows and Columns.

void set_init_3 ( void  )
void set_number_default ( char *  name,
long  val 
char* set_option_value ( const char *const  name,
const long  number,
const char *const  string,
const int  opt_flags 

Set the value of an option

[in]nameOption name.
[in]numberNew value for the number or boolean option.
[in]stringNew value for string option.
[in]opt_flagsFlags: OPT_LOCAL, OPT_GLOBAL, or 0 (both).
NULL on success, error message on error.
void set_options_bin ( int  oldval,
int  newval,
int  opt_flags 
void set_string_option_direct ( char_u name,
int  opt_idx,
char_u val,
int  opt_flags,
int  set_sid 
void set_title_defaults ( void  )
bool set_tty_option ( const char *  name,
char *  value 
bool shortmess ( int  x)
true if "x" is present in 'shortmess' option, or 'shortmess' contains 'a' and "x" is present in SHM_ALL_ABBREVIATIONS.
bool signcolumn_on ( win_T wp)

Return true when window "wp" has a column to draw signs in.

char_u* skip_to_option_part ( const char_u p)

Skip to next part of an option argument: skip space and comma.

void ui_refresh_options ( void  )

Send update to UIs with values of UI relevant options.

void unset_global_local_option ( char *  name,
void *  from 
void vimrc_found ( char_u fname,
char_u envname 

vimrc_found() - Called when a vimrc or "VIMINIT" has been found.

Set the values for options that didn't get set yet to the Vim defaults. When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.

int was_set_insecurely ( char_u opt,
int  opt_flags 
void win_copy_options ( win_T wp_from,
win_T wp_to