mirror of
https://github.com/junegunn/vim-easy-align.git
synced 2025-11-12 03:43:48 -05:00
Add support for arbitrary regular expressions
This commit is contained in:
259
test/basic.expected
Normal file
259
test/basic.expected
Normal file
@@ -0,0 +1,259 @@
|
||||
" :source run.vim
|
||||
" @a
|
||||
|
||||
Pa ul Mc Ca rt ne y{ {1 }} 94 2
|
||||
Ge or ge Ha rr is on {{ 1} }9 43
|
||||
Ri ng o St ar r {{ 1} }9 40
|
||||
Pe te Be st {{ 1} }9 41
|
||||
|
||||
Paul McCartney{{1}}942
|
||||
George Harrison {{1}}943
|
||||
Ringo Starr {{1}}940
|
||||
Pete Best {{1}}941
|
||||
|
||||
Paul McCartney 1942
|
||||
George Harrison 1943
|
||||
Ringo Starr 1940
|
||||
Pete Best 1941
|
||||
|
||||
Paul McCartney 1942
|
||||
George Harrison 1943
|
||||
Ringo Starr 1940
|
||||
Pete Best 1941
|
||||
|
||||
Paul McCartney 1942
|
||||
George Harrison 1943
|
||||
Ringo Starr 1940
|
||||
Pete Best 1941
|
||||
|
||||
Paul McCartney 1942
|
||||
George Harrison 1943
|
||||
Ringo Starr 1940
|
||||
Pete Best 1941
|
||||
|
||||
Paul McCartney 1942
|
||||
George Harrison 1943
|
||||
Ringo Starr 1940
|
||||
Pete Best 1941
|
||||
|
||||
Paul McCartney 1942
|
||||
George Harrison 1943
|
||||
Ringo Starr 1940
|
||||
Pete Best 1941
|
||||
|
||||
Paul McCartney 1942
|
||||
George Harrison 1943
|
||||
Ringo Starr 1940
|
||||
Pete Best 1941
|
||||
|
||||
Paul McCartney 1942
|
||||
George Harrison 1943
|
||||
Ringo Starr 1940
|
||||
Pete Best 1941
|
||||
|
||||
Paul McCartney 1942
|
||||
George Harrison 1943
|
||||
Ringo Starr 1940
|
||||
Pete Best 1941
|
||||
|
||||
Paul McCartney 1942
|
||||
George Harrison 1943
|
||||
Ringo Starr 1940
|
||||
Pete Best 1941
|
||||
|
||||
Paul McCartney 1942
|
||||
George Harrison 1943
|
||||
Ringo Starr 1940
|
||||
Pete Best 1941
|
||||
|
||||
| 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 |
|
||||
|
||||
| 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 |
|
||||
|
||||
| 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 |
|
||||
|
||||
aaa, bb, c
|
||||
d, eeeeeee
|
||||
fffff, gggggggggg,
|
||||
h, , ii
|
||||
j, , k
|
||||
|
||||
```ruby
|
||||
|
||||
a =
|
||||
a = 1
|
||||
bbbb = 2
|
||||
ccccccc = 3
|
||||
ccccccccccccccc
|
||||
ddd = 4
|
||||
eeee === eee = eee = eee=f
|
||||
fff = ggg += gg &&= gg
|
||||
g != hhhhhhhh == 888
|
||||
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 = 4
|
||||
eeee === eee = eee = eee = f
|
||||
fff = ggg += gg &&= gg
|
||||
g != hhhhhhhh == 888
|
||||
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 = 4
|
||||
eeee === eee = eee = eee = f
|
||||
fff = ggg += gg &&= gg
|
||||
g != hhhhhhhh == 888
|
||||
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 = 4
|
||||
eeee === eee = eee = eee=f
|
||||
fff = ggg += gg &&= gg
|
||||
g != hhhhhhhh == 888
|
||||
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
|
||||
|
||||
options = { :caching => nil,
|
||||
:versions => 3,
|
||||
"cache=blocks" => false }.merge(options)
|
||||
|
||||
options = { :caching => nil,
|
||||
:versions => 3,
|
||||
"cache=blocks" => false }.merge(options)
|
||||
|
||||
options = { :caching => nil,
|
||||
:versions => 3,
|
||||
"cache=blocks" => false }.merge(options)
|
||||
|
||||
apple = 1 # comment not aligned
|
||||
banana = 'Gros Michel' # comment 2
|
||||
|
||||
# let g:easy_align_delimiters = { '#': { 'pattern': '#\+', 'ignores': ['String'] } }
|
||||
|
||||
apple = 1 # comment not aligned
|
||||
apricot = 'DAD' + 'F#AD'
|
||||
banana = 'Gros Michel' # comment 2
|
||||
|
||||
apple = 1 # comment not aligned
|
||||
apricot = 'DAD' + 'F#AD'
|
||||
banana = 'Gros Michel' # comment 2
|
||||
|
||||
```
|
||||
|
||||
```yaml
|
||||
|
||||
mysql:
|
||||
# JDBC driver for MySQL database:
|
||||
driver: com.mysql.jdbc.Driver
|
||||
# JDBC URL for the connection (jdbc:mysql://HOSTNAME/DATABASE)
|
||||
url: jdbc:mysql://localhost/test
|
||||
database: test
|
||||
"user:pass": r00t:pa55
|
||||
|
||||
```
|
||||
```c
|
||||
|
||||
/* a */ b = c
|
||||
aa >= bb
|
||||
// aaa = bbb = cccc
|
||||
/* aaaa = */ bbbb === cccc " = dddd = " = eeee
|
||||
aaaaa /* bbbbb */ == ccccc /* != eeeee = */ === fffff
|
||||
|
||||
/* a */ b = c
|
||||
aa >= bb
|
||||
// aaa = bbb = cccc
|
||||
/* aaaa = */ bbbb === cccc " = dddd = " = eeee
|
||||
aaaaa /* bbbbb */ == ccccc /* != eeeee = */ === fffff
|
||||
|
||||
```
|
||||
86
test/basic.md
Normal file
86
test/basic.md
Normal file
@@ -0,0 +1,86 @@
|
||||
" :source run.vim
|
||||
" @a
|
||||
|
||||
Paul McCartney 1942
|
||||
George Harrison 1943
|
||||
Ringo Starr 1940
|
||||
Pete Best 1941
|
||||
|
||||
| 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 |
|
||||
|
||||
aaa, bb,c
|
||||
d,eeeeeee
|
||||
fffff, gggggggggg,
|
||||
h, , ii
|
||||
j,,k
|
||||
|
||||
```ruby
|
||||
|
||||
a =
|
||||
a = 1
|
||||
bbbb = 2
|
||||
ccccccc = 3
|
||||
ccccccccccccccc
|
||||
ddd = 4
|
||||
eeee === eee = eee = eee=f
|
||||
fff = ggg += gg &&= gg
|
||||
g != hhhhhhhh == 888
|
||||
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
|
||||
|
||||
options = { :caching => nil,
|
||||
:versions => 3,
|
||||
"cache=blocks" => false }.merge(options)
|
||||
|
||||
apple = 1 # comment not aligned
|
||||
banana = 'Gros Michel' # comment 2
|
||||
|
||||
# let g:easy_align_delimiters = { '#': { 'pattern': '#\+', 'ignores': ['String'] } }
|
||||
|
||||
apple = 1 # comment not aligned
|
||||
apricot = 'DAD' + 'F#AD'
|
||||
banana = 'Gros Michel' # comment 2
|
||||
|
||||
```
|
||||
|
||||
```yaml
|
||||
|
||||
mysql:
|
||||
# JDBC driver for MySQL database:
|
||||
driver: com.mysql.jdbc.Driver
|
||||
# JDBC URL for the connection (jdbc:mysql://HOSTNAME/DATABASE)
|
||||
url: jdbc:mysql://localhost/test
|
||||
database: test
|
||||
"user:pass":r00t:pa55
|
||||
|
||||
```
|
||||
```c
|
||||
|
||||
/* a */ b = c
|
||||
aa >= bb
|
||||
// aaa = bbb = cccc
|
||||
/* aaaa = */ bbbb === cccc " = dddd = " = eeee
|
||||
aaaaa /* bbbbb */ == ccccc /* != eeeee = */ === fffff
|
||||
|
||||
```
|
||||
1
test/basic.script
Normal file
1
test/basic.script
Normal file
@@ -0,0 +1 @@
|
||||
4Gvipjyvip
|
||||
42
test/include.vim
Normal file
42
test/include.vim
Normal file
@@ -0,0 +1,42 @@
|
||||
function! GFM()
|
||||
let syntaxes = {
|
||||
\ 'ruby': 'syntax/ruby.vim',
|
||||
\ 'yaml': 'syntax/yaml.vim',
|
||||
\ 'vim': 'syntax/vim.vim',
|
||||
\ 'sh': 'syntax/sh.vim',
|
||||
\ 'python': 'syntax/python.vim',
|
||||
\ 'java': 'syntax/java.vim',
|
||||
\ 'c': 'syntax/c.vim'
|
||||
\ }
|
||||
|
||||
for [lang, syn] in items(syntaxes)
|
||||
unlet b:current_syntax
|
||||
silent! exec printf("syntax include @%s %s", lang, syn)
|
||||
exec printf("syntax region %sSnip matchgroup=Snip start='```%s' end='```' contains=@%s",
|
||||
\ lang, lang, lang)
|
||||
endfor
|
||||
let b:current_syntax='mkd'
|
||||
endfunction
|
||||
|
||||
silent! unlet g:easy_align_delimiters
|
||||
silent! unlet g:easy_align_ignore_unmatched
|
||||
silent! unlet g:easy_align_ignores
|
||||
|
||||
vnoremap <silent> <Enter> :EasyAlign<cr>
|
||||
|
||||
noremap <silent> <C-k> <nop>
|
||||
noremap <silent> <C-j> <nop>
|
||||
noremap <silent> <C-h> <nop>
|
||||
noremap <silent> <C-l> <nop>
|
||||
vnoremap <silent> <C-k> <nop>
|
||||
vnoremap <silent> <C-j> <nop>
|
||||
vnoremap <silent> <C-h> <nop>
|
||||
vnoremap <silent> <C-l> <nop>
|
||||
|
||||
set nolazyredraw
|
||||
set buftype=nofile
|
||||
|
||||
silent! ScrollPositionHide
|
||||
|
||||
call GFM()
|
||||
|
||||
87
test/regexp.expected
Normal file
87
test/regexp.expected
Normal file
@@ -0,0 +1,87 @@
|
||||
" :source run.vim
|
||||
" @a
|
||||
|
||||
apple;:banana :: cake
|
||||
data;;exchange :; format
|
||||
|
||||
apple ;: banana :: cake
|
||||
data ;; exchange :; format
|
||||
|
||||
apple ;: banana :: cake
|
||||
data ;; exchange :; format
|
||||
|
||||
apple ;:____banana::cake
|
||||
data ;;____exchange:;format
|
||||
|
||||
apple ; : banana : : cake
|
||||
data ; ; exchange : ; format
|
||||
|
||||
ap pl e; :b an an a: :c ak e
|
||||
da ta ;; ex ch an ge :; fo rm at
|
||||
|
||||
ap ple;:banana::cake
|
||||
da ta;;exchange:;format
|
||||
|
||||
apple???;:~~~banana???::~~~ cake
|
||||
data???;;~~~ exchange???:;~~~format
|
||||
|
||||
apple;: banana::cake
|
||||
data;; exchange:;format
|
||||
|
||||
apple<<<;:>>>banana::cake
|
||||
data <<<;;>>>exchange:;format
|
||||
|
||||
apple ;: banana::cake
|
||||
data ;; exchange:;format
|
||||
|
||||
apple;:banana :: cake
|
||||
data;;exchange :; format
|
||||
|
||||
apple ;: banana :: cake
|
||||
data ;; exchange :; format
|
||||
|
||||
apple ;: banana :: cake
|
||||
data ;; exchange :; format
|
||||
|
||||
apple ;: banana :: cake
|
||||
data ;; exchange :; format
|
||||
|
||||
apple ;: banana :: cake
|
||||
data ;; exchange :; format
|
||||
|
||||
apple ;: banana::cake
|
||||
data ;; exchange:;format
|
||||
|
||||
apple ; :banana::cake
|
||||
data ; ; exchange: ; format
|
||||
|
||||
apple ; :banana::cake
|
||||
data ; ;exchange:;format
|
||||
|
||||
apple ; :banana::cake
|
||||
data ; ;exchange:;format
|
||||
|
||||
apple;:banana::cake
|
||||
data;;exchange:;format
|
||||
|
||||
apple;: banana: : cake
|
||||
data;;exchange: ;format
|
||||
|
||||
apple;:banana: :cake
|
||||
data;;exchange:;format
|
||||
|
||||
apple;:banana: :cake
|
||||
data;;exchange:;format
|
||||
|
||||
apple;: banana: : cake
|
||||
data;;exchange: ;format
|
||||
|
||||
apple;:banana:: cake
|
||||
data;;exchange: ;format
|
||||
|
||||
apple;: banana: : cake
|
||||
data;;exchange: ;format
|
||||
|
||||
apple;: banana::cake
|
||||
data;;exchange: ;format
|
||||
|
||||
6
test/regexp.md
Normal file
6
test/regexp.md
Normal file
@@ -0,0 +1,6 @@
|
||||
" :source run.vim
|
||||
" @a
|
||||
|
||||
apple;:banana::cake
|
||||
data;;exchange:;format
|
||||
|
||||
1
test/regexp.script
Normal file
1
test/regexp.script
Normal file
@@ -0,0 +1 @@
|
||||
4Gvipjyvip:EasyAlign:
|
||||
12
test/run.vim
Normal file
12
test/run.vim
Normal file
@@ -0,0 +1,12 @@
|
||||
source include.vim
|
||||
|
||||
while line('.') < line('$')
|
||||
normal 30j
|
||||
redraw
|
||||
endwhile
|
||||
|
||||
normal gg
|
||||
let @b=system('cat '. expand('%:r') . '.script')
|
||||
let @a='@b:vert diffsplit ' . expand('%:r') . '.expected
|
||||
'
|
||||
" Syntax highlighting doesn't work
|
||||
Reference in New Issue
Block a user