neovim 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.gitmodules +1 -1
  4. data/.rspec +1 -0
  5. data/.travis.yml +1 -1
  6. data/CHANGELOG.md +8 -0
  7. data/README.md +5 -3
  8. data/Rakefile +14 -8
  9. data/lib/neovim/buffer.rb +86 -114
  10. data/lib/neovim/client.rb +105 -103
  11. data/lib/neovim/current.rb +8 -18
  12. data/lib/neovim/executable.rb +2 -2
  13. data/lib/neovim/line_range.rb +48 -59
  14. data/lib/neovim/plugin/dsl.rb +11 -3
  15. data/lib/neovim/remote_object.rb +3 -13
  16. data/lib/neovim/ruby_provider.rb +3 -3
  17. data/lib/neovim/ruby_provider/buffer_ext.rb +3 -3
  18. data/lib/neovim/ruby_provider/vim.rb +2 -2
  19. data/lib/neovim/ruby_provider/window_ext.rb +3 -3
  20. data/lib/neovim/session.rb +4 -4
  21. data/lib/neovim/session/api.rb +50 -22
  22. data/lib/neovim/tabpage.rb +29 -19
  23. data/lib/neovim/version.rb +1 -1
  24. data/lib/neovim/window.rb +60 -40
  25. data/script/dump_api +1 -1
  26. data/script/generate_docs +35 -22
  27. data/spec/helper.rb +3 -1
  28. data/spec/integration/rplugin_autocmd_spec.vim +18 -0
  29. data/spec/integration/rplugin_command_spec.vim +97 -0
  30. data/spec/integration/rplugin_function_spec.vim +26 -0
  31. data/spec/integration/ruby_buffer_spec.rb +151 -0
  32. data/spec/{acceptance → integration}/ruby_spec.vim +2 -22
  33. data/spec/integration/ruby_vim_spec.rb +27 -0
  34. data/spec/integration/ruby_window_spec.rb +56 -0
  35. data/spec/{acceptance → integration}/rubydo_spec.vim +27 -18
  36. data/spec/{acceptance → integration}/rubyfile/call_foo.rb +0 -0
  37. data/spec/{acceptance → integration}/rubyfile/curbuf_ivar_get.rb +0 -0
  38. data/spec/{acceptance → integration}/rubyfile/curbuf_ivar_set.rb +0 -0
  39. data/spec/{acceptance → integration}/rubyfile/define_foo.rb +0 -0
  40. data/spec/{acceptance → integration}/rubyfile/raise_standard_error.rb +0 -0
  41. data/spec/{acceptance → integration}/rubyfile/raise_syntax_error.rb +0 -0
  42. data/spec/{acceptance → integration}/rubyfile/set_pwd_after.rb +0 -0
  43. data/spec/{acceptance → integration}/rubyfile/set_pwd_before.rb +0 -0
  44. data/spec/{acceptance → integration}/rubyfile_spec.vim +12 -30
  45. data/spec/integration/runtime/init.vim +9 -0
  46. data/spec/integration/runtime/rplugin/ruby/autocmds.rb +9 -0
  47. data/spec/integration/runtime/rplugin/ruby/commands.rb +59 -0
  48. data/spec/integration/runtime/rplugin/ruby/functions.rb +17 -0
  49. data/spec/integration_spec.rb +119 -0
  50. data/spec/neovim/buffer_spec.rb +0 -167
  51. data/spec/neovim/client_spec.rb +1 -44
  52. data/spec/neovim/current_spec.rb +0 -8
  53. data/spec/neovim/line_range_spec.rb +92 -97
  54. data/spec/neovim/plugin_spec.rb +14 -2
  55. data/spec/neovim/remote_object_spec.rb +4 -4
  56. data/spec/neovim/ruby_provider/buffer_ext_spec.rb +3 -3
  57. data/spec/neovim/ruby_provider/window_ext_spec.rb +1 -1
  58. data/spec/neovim/session/api_spec.rb +40 -35
  59. data/spec/neovim/session/event_loop_spec.rb +1 -1
  60. data/spec/neovim/session_spec.rb +15 -15
  61. metadata +49 -41
  62. data/script/acceptance_tests +0 -46
  63. data/spec/acceptance/rplugin_spec.vim +0 -19
  64. data/spec/acceptance/rubyfile/curbuf.rb +0 -1
  65. data/spec/acceptance/rubyfile/curwin.rb +0 -1
  66. data/spec/acceptance/rubyfile/vim_constants.rb +0 -2
  67. data/spec/acceptance/runtime/init.vim +0 -1
  68. data/spec/acceptance/runtime/rplugin/ruby/plugin.rb +0 -13
  69. data/spec/documentation_spec.rb +0 -24
  70. data/spec/neovim/window_spec.rb +0 -91
