~ubuntu-branches/debian/sid/neovim/sid

« back to all changes in this revision

Viewing changes to src/nvim/syntax.c

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2016-04-18 21:42:19 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20160418214219-1e6d4o1fwqarzk46
Tags: 0.1.3-1
* New upstream release.  (Closes: #820562)
* debian/control:
  + Remove unnecessary luarocks Build-Depends
  + Add libkvm-dev Build-Depends for kfreebsd-*
  + Add python(3)-neovim to Recommends.  (Closes: #812737)
  + Declare compiance with policy 3.9.8, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
#include "nvim/os/os.h"
42
42
#include "nvim/os/time.h"
43
43
 
 
44
static bool did_syntax_onoff = false;
 
45
 
44
46
// Structure that stores information about a highlight group.
45
47
// The ID of a highlight group is also called group ID.  It is the index in
46
48
// the highlight_ga array PLUS ONE.
3004
3006
    return;
3005
3007
 
3006
3008
  next = skiptowhite(arg);
3007
 
  if (STRNICMP(arg, "toplevel", 8) == 0 && next - arg == 8)
 
3009
  if (STRNICMP(arg, "toplevel", 8) == 0 && next - arg == 8) {
3008
3010
    curwin->w_s->b_syn_spell = SYNSPL_TOP;
3009
 
  else if (STRNICMP(arg, "notoplevel", 10) == 0 && next - arg == 10)
 
3011
  } else if (STRNICMP(arg, "notoplevel", 10) == 0 && next - arg == 10) {
3010
3012
    curwin->w_s->b_syn_spell = SYNSPL_NOTOP;
3011
 
  else if (STRNICMP(arg, "default", 7) == 0 && next - arg == 7)
 
3013
  } else if (STRNICMP(arg, "default", 7) == 0 && next - arg == 7) {
3012
3014
    curwin->w_s->b_syn_spell = SYNSPL_DEFAULT;
3013
 
  else
 
3015
  } else {
3014
3016
    EMSG2(_("E390: Illegal argument: %s"), arg);
 
3017
    return;
 
3018
  }
 
3019
 
 
3020
  // assume spell checking changed, force a redraw
 
3021
  redraw_win_later(curwin, NOT_VALID);
3015
3022
}
3016
3023
 
3017
3024
/*
3281
3288
}
3282
3289
 
3283
3290
static void syn_cmd_onoff(exarg_T *eap, char *name)
 
3291
  FUNC_ATTR_NONNULL_ALL
3284
3292
{
3285
 
  char buf[100];
3286
 
 
 
3293
  did_syntax_onoff = true;
3287
3294
  eap->nextcmd = check_nextcmd(eap->arg);
3288
3295
  if (!eap->skip) {
3289
 
    strcpy(buf, "so ");
 
3296
    char buf[100];
 
3297
    strncpy(buf, "so ", 4);
3290
3298
    vim_snprintf(buf + 3, sizeof(buf) - 3, SYNTAX_FNAME, name);
3291
3299
    do_cmdline_cmd(buf);
3292
3300
  }
3293
3301
}
3294
3302
 
 
3303
void syn_maybe_on(void)
 
3304
{
 
3305
  if (!did_syntax_onoff) {
 
3306
    exarg_T ea;
 
3307
    ea.arg = (char_u *)"";
 
3308
    ea.skip = false;
 
3309
    syn_cmd_onoff(&ea, "syntax");
 
3310
  }
 
3311
}
 
3312
 
3295
3313
/*
3296
3314
 * Handle ":syntax [list]" command: list current syntax words.
3297
3315
 */
4183
4201
            break;
4184
4202
          if (p[1] == NUL) {
4185
4203
            EMSG2(_("E789: Missing ']': %s"), kw);
4186
 
            kw = p + 2;                       /* skip over the NUL */
4187
 
            break;
 
4204
            goto error;
4188
4205
          }
4189
4206
          if (p[1] == ']') {
4190
 
            kw = p + 1;                       /* skip over the "]" */
4191
 
            break;
 
4207
            if (p[2] != NUL) {
 
4208
              EMSG3(_("E890: trailing char after ']': %s]%s"),
 
4209
                    kw, &p[2]);
 
4210
              goto error;
 
4211
            }
 
4212
            kw = p + 1;
 
4213
            break;   // skip over the "]"
4192
4214
          }
4193
4215
          if (has_mbyte) {
4194
4216
            int l = (*mb_ptr2len)(p + 1);
4203
4225
      }
4204
4226
    }
