Module: VimProxy

Includes:
CommonProxy
Defined in:
lib/shell-proxy/vim.rb

Defined Under Namespace

Classes: InvalidMethodName

Instance Method Summary collapse

Methods included from CommonProxy

#__emit, #__eval, #__main__, #__writer

Instance Method Details

#__call(fn, *args) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/shell-proxy/vim.rb', line 37

def __call(fn, *args)
  opts = (args.last.is_a? Hash) ? args.pop : {}
  prefix = opts.include?(:prefix) ? "#{opts[:prefix]}:" : ""
  call = "call #{prefix}#{fn}("
  call << args.join(", ")
  call << ")"
  __eval(call)
end

#__chdir(dir, &block) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/shell-proxy/vim.rb', line 24

def __chdir(dir, &block)
  __eval "let __here=\"cd \" . getcwd()"
  __eval "cd #{dir}"
  @cmd_buffer.indent
  block.call
  @cmd_buffer.undent
  __eval "exec __here"
end

#__function(name, &block) ⇒ Object

Raises:



7
8
9
10
11
12
13
14
# File 'lib/shell-proxy/vim.rb', line 7

def __function(name, &block)
  raise InvalidMethodName, "Methods must start with caps" unless (name =~ /[A-Z]/) == 0
  @cmd_buffer << "function! #{name}()"
  @cmd_buffer.indent
  yield
  @cmd_buffer.undent
  @cmd_buffer << "endfunction"
end

#__set(variable, value) ⇒ Object



33
34
35
# File 'lib/shell-proxy/vim.rb', line 33

def __set(variable, value)
  __eval "let #{variable}=#{value}"
end

#__subshell(&block) ⇒ Object



20
21
22
# File 'lib/shell-proxy/vim.rb', line 20

def __subshell(&block)
  @cmd_buffer << '" subshell currently not implemented'
end

#cd(dir) ⇒ Object



3
4
5
# File 'lib/shell-proxy/vim.rb', line 3

def cd(dir)
  __eval("cd #{dir}")
end

#touch(file) ⇒ Object



16
17
18
# File 'lib/shell-proxy/vim.rb', line 16

def touch(file)
  __eval("!touch #{file}")
end