Class: Neovim::Buffer Private
- Inherits:
-
RemoteObject
- Object
- RemoteObject
- Neovim::Buffer
- Defined in:
- lib/neovim/buffer.rb,
lib/neovim/ruby_provider/buffer_ext.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
-
#lines ⇒ Object
Returns the value of attribute lines.
Attributes inherited from RemoteObject
Class Method Summary collapse
- .[](index) ⇒ Object private
- .count ⇒ Object private
- .current ⇒ Object private
Instance Method Summary collapse
-
#[](index) ⇒ String
Get the given line (1-indexed).
-
#[]=(index, str) ⇒ String
Set the given line (1-indexed).
-
#active? ⇒ Boolean
Determine if the buffer is active.
-
#add_highlight(ns_id, hl_group, line, col_start, col_end) ⇒ Integer
See :h nvim_buf_add_highlight().
-
#append(index, str) ⇒ String
Append a line after the given line (1-indexed).
-
#attach(send_buffer, opts) ⇒ Boolean
See :h nvim_buf_attach().
-
#call(fun) ⇒ Object
See :h nvim_buf_call().
-
#clear_highlight(ns_id, line_start, line_end) ⇒ void
See :h nvim_buf_clear_highlight().
-
#clear_namespace(ns_id, line_start, line_end) ⇒ void
See :h nvim_buf_clear_namespace().
-
#count ⇒ Integer
Get the number of lines.
-
#create_user_command(name, command, opts) ⇒ void
See :h nvim_buf_create_user_command().
-
#del_extmark(ns_id, id) ⇒ Boolean
See :h nvim_buf_del_extmark().
-
#del_keymap(mode, lhs) ⇒ void
See :h nvim_buf_del_keymap().
-
#del_mark(name) ⇒ Boolean
See :h nvim_buf_del_mark().
-
#del_user_command(name) ⇒ void
See :h nvim_buf_del_user_command().
-
#del_var(name) ⇒ void
See :h nvim_buf_del_var().
-
#delete(index) ⇒ void
Delete the given line (1-indexed).
-
#detach ⇒ Boolean
See :h nvim_buf_detach().
-
#get_changedtick ⇒ Integer
See :h nvim_buf_get_changedtick().
-
#get_commands(opts) ⇒ Hash
See :h nvim_buf_get_commands().
-
#get_extmark_by_id(ns_id, id, opts) ⇒ Array<Integer>
See :h nvim_buf_get_extmark_by_id().
-
#get_extmarks(ns_id, start, end) ⇒ Array
See :h nvim_buf_get_extmarks().
-
#get_keymap(mode) ⇒ Array<Hash>
See :h nvim_buf_get_keymap().
-
#get_lines(start, end) ⇒ Array<String>
See :h nvim_buf_get_lines().
-
#get_mark(name) ⇒ Array<Integer>
See :h nvim_buf_get_mark().
-
#get_name ⇒ String
See :h nvim_buf_get_name().
-
#get_number ⇒ Integer
See :h nvim_buf_get_number().
-
#get_offset(index) ⇒ Integer
See :h nvim_buf_get_offset().
-
#get_option(name) ⇒ Object
See :h nvim_buf_get_option().
-
#get_text(start_row, start_col, end_row, end_col, opts) ⇒ Array<String>
See :h nvim_buf_get_text().
-
#get_var(name) ⇒ Object
See :h nvim_buf_get_var().
-
#initialize(*args) ⇒ Buffer
constructor
A new instance of Buffer.
-
#is_loaded ⇒ Boolean
See :h nvim_buf_is_loaded().
-
#is_valid ⇒ Boolean
See :h nvim_buf_is_valid().
-
#length ⇒ Integer
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 ⇒ Integer
See :h nvim_buf_line_count().
-
#line_number ⇒ Integer?
Get the current line number of an active buffer.
-
#name ⇒ String
Get the buffer name.
-
#number ⇒ Integer
Get the buffer index.
-
#set_extmark(ns_id, line, col, opts) ⇒ Integer
See :h nvim_buf_set_extmark().
-
#set_keymap(mode, lhs, rhs, opts) ⇒ void
See :h nvim_buf_set_keymap().
-
#set_lines(start, end) ⇒ void
See :h nvim_buf_set_lines().
-
#set_mark(name, line, col, opts) ⇒ Boolean
See :h nvim_buf_set_mark().
-
#set_name(name) ⇒ void
See :h nvim_buf_set_name().
-
#set_option(name, value) ⇒ void
See :h nvim_buf_set_option().
-
#set_text(start_row, start_col, end_row, end_col, replacement) ⇒ void
See :h nvim_buf_set_text().
-
#set_var(name, value) ⇒ void
See :h nvim_buf_set_var().
-
#set_virtual_text(src_id, line, chunks, opts) ⇒ Integer
See :h nvim_buf_set_virtual_text().
Methods inherited from RemoteObject
#==, #method_missing, #methods, #respond_to_missing?, #to_msgpack
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Neovim::RemoteObject
Instance Attribute Details
#lines ⇒ Object
Returns the value of attribute lines.
9 10 11 |
# File 'lib/neovim/buffer.rb', line 9 def lines @lines end |
Class Method Details
.[](index) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/neovim/ruby_provider/buffer_ext.rb', line 14 def self.[](index) ::Vim.list_bufs[index] end |
Instance Method Details
#[](index) ⇒ String
Get the given line (1-indexed).
56 57 58 59 |
# File 'lib/neovim/buffer.rb', line 56 def [](index) check_index(index, 1) @lines[index - 1] end |
#[]=(index, str) ⇒ String
Set the given line (1-indexed).
66 67 68 69 |
# File 'lib/neovim/buffer.rb', line 66 def []=(index, str) check_index(index, 1) @lines[index - 1] = str end |
#active? ⇒ Boolean
Determine if the buffer is active.
127 128 129 |
# File 'lib/neovim/buffer.rb', line 127 def active? @session.request(:nvim_get_current_buf) == self end |
#add_highlight(ns_id, hl_group, line, col_start, col_end) ⇒ Integer
See :h nvim_buf_add_highlight()
|
# File 'lib/neovim/buffer.rb', line 141
|
#append(index, str) ⇒ String
Append a line after the given line (1-indexed).
Unlike the other methods, ‘0` is a valid index argument here, and inserts into the first line of the buffer.
To maintain backwards compatibility with vim
, the cursor is forced back to its previous position after inserting the line.
92 93 94 95 96 97 98 99 100 |
# File 'lib/neovim/buffer.rb', line 92 def append(index, str) check_index(index, 0) window = @session.request(:nvim_get_current_win) cursor = window.cursor set_lines(index, index, true, [*str.split($/)]) window.set_cursor(cursor) str end |
#attach(send_buffer, opts) ⇒ Boolean
See :h nvim_buf_attach()
|
# File 'lib/neovim/buffer.rb', line 141
|
#clear_highlight(ns_id, line_start, line_end) ⇒ void
This method returns an undefined value.
See :h nvim_buf_clear_highlight()
|
# File 'lib/neovim/buffer.rb', line 141
|
#clear_namespace(ns_id, line_start, line_end) ⇒ void
This method returns an undefined value.
See :h nvim_buf_clear_namespace()
|
# File 'lib/neovim/buffer.rb', line 141
|
#count ⇒ Integer
Get the number of lines.
41 42 43 |
# File 'lib/neovim/buffer.rb', line 41 def count line_count end |
#create_user_command(name, command, opts) ⇒ void
This method returns an undefined value.
See :h nvim_buf_create_user_command()
|
# File 'lib/neovim/buffer.rb', line 141
|
#del_extmark(ns_id, id) ⇒ Boolean
See :h nvim_buf_del_extmark()
|
# File 'lib/neovim/buffer.rb', line 141
|
#del_keymap(mode, lhs) ⇒ void
This method returns an undefined value.
See :h nvim_buf_del_keymap()
|
# File 'lib/neovim/buffer.rb', line 141
|
#del_mark(name) ⇒ Boolean
See :h nvim_buf_del_mark()
|
# File 'lib/neovim/buffer.rb', line 141
|
#del_user_command(name) ⇒ void
This method returns an undefined value.
See :h nvim_buf_del_user_command()
|
# File 'lib/neovim/buffer.rb', line 141
|
#del_var(name) ⇒ void
This method returns an undefined value.
See :h nvim_buf_del_var()
|
# File 'lib/neovim/buffer.rb', line 141
|
#delete(index) ⇒ void
This method returns an undefined value.
Delete the given line (1-indexed).
75 76 77 78 79 |
# File 'lib/neovim/buffer.rb', line 75 def delete(index) check_index(index, 1) @lines.delete(index - 1) nil end |
#detach ⇒ Boolean
See :h nvim_buf_detach()
|
# File 'lib/neovim/buffer.rb', line 141
|
#get_changedtick ⇒ Integer
See :h nvim_buf_get_changedtick()
|
# File 'lib/neovim/buffer.rb', line 141
|
#get_commands(opts) ⇒ Hash
See :h nvim_buf_get_commands()
|
# File 'lib/neovim/buffer.rb', line 141
|
#get_extmark_by_id(ns_id, id, opts) ⇒ Array<Integer>
See :h nvim_buf_get_extmark_by_id()
|
# File 'lib/neovim/buffer.rb', line 141
|
#get_extmarks(ns_id, start, end) ⇒ Array
See :h nvim_buf_get_extmarks()
|
# File 'lib/neovim/buffer.rb', line 141
|
#get_keymap(mode) ⇒ Array<Hash>
See :h nvim_buf_get_keymap()
|
# File 'lib/neovim/buffer.rb', line 141
|
#get_lines(start, end) ⇒ Array<String>
See :h nvim_buf_get_lines()
|
# File 'lib/neovim/buffer.rb', line 141
|
#get_mark(name) ⇒ Array<Integer>
See :h nvim_buf_get_mark()
|
# File 'lib/neovim/buffer.rb', line 141
|
#get_name ⇒ String
See :h nvim_buf_get_name()
|
# File 'lib/neovim/buffer.rb', line 141
|
#get_number ⇒ Integer
See :h nvim_buf_get_number()
|
# File 'lib/neovim/buffer.rb', line 141
|
#get_offset(index) ⇒ Integer
See :h nvim_buf_get_offset()
|
# File 'lib/neovim/buffer.rb', line 141
|
#get_text(start_row, start_col, end_row, end_col, opts) ⇒ Array<String>
See :h nvim_buf_get_text()
|
# File 'lib/neovim/buffer.rb', line 141
|
#is_loaded ⇒ Boolean
See :h nvim_buf_is_loaded()
|
# File 'lib/neovim/buffer.rb', line 141
|
#is_valid ⇒ Boolean
See :h nvim_buf_is_valid()
|
# File 'lib/neovim/buffer.rb', line 141
|
#length ⇒ Integer
Get the number of lines.
48 49 50 |
# File 'lib/neovim/buffer.rb', line 48 def length count end |
#line ⇒ String?
Get the current line of an active buffer.
105 106 107 |
# File 'lib/neovim/buffer.rb', line 105 def line @session.request(:nvim_get_current_line) if active? end |
#line=(str) ⇒ String?
Set the current line of an active buffer.
113 114 115 |
# File 'lib/neovim/buffer.rb', line 113 def line=(str) @session.request(:nvim_set_current_line, str) if active? end |
#line_count ⇒ Integer
See :h nvim_buf_line_count()
|
# File 'lib/neovim/buffer.rb', line 141
|
#line_number ⇒ Integer?
Get the current line number of an active buffer.
120 121 122 |
# File 'lib/neovim/buffer.rb', line 120 def line_number @session.request(:nvim_get_current_win).get_cursor[0] if active? end |
#name ⇒ String
Get the buffer name.
27 28 29 |
# File 'lib/neovim/buffer.rb', line 27 def name get_name end |
#number ⇒ Integer
Get the buffer index.
34 35 36 |
# File 'lib/neovim/buffer.rb', line 34 def number get_number end |
#set_extmark(ns_id, line, col, opts) ⇒ Integer
See :h nvim_buf_set_extmark()
|
# File 'lib/neovim/buffer.rb', line 141
|
#set_keymap(mode, lhs, rhs, opts) ⇒ void
This method returns an undefined value.
See :h nvim_buf_set_keymap()
|
# File 'lib/neovim/buffer.rb', line 141
|
#set_lines(start, end) ⇒ void
This method returns an undefined value.
See :h nvim_buf_set_lines()
|
# File 'lib/neovim/buffer.rb', line 141
|
#set_mark(name, line, col, opts) ⇒ Boolean
See :h nvim_buf_set_mark()
|
# File 'lib/neovim/buffer.rb', line 141
|
#set_name(name) ⇒ void
This method returns an undefined value.
See :h nvim_buf_set_name()
|
# File 'lib/neovim/buffer.rb', line 141
|
#set_option(name, value) ⇒ void
This method returns an undefined value.
See :h nvim_buf_set_option()
|
# File 'lib/neovim/buffer.rb', line 141
|
#set_text(start_row, start_col, end_row, end_col, replacement) ⇒ void
This method returns an undefined value.
See :h nvim_buf_set_text()
|
# File 'lib/neovim/buffer.rb', line 141
|
#set_var(name, value) ⇒ void
This method returns an undefined value.
See :h nvim_buf_set_var()
|
# File 'lib/neovim/buffer.rb', line 141
|
#set_virtual_text(src_id, line, chunks, opts) ⇒ Integer
See :h nvim_buf_set_virtual_text()
|
# File 'lib/neovim/buffer.rb', line 141
|