Class: Neovim::Buffer
- Inherits:
-
RemoteObject
- Object
- RemoteObject
- Neovim::Buffer
- Defined in:
- lib/neovim/buffer.rb,
lib/neovim/ruby_provider.rb
Overview
Make VIM::Buffer.current
return the current buffer.
Instance Attribute Summary
Attributes inherited from RemoteObject
Class Method Summary collapse
Instance Method Summary collapse
-
#[](index) ⇒ String
Get the line at the given index.
-
#[]=(index, str) ⇒ String
Set the line at the given index.
-
#active? ⇒ Boolean
Determine if the buffer is active.
- #add_highlight(src_id, hl_group, line, col_start, col_end) ⇒ Fixnum
-
#append(index, str) ⇒ String
Append a line after the given index.
- #clear_highlight(src_id, line_start, line_end) ⇒ void
-
#count ⇒ Fixnum
Get the number of lines.
- #del_line(index) ⇒ void
-
#delete(index) ⇒ void
Delete the line at the given index.
- #get_line(index) ⇒ String
- #get_line_slice(start, end) ⇒ Array<String>
- #get_lines(start, end) ⇒ Array<String>
- #get_mark(name) ⇒ Array<Fixnum>
- #get_name ⇒ String
- #get_number ⇒ Fixnum
- #get_option(name) ⇒ Object
- #get_var(name) ⇒ Object
- #insert(lnum, lines) ⇒ void
- #is_valid ⇒ Boolean
-
#length ⇒ Fixnum
Get the number of lines.
-
#line ⇒ String?
Get the current line of an active buffer.
-
#line=(str) ⇒ String?
Set the current line of an active buffer.
- #line_count ⇒ Fixnum
-
#line_number ⇒ Fixnum?
Get the current line number of an active buffer.
-
#lines ⇒ LineRange
A
LineRange
object representing the buffer’s lines. -
#lines=(strs) ⇒ Array<String>
Replace all the lines of the buffer.
-
#name ⇒ String
Get the buffer name.
-
#number ⇒ Fixnum
Get the buffer index.
-
#range ⇒ LineRange
A
LineRange
object representing the buffer’s selection range. -
#range=(_range) ⇒ LineRange
Set the buffer’s current selection range.
- #set_line(index, line) ⇒ void
- #set_line_slice(start, end) ⇒ void
- #set_lines(start, end) ⇒ void
- #set_name(name) ⇒ void
- #set_option(name, value) ⇒ void
- #set_var(name, value) ⇒ Object
Methods inherited from RemoteObject
#==, #initialize, #method_missing, #methods, #respond_to?, #to_msgpack
Constructor Details
This class inherits a constructor from Neovim::RemoteObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Neovim::RemoteObject
Class Method Details
.current ⇒ Object
17 18 19 |
# File 'lib/neovim/ruby_provider.rb', line 17 def self.current ::VIM.current.buffer end |
Instance Method Details
#[](index) ⇒ String
Get the line at the given index.
73 74 75 |
# File 'lib/neovim/buffer.rb', line 73 def [](index) lines[index] end |
#[]=(index, str) ⇒ String
Set the line at the given index.
82 83 84 |
# File 'lib/neovim/buffer.rb', line 82 def []=(index, str) lines[index] = str end |
#active? ⇒ Boolean
Determine if the buffer is active.
136 137 138 |
# File 'lib/neovim/buffer.rb', line 136 def active? @session.request(:vim_get_current_buffer) == self end |
#add_highlight(src_id, hl_group, line, col_start, col_end) ⇒ Fixnum
|
# File 'lib/neovim/buffer.rb', line 142
|
#append(index, str) ⇒ String
Append a line after the given index.
99 100 101 102 |
# File 'lib/neovim/buffer.rb', line 99 def append(index, str) lines[index, 1] = [lines[index], str] str end |
#clear_highlight(src_id, line_start, line_end) ⇒ void
This method returns an undefined value.
|
# File 'lib/neovim/buffer.rb', line 142
|
#count ⇒ Fixnum
Get the number of lines.
58 59 60 |
# File 'lib/neovim/buffer.rb', line 58 def count lines.to_a.size end |
#del_line(index) ⇒ void
This method returns an undefined value.
|
# File 'lib/neovim/buffer.rb', line 142
|
#delete(index) ⇒ void
This method returns an undefined value.
Delete the line at the given index.
90 91 92 |
# File 'lib/neovim/buffer.rb', line 90 def delete(index) lines.delete(index) end |
#get_line(index) ⇒ String
|
# File 'lib/neovim/buffer.rb', line 142
|
#get_line_slice(start, end) ⇒ Array<String>
|
# File 'lib/neovim/buffer.rb', line 142
|
#get_lines(start, end) ⇒ Array<String>
|
# File 'lib/neovim/buffer.rb', line 142
|
#get_mark(name) ⇒ Array<Fixnum>
|
# File 'lib/neovim/buffer.rb', line 142
|
#get_name ⇒ String
|
# File 'lib/neovim/buffer.rb', line 142
|
#get_number ⇒ Fixnum
|
# File 'lib/neovim/buffer.rb', line 142
|
#get_option(name) ⇒ Object
|
# File 'lib/neovim/buffer.rb', line 142
|
#get_var(name) ⇒ Object
|
# File 'lib/neovim/buffer.rb', line 142
|
#insert(lnum, lines) ⇒ void
This method returns an undefined value.
|
# File 'lib/neovim/buffer.rb', line 142
|
#is_valid ⇒ Boolean
|
# File 'lib/neovim/buffer.rb', line 142
|
#length ⇒ Fixnum
Get the number of lines.
65 66 67 |
# File 'lib/neovim/buffer.rb', line 65 def length count end |
#line ⇒ String?
Get the current line of an active buffer.
107 108 109 110 111 |
# File 'lib/neovim/buffer.rb', line 107 def line if active? @session.request(:vim_get_current_line) end end |
#line=(str) ⇒ String?
Set the current line of an active buffer.
117 118 119 120 121 |
# File 'lib/neovim/buffer.rb', line 117 def line=(str) if active? @session.request(:vim_set_current_line, str) end end |
#line_count ⇒ Fixnum
|
# File 'lib/neovim/buffer.rb', line 142
|
#line_number ⇒ Fixnum?
Get the current line number of an active buffer.
126 127 128 129 130 131 |
# File 'lib/neovim/buffer.rb', line 126 def line_number if active? window = @session.request(:vim_get_current_window) @session.request(:window_get_cursor, window)[0] end end |
#lines ⇒ LineRange
A LineRange
object representing the buffer’s lines.
11 12 13 |
# File 'lib/neovim/buffer.rb', line 11 def lines @lines ||= LineRange.new(self, 0, -1) end |
#lines=(strs) ⇒ Array<String>
Replace all the lines of the buffer.
19 20 21 |
# File 'lib/neovim/buffer.rb', line 19 def lines=(strs) lines[0..-1] = strs end |
#name ⇒ String
Get the buffer name.
44 45 46 |
# File 'lib/neovim/buffer.rb', line 44 def name get_name end |
#number ⇒ Fixnum
Get the buffer index.
51 52 53 |
# File 'lib/neovim/buffer.rb', line 51 def number get_number end |
#range ⇒ LineRange
A LineRange
object representing the buffer’s selection range.
27 28 29 |
# File 'lib/neovim/buffer.rb', line 27 def range @range ||= LineRange.new(self, 0, -1) end |
#range=(_range) ⇒ LineRange
Set the buffer’s current selection range.
36 37 38 39 |
# File 'lib/neovim/buffer.rb', line 36 def range=(_range) _end = _range.exclude_end? ? _range.end - 1 : _range.end @range = LineRange.new(self, _range.begin, _end) end |
#set_line(index, line) ⇒ void
This method returns an undefined value.
|
# File 'lib/neovim/buffer.rb', line 142
|
#set_line_slice(start, end) ⇒ void
This method returns an undefined value.
|
# File 'lib/neovim/buffer.rb', line 142
|
#set_lines(start, end) ⇒ void
This method returns an undefined value.
|
# File 'lib/neovim/buffer.rb', line 142
|
#set_name(name) ⇒ void
This method returns an undefined value.
|
# File 'lib/neovim/buffer.rb', line 142
|
#set_option(name, value) ⇒ void
This method returns an undefined value.
|
# File 'lib/neovim/buffer.rb', line 142
|
#set_var(name, value) ⇒ Object
|
# File 'lib/neovim/buffer.rb', line 142
|