5 Commits

Author SHA1 Message Date
Andreas Guth
a04da5d277 Merge a496fe2cb7 into 12dd631697 2020-07-01 22:46:56 +00:00
Gordin
a496fe2cb7 fixed documentation 2020-07-02 00:46:49 +02:00
Gordin
bc76930333 Added hjkl to documentation 2020-07-01 23:51:31 +02:00
Gordin
207482468a typo 2020-07-01 23:32:32 +02:00
Gordin
a8a8feb8a5 Makes hjkl work like arrow keys in live mode 2020-07-01 23:30:17 +02:00
4 changed files with 29 additions and 70 deletions

View File

@@ -406,7 +406,7 @@ highlighted as code comments or strings are ignored.
```vim
" Default:
" If a delimiter is in a highlight group whose name matches
" any of the following regular expressions, it will be ignored.
" any of the followings, it will be ignored.
let g:easy_align_ignore_groups = ['Comment', 'String']
```
@@ -463,19 +463,6 @@ If a pattern in `ignore_groups` is prepended by a `!`, it will have the opposite
meaning. For instance, if `ignore_groups` is given as `['!Comment']`, delimiters
that are *not* highlighted as Comment will be ignored during the alignment.
To make `ignore_groups` work, and to debug the related issues, it is useful to
know which highlight group a certain location in a file belongs to. A special
function exists for this purpose, returning exactly the name of the highlight
group that is used by the easy align plugin.
```vim
" Highlight group name of the cursor position
echo easy_align#get_highlight_group_name()
" Highlight group name of the line 10, column 20
echo easy_align#get_highlight_group_name(10, 20)
```
### Ignoring unmatched lines
`ignore_unmatched` option determines how EasyAlign command processes lines that

View File

@@ -89,30 +89,9 @@ function! s:floor2(v)
return a:v % 2 == 0 ? a:v : a:v - 1
endfunction
function! s:get_highlight_group_name(line, col)
let hl = synIDattr(synID(a:line, a:col, 0), 'name')
if hl == '' && has('nvim-0.9.0')
let insp = luaeval('vim.inspect_pos and vim.inspect_pos( nil, ' .. (a:line-1) .. ', ' .. (a:col-1) .. ' ) or { treesitter = {} }')
if !empty(insp.treesitter)
let hl = insp.treesitter[0].hl_group_link
endif
endif
" and, finally
return hl
endfunction
function! easy_align#get_highlight_group_name(...)
let l = get(a:, 1, line('.'))
let c = get(a:, 2, col('.'))
let hl = s:get_highlight_group_name(l, c)
return { 'line': l, 'column': c, 'group': hl }
endfunction
function! s:highlighted_as(line, col, groups)
if empty(a:groups) | return 0 | endif
let hl = s:get_highlight_group_name(a:line, a:col)
let hl = synIDattr(synID(a:line, a:col, 0), 'name')
for grp in a:groups
if grp[0] == '!'
if hl !~# grp[1:-1]
@@ -752,16 +731,16 @@ function! s:interactive(range, modes, n, d, opts, rules, vis, bvis)
else
let s:live = 1
endif
elseif c == "\<Left>"
elseif c == "\<Left>" || ch == "h"
let opts['stl'] = 1
let opts['lm'] = 0
elseif c == "\<Right>"
elseif c == "\<Right>" || ch == "l"
let opts['stl'] = 0
let opts['lm'] = 1
elseif c == "\<Down>"
elseif c == "\<Down>" || ch == "j"
let opts['lm'] = 0
let opts['rm'] = 0
elseif c == "\<Up>"
elseif c == "\<Up>" || ch == "k"
silent! call remove(opts, 'stl')
silent! call remove(opts, 'lm')
silent! call remove(opts, 'rm')
@@ -1167,4 +1146,3 @@ endfunction
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: set et sw=2 :

View File

@@ -279,7 +279,7 @@ to align text around all occurrences of numbers:
- <Enter>
- `*`
- CTRL-X
- `[0-9]\+`
- `[0-9]\+`
Alignment options in interactive mode~
@@ -290,21 +290,27 @@ While in interactive mode, you can set alignment options using special
shortcut keys listed below. The meaning of each option will be described in
{the following sections}{6}.
--------+--------------------+---------------------------------------------------
Key | Option | Values ~
--------+--------------------+---------------------------------------------------
CTRL-F | `filter` | Input string ( `[gv]/.*/?` )
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']
CTRL-A | `align` | Input string ( `/[lrc]+\*{0,2}/` )
<Left> | `stick_to_left` | `{ 'stick_to_left': 1, 'left_margin': 0 }`
<Right> | `stick_to_left` | `{ 'stick_to_left': 0, 'left_margin': 1 }`
<Down> | `*_margin` | `{ 'left_margin': 0, 'right_margin': 0 }`
--------+--------------------+---------------------------------------------------
--------+----------------------+---------------------------------------------
Key | Option | Values ~
--------+----------------------+---------------------------------------------
CTRL-F | `filter` | Input string ( `[gv]/.*/?` )
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']
CTRL-A | `align` | Input string ( `/[lrc]+\*{0,2}/` )
<Left> | `stick_to_left` | `{ 'left_margin': 0, 'stick_to_left': 1 }`
h | `stick_to_left` | `{ 'left_margin': 0, 'stick_to_left': 1 }`
<Right> | `stick_to_left` | `{ 'left_margin': 1, 'stick_to_left': 0 }`
l | `stick_to_left` | `{ 'left_margin': 1, 'stick_to_left': 0 }`
<Down> | `*_margin` | `{ 'left_margin': 0, 'right_margin': 0 }`
j | `*_margin` | `{ 'left_margin': 0, 'right_margin': 0 }`
<Up> | `reset_stl_and_margin` | `{ 'left_margin': 1, 'right_margin': 1 }`
k | `reset_stl_and_margin` | `{ 'left_margin': 1, 'right_margin': 1 }`
--------+----------------------+---------------------------------------------
{6} https://github.com/junegunn/vim-easy-align#alignment-options
@@ -517,7 +523,7 @@ highlighted as code comments or strings are ignored.
>
" Default:
" If a delimiter is in a highlight group whose name matches
" any of the following regular expressions, it will be ignored.
" any of the followings, it will be ignored.
let g:easy_align_ignore_groups = ['Comment', 'String']
<
For example, the following paragraph
@@ -567,17 +573,6 @@ opposite meaning. For instance, if `ignore_groups` is given as `['!Comment']`,
delimiters that are not highlighted as Comment will be ignored during the
alignment.
To make `ignore_groups` work, and to debug the related issues, it is useful to
know which highlight group a certain location in a file belongs to. A special
function exists for this purpose, returning exactly the name of the highlight
group that is used by the easy align plugin.
>
" Highlight group name of the cursor position
echo easy_align#get_highlight_group_name()
" Highlight group name of the line 10, column 20
echo easy_align#get_highlight_group_name(10, 20)
<
< Ignoring unmatched lines >__________________________________________________~
*easy-align-ignoring-unmatched-lines*

View File

@@ -140,4 +140,3 @@ vnoremap <silent> <Plug>(EasyAlignRepeat) :<C-U>call <SID>repeat_in_visual()<Ent
" Backward-compatibility (deprecated)
nnoremap <silent> <Plug>(EasyAlignOperator) :set opfunc=<SID>easy_align_op<Enter>g@
" vim: set et sw=2 :