@@ -3,37 +3,47 @@ require "neovim/remote_object"
3
3
  module Neovim
4
4
  # Class representing an +nvim+ tabpage.
5
5
  #
6
- # The methods documented here were generated using NVIM v0.1.7
6
+ # The methods documented here were generated using NVIM v0.2.0
7
7
  class Tabpage < RemoteObject
8
-
9
8
  # The following methods are dynamically generated.
10
9
  =begin
11
- @method set_var(name, value)
12
- Send the +tabpage_set_var+ RPC to +nvim+
13
- @param [String] name
14
- @param [Object] value
15
- @return [Object]
10
+ @method list_wins(tabpage)
11
+ See +:h nvim_tabpage_list_wins()+
12
+ @param [Tabpage] tabpage
13
+ @return [Array<Window>]
16
14
 
17
- @method del_var(name)
18
- Send the +tabpage_del_var+ RPC to +nvim+
15
+ @method get_var(tabpage, name)
16
+ See +:h nvim_tabpage_get_var()+
17
+ @param [Tabpage] tabpage
19
18
  @param [String] name
20
19
  @return [Object]
21
20
 
22
- @method get_windows
23
- Send the +tabpage_get_windows+ RPC to +nvim+
24
- @return [Array<Window>]
21
+ @method set_var(tabpage, name, value)
22
+ See +:h nvim_tabpage_set_var()+
23
+ @param [Tabpage] tabpage
24
+ @param [String] name
25
+ @param [Object] value
26
+ @return [void]
25
27
 
26
- @method get_var(name)
27
- Send the +tabpage_get_var+ RPC to +nvim+
28
+ @method del_var(tabpage, name)
29
+ See +:h nvim_tabpage_del_var()+
30
+ @param [Tabpage] tabpage
28
31
  @param [String] name
29
- @return [Object]
32
+ @return [void]
30
33
 
31
- @method get_window
32
- Send the +tabpage_get_window+ RPC to +nvim+
34
+ @method get_win(tabpage)
35
+ See +:h nvim_tabpage_get_win()+
36
+ @param [Tabpage] tabpage
33
37
  @return [Window]
34
38
 
35
- @method is_valid
36
- Send the +tabpage_is_valid+ RPC to +nvim+
39
+ @method get_number(tabpage)
40
+ See +:h nvim_tabpage_get_number()+
41
+ @param [Tabpage] tabpage
42
+ @return [Integer]
43
+
44
+ @method is_valid(tabpage)
45
+ See +:h nvim_tabpage_is_valid()+
46
+ @param [Tabpage] tabpage
37
47
  @return [Boolean]
38
48
 
39
49
  =end
@@ -1,3 +1,3 @@
1
1
  module Neovim
2
- VERSION = Gem::Version.new("0.4.0")
2
+ VERSION = Gem::Version.new("0.5.0")
3
3
  end
@@ -3,13 +3,13 @@ require "neovim/remote_object"
3
3
  module Neovim
4
4
  # Class representing an +nvim+ window.
