Skip to content

Commit

Permalink
remote/define.vim: support remote function "range"
Browse files Browse the repository at this point in the history
  • Loading branch information
myitcv authored and justinmk committed Apr 18, 2016
1 parent 376ba4e commit d835c03
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions runtime/autoload/remote/define.vim
@@ -1,7 +1,7 @@
function! remote#define#CommandOnHost(host, method, sync, name, opts)
let prefix = ''

if has_key(a:opts, 'range')
if has_key(a:opts, 'range')
if a:opts.range == '' || a:opts.range == '%'
" -range or -range=%, pass the line range in a list
let prefix = '<line1>,<line2>'
Expand Down Expand Up @@ -157,6 +157,9 @@ endfunction

function! remote#define#FunctionOnChannel(channel, method, sync, name, opts)
let rpcargs = [a:channel, '"'.a:method.'"', 'a:000']
if has_key(a:opts, 'range') && a:opts.range != '0'
call add(rpcargs, '[a:firstline, a:lastline]')
endif
call s:AddEval(rpcargs, a:opts)

let function_def = s:GetFunctionPrefix(a:name, a:opts)
Expand Down Expand Up @@ -187,7 +190,7 @@ let s:next_gid = 1
function! s:GetNextAutocmdGroup()
let gid = s:next_gid
let s:next_gid += 1

let group_name = 'RPC_DEFINE_AUTOCMD_GROUP_'.gid
" Ensure the group is defined
exe 'augroup '.group_name.' | augroup END'
Expand Down Expand Up @@ -218,7 +221,11 @@ endfunction


function! s:GetFunctionPrefix(name, opts)
return "function! ".a:name."(...)\n"
let res = "function! ".a:name."(...)"
if has_key(a:opts, 'range') && a:opts.range != '0'
let res = res." range"
endif
return res."\n"
endfunction


Expand Down

0 comments on commit d835c03

Please sign in to comment.