Data Structures | Macros | Typedefs | Enumerations | Functions
option.c File Reference
#include <assert.h>
#include <inttypes.h>
#include <stdbool.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/highlight.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/popupmnu.h"
#include "nvim/regexp.h"
#include "nvim/ex_session.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/ui_compositor.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 SCTX_INIT   , { 0, 0, 0 }
#define VI_DEFAULT   0
#define VIM_DEFAULT   1
#define P_BOOL   0x01U
#define P_NUM   0x02U
#define P_STRING   0x04U
#define P_ALLOCED   0x08U
#define P_EXPAND   0x10U
#define P_NODEFAULT   0x40U
#define P_DEF_ALLOCED   0x80U
#define P_WAS_SET   0x100U
#define P_NO_MKRC   0x200U
#define P_VI_DEF   0x400U
#define P_VIM   0x800U
#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 P_MLE   0x80000000U
 under control of 'modelineexpr' 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


typedef struct vimoption vimoption_T


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


char * get_lib_dir (void)
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)
 Initialize the options, part three: After reading the .vimrc. More...
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)
 Return true if "val" is a valid 'spellang' value. More...
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_arg, size_t len, bool has_lt)
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) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
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 (const buf_T *buf, const exarg_T *eap) FUNC_ATTR_NONNULL_ARG(1)
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...
int win_signcol_count (win_T *wp)
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
#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
#define P_BOOL   0x01U
#define P_COMMA   0x8000U

comma separated list

#define P_CURSWANT   0x4000000U

when there is a redraw flag

update curswant required; not needed

#define P_DEF_ALLOCED   0x80U
#define P_EXPAND   0x10U
#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_MLE   0x80000000U

under control of 'modelineexpr'

#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
#define P_NO_ML   0x2000000U

not allowed in modeline

#define P_NODEFAULT   0x40U
#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
#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
#define P_UI_OPTION   0x40000000U

send option to remote ui

#define P_VI_DEF   0x400U
#define P_VIM   0x800U
#define P_WAS_SET   0x100U
#define PARAM_COUNT   ARRAY_SIZE(options)
#define PV_BOTH   0x1000
#define PV_BUF   0x4000
#define PV_MASK   0x0fff
#define PV_WIN   0x2000
#define SCTX_INIT   , { 0, 0, 0 }
#define SITE_SIZE   (sizeof("site") - 1)
#define TCO_BUFFER_SIZE   8
#define VAR_WIN   ((char_u *)-1)
#define VI_DEFAULT   0
#define VIM_DEFAULT   1

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)

Handle setting 'colorcolumn' or 'textwidth' in window "wp".

error message, NULL if it's OK.
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 

Return true if 'fileformat' and/or 'fileencoding' has a different value from when editing started (save_file_ff() called). Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was changed and 'binary' is not set. Also when 'endofline' was changed and 'fixeol' is not set. When "ignore_empty" is true don't consider a new, empty buffer to be changed.

int find_key_option_len ( const char_u arg_arg,
size_t  len,
bool  has_lt 
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 ( const buf_T buf,
const exarg_T eap 

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

eapcan be NULL!
char* get_lib_dir ( void  )
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)

Return true if format option 'x' is in effect. Take care of no formatting when 'paste' is set.

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  )

Initialize the options, part three: After reading the .vimrc.

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.
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 
bool valid_spellang ( const char_u val)

Return true if "val" is a valid 'spellang' value.

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 

Return true when option "opt" was set from a modeline or in secure mode. Return false when it wasn't. Return -1 for an unknown option.

void win_copy_options ( win_T wp_from,
win_T wp_to 
int win_signcol_count ( win_T wp)

Return the number of requested sign columns, based on current buffer signs and on user configuration.