5
5
  #
6
- # The methods documented here were generated using NVIM v0.1.7
6
+ # The methods documented here were generated using NVIM v0.2.0
7
7
  class Window < RemoteObject
8
8
  # Get the buffer displayed in the window
9
9
  #
10
10
  # @return [Buffer]
11
11
  def buffer
12
- get_buffer
12
+ get_buf
13
13
  end
14
14
 
15
15
  # Get the height of the window
@@ -59,79 +59,99 @@ module Neovim
59
59
  _x, _y = coords
60
60
  x = [_x, 1].max
61
61
  y = [_y, 0].max + 1
62
- @session.request(:vim_eval, "cursor(#{x}, #{y})")
62
+ @session.request(:nvim_eval, "cursor(#{x}, #{y})")
63
63
  end
64
64
 
65
65
  # The following methods are dynamically generated.
66
66
  =begin
67
- @method set_var(name, value)
68
- Send the +window_set_var+ RPC to +nvim+
69
- @param [String] name
70
- @param [Object] value
71
- @return [Object]
72
-
73
- @method del_var(name)
74
- Send the +window_del_var+ RPC to +nvim+
75
- @param [String] name
76
- @return [Object]
77
-
78
- @method get_buffer
79
- Send the +window_get_buffer+ RPC to +nvim+
67
+ @method get_buf(window)
68
+ See +:h nvim_win_get_buf()+
69
+ @param [Window] window
80
70
  @return [Buffer]
81
71
 
82
- @method get_cursor
83
- Send the +window_get_cursor+ RPC to +nvim+
72
+ @method get_cursor(window)
73
+ See +:h nvim_win_get_cursor()+
74
+ @param [Window] window
84
75
  @return [Array<Integer>]
85
76
 
86
- @method set_cursor(pos)
87
- Send the +window_set_cursor+ RPC to +nvim+
77
+ @method set_cursor(window, pos)
78
+ See +:h nvim_win_set_cursor()+
79
+ @param [Window] window
88
80
  @param [Array<Integer>] pos
89
81
  @return [void]
90
82
 
91
- @method get_height
92
- Send the +window_get_height+ RPC to +nvim+
83
+ @method get_height(window)
84
+ See +:h nvim_win_get_height()+
85
+ @param [Window] window
93
86
  @return [Integer]
94
87
 
95
- @method set_height(height)
96
- Send the +window_set_height+ RPC to +nvim+
88
+ @method set_height(window, height)
89
+ See +:h nvim_win_set_height()+
90
+ @param [Window] window
97
91
  @param [Integer] height
98
92
  @return [void]
99
93
 
100
- @method get_width
101
- Send the +window_get_width+ RPC to +nvim+
94
+ @method get_width(window)
95
+ See +:h nvim_win_get_width()+
96
+ @param [Window] window
102
97
  @return [Integer]
103
98
 
104
- @method set_width(width)
105
- Send the +window_set_width+ RPC to +nvim+
99
+ @method set_width(window, width)
100
+ See +:h nvim_win_set_width()+
101
+ @param [Window] window
106
102
  @param [Integer] width
107
103
  @return [void]
108
104
 
109
- @method get_var(name)
110
- Send the +window_get_var+ RPC to +nvim+
105
+ @method get_var(window, name)
106
+ See +:h nvim_win_get_var()+
107
+ @param [Window] window
111
108
  @param [String] name
112
109
  @return [Object]
113
110
 
114
- @method get_option(name)
115
- Send the +window_get_option+ RPC to +nvim+
111
+ @method set_var(window, name, value)
112
+ See +:h nvim_win_set_var()+
113
+ @param [Window] window
114
+ @param [String] name
115
+ @param [Object] value
116
+ @return [void]
117
+
118
+ @method del_var(window, name)
119
+ See +:h nvim_win_del_var()+
120
+ @param [Window] window
121
+ @param [String] name
122
+ @return [void]
123
+
124
+ @method get_option(window, name)
125
+ See +:h nvim_win_get_option()+
126
+ @param [Window] window
116
127
  @param [String] name
