Data Structures | Macros | Typedefs | Enumerations | Functions
syntax.c File Reference
#include <assert.h>
#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/cursor_shape.h"
#include "nvim/eval.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_docmd.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/garray.h"
#include "nvim/hashtab.h"
#include "nvim/highlight.h"
#include "nvim/highlight_group.h"
#include "nvim/indent_c.h"
#include "nvim/keycodes.h"
#include "nvim/lua/executor.h"
#include "nvim/macros.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/sign.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/syntax_defs.h"
#include "nvim/terminal.h"
#include "nvim/ui.h"
#include "nvim/vim.h"

Data Structures

struct  syn_pattern
 
struct  syn_cluster_S
 
struct  state_item
 
struct  syn_opt_arg_T
 
struct  time_entry_T
 
struct  name_list
 
struct  subcommand
 

Macros

#define SPO_MS_OFF   0
 
#define SPO_ME_OFF   1
 
#define SPO_HS_OFF   2
 
#define SPO_HE_OFF   3
 
#define SPO_RS_OFF   4
 
#define SPO_RE_OFF   5
 
#define SPO_LC_OFF   6
 
#define SPO_COUNT   7
 
#define SPTYPE_MATCH   1
 
#define SPTYPE_START   2
 
#define SPTYPE_END   3
 
#define SPTYPE_SKIP   4
 
#define SYN_ITEMS(buf)   ((synpat_T *)((buf)->b_syn_patterns.ga_data))
 
#define NONE_IDX   (-2)
 
#define SF_CCOMMENT   0x01
 
#define SF_MATCH   0x02
 
#define SYN_STATE_P(ssp)   ((bufstate_T *)((ssp)->ga_data))
 
#define MAXKEYWLEN   80
 
#define CLUSTER_REPLACE   1
 
#define CLUSTER_ADD   2
 
#define CLUSTER_SUBTRACT   3
 
#define SYN_CLSTR(buf)   ((syn_cluster_T *)((buf)->b_syn_clusters.ga_data))
 
#define SYNID_ALLBUT   MAX_HL_ID
 
#define SYNID_TOP   21000
 
#define SYNID_CONTAINED   22000
 
#define SYNID_CLUSTER   23000
 
#define MAX_SYN_INC_TAG   999
 
#define MAX_CLUSTER_ID   (32767 - SYNID_CLUSTER)
 
#define KE2HIKEY(kp)   ((kp)->keyword)
 
#define HIKEY2KE(p)   ((keyentry_T *)((p) - (dumkey.keyword - (char_u *)&dumkey)))
 
#define HI2KE(hi)   HIKEY2KE((hi)->hi_key)
 
#define KEYWORD_IDX   (-1)
 
#define ID_LIST_ALL   ((int16_t *)-1)
 
#define INVALID_STATE(ssp)   ((ssp)->ga_itemsize == 0)
 
#define VALID_STATE(ssp)   ((ssp)->ga_itemsize != 0)
 
#define CUR_STATE(idx)   ((stateitem_T *)(current_state.ga_data))[idx]
 
#define IF_SYN_TIME(p)   (p)
 
#define UNREF_BUFSTATE_EXTMATCH(bs)   unref_extmatch((bs)->bs_extmatch)
 
#define UNREF_STATEITEM_EXTMATCH(si)   unref_extmatch((si)->si_extmatch)
 
#define ITEM_START   0
 
#define ITEM_SKIP   1
 
#define ITEM_END   2
 
#define ITEM_MATCHGROUP   3
 

Typedefs

typedef struct syn_pattern synpat_T
 
typedef struct syn_cluster_S syn_cluster_T
 
typedef struct state_item stateitem_T
 

Enumerations

enum  { EXP_SUBCMD, EXP_CASE, EXP_SPELL, EXP_SYNC }
 

Functions

void syn_set_timeout (proftime_T *tm)
 
void syntax_start (win_T *wp, linenr_T lnum)
 
void syn_stack_free_all (synblock_T *block)
 
void syn_stack_apply_changes (buf_T *buf)
 
void syntax_end_parsing (linenr_T lnum)
 
bool syntax_check_changed (linenr_T lnum)
 
int get_syntax_attr (const colnr_T col, bool *const can_spell, const bool keep_state)
 
void syntax_clear (synblock_T *block)
 
