Class: VimDo::CLI
Instance Method Summary collapse
- #commands(*cmd) ⇒ Object
- #diff(from, to) ⇒ Object
- #edit(filename) ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #merge(local, merge, remote, base = nil) ⇒ Object
- #normal(keys = "") ⇒ Object
Constructor Details
Instance Method Details
#commands(*cmd) ⇒ Object
39 40 41 |
# File 'lib/vimdo/cli.rb', line 39 def commands(*cmd) vim.normal(":<C-u>#{cmd.join(' <Bar> ')}<CR>") end |
#diff(from, to) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/vimdo/cli.rb', line 55 def diff(from, to) [from, to].each do |f| raise PathError "#{f} is not readable!" unless File.readable?(f) end from = File.(from) to = File.(to) from, to = [from, to].map {|f| File.(f) } commands('tabnew', 'edit '+vim.fesc(from), 'diffsplit '+vim.fesc(to)) end |
#edit(filename) ⇒ Object
50 51 52 |
# File 'lib/vimdo/cli.rb', line 50 def edit(filename) vim.edit(filename) end |
#merge(local, merge, remote, base = nil) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/vimdo/cli.rb', line 70 def merge(local, merge, remote, base = nil) [local, merge, remote].each do |f| unless File.readable?(f) raise PathError "#{f} is not readable!" end end raise PathError "#{base} is not readable!" unless File.readable?(base) or base.nil? local, merge, remote = [local, merge, remote].map {|f| File.(f) } merge_command = 'tabnew<Bar>edit ' + vim.fesc(local) + '<Bar>diffsplit ' + vim.fesc(merge) + '<Bar>diffsplit ' + vim.fesc(remote) if base base_split_command = "<Bar>diffsplit #{vim.fesc(File.(base))}<Bar>wincmd J" else base_split_command = '' end switch_command = "<Bar>2wincmd w" commands(merge_command + base_split_command + switch_command) end |
#normal(keys = "") ⇒ Object
44 45 46 |
# File 'lib/vimdo/cli.rb', line 44 def normal(keys = "") vim.normal(keys) end |