Skip to content

Commit

Permalink
Make surroundings function public
Browse files Browse the repository at this point in the history
Integrate tpope#51
  • Loading branch information
somini committed Apr 24, 2018
1 parent 3b01e29 commit a8ac559
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions autoload/commentary.vim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function! s:surroundings() abort
function! commentary#surroundings() abort
return split(get(b:, 'commentary_format', substitute(substitute(
\ &commentstring, '\S\zs%s',' %s','') ,'%s\ze\S', '%s ', '')), '%s', 1)
endfunction
Expand All @@ -24,7 +24,7 @@ function! commentary#go(...) abort
let [lnum1, lnum2] = [line("'["), line("']")]
endif

let [l, r] = s:surroundings()
let [l, r] = commentary#surroundings()
let uncomment = 2
for lnum in range(lnum1,lnum2)
let line = matchstr(getline(lnum),'\S.*\s\@<!')
Expand Down Expand Up @@ -59,7 +59,7 @@ function! commentary#go(...) abort
endfunction

function! commentary#textobject(inner) abort
let [l, r] = s:surroundings()
let [l, r] = commentary#surroundings()
let lnums = [line('.')+1, line('.')-2]
for [index, dir, bound, line] in [[0, -1, 1, ''], [1, 1, line('$'), '']]
while lnums[index] != bound && line ==# '' || !(stridx(line,l) || line[strlen(line)-strlen(r) : -1] != r)
Expand Down
2 changes: 1 addition & 1 deletion plugin/commentary.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if exists("g:loaded_commentary") || v:version < 700
endif
let g:loaded_commentary = 1

command! -range -bar Commentary call s:go(<line1>,<line2>)
command! -range -bar Commentary call commentary#go(<line1>,<line2>)
xnoremap <silent> <Plug>Commentary :Commentary<CR>
nnoremap <expr> <Plug>Commentary commentary#go()
nnoremap <expr> <Plug>CommentaryLine commentary#go() . '_'
Expand Down

0 comments on commit a8ac559

Please sign in to comment.