4205
4227
 
 
4228
error:
4206
4229
    xfree(keyword_copy);
4207
4230
    xfree(syn_opt_arg.cont_in_list);
4208
4231
    xfree(syn_opt_arg.next_list);
4843
4866
  int idx;
4844
4867
  char_u      *cpo_save;
4845
4868
 
4846
 
  /* need at least three chars */
4847
 
  if (arg == NULL || arg[1] == NUL || arg[2] == NUL)
 
4869
  // need at least three chars
 
4870
  if (arg == NULL || arg[0] == NUL || arg[1] == NUL || arg[2] == NUL) {
4848
4871
    return NULL;
 
4872
  }
4849
4873
 
4850
4874
  end = skip_regexp(arg + 1, *arg, TRUE, NULL);
4851
4875
  if (*end != *arg) {                       /* end delimiter not found */
5395
5419
  if (curwin->w_s == &curwin->w_buffer->b_s) {
5396
5420
    curwin->w_s = xmalloc(sizeof(synblock_T));
5397
5421
    memset(curwin->w_s, 0, sizeof(synblock_T));
5398
 
    // TODO: Keep the spell checking as it was.
5399
 
    curwin->w_p_spell = FALSE;          /* No spell checking */
 
5422
    hash_init(&curwin->w_s->b_keywtab);
 
5423
    hash_init(&curwin->w_s->b_keywtab_ic);
 
5424
    // TODO: Keep the spell checking as it was. NOLINT(readability/todo)
 
5425
    curwin->w_p_spell = false;  // No spell checking
5400
5426
    clear_string_option(&curwin->w_s->b_p_spc);
5401
5427
    clear_string_option(&curwin->w_s->b_p_spf);
5402
5428
    clear_string_option(&curwin->w_s->b_p_spl);
5507
5533
}
5508
5534
 
5509
5535
 
5510
 
/*
5511
 
 * Function called for expression evaluation: get syntax ID at file position.
5512
 
 */
5513
 
int 
5514
 
syn_get_id (
 
5536
// Function called for expression evaluation: get syntax ID at file position.
 
5537
int syn_get_id(
5515
5538
    win_T *wp,
5516
5539
    long lnum,
5517
5540
    colnr_T col,
5518
 
    int trans,                  /* remove transparency */
5519
 
    bool *spellp,               /* return: can do spell checking */
5520
 
    int keep_state              /* keep state of char at "col" */
 
5541
    int trans,      // remove transparency
 
5542
    bool *spellp,   // return: can do spell checking
 
5543
    int keep_state  // keep state of char at "col"
5521
5544
)
5522
5545
{
5523
 
  /* When the position is not after the current position and in the same
5524
 
   * line of the same buffer, need to restart parsing. */
 
5546
  // When the position is not after the current position and in the same
 
5547
  // line of the same buffer, need to restart parsing.
5525
5548
  if (wp->w_buffer != syn_buf
5526
5549
      || lnum != current_lnum
5527
 
      || col < current_col)
 
5550
      || col < current_col) {
5528
5551
    syntax_start(wp, lnum);
 
5552
  } else if (wp->w_buffer == syn_buf
 
5553
             && lnum == current_lnum
 
5554
             && col > current_col) {
 
5555
      // next_match may not be correct when moving around, e.g. with the
 
5556
      // "skip" expression in searchpair()
 
5557
      next_match_idx = -1;
 
5558
  }
5529
5559
 
5530
5560
  (void)get_syntax_attr(col, spellp, keep_state);
5531
5561
 
6365
6395
            HL_TABLE()[idx].sg_cterm_bg = color + 1;
6366
6396
            if (is_normal_group) {
6367
6397
              cterm_normal_bg_color = color + 1;
6368
 
              {
 
6398
              if (!ui_rgb_attached()) {
6369
6399
                must_redraw = CLEAR;
6370
6400
                if (color >= 0) {
6371
6401
                  if (t_colors < 16)