117
128
  @return [Object]
118
129
 
119
- @method set_option(name, value)
120
- Send the +window_set_option+ RPC to +nvim+
130
+ @method set_option(window, name, value)
131
+ See +:h nvim_win_set_option()+
132
+ @param [Window] window
121
133
  @param [String] name
122
134
  @param [Object] value
123
135
  @return [void]
124
136
 
125
- @method get_position
126
- Send the +window_get_position+ RPC to +nvim+
137
+ @method get_position(window)
138
+ See +:h nvim_win_get_position()+
139
+ @param [Window] window
127
140
  @return [Array<Integer>]
128
141
 
129
- @method get_tabpage
130
- Send the +window_get_tabpage+ RPC to +nvim+
142
+ @method get_tabpage(window)
143
+ See +:h nvim_win_get_tabpage()+
144
+ @param [Window] window
131
145
  @return [Tabpage]
132
146
 
133
- @method is_valid
134
- Send the +window_is_valid+ RPC to +nvim+
147
+ @method get_number(window)
148
+ See +:h nvim_win_get_number()+
149
+ @param [Window] window
150
+ @return [Integer]
151
+
152
+ @method is_valid(window)
153
+ See +:h nvim_win_is_valid()+
154
+ @param [Window] window
135
155
  @return [Boolean]
136
156
 
137
157
  =end
@@ -7,4 +7,4 @@ require "pp"
7
7
 
8
8
  nvim_exe = ENV.fetch("NVIM_EXECUTABLE", "nvim")
9
9
  session = Neovim::Session.child([nvim_exe, "-u", "NONE", "-n"])
10
- pp session.request(:vim_get_api_info)
10
+ pp session.request(:nvim_get_api_info)
@@ -5,7 +5,7 @@ $:.unshift File.expand_path("../../lib", __FILE__)
5
5
  require "neovim"
6
6
  require "pathname"
7
7
 
8
- vim_docs = []
8
+ nvim_docs = []
9
9
  buffer_docs = []
10
10
  window_docs = []
11
11
  tabpage_docs = []
@@ -13,54 +13,67 @@ nvim_exe = ENV.fetch("NVIM_EXECUTABLE", "nvim")
13
13
  nvim_vrs = %x(#{nvim_exe} --version).split("\n").first
14
14
 
15
15
  session = Neovim::Session.child([nvim_exe, "-u", "NONE", "-n"])
16
- vim_defs = Neovim::Client.instance_methods(false)
16
+ nvim_defs = Neovim::Client.instance_methods(false)
17
17
  buffer_defs = Neovim::Buffer.instance_methods(false)
18
18
  tabpage_defs = Neovim::Tabpage.instance_methods(false)
19
19
  window_defs = Neovim::Window.instance_methods(false)
20
20
 
21
- session.request(:vim_get_api_info)[1]["functions"].each do |func|
22
- prefix, method_name = func["name"].split("_", 2)
21
+ def add_method(docs, defs, method_name)
22
+ return if defs.include?(method_name.to_s)
23
+ end
24
+
25
+ session.request(:nvim_get_api_info)[1]["functions"].each do |func|
26
+ func_name = func["name"]
27
+ params = func["parameters"]
23
28
 
24
- case prefix
25
- when "vim"
26
- next if vim_defs.include?(method_name.to_sym)
27
- when "buffer"
29
+ case func_name
30
+ when /^nvim_buf_(.+)/
31
+ method_name = $1
28
32
  next if buffer_defs.include?(method_name.to_sym)
29
- when "tabpage"
30
- next if tabpage_defs.include?(method_name.to_sym)
31
- when "window"
33
+ when /^nvim_win_(.+)/
34
+ method_name = $1
32
35
  next if window_defs.include?(method_name.to_sym)
36
+ when /^nvim_tabpage_(.+)/
37
+ method_name = $1
38
+ next if tabpage_defs.include?(method_name.to_sym)
39
+ when /^nvim_(.+)/
40
+ method_name = $1
41
+ params.shift
42
+ next if nvim_defs.include?(method_name.to_sym)
43
+ else
44
+ next
33
45
  end
34
46
 
35
47
  return_type = func["return_type"]
36
- params = func["parameters"]
37
- params.shift unless prefix == "vim"
38
48
  param_names = params.map(&:last)
39
49
  param_str = params.empty? ? "" : "(#{param_names.join(", ")})"
40
50
  method_decl = "@method #{method_name}#{param_str}"
41
- method_desc = " Send the +#{prefix}_#{method_name}+ RPC to +nvim+"
51
+ method_desc = " See +:h #{func_name}()+"
42
52
  param_docs = params.map do |type, name|
43
53
  " @param [#{type}] #{name}"
44
54
  end
45
55
  return_doc = " @return [#{return_type}]\n"
46
56
  method_doc = [method_decl, method_desc, *param_docs, return_doc].join("\n")
47
57
  method_doc.gsub!(/ArrayOf\((\w+)[^)]*\)/, 'Array<\1>')