void reset_synblock (win_T *wp)
 
void syn_maybe_enable (void)
 
void ex_syntax (exarg_T *eap)
 
void ex_ownsyntax (exarg_T *eap)
 
bool syntax_present (win_T *win)
 
void reset_expand_highlight (void)
 
void set_context_in_echohl_cmd (expand_T *xp, const char *arg)
 
void set_context_in_syntax_cmd (expand_T *xp, const char *arg)
 
char * get_syntax_name (expand_T *xp, int idx)
 
int syn_get_id (win_T *wp, long lnum, colnr_T col, int trans, bool *spellp, int keep_state)
 
int get_syntax_info (int *seqnrp)
 
int syn_get_concealed_id (win_T *wp, linenr_T lnum, colnr_T col)
 
int syn_get_sub_char (void)
 
int syn_get_stack_item (int i)
 
int syn_get_foldlevel (win_T *wp, long lnum)
 
void ex_syntime (exarg_T *eap)
 
char * get_syntime_arg (expand_T *xp, int idx)
 

Macro Definition Documentation

◆ CLUSTER_ADD

#define CLUSTER_ADD   2

◆ CLUSTER_REPLACE

#define CLUSTER_REPLACE   1

◆ CLUSTER_SUBTRACT

#define CLUSTER_SUBTRACT   3

◆ CUR_STATE

#define CUR_STATE (   idx)    ((stateitem_T *)(current_state.ga_data))[idx]

◆ HI2KE

#define HI2KE (   hi)    HIKEY2KE((hi)->hi_key)

◆ HIKEY2KE

#define HIKEY2KE (   p)    ((keyentry_T *)((p) - (dumkey.keyword - (char_u *)&dumkey)))

◆ ID_LIST_ALL

#define ID_LIST_ALL   ((int16_t *)-1)

◆ IF_SYN_TIME

#define IF_SYN_TIME (   p)    (p)

◆ INVALID_STATE

#define INVALID_STATE (   ssp)    ((ssp)->ga_itemsize == 0)

◆ ITEM_END

#define ITEM_END   2

◆ ITEM_MATCHGROUP

#define ITEM_MATCHGROUP   3

◆ ITEM_SKIP

#define ITEM_SKIP   1

◆ ITEM_START

#define ITEM_START   0

◆ KE2HIKEY

#define KE2HIKEY (   kp)    ((kp)->keyword)

◆ KEYWORD_IDX

#define KEYWORD_IDX   (-1)

◆ MAX_CLUSTER_ID

#define MAX_CLUSTER_ID   (32767 - SYNID_CLUSTER)

◆ MAX_SYN_INC_TAG

#define MAX_SYN_INC_TAG   999

◆ MAXKEYWLEN

#define MAXKEYWLEN   80

◆ NONE_IDX

#define NONE_IDX   (-2)

◆ SF_CCOMMENT

#define SF_CCOMMENT   0x01

◆ SF_MATCH

#define SF_MATCH   0x02

◆ SPO_COUNT

#define SPO_COUNT   7

◆ SPO_HE_OFF

#define SPO_HE_OFF   3

◆ SPO_HS_OFF

#define SPO_HS_OFF   2

◆ SPO_LC_OFF

#define SPO_LC_OFF   6

◆ SPO_ME_OFF

#define SPO_ME_OFF   1

◆ SPO_MS_OFF

#define SPO_MS_OFF   0

◆ SPO_RE_OFF

#define SPO_RE_OFF   5

◆ SPO_RS_OFF

#define SPO_RS_OFF   4

◆ SPTYPE_END

#define SPTYPE_END   3

◆ SPTYPE_MATCH

#define SPTYPE_MATCH   1

◆ SPTYPE_SKIP

#define SPTYPE_SKIP   4

◆ SPTYPE_START

#define SPTYPE_START   2

◆ SYN_CLSTR

#define SYN_CLSTR (   buf)    ((syn_cluster_T *)((buf)->b_syn_clusters.ga_data))

◆ SYN_ITEMS

#define SYN_ITEMS (   buf)    ((synpat_T *)((buf)->b_syn_patterns.ga_data))

◆ SYN_STATE_P

#define SYN_STATE_P (   ssp)    ((bufstate_T *)((ssp)->ga_data))

◆ SYNID_ALLBUT

