Class: WatchTower::Editor::Vim
- Inherits:
-
Object
- Object
- WatchTower::Editor::Vim
- Includes:
- BasePs
- Defined in:
- lib/watch_tower/editor/vim.rb
Constant Summary collapse
- VIM_EXTENSION_PATH =
File.join(EDITOR_EXTENSIONS_PATH, 'watchtower.vim')
Instance Attribute Summary collapse
-
#version ⇒ Object
readonly
Set the attributes read/write of this class.
Instance Method Summary collapse
-
#current_paths ⇒ Array
Return the open documents of all vim servers.
-
#initialize ⇒ Vim
constructor
A new instance of Vim.
-
#is_running? ⇒ Boolean
Is it running ?.
-
#name ⇒ String
Return the name of the Editor.
Methods included from BasePs
Constructor Details
#initialize ⇒ Vim
Returns a new instance of Vim.
15 16 17 18 19 20 |
# File 'lib/watch_tower/editor/vim.rb', line 15 def initialize # Get the list of supported vims supported_vims # Fetch the version @version ||= fetch_version end |
Instance Attribute Details
#version ⇒ Object (readonly)
Set the attributes read/write of this class.
13 14 15 |
# File 'lib/watch_tower/editor/vim.rb', line 13 def version @version end |
Instance Method Details
#current_paths ⇒ Array
Return the open documents of all vim servers
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/watch_tower/editor/vim.rb', line 39 def current_paths if is_running? # Init documents documents = [] servers.each do |server| stdin, stdout, stderr, wait_thr = Open3.popen3 "#{editor} --servername #{server} --remote-expr 'watchtower#ls()'" if stderr.read =~ /Invalid expression received: Send expression failed/i # Close the pipes [stdin, stdout, stderr].each { |p| p.try(:close) } # Send the extenstion to the ViM server send_extensions_to_editor # Ask ViM for the documents again stdin, stdout, stderr, wait_thr = Open3.popen3 "#{editor} --servername #{server} --remote-expr 'watchtower#ls()'" end documents += stdout.read.split("\n") # Close the pipes [stdin, stdout, stderr].each { |p| p.try(:close) } end documents.uniq end end |
#is_running? ⇒ Boolean
Is it running ?
32 33 34 |
# File 'lib/watch_tower/editor/vim.rb', line 32 def is_running? servers && servers.any? end |
#name ⇒ String
Return the name of the Editor
25 26 27 |
# File 'lib/watch_tower/editor/vim.rb', line 25 def name "ViM" end |