diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-02-14 15:14:38 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-02-14 16:23:04 -0500 |
commit | cc2dce45d09fab2ec2269924942fdca7d5643e63 (patch) | |
tree | 8ee4ddef759fd8b995ca5672eaf9bd537faa4dd5 /src/nvim/syntax.c | |
parent | 6c9c08c3703b2044bce2cdd5b20e66222cf46483 (diff) | |
download | rneovim-cc2dce45d09fab2ec2269924942fdca7d5643e63.tar.gz rneovim-cc2dce45d09fab2ec2269924942fdca7d5643e63.tar.bz2 rneovim-cc2dce45d09fab2ec2269924942fdca7d5643e63.zip |
startup: Avoid VimL global. Introduce TriState enum.
- `syntax_on` is documented. Rather than introduce a new undocumented
VimL global `g:syntax_off`, use a module-local flag.
- Rename "maybe" functions to follow style guidelines (use standard
module prefix)
Diffstat (limited to 'src/nvim/syntax.c')
-rw-r--r-- | src/nvim/syntax.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index ce19320331..b7d8a19de9 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -41,6 +41,8 @@ #include "nvim/os/os.h" #include "nvim/os/time.h" +static bool did_syntax_onoff = false; + // Structure that stores information about a highlight group. // The ID of a highlight group is also called group ID. It is the index in // the highlight_ga array PLUS ONE. @@ -3288,19 +3290,24 @@ static void syn_cmd_off(exarg_T *eap, int syncing) static void syn_cmd_onoff(exarg_T *eap, char *name) FUNC_ATTR_NONNULL_ALL { + did_syntax_onoff = true; eap->nextcmd = check_nextcmd(eap->arg); if (!eap->skip) { - syn_cmd(name); + char buf[100]; + strncpy(buf, "so ", 3); + vim_snprintf(buf + 3, sizeof(buf) - 3, SYNTAX_FNAME, name); + do_cmdline_cmd(buf); } } -void syn_cmd(char *name) - FUNC_ATTR_NONNULL_ALL +void syn_maybe_on(void) { - char buf[100]; - strncpy(buf, "so ", 3); - vim_snprintf(buf + 3, sizeof(buf) - 3, SYNTAX_FNAME, name); - do_cmdline_cmd(buf); + if (!did_syntax_onoff) { + exarg_T ea; + ea.arg = (char_u *)""; + ea.skip = false; + syn_cmd_onoff(&ea, "syntax"); + } } /* |