#define SYNID_ALLBUT   MAX_HL_ID

◆ SYNID_CLUSTER

#define SYNID_CLUSTER   23000

◆ SYNID_CONTAINED

#define SYNID_CONTAINED   22000

◆ SYNID_TOP

#define SYNID_TOP   21000

◆ UNREF_BUFSTATE_EXTMATCH

#define UNREF_BUFSTATE_EXTMATCH (   bs)    unref_extmatch((bs)->bs_extmatch)

◆ UNREF_STATEITEM_EXTMATCH

#define UNREF_STATEITEM_EXTMATCH (   si)    unref_extmatch((si)->si_extmatch)

◆ VALID_STATE

#define VALID_STATE (   ssp)    ((ssp)->ga_itemsize != 0)

Typedef Documentation

◆ stateitem_T

typedef struct state_item stateitem_T

◆ syn_cluster_T

typedef struct syn_cluster_S syn_cluster_T

◆ synpat_T

typedef struct syn_pattern synpat_T

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
EXP_SUBCMD 
EXP_CASE 
EXP_SPELL 
EXP_SYNC 

Function Documentation

◆ ex_ownsyntax()

void ex_ownsyntax ( exarg_T eap)

◆ ex_syntax()

void ex_syntax ( exarg_T eap)

◆ ex_syntime()

void ex_syntime ( exarg_T eap)

◆ get_syntax_attr()

int get_syntax_attr ( const colnr_T  col,
bool *const  can_spell,
const bool  keep_state 
)

Gets highlight attributes for next character. Must first call syntax_start() once for the line. "col" is normally 0 for the first use in a line, and increments by one each time. It's allowed to skip characters and to stop before the end of the line. But only a "col" after a previously used column is allowed. When "can_spell" is not NULL set it to TRUE when spell-checking should be done.

Parameters
keep_statekeep state of char at "col"
Returns
highlight attributes for next character.

◆ get_syntax_info()

int get_syntax_info ( int *  seqnrp)

◆ get_syntax_name()

char* get_syntax_name ( expand_T xp,
int  idx 
)

◆ get_syntime_arg()

char* get_syntime_arg ( expand_T xp,
int  idx 
)

◆ reset_expand_highlight()

void reset_expand_highlight ( void  )

◆ reset_synblock()

void reset_synblock ( win_T wp)

◆ set_context_in_echohl_cmd()

void set_context_in_echohl_cmd ( expand_T xp,
const char *  arg 
)

◆ set_context_in_syntax_cmd()

void set_context_in_syntax_cmd ( expand_T xp,
const char *  arg 
)

◆ syn_get_concealed_id()

int syn_get_concealed_id ( win_T wp,
linenr_T  lnum,
colnr_T  col 
)

Get the sequence number of the concealed file position.

Returns
seqnr if the file position is concealed, 0 otherwise.

◆ syn_get_foldlevel()

int syn_get_foldlevel ( win_T wp,
long  lnum 
)

◆ syn_get_id()

int syn_get_id ( win_T wp,
long  lnum,
colnr_T  col,
int  trans,
bool spellp,
int  keep_state 
)

Function called for expression evaluation: get syntax ID at file position.

Parameters
transremove transparency
spellpreturn: can do spell checking
keep_statekeep state of char at "col"

◆ syn_get_stack_item()

int syn_get_stack_item ( int  i)

◆ syn_get_sub_char()

int syn_get_sub_char ( void  )

◆ syn_maybe_enable()

void syn_maybe_enable ( void  )

◆ syn_set_timeout()

void syn_set_timeout ( proftime_T tm)

◆ syn_stack_apply_changes()

void syn_stack_apply_changes ( buf_T buf)

◆ syn_stack_free_all()

void syn_stack_free_all ( synblock_T block)

◆ syntax_check_changed()

bool syntax_check_changed ( linenr_T  lnum)

This will only be called just after get_syntax_attr() for the previous line, to check if the next line needs to be redrawn too.

Returns
true if the syntax at start of lnum changed since last time.

◆ syntax_clear()

void syntax_clear ( synblock_T block)

◆ syntax_end_parsing()

void syntax_end_parsing ( linenr_T  lnum)

◆ syntax_present()

bool syntax_present ( win_T win)

◆ syntax_start()

void syntax_start ( win_T wp,
linenr_T  lnum 
)