Merge pull request #99 from yanma/default_nth

Add g:easy_align_nth to allow configuring default nth
This commit is contained in:
Junegunn Choi
2017-02-08 00:38:53 +09:00
committed by GitHub
2 changed files with 115 additions and 1 deletions

View File

@@ -1050,7 +1050,7 @@ function! s:build_mode_sequence(expr, recur)
endfunction
function! s:process(range, mode, n, ch, opts, regexp, rules, bvis)
let [nth, recur] = s:parse_nth(a:n)
let [nth, recur] = s:parse_nth((empty(a:n) && exists('g:easy_align_nth')) ? g:easy_align_nth : a:n)
let dict = s:build_dict(a:rules, a:ch, a:regexp, a:opts)
let [mode_sequence, recur] = s:build_mode_sequence(
\ get(dict, 'align', recur == 2 ? s:alternating_modes(a:mode) : a:mode),

View File

@@ -581,6 +581,120 @@ Do:
Execute (g:easy_align_last_command should not be set if interrupted):
Assert !exists('g:easy_align_last_command')
Do (g:easy_align_nth is not set (work with default value 1)):
vip\<Enter>|
Expect:
| Option| Type | Default | Description |
| --|--|--|--|
| threads | Fixnum | 1 | number of threads in the thread pool |
| queues |Fixnum | 1 | number of concurrent queues |
| queue_size | Fixnum | 1000 | size of each queue |
| interval | Numeric | 0 | dispatcher interval for batch processing |
| batch | Boolean | false | enables batch processing mode |
| batch_size | Fixnum | nil | number of maximum items to be assigned at once |
| logger | Logger | nil | logger instance for debug logs |
Execute (set g:easy_align_nth):
let g:easy_align_nth = '2'
Do (g:easy_align_nth is set as 2):
vip\<Enter>|
Expect:
| Option | Type | Default | Description |
|-- | --|--|--|
| threads | Fixnum | 1 | number of threads in the thread pool |
|queues | Fixnum | 1 | number of concurrent queues |
|queue_size | Fixnum | 1000 | size of each queue |
| interval | Numeric | 0 | dispatcher interval for batch processing |
|batch | Boolean | false | enables batch processing mode |
|batch_size | Fixnum | nil | number of maximum items to be assigned at once |
|logger | Logger | nil | logger instance for debug logs |
Execute (unset g:easy_align_nth):
unlet g:easy_align_nth
Execute (set g:easy_align_nth):
let g:easy_align_nth = '*'
Do (g:easy_align_nth is set as *):
vip\<Enter>|
Expect:
| Option | Type | Default | Description |
| -- | -- | -- | -- |
| threads | Fixnum | 1 | number of threads in the thread pool |
| queues | Fixnum | 1 | number of concurrent queues |
| queue_size | Fixnum | 1000 | size of each queue |
| interval | Numeric | 0 | dispatcher interval for batch processing |
| batch | Boolean | false | enables batch processing mode |
| batch_size | Fixnum | nil | number of maximum items to be assigned at once |
| logger | Logger | nil | logger instance for debug logs |
Execute (unset g:easy_align_nth):
unlet g:easy_align_nth
Execute (set g:easy_align_nth):
let g:easy_align_nth = '**'
Do (g:easy_align_nth is set as **):
vip\<Enter>|
Expect:
| Option | Type | Default | Description |
| -- | -- | -- | -- |
| threads | Fixnum | 1 | number of threads in the thread pool |
| queues | Fixnum | 1 | number of concurrent queues |
| queue_size | Fixnum | 1000 | size of each queue |
| interval | Numeric | 0 | dispatcher interval for batch processing |
| batch | Boolean | false | enables batch processing mode |
| batch_size | Fixnum | nil | number of maximum items to be assigned at once |
| logger | Logger | nil | logger instance for debug logs |
Execute (unset g:easy_align_nth):
unlet g:easy_align_nth
Execute (set g:easy_align_nth):
let g:easy_align_nth = '-'
Do (g:easy_align_nth is set as -):
vip\<Enter>|
Expect:
| Option| Type | Default | Description |
|--|--|--|-- |
| threads | Fixnum | 1 | number of threads in the thread pool |
|queues |Fixnum | 1 | number of concurrent queues |
|queue_size | Fixnum | 1000 | size of each queue |
| interval | Numeric | 0 | dispatcher interval for batch processing |
|batch | Boolean | false | enables batch processing mode |
|batch_size | Fixnum | nil | number of maximum items to be assigned at once |
|logger | Logger | nil | logger instance for debug logs |
Execute (unset g:easy_align_nth):
unlet g:easy_align_nth
Execute (set g:easy_align_nth):
let g:easy_align_nth = '-2'
Do (g:easy_align_nth is set as -2):
vip\<Enter>|
Expect:
| Option| Type | Default | Description |
|--|--|-- | --|
| threads | Fixnum | 1 | number of threads in the thread pool |
|queues |Fixnum | 1 | number of concurrent queues |
|queue_size | Fixnum | 1000 | size of each queue |
| interval | Numeric | 0 | dispatcher interval for batch processing |
|batch | Boolean | false | enables batch processing mode |
|batch_size | Fixnum | nil | number of maximum items to be assigned at once |
|logger | Logger | nil | logger instance for debug logs |
Execute (unset g:easy_align_nth):
unlet g:easy_align_nth
###########################################################
Given (comma-separated items):