diff --git a/EXAMPLES.md b/EXAMPLES.md index c56307e..2acf99a 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -240,10 +240,10 @@ So, let's define a custom mapping for `#`. if !exists('g:easy_align_delimiters') let g:easy_align_delimiters = {} endif -let g:easy_align_delimiters['#'] = { 'pattern': '#', 'ignores': ['String'] } +let g:easy_align_delimiters['#'] = { 'pattern': '#', 'ignore_groups': ['String'] } ``` -Notice that the rule overrides `ignores` attribute in order *not to ignore* +Notice that the rule overrides `ignore_groups` attribute in order *not to ignore* delimiters highlighted as comments. Then on `#`, we get @@ -285,7 +285,7 @@ let g:easy_align_ignore_unmatched = 0 " 3. Update the alignment rule with ignore_unmatched option let g:easy_align_delimiters['#'] = { - \ 'pattern': '#', 'ignores': ['String'], 'ignore_unmatched': 0 } + \ 'pattern': '#', 'ignore_groups': ['String'], 'ignore_unmatched': 0 } ``` Then we get, diff --git a/README.md b/README.md index 85f16db..e0417ec 100644 --- a/README.md +++ b/README.md @@ -194,28 +194,40 @@ lowest precedence. ### List of options -| Option | Type | Default | Description | -| ------------------ | ----------------- | --------------------- | ------------------------------------------------------- | -| `left_margin` | number | 0 | Number of spaces to attach before delimiter | -| `left_margin` | string | `''` | String to attach before delimiter | -| `right_margin` | number | 0 | Number of spaces to attach after delimiter | -| `right_margin` | string | `''` | String to attach after delimiter | -| `stick_to_left` | boolean | 0 | Whether to position delimiter on the left-side | -| `ignore_unmatched` | boolean | 1 | Whether to ignore lines without matching delimiter | -| `ignores` | list | ['String', 'Comment'] | Delimiters in these syntax highlight groups are ignored | -| `indentation` | string | `k` | Indentation method (*k*eep, *d*eep, *s*hallow, *n*one) | -| `delimiter_align` | string | `r` | Determines how to align delimiters of different lengths | -| `mode_sequence` | string | | Alignment modes for multiple occurrences of delimiters | +| Option | Type | Default | Description | +| ------------------ | ------- | --------------------- | ------------------------------------------------------- | +| `left_margin` | number | 0 | Number of spaces to attach before delimiter | +| `left_margin` | string | `''` | String to attach before delimiter | +| `right_margin` | number | 0 | Number of spaces to attach after delimiter | +| `right_margin` | string | `''` | String to attach after delimiter | +| `stick_to_left` | boolean | 0 | Whether to position delimiter on the left-side | +| `ignore_groups` | list | ['String', 'Comment'] | Delimiters in these syntax highlight groups are ignored | +| `ignore_unmatched` | boolean | 1 | Whether to ignore lines without matching delimiter | +| `indentation` | string | `k` | Indentation method (*k*eep, *d*eep, *s*hallow, *n*one) | +| `delimiter_align` | string | `r` | Determines how to align delimiters of different lengths | +| `mode_sequence` | string | | Alignment modes for multiple occurrences of delimiters | Some of the options can be specified using corresponding global variables. | Option | Global variable | | ------------------ | ------------------------------- | +| `ignore_groups` | `g:easy_align_ignore_groups` | | `ignore_unmatched` | `g:easy_align_ignore_unmatched` | -| `ignores` | `g:easy_align_ignores` | | `delimiter_align` | `g:easy_align_delimiter_align` | | `indentation` | `g:easy_align_indentation` | +In interactive mode, you can switch some of the alignment options using special +keys listed below. + +| Key | Option | Values | +| -------- | ------------------ | -------------------------------------------------- | +| `CTRL-I` | `indentation` | shallow, deep, none, keep | +| `CTRL-L` | `left_margin` | Input number or string | +| `CTRL-R` | `right_margin` | Input number or string | +| `CTRL-D` | `delimiter_align` | left, center, right | +| `CTRL-U` | `ignore_unmatched` | 0, 1 | +| `CTRL-G` | `ignore_groups` | [], ['String'], ['Comment'], ['String', 'Comment'] | + ### Ignoring delimiters in comments or strings EasyAlign can be configured to ignore delimiters in certain syntax highlight @@ -226,7 +238,7 @@ highlighted as code comments or strings are ignored. " Default: " If a delimiter is in a highlight group whose name matches " any of the followings, it will be ignored. -let g:easy_align_ignores = ['Comment', 'String'] +let g:easy_align_ignore_groups = ['Comment', 'String'] ``` For example, the following paragraph @@ -257,13 +269,15 @@ becomes as follows on `:` (or `:EasyAlign:`) Naturally, this feature only works when syntax highlighting is enabled. -You can change the default rule by using one of these 3 methods. +You can change the default rule by using one of these 4 methods. -1. Define global `g:easy_align_ignores` list -2. Define a custom alignment rule in `g:easy_align_delimiters` with `ignores` option -3. Provide `ignores` option to `:EasyAlign` command. e.g. `:EasyAlign:{'is':[]}` +1. Press `CTRL-G` in interactive mode to switch groups +2. Define global `g:easy_align_ignore_groups` list +3. Define a custom rule in `g:easy_align_delimiters` with `ignore_groups` option +4. Provide `ignore_groups` option to `:EasyAlign` command. + e.g. `:EasyAlign:{'ig':[]}` -For example if you set `ignores` option to be an empty list, you get +For example if you set `ignore_groups` option to be an empty list, you get ```ruby { @@ -307,12 +321,13 @@ this is usually what we want. } ``` -However, this default behavior is also configurable by using one of these 3 +However, this default behavior is also configurable by using one of these 4 methods. -1. Set the global `g:easy_align_ignore_unmatched` variable to 0 -2. Define a custom alignment rule with `ignore_unmatched` option set to 0 -3. Provide `ignore_unmatched` option to `:EasyAlign` command. e.g. `:EasyAlign:{'iu':0}` +1. Press `CTRL-U` in interactive mode to toggle `ignore_unmatched` option +2. Set the global `g:easy_align_ignore_unmatched` variable to 0 +3. Define a custom alignment rule with `ignore_unmatched` option set to 0 +4. Provide `ignore_unmatched` option to `:EasyAlign` command. e.g. `:EasyAlign:{'iu':0}` Then we get, @@ -362,6 +377,8 @@ banana += apple cake ||= banana ``` +In interactive mode, you can change the option value with `CTRL-D` key. + ### Adjusting indentation By default :EasyAlign command keeps the original indentation of the lines. But @@ -410,6 +427,8 @@ eggplant = 5 Notice that `idt` is fuzzy-matched to `indentation`. +In interactive mode, you can change the option value with `CTRL-I` key. + ### Left/right/center mode switch in interactive mode In interactive mode, you can choose the alignment mode you want by pressing @@ -489,8 +508,8 @@ you can extend the rules by setting a dictionary named `g:easy_align_delimiters` ```vim let g:easy_align_delimiters = { \ '>': { 'pattern': '>>\|=>\|>' }, -\ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignores': ['String'] }, -\ '#': { 'pattern': '#\+', 'ignores': ['String'], 'delimiter_align': 'l' }, +\ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignore_groups': ['String'] }, +\ '#': { 'pattern': '#\+', 'ignore_groups': ['String'], 'delimiter_align': 'l' }, \ ']': { \ 'pattern': '[[\]]', \ 'left_margin': 0, diff --git a/autoload/easy_align.vim b/autoload/easy_align.vim index 223f466..2d441a7 100644 --- a/autoload/easy_align.vim +++ b/autoload/easy_align.vim @@ -44,8 +44,15 @@ let s:mode_labels = { 'l': '', 'r': '[R]', 'c': '[C]' } let s:known_options = { \ 'margin_left': [0, 1], 'margin_right': [0, 1], 'stick_to_left': [0], \ 'left_margin': [0, 1], 'right_margin': [0, 1], 'indentation': [1], -\ 'ignores': [3 ], 'ignore_unmatched': [0 ], 'delimiter_align': [1], -\ 'mode_sequence': [1 ] +\ 'ignore_groups': [3 ], 'ignore_unmatched': [0 ], 'delimiter_align': [1], +\ 'mode_sequence': [1 ], 'ignores': [3] +\ } + +let s:option_values = { +\ 'indentation': ['shallow', 'deep', 'none', 'keep'], +\ 'delimiter_align': ['left', 'center', 'right'], +\ 'ignore_unmatched': [0, 1], +\ 'ignore_groups': [[], ['String'], ['Comment'], ['String', 'Comment']] \ } if exists("*strwidth") @@ -72,17 +79,19 @@ endfunction function! s:ignored_syntax() if has('syntax') && exists('g:syntax_on') " Backward-compatibility - return get(g:, 'easy_align_ignores', - \ (get(g:, 'easy_align_ignore_comment', 1) == 0) ? - \ ['String'] : ['String', 'Comment']) + return get(g:, 'easy_align_ignore_groups', + \ get(g:, 'easy_align_ignores', + \ (get(g:, 'easy_align_ignore_comment', 1) == 0) ? + \ ['String'] : ['String', 'Comment'])) else return [] endif endfunction -function! s:echon(l, n, d) +function! s:echon(l, n, d, o) echon "\r" echon "\rEasyAlign". s:mode_labels[a:l] ." (" .a:n.a:d. ")" + \ . (empty(a:o) ? '' : ' '.string(a:o)) endfunction function! s:exit(msg) @@ -106,9 +115,18 @@ function! s:fuzzy_lu(key) if has_key(s:known_options, a:key) return a:key endif + let key = tolower(a:key) - let regexp = '^' . substitute(substitute(a:key, '-', '_', 'g'), '\(.\)', '\1.*', 'g') - let matches = filter(keys(s:known_options), 'v:val =~ regexp') + " stl -> ^s.*_t.*_l.* + let regexp1 = '^' .key[0]. '.*' .substitute(key[1 : -1], '\(.\)', '_\1.*', 'g') + let matches = filter(keys(s:known_options), 'v:val =~ regexp1') + if len(matches) == 1 + return matches[0] + endif + + " stl -> ^s.*t.*l.* + let regexp2 = '^' . substitute(substitute(key, '-', '_', 'g'), '\(.\)', '\1.*', 'g') + let matches = filter(keys(s:known_options), 'v:val =~ regexp2') if empty(matches) call s:exit("Unknown option key: ". a:key) @@ -116,9 +134,12 @@ function! s:fuzzy_lu(key) return matches[0] else " Avoid ambiguity introduced by deprecated margin_left and margin_right - if index(matches, 'mode_sequence') != -1 + if sort(matches) == ['margin_left', 'margin_right', 'mode_sequence'] return 'mode_sequence' endif + if sort(matches) == ['ignore_groups', 'ignores'] + return 'ignore_groups' + endif call s:exit("Ambiguous option key: ". a:key ." (" .join(matches, ', '). ")") endif endfunction @@ -156,7 +177,7 @@ function! s:validate_options(opts) return a:opts endfunction -function! s:split_line(line, nth, modes, cycle, fc, lc, pattern, stick_to_left, ignore_unmatched, ignores) +function! s:split_line(line, nth, modes, cycle, fc, lc, pattern, stick_to_left, ignore_unmatched, ignore_groups) let mode = '' let string = a:lc ? @@ -189,7 +210,7 @@ function! s:split_line(line, nth, modes, cycle, fc, lc, pattern, stick_to_left, let [match, part, delim] = matches[1 : 3] endif - let ignorable = s:highlighted_as(a:line, idx + len(part) + a:fc, a:ignores) + let ignorable = s:highlighted_as(a:line, idx + len(part) + a:fc, a:ignore_groups) if ignorable let token .= match else @@ -212,7 +233,7 @@ function! s:split_line(line, nth, modes, cycle, fc, lc, pattern, stick_to_left, let leftover = token . strpart(string, idx) if !empty(leftover) - let ignorable = s:highlighted_as(a:line, len(string) + a:fc - 1, a:ignores) + let ignorable = s:highlighted_as(a:line, len(string) + a:fc - 1, a:ignore_groups) call add(tokens, leftover) call add(delims, '') endif @@ -249,7 +270,7 @@ function! s:max(old, new) endfunction function! s:do_align(modes, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth, - \ ml, mr, da, indentation, stick_to_left, ignore_unmatched, ignores, recur) + \ ml, mr, da, indentation, stick_to_left, ignore_unmatched, ignore_groups, recur) let mode = a:modes[0] let lines = {} let min_indent = -1 @@ -263,7 +284,7 @@ function! s:do_align(modes, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth let [tokens, delims] = s:split_line( \ line, a:nth, copy(a:modes), a:recur == 2, \ a:fc, a:lc, a:pattern, - \ a:stick_to_left, a:ignore_unmatched, a:ignores) + \ a:stick_to_left, a:ignore_unmatched, a:ignore_groups) " Remember tokens for subsequent recursive calls let a:all_tokens[line] = tokens @@ -434,17 +455,31 @@ function! s:do_align(modes, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth \ a:modes, a:all_tokens, a:all_delims, \ a:fl, a:ll, a:fc, a:lc, a:pattern, \ a:nth + 1, a:ml, a:mr, a:da, a:indentation, a:stick_to_left, - \ a:ignore_unmatched, a:ignores, a:recur) + \ a:ignore_unmatched, a:ignore_groups, a:recur) endif endfunction +function! s:input(str) + redraw + call inputsave() + let got = input(a:str) + call inputrestore() + try + return eval(got) + catch + return got + endtry +endfunction + function! s:interactive(modes) let mode = s:shift(a:modes, 1) let n = '' let ch = '' + let opts = {} + let vals = deepcopy(s:option_values) while 1 - call s:echon(mode, n, '') + call s:echon(mode, n, '', opts) let c = getchar() let ch = nr2char(c) @@ -471,11 +506,23 @@ function! s:interactive(modes) if n[0] == '*' | break else | let n = n . ch end + elseif ch == "\" + let opts['da'] = s:shift(vals['delimiter_align'], 1) + elseif ch == "\" + let opts['idt'] = s:shift(vals['indentation'], 1) + elseif ch == "\" + let opts['lm'] = s:input("Left margin: ") + elseif ch == "\" + let opts['rm'] = s:input("Right margin: ") + elseif ch == "\" + let opts['iu'] = s:shift(vals['ignore_unmatched'], 1) + elseif ch == "\" + let opts['ig'] = s:shift(vals['ignore_groups'], 1) else break endif endwhile - return [mode, n, ch] + return [mode, n, ch, s:normalize_options(opts)] endfunction function! s:parse_args(args) @@ -483,7 +530,7 @@ function! s:parse_args(args) let ch = '' let args = a:args let cand = '' - let option = {} + let opts = {} " Poor man's option parser let idx = 0 @@ -497,7 +544,7 @@ function! s:parse_args(args) let [L, R, C, K, S, D, N] = ['l', 'r', 'c', 'k', 's', 'd', 'n'] let o = eval(cand) if type(o) == 4 - let option = o + let opts = o if args[midx - 1 : midx] == '\ ' let midx += 1 endif @@ -511,8 +558,10 @@ function! s:parse_args(args) endwhile " Invalid option dictionary - if len(substitute(cand, '\s', '', 'g')) > 2 && empty(option) + if len(substitute(cand, '\s', '', 'g')) > 2 && empty(opts) call s:exit("Invalid option: ". cand) + else + let opts = s:normalize_options(opts) endif " Has /Regexp/? @@ -525,10 +574,10 @@ function! s:parse_args(args) try | call matchlist('', regexp) catch | call s:exit("Invalid regular expression: ". regexp) endtry - return [matches[1], regexp, option, 1] + return [matches[1], regexp, opts, 1] else let tokens = matchlist(args, '^\([1-9][0-9]*\|-[0-9]*\|\*\*\?\)\?\s*\(.\{-}\)\?$') - return [tokens[1], tokens[2], option, 0] + return [tokens[1], tokens[2], opts, 0] endif endfunction @@ -540,16 +589,17 @@ function! easy_align#align(bang, expr) range let recur = 0 let n = '' let ch = '' - let option = {} + let opts = {} + let iopts = {} let regexp = 0 try if empty(a:expr) - let [mode, n, ch] = s:interactive(copy(modes)) + let [mode, n, ch, iopts] = s:interactive(copy(modes)) else - let [n, ch, option, regexp] = s:parse_args(a:expr) + let [n, ch, opts, regexp] = s:parse_args(a:expr) if empty(n) && empty(ch) - let [mode, n, ch] = s:interactive(copy(modes)) + let [mode, n, ch, iopts] = s:interactive(copy(modes)) elseif empty(ch) " Try swapping n and ch let [n, ch] = ['', n] @@ -595,13 +645,11 @@ function! easy_align#align(bang, expr) range let dict = delimiters[ch] endif - try - if !empty(option) - let dict = extend(copy(dict), s:normalize_options(option)) + for opt in [opts, iopts] + if !empty(opt) + let dict = extend(copy(dict), opt) endif - catch 'exit' - return - endtry + endfor let ml = get(dict, 'left_margin', ' ') let mr = get(dict, 'right_margin', ' ') @@ -628,13 +676,13 @@ function! easy_align#align(bang, expr) range \ nth, \ ml, \ mr, - \ get(dict, 'delimiter_align', get(g:, 'easy_align_delimiter_align', 'r')), - \ get(dict, 'indentation', get(g:, 'easy_align_indentation', 'k')), + \ get(dict, 'delimiter_align', get(g:, 'easy_align_delimiter_align', 'r'))[0], + \ get(dict, 'indentation', get(g:, 'easy_align_indentation', 'k'))[0], \ get(dict, 'stick_to_left', 0), \ get(dict, 'ignore_unmatched', get(g:, 'easy_align_ignore_unmatched', 1)), - \ get(dict, 'ignores', s:ignored_syntax()), + \ get(dict, 'ignore_groups', get(dict, 'ignores', s:ignored_syntax())), \ recur) - call s:echon(mode, n, regexp ? '/'.ch.'/' : ch) + call s:echon(mode, n, regexp ? '/'.ch.'/' : ch, iopts) catch 'exit' endtry endfunction diff --git a/doc/easy_align.txt b/doc/easy_align.txt index 19089a9..cdae827 100644 --- a/doc/easy_align.txt +++ b/doc/easy_align.txt @@ -116,21 +116,7 @@ You can even omit spaces between the arguments, so concisely (or cryptically): - :EasyAlign*/[:;]\+/{'s':1,'l':''} -Available options are as follows. - -| Atrribute | Type | Default | -| ---------------- | ---------------- | ----------------------------- | -| left_margin | number or string | 0 | -| right_margin | number or string | 0 | -| stick_to_left | boolean | 0 | -| ignore_unmatched | boolean | 1 | -| ignores | array | ['String', 'Comment'] | -| delimiter_align | string | 'r' | -| | | (right, left, center) | -| indentation | string | 'k' | -| | | (keep, shallow, deep, none) | -| mode_sequence | string | (Depends on field number and | -| | | selected alignment mode) | +Available options will be shown later in the document. Partial alignment in blockwise-visual mode @@ -140,7 +126,50 @@ In blockwise-visual mode (CTRL-V), EasyAlign command aligns only the selected text in the block, instead of the whole lines in the range. -Ignoring delimiters in comments or strings *g:easy_align_ignores* +Alignment options +------------------------------------------------------------------------- + +Available options are as follows. + +| Atrribute | Type | Default | +| ---------------- | ---------------- | ----------------------------- | +| left_margin | number or string | 0 | +| right_margin | number or string | 0 | +| stick_to_left | boolean | 0 | +| ignore_unmatched | boolean | 1 | +| ignore_groups | array | ['String', 'Comment'] | +| delimiter_align | string | 'r' | +| | | (right, left, center) | +| indentation | string | 'k' | +| | | (keep, shallow, deep, none) | +| mode_sequence | string | (Depends on field number and | +| | | selected alignment mode) | + + +Some of the options can be specified using corresponding global variables. + +| Option | Global variable | +| ------------------ | ------------------------------- | +| ignore_groups | `g:easy_align_ignore_groups` | +| ignore_unmatched | `g:easy_align_ignore_unmatched` | +| delimiter_align | `g:easy_align_delimiter_align` | +| indentation | `g:easy_align_indentation` | + + +In interactive mode, you can switch some of the alignment options using special +keys listed below. + +| Key | Option | Values | +| ------ | ---------------- | -------------------------------------------------- | +| CTRL-I | indentation | shallow, deep, none, keep | +| CTRL-L | left_margin | Input number or string | +| CTRL-R | right_margin | Input number or string | +| CTRL-D | delimiter_align | left, center, right | +| CTRL-U | ignore_unmatched | 0, 1 | +| CTRL-G | ignore_groups | [], ['String'], ['Comment'], ['String', 'Comment'] | + + +Ignoring delimiters in comments or strings *g:easy_align_ignore_groups* ------------------------------------------------------------------------- EasyAlign can be configured to ignore delimiters in certain syntax @@ -150,7 +179,7 @@ that are highlighted as code comments or strings are ignored. " Default: " If a delimiter is in a highlight group whose name matches " any of the followings, it will be ignored. - let g:easy_align_ignores = ['Comment', 'String'] + let g:easy_align_ignore_groups = ['Comment', 'String'] For example, the following paragraph @@ -176,13 +205,15 @@ becomes as follows on ':' (or `:EasyAlign:`) Naturally, this feature only works when syntax highlighting is enabled. -You can change the default rule by using one of these 3 methods. +You can change the default rule by using one of these 4 methods. -1. Define global `g:easy_align_ignores` list -2. Define a custom rule in `g:easy_align_delimiters` with 'ignores' option -3. Provide 'ignores' option to `:EasyAlign` command. e.g. :EasyAlign:{'is':[]} +1. Press CTRL-G in interactive mode to switch groups +2. Define global `g:easy_align_ignore_groups` list +3. Define a custom rule in `g:easy_align_delimiters` with 'ignore_groups' option +4. Provide 'ignore_groups' option to `:EasyAlign` command. + e.g. :EasyAlign:{'is':[]} -For example if you set 'ignores' option to be an empty list, you get +For example if you set 'ignore_groups' option to be an empty list, you get { # Quantity of apples: 1 @@ -220,12 +251,13 @@ this is usually what we want. grapefruits: 3 } -However, this default behavior is also configurable by using one of these 3 +However, this default behavior is also configurable by using one of these 4 methods. -1. Set the global `g:easy_align_ignore_unmatched` variable to 0 -2. Define a custom alignment rule with 'ignore_unmatched' option set to 0 -3. Provide 'ignore_unmatched' option to `:EasyAlign` command. +1. Press CTRL-U in interactive mode to toggle 'ignore_unmatched' option +2. Set the global `g:easy_align_ignore_unmatched` variable to 0 +3. Define a custom alignment rule with 'ignore_unmatched' option set to 0 +4. Provide 'ignore_unmatched' option to `:EasyAlign` command. e.g. :EasyAlign:{'iu':0} Then we get, @@ -268,6 +300,8 @@ And on ':EasyAlign={'da':c}', center-aligned. banana += apple cake ||= banana +In interactive mode, you can change the option value with `CTRL-D` key. + Adjusting indentation *g:easy_align_indentation* ------------------------------------------------------------------------- @@ -317,6 +351,8 @@ But then again we have 'indentation' option. See the following example. Notice that 'idt' is fuzzy-matched to 'indentation'. +In interactive mode, you can change the option value with `CTRL-I` key. + Left/right/center mode switch in interactive mode ------------------------------------------------------------------------- @@ -396,8 +432,8 @@ you can extend the rules by setting a dictionary named let g:easy_align_delimiters = { \ '>': { 'pattern': '>>\|=>\|>' }, - \ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignores': ['String'] }, - \ '#': { 'pattern': '#\+', 'ignores': ['String'] }, + \ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignore_groups': ['String'] }, + \ '#': { 'pattern': '#\+', 'ignore_groups': ['String'] }, \ ']': { \ 'pattern': '[[\]]', \ 'left_margin': 0, diff --git a/test/basic.expected b/test/basic.expected index 3912d48..5f6b807 100644 --- a/test/basic.expected +++ b/test/basic.expected @@ -104,6 +104,56 @@ j, , k ```ruby + a = + a = 1 + bbbb = 2 + ccccccc = 3 +ccccccccccccccc + ddd = # + eeee === eee = eee = eee = f + fff = ggg += gg &&= gg + g != hhhhhhhh == # 8 + i := 5 + i %= 5 + i *= 5 + j =~ 5 + j >= 5 + aa => 123 + aa <<= 123 + aa >>= 123 + bbb => 123 + c => 1233123 + d => 123 + dddddd &&= 123 + dddddd ||= 123 + dddddd /= 123 + gg <=> ee + +a = +a = 1 +bbbb = 2 +ccccccc = 3 +ccccccccccccccc +ddd = # +eeee === eee = eee = eee = f +fff = ggg += gg &&= gg +g != hhhhhhhh == # 8 +i := 5 +i %= 5 +i *= 5 +j =~ 5 +j >= 5 +aa => 123 +aa <<= 123 +aa >>= 123 +bbb => 123 +c => 1233123 +d => 123 +dddddd &&= 123 +dddddd ||= 123 +dddddd /= 123 +gg <=> ee + a = a = 1 bbbb = 2 diff --git a/test/basic.script b/test/basic.script index ee92770..b377b76 100644 --- a/test/basic.script +++ b/test/basic.script @@ -1 +1 @@ -4Gvipjyvip Pvip 2 Pvip * Pvip Pvip 2 Pvip * Pvip ** Pvip - Pvip -2 Pvip -1 Pvip ** 60zzvipjyvip *|Pvip *|Pvip **|80zzvip **|gv 3|vip *|90zzvip *,100zzvipjyvip =Pvip *=Pvip **=Pvip =vip 2=198Gvipjyvip =Pvip -=Pf:jj3E =209Gvip - 214zzvipjyvip #P:let g:easy_align_delimiters = { '#': {'pattern': '#\+', 'ignores': ['String'] } } vip #227zzvip :239zzvip *=vipjyP:let g:easy_align_ignores = [] vip *=:unlet g:easy_align_delimiters :unlet g:easy_align_ignores 4Gvipy4GP7Gojkkvip:EasyAlign /1/{'ml':'{{', 'mr-r':'}}'} vipjyPvip:EasyAlign */../ 263zzvipjygv .Pvip *.Pvip * .Pvip .vip 2.Pvip **.Pvip **.Pvip -.G303zzvip .310zzvipjygv *|Pvip *|Pvip |gv -|gv **|gv *|gv **|jji jjjhi vip ** |339Gpvip:EasyAlign*|{'ml': 5, 'mrr': 0 } 349Gpvip:EasyAlign*/|/{'ml':'~', 'mrr': 4} 362G:let g:easy_align_delimiters = { 'd': { 'pattern': '\s\+\(\S\+\s*[;=]\)\@=', 'left_margin': 0, 'right_margin': 0 } } vip dgv =236GvipjyPvip :377Gvip gv 2 382Gvipjyvip:EasyAlign/-\+/ Pvip:EasyAlign2/-\+/ Pvip:EasyAlign*/-\+/ Pvip:EasyAlign*/-\+/{'da': L} Pvip:EasyAlign/-\+/{'da': c} Pvip:EasyAlign*/-\+/{'delimiter_align':'C'} Pvip:EasyAlign*/-\+/{'da': 'x'} 381Gpvip:EasyAlign/-\+/{'da':r} :let g:easy_align_delimiter_align = 'l' Pvip:EasyAlign/-\+/ Pvip:EasyAlign*/-\+/ :unlet g:easy_align_delimiter_align :let g:easy_align_delimiters['\'] = { 'pattern': '-\+', 'delimiter_align': 'c' } Pvip \Pvip *-vip *\Pvip:EasyAlign *\\ {'da':l} Pvip:EasyAlign*\\ Pvip:EasyAlign*\\{'da': 'R'} 377GvipjyPvip:EasyAlign\ {'l': '@@@'} gv:EasyAlign 2 \ {'l': '{{{'} 507Gvipjygv:EasyAlign= Pvip:EasyAlign = {'idt': s} Pvip:EasyAlign= {'idt': d} Pvip:EasyAlign**={'indentation': 'd'} Pvip:EasyAlign!= Pvip:EasyAlign! **= {'indent': s} Pvip:EasyAlign!* = {'idt': D} Pvip:EasyAlign! ={'idt':'S'} 507GPvip:EasyAlign-={'idt':d} PA = 2j.j.j.j.vip:EasyAlign2={'idt': s} 507GPljjjj$:EasyAlign = {'idt': s} Pljjjj$:EasyAlign={'indent':d} Phhxxvip:EasyAlign={'idt':'s'} 525Gvipjy507GPPvip:EasyAlign*={'idt':s} Pvip:EasyAlign!**={'idt':s} Pvip:EasyAlign = {'idt': D} 525G^hhr1jr1jr1jr1jr1llkkkk$:EasyAlign = { 'idt': s } 513GvipjyPvip:EasyAlign*={'idt':n} Pvip:EasyAlign = { 'idt': N } Pvip:EasyAlign!*= {'idt': 'n'} 630Gvipjygv =Pvip =656Gvipjygv =Pvip *=Pvip **=Pvip **=Pvip:EasyAlign**= {'iu':0} Pvip =vip 2=vip -0 =818Gvipjygv =Pvip 2=Pvip *=Pvip **=Pvip **=Pvip -0=Pvip -0=855Gvip ** 860Gvip 2=}863Gvip 2=866Gvip 2=869Gvip 2=872Gvip *=875Gvip 2 878Gvip 2 881Gvip:EasyAlign**={'m': 'c','idt':s} ggjjj70GvipjyGpvip *|vipjyGpvip:EasyAlign*|{'m': 'lcr'} Gpvip:EasyAlign**|{'m':'llc'} Gpvip:s/^|// vip:EasyAlign*|{'idt':n} vip:EasyAlign**|{'m':'cl'} +4Gvipjyvip Pvip 2 Pvip * Pvip Pvip 2 Pvip * Pvip ** Pvip - Pvip -2 Pvip -1 Pvip ** 60zzvipjyvip *|Pvip *|Pvip **|80zzvip **|gv 3|vip *|90zzvip *,100zzvipjyvip =Pvip *=Pvip **=Pvip =vip 2=198Gvipjyvip =Pvip -=Pf:jj3E =209Gvip - 214zzvipjyvip #P:let g:easy_align_delimiters = { '#': {'pattern': '#\+', 'ignore_groups': ['String'] } } vip #227zzvip :239zzvip *=vipjyP:let g:easy_align_ignore_groups = [] vip *=:unlet g:easy_align_delimiters :unlet g:easy_align_ignore_groups 4Gvipy4GP7Gojkkvip:EasyAlign /1/{'ml':'{{', 'mr-r':'}}'} vipjyPvip:EasyAlign */../ 263zzvipjygv .Pvip *.Pvip * .Pvip .vip 2.Pvip **.Pvip **.Pvip -.G303zzvip .310zzvipjygv *|Pvip *|Pvip |gv -|gv **|gv *|gv **|jji jjjhi vip ** |339Gpvip:EasyAlign*|{'ml': 5, 'mrr': 0 } 349Gpvip:EasyAlign*/|/{'ml':'~', 'mrr': 4} 362G:let g:easy_align_delimiters = { 'd': { 'pattern': '\s\+\(\S\+\s*[;=]\)\@=', 'left_margin': 0, 'right_margin': 0 } } vip dgv =236GvipjyPvip :377Gvip gv 2 382Gvipjyvip:EasyAlign/-\+/ Pvip:EasyAlign2/-\+/ Pvip:EasyAlign*/-\+/ Pvip:EasyAlign*/-\+/{'da': L} Pvip:EasyAlign/-\+/{'da': c} Pvip:EasyAlign*/-\+/{'delimiter_align':'C'} Pvip:EasyAlign*/-\+/{'da': 'x'} 381Gpvip:EasyAlign/-\+/{'da':r} :let g:easy_align_delimiter_align = 'l' Pvip:EasyAlign/-\+/ Pvip:EasyAlign*/-\+/ :unlet g:easy_align_delimiter_align :let g:easy_align_delimiters['\'] = { 'pattern': '-\+', 'delimiter_align': 'c' } Pvip \Pvip *-vip *\Pvip:EasyAlign *\\ {'da':l} Pvip:EasyAlign*\\ Pvip:EasyAlign*\\{'da': 'R'} 377GvipjyPvip:EasyAlign\ {'l': '@@@'} gv:EasyAlign 2 \ {'l': '{{{'} 507Gvipjygv:EasyAlign= Pvip:EasyAlign = {'idt': s} Pvip:EasyAlign= {'idt': d} Pvip:EasyAlign**={'indentation': 'd'} Pvip:EasyAlign!= Pvip:EasyAlign! **= {'indent': s} Pvip:EasyAlign!* = {'idt': D} Pvip:EasyAlign! ={'idt':'S'} 507GPvip:EasyAlign-={'idt':d} PA = 2j.j.j.j.vip:EasyAlign2={'idt': s} 507GPljjjj$:EasyAlign = {'idt': s} Pljjjj$:EasyAlign={'indent':d} Phhxxvip:EasyAlign={'idt':'s'} 525Gvipjy507GPPvip:EasyAlign*={'idt':s} Pvip:EasyAlign!**={'idt':s} Pvip:EasyAlign = {'idt': D} 525G^hhr1jr1jr1jr1jr1llkkkk$:EasyAlign = { 'idt': s } 513GvipjyPvip:EasyAlign*={'idt':n} Pvip:EasyAlign = { 'idt': N } Pvip:EasyAlign!*= {'idt': 'n'} 630Gvipjygv =Pvip =656Gvipjygv =Pvip *=Pvip **=Pvip **=Pvip:EasyAlign**= {'iu':0} Pvip =vip 2=vip -0 =818Gvipjygv =Pvip 2=Pvip *=Pvip **=Pvip **=Pvip -0=Pvip -0=855Gvip ** 860Gvip 2=}863Gvip 2=866Gvip 2=869Gvip 2=872Gvip *=875Gvip 2 878Gvip 2 881Gvip:EasyAlign**={'m': 'c','idt':s} ggjjj70GvipjyGpvip *|vipjyGpvip:EasyAlign*|{'m': 'lcr'} Gpvip:EasyAlign**|{'m':'llc'} Gpvip:s/^|// vip:EasyAlign*|{'idt':n} vip:EasyAlign**|{'m':'cl'} 107GvipjyPvip  *=Pvip  *=