Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
106 lines
2.6 KiB
VimL
106 lines
2.6 KiB
VimL
function! sj#handlebars#SplitComponent()
|
|
if !sj#SearchUnderCursor('{{#\=\%(\k\|-\|\/\)\+ .\{-}}}')
|
|
return 0
|
|
endif
|
|
|
|
let body = sj#GetMotion('vi{')
|
|
let body = substitute(body, '\s\+\(\k\+=\)', '\n\1', 'g')
|
|
if !sj#settings#Read('handlebars_closing_bracket_on_same_line')
|
|
let body = substitute(body, '}$', "\n}", '')
|
|
endif
|
|
|
|
if sj#settings#Read('handlebars_hanging_arguments')
|
|
" substitute just the first newline with a space
|
|
let body = substitute(body, '\n', ' ', '')
|
|
endif
|
|
|
|
call sj#ReplaceMotion('vi{', body)
|
|
return 1
|
|
endfunction
|
|
|
|
function! sj#handlebars#JoinComponent()
|
|
if !(sj#SearchUnderCursor('{{#\=\%(\k\|-\|\/\)\+.*$') && getline('.') !~ '}}')
|
|
return 0
|
|
endif
|
|
|
|
normal! vi{J
|
|
call sj#Keeppatterns('s/\s\+}}/}}/ge')
|
|
return 1
|
|
endfunction
|
|
|
|
function! sj#handlebars#SplitBlockComponent()
|
|
let saved_iskeyword = &iskeyword
|
|
|
|
try
|
|
set iskeyword+=-,/
|
|
let start_pattern = '{{#\k\+\%( .\{-}\)\=}}'
|
|
|
|
if !search(start_pattern, 'bWc', line('.'))
|
|
return 0
|
|
endif
|
|
|
|
call search('\k', 'W', line('.'))
|
|
let component_name = expand('<cword>')
|
|
call search(start_pattern, 'eW', line('.'))
|
|
let start_col = col('.') + 1
|
|
|
|
if !search('{{/'.component_name.'}}', 'W', line('.'))
|
|
return 0
|
|
endif
|
|
let end_col = col('.') - 1
|
|
|
|
if end_col - start_col > 0
|
|
let body = sj#GetCols(start_col, end_col)
|
|
call sj#ReplaceCols(start_col, end_col, "\n".sj#Trim(body)."\n")
|
|
else
|
|
" empty block component
|
|
call sj#ReplaceCols(start_col, start_col, "\n{")
|
|
endif
|
|
|
|
return 1
|
|
finally
|
|
let &iskeyword = saved_iskeyword
|
|
endtry
|
|
endfunction
|
|
|
|
function! sj#handlebars#JoinBlockComponent()
|
|
let saved_iskeyword = &iskeyword
|
|
|
|
try
|
|
set iskeyword+=-,/
|
|
let start_pattern = '{{#\k\+\%( .\{-}\)\=}}\s*$'
|
|
|
|
if !search(start_pattern, 'bWc', line('.'))
|
|
return 0
|
|
endif
|
|
|
|
call search('\k', 'W', line('.'))
|
|
let component_name = expand('<cword>')
|
|
let start_line = line('.')
|
|
|
|
if !search('{{/'.component_name.'}}', 'W')
|
|
return 0
|
|
endif
|
|
let end_line = line('.')
|
|
|
|
if end_line - start_line <= 0
|
|
" not right, there needs to be at least one line of a difference
|
|
return 0
|
|
endif
|
|
|
|
if end_line - start_line > 1
|
|
let body = join(sj#TrimList(getbufline('%', start_line + 1, end_line -1)), ' ')
|
|
else
|
|
let body = ''
|
|
endif
|
|
|
|
let start_tag = sj#Rtrim(getline(start_line))
|
|
let end_tag = sj#Ltrim(getline(end_line))
|
|
|
|
call sj#ReplaceLines(start_line, end_line, start_tag.body.end_tag)
|
|
return 1
|
|
finally
|
|
let &iskeyword = saved_iskeyword
|
|
endtry
|
|
endfunction
|