58
+ method_doc.gsub!(/Dictionary/, "Hash")
48
59
 
49
- case prefix
50
- when "vim"
51
- vim_docs << method_doc
52
- when "buffer"
60
+ case func_name
61
+ when /nvim_buf_(.+)/
53
62
  buffer_docs << method_doc
54
- when "tabpage"
55
- tabpage_docs << method_doc
56
- when "window"
63
+ when /nvim_win_(.+)/
57
64
  window_docs << method_doc
65
+ when /nvim_tabpage_(.+)/
66
+ tabpage_docs << method_doc
67
+ when /nvim_(.+)/
68
+ nvim_docs << method_doc
69
+ else
70
+ raise "Unexpected function #{func_name.inspect}"
58
71
  end
59
72
  end
60
73
 
61
74
  lib_dir = Pathname.new(File.expand_path("../../lib/neovim", __FILE__))
62
75
  {
63
- "client.rb" => vim_docs,
76
+ "client.rb" => nvim_docs,
64
77
  "buffer.rb" => buffer_docs,
65
78
  "tabpage.rb" => tabpage_docs,
66
79
  "window.rb" => window_docs,
@@ -22,12 +22,14 @@ RSpec.configure do |config|
22
22
  config.disable_monkey_patching!
23
23
  config.order = :random
24
24
  config.color = true
25
+ config.filter_run_excluding :embedded
25
26
 
26
27
  config.around(:example) do |spec|
27
28
  Support.setup_workspace
29
+ timeout = spec.metadata.fetch(:timeout, 3)
28
30
 
29
31
  begin
30
- Timeout.timeout(5) { spec.run }
32
+ Timeout.timeout(timeout) { spec.run }
31
33
  ensure
32
34
  Support.teardown_workspace
33
35
  end
@@ -0,0 +1,18 @@
1
+ Before (Generate rplugin manifest):
2
+ silent UpdateRemotePlugins
3
+
4
+ Execute (Trigger event for matching patterns):
5
+ silent split file.rb
6
+ sleep 50m
7
+ AssertEqual v:true, b:rplugin_autocmd_BufEnter
8
+
9
+ Execute (Don't trigger event for non-matching patterns):
10
+ silent split file.py
11
+ sleep 50m
12
+ AssertEqual 0, exists("b:rplugin_autocmd_BufEnter")
13
+
14
+ Execute (Trigger event with eval):
15
+ let g:to_eval = {'a': 42}
16
+ silent split file.c
17
+ sleep 50m
18
+ AssertEqual {'a': 42}, g:rplugin_autocmd_BufEnter_eval
@@ -0,0 +1,97 @@
1
+ Before (Generate rplugin manifest):
2
+ silent UpdateRemotePlugins
3
+
4
+ Execute (Call rplugin commands with arguments):
5
+ RPluginCommandNargs0
6
+ RPluginCommandNargs1 1
7
+ RPluginCommandNargsN
8
+ RPluginCommandNargsN 1
9
+ RPluginCommandNargsN 1 2
10
+ RPluginCommandNargsQ
11
+ RPluginCommandNargsQ 1
12
+ RPluginCommandNargsP 1
13
+ RPluginCommandNargsP 1 2
14
+ sleep 100m
15
+
16
+ Then:
17
+ AssertEqual v:true, g:rplugin_command_nargs_0
18
+ AssertEqual "1", g:rplugin_command_nargs_1
19
+ AssertEqual ["1", "2"], g:rplugin_command_nargs_n
20
+ AssertEqual "1", g:rplugin_command_nargs_q
21
+ AssertEqual ["1", "2"], g:rplugin_command_nargs_p
22
+
23
+ Given:
24
+ one
25
+ two
26
+ three
27
+
28
+ Execute (Call rplugin commands with a range):
29
+ RPluginCommandRange
30
+ sleep 50m
31
+ AssertEqual [1, 1], g:rplugin_command_range
32
+
33
+ 1,2RPluginCommandRange
34
+ sleep 50m
35
+ AssertEqual [1, 2], g:rplugin_command_range
36
+
37
+ %RPluginCommandRange
38
+ sleep 50m
39
+ AssertEqual [1, 3], g:rplugin_command_range
40
+
41
+ RPluginCommandRangeP
42
+ sleep 50m
43
+ AssertEqual [1, 3], g:rplugin_command_range_p
44
+
45
+ 1,2RPluginCommandRangeP
46
+ sleep 50m
47
+ AssertEqual [1, 2], g:rplugin_command_range_p
48
+
49
+ %RPluginCommandRangeP
50
+ sleep 50m
51
+ AssertEqual [1, 3], g:rplugin_command_range_p
52
+
53
+ RPluginCommandRangeN
54
+ sleep 50m
55
+ AssertEqual [1], g:rplugin_command_range_n
56
+
57
+ 2RPluginCommandRangeN
58
+ sleep 50m
59
+ AssertEqual [2], g:rplugin_command_range_n
60
+
61
+ Execute (Call rplugin commands with a count):
62
+ RPluginCommandCountN
63
+ sleep 50m
64
+ AssertEqual [1], g:rplugin_command_count_n
65
+
66
+ 2RPluginCommandCountN
67
+ sleep 50m
68
+ AssertEqual [2], g:rplugin_command_count_n
69
+
70
+ Execute (Call rplugin commands with a bang):
71
+ RPluginCommandBang
72
+ sleep 50m
73
+ AssertEqual 0, g:rplugin_command_bang
74
+
75
+ RPluginCommandBang!
76
+ sleep 50m
77
+ AssertEqual 1, g:rplugin_command_bang
78
+
79
+ Execute (Call rplugin commands with a register):
80
+ RPluginCommandRegister a
81
+ sleep 50m
82
+ AssertEqual "a", g:rplugin_command_register
83
+
84
+ Execute (Call rplugin commands with completion):
85
+ RPluginCommandCompletion
86
+ sleep 50m
87
+ AssertEqual "buffer", g:rplugin_command_completion
88
+
89
+ Execute (Call rplugin commands with eval):
90
+ let g:to_eval = {'n': 42}
91
+ RPluginCommandEval
92
+ sleep 50m
93
+ AssertEqual {'n': 42}, g:rplugin_command_eval
94
+
95
+ Execute (Call synchronous rplugin commands):
96
+ RPluginCommandSync
97
+ AssertEqual v:true, g:rplugin_command_sync