neovim 0.7.1 → 0.9.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 (75) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/docs.yml +39 -0
  3. data/.github/workflows/tests.yml +64 -0
  4. data/.gitignore +2 -0
  5. data/CHANGELOG.md +22 -0
  6. data/CODE_OF_CONDUCT.md +3 -3
  7. data/README.md +19 -20
  8. data/Rakefile +21 -11
  9. data/exe/neovim-ruby-host +5 -0
  10. data/lib/neovim/buffer.rb +120 -41
  11. data/lib/neovim/client.rb +304 -39
  12. data/lib/neovim/client_info.rb +46 -0
  13. data/lib/neovim/connection.rb +7 -2
  14. data/lib/neovim/event_loop.rb +8 -4
  15. data/lib/neovim/host/cli.rb +41 -0
  16. data/lib/neovim/host.rb +3 -0
  17. data/lib/neovim/logging.rb +1 -1
  18. data/lib/neovim/message.rb +1 -1
  19. data/lib/neovim/plugin/dsl.rb +6 -0
  20. data/lib/neovim/plugin.rb +7 -2
  21. data/lib/neovim/remote_object.rb +5 -2
  22. data/lib/neovim/ruby_provider/object_ext.rb +5 -0
  23. data/lib/neovim/ruby_provider/vim.rb +6 -5
  24. data/lib/neovim/ruby_provider.rb +29 -10
  25. data/lib/neovim/session.rb +21 -16
  26. data/lib/neovim/tabpage.rb +8 -15
  27. data/lib/neovim/version.rb +1 -1
  28. data/lib/neovim/window.rb +45 -33
  29. data/lib/neovim.rb +12 -3
  30. data/neovim.gemspec +4 -5
  31. data/script/ci/download_nvim.sh +40 -0
  32. data/script/dump_api.rb +1 -1
  33. data/script/generate_docs.rb +6 -7
  34. data/script/run_acceptance.rb +15 -11
  35. data/spec/acceptance/client_info_spec.vim +42 -0
  36. data/spec/acceptance/rplugin_command_spec.vim +2 -2
  37. data/spec/acceptance/ruby_spec.vim +18 -11
  38. data/spec/acceptance/rubydo_spec.vim +9 -0
  39. data/spec/acceptance/rubyeval_spec.vim +22 -0
  40. data/spec/acceptance/rubyfile/curbuf_ivar_get.rb +1 -1
  41. data/spec/acceptance/rubyfile/curbuf_ivar_set.rb +1 -1
  42. data/spec/acceptance/rubyfile/define_foo.rb +1 -1
  43. data/spec/acceptance/rubyfile/nested_inner.rb +1 -1
  44. data/spec/acceptance/rubyfile/set_pwd_after.rb +1 -1
  45. data/spec/acceptance/rubyfile/set_pwd_before.rb +1 -1
  46. data/spec/acceptance/rubyfile_spec.vim +19 -19
  47. data/spec/acceptance/runtime/init.vim +2 -2
  48. data/spec/acceptance/runtime/rplugin/ruby/commands.rb +2 -2
  49. data/spec/helper.rb +25 -7
  50. data/spec/neovim/api_spec.rb +1 -1
  51. data/spec/neovim/buffer_spec.rb +10 -6
  52. data/spec/neovim/client_info_spec.rb +77 -0
  53. data/spec/neovim/client_spec.rb +9 -2
  54. data/spec/neovim/connection_spec.rb +32 -4
  55. data/spec/neovim/current_spec.rb +1 -2
  56. data/spec/neovim/event_loop_spec.rb +16 -0
  57. data/spec/neovim/host/cli_spec.rb +94 -0
  58. data/spec/neovim/host_spec.rb +16 -14
  59. data/spec/neovim/line_range_spec.rb +1 -3
  60. data/spec/neovim/remote_object_spec.rb +1 -2
  61. data/spec/neovim/ruby_provider/buffer_ext_spec.rb +6 -7
  62. data/spec/neovim/ruby_provider/object_ext_spec.rb +10 -0
  63. data/spec/neovim/ruby_provider/vim_spec.rb +1 -1
  64. data/spec/neovim/ruby_provider/window_ext_spec.rb +7 -10
  65. data/spec/neovim/session_spec.rb +13 -40
  66. data/spec/neovim/window_spec.rb +1 -1
  67. data/spec/neovim_spec.rb +28 -51
  68. data/spec/support.rb +27 -1
  69. metadata +26 -44
  70. data/.coveralls.yml +0 -1
  71. data/.rubocop.yml +0 -118
  72. data/.travis.yml +0 -22
  73. data/appveyor.yml +0 -31
  74. data/bin/neovim-ruby-host +0 -18
  75. data/script/validate_docs.rb +0 -29
@@ -3,47 +3,40 @@ 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.2.2
6
+ # The methods documented here were generated using NVIM v0.5.0
7
7
  class Tabpage < RemoteObject
8
8
  # The following methods are dynamically generated.
9
9
  =begin
10
- @method list_wins(tabpage)
10
+ @method list_wins
11
11
  See +:h nvim_tabpage_list_wins()+
12
- @param [Tabpage] tabpage
13
12
  @return [Array<Window>]
14
13
 
15
- @method get_var(tabpage, name)
14
+ @method get_var(name)
16
15
  See +:h nvim_tabpage_get_var()+
17
- @param [Tabpage] tabpage
18
16
  @param [String] name
19
17
  @return [Object]
20
18
 
21
- @method set_var(tabpage, name, value)
19
+ @method set_var(name, value)
22
20
  See +:h nvim_tabpage_set_var()+
23
- @param [Tabpage] tabpage
24
21
  @param [String] name
25
22
  @param [Object] value
26
23
  @return [void]
27
24
 
28
- @method del_var(tabpage, name)
25
+ @method del_var(name)
29
26
  See +:h nvim_tabpage_del_var()+
30
- @param [Tabpage] tabpage
31
27
  @param [String] name
32
28
  @return [void]
33
29
 
34
- @method get_win(tabpage)
30
+ @method get_win
35
31
  See +:h nvim_tabpage_get_win()+
36
- @param [Tabpage] tabpage
37
32
  @return [Window]
38
33
 
39
- @method get_number(tabpage)
34
+ @method get_number
40
35
  See +:h nvim_tabpage_get_number()+
41
- @param [Tabpage] tabpage
42
36
  @return [Integer]
43
37
 
44
- @method is_valid(tabpage)
38
+ @method is_valid
45
39
  See +:h nvim_tabpage_is_valid()+
46
- @param [Tabpage] tabpage
47
40
  @return [Boolean]
48
41
 
49
42
  =end
@@ -1,3 +1,3 @@
1
1
  module Neovim
2
- VERSION = Gem::Version.new("0.7.1")
2
+ VERSION = Gem::Version.new("0.9.0")
3
3
  end
data/lib/neovim/window.rb CHANGED
@@ -3,7 +3,7 @@ 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.2.2
6
+ # The methods documented here were generated using NVIM v0.5.0
7
7
  class Window < RemoteObject
8
8
  # Get the buffer displayed in the window
9
9
  #
@@ -64,96 +64,108 @@ module Neovim
64
64
 
65
65
  # The following methods are dynamically generated.
66
66
  =begin
67
- @method get_buf(window)
67
+ @method get_buf
68
68
  See +:h nvim_win_get_buf()+
69
- @param [Window] window
70
69
  @return [Buffer]
71
70
 
72
- @method get_cursor(window)
71
+ @method set_buf(buffer)
72
+ See +:h nvim_win_set_buf()+
73
+ @param [Buffer] buffer
74
+ @return [void]
75
+
76
+ @method get_cursor
73
77
  See +:h nvim_win_get_cursor()+
74
- @param [Window] window
75
78
  @return [Array<Integer>]
76
79
 
77
- @method set_cursor(window, pos)
80
+ @method set_cursor(pos)
78
81
  See +:h nvim_win_set_cursor()+
79
- @param [Window] window
80
82
  @param [Array<Integer>] pos
81
83
  @return [void]
82
84
 
83
- @method get_height(window)
85
+ @method get_height
84
86
  See +:h nvim_win_get_height()+
85
- @param [Window] window
86
87
  @return [Integer]
87
88
 
88
- @method set_height(window, height)
89
+ @method set_height(height)
89
90
  See +:h nvim_win_set_height()+
90
- @param [Window] window
91
91
  @param [Integer] height
92
92
  @return [void]
93
93
 
94
- @method get_width(window)
94
+ @method get_width
95
95
  See +:h nvim_win_get_width()+
96
- @param [Window] window
97
96
  @return [Integer]
98
97
 
99
- @method set_width(window, width)
98
+ @method set_width(width)
100
99
  See +:h nvim_win_set_width()+
101
- @param [Window] window
102
100
  @param [Integer] width
103
101
  @return [void]
104
102
 
105
- @method get_var(window, name)
103
+ @method get_var(name)
106
104
  See +:h nvim_win_get_var()+
107
- @param [Window] window
108
105
  @param [String] name
109
106
  @return [Object]
110
107
 
111
- @method set_var(window, name, value)
108
+ @method set_var(name, value)
112
109
  See +:h nvim_win_set_var()+
113
- @param [Window] window
114
110
  @param [String] name
115
111
  @param [Object] value
116
112
  @return [void]
117
113
 
118
- @method del_var(window, name)
114
+ @method del_var(name)
119
115
  See +:h nvim_win_del_var()+
120
- @param [Window] window
121
116
  @param [String] name
122
117
  @return [void]
123
118
 
124
- @method get_option(window, name)
119
+ @method get_option(name)
125
120
  See +:h nvim_win_get_option()+
126
- @param [Window] window
127
121
  @param [String] name
128
122
  @return [Object]
129
123
 
130
- @method set_option(window, name, value)
124
+ @method set_option(name, value)
131
125
  See +:h nvim_win_set_option()+
132
- @param [Window] window
133
126
  @param [String] name
134
127
  @param [Object] value
135
128
  @return [void]
136
129
 
137
- @method get_position(window)
130
+ @method get_position
138
131
  See +:h nvim_win_get_position()+
139
- @param [Window] window
140
132
  @return [Array<Integer>]
141
133
 
142
- @method get_tabpage(window)
134
+ @method get_tabpage
143
135
  See +:h nvim_win_get_tabpage()+
144
- @param [Window] window
145
136
  @return [Tabpage]
146
137
 
147
- @method get_number(window)
138
+ @method get_number
148
139
  See +:h nvim_win_get_number()+
149
- @param [Window] window
150
140
  @return [Integer]
151
141
 
152
- @method is_valid(window)
142
+ @method is_valid
153
143
  See +:h nvim_win_is_valid()+
154
- @param [Window] window
155
144
  @return [Boolean]
156
145
 
146
+ @method set_config(config)
147
+ See +:h nvim_win_set_config()+
148
+ @param [Hash] config
149
+ @return [void]
150
+
151
+ @method get_config
152
+ See +:h nvim_win_get_config()+
153
+ @return [Hash]
154
+
155
+ @method hide
156
+ See +:h nvim_win_hide()+
157
+ @return [void]
158
+
159
+ @method close(force)
160
+ See +:h nvim_win_close()+
161
+ @param [Boolean] force
162
+ @return [void]
163
+
164
+ @method call(fun)
165
+ See +:h nvim_win_call()+
166
+ @param [LuaRef] fun
167
+ @return [Object]
168
+
157
169
  =end
158
170
  end
159
171
  end
data/lib/neovim.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "neovim/client"
2
+ require "neovim/client_info"
2
3
  require "neovim/session"
3
4
  require "neovim/event_loop"
4
5
  require "neovim/executable"
@@ -62,7 +63,7 @@ module Neovim
62
63
  # @return [Client]
63
64
  # @see EventLoop.tcp
64
65
  def self.attach_tcp(host, port)
65
- Client.from_event_loop EventLoop.tcp(host, port)
66
+ attach(EventLoop.tcp(host, port))
66
67
  end
67
68
 
68
69
  # Connect to a running +nvim+ instance over a UNIX domain socket.
@@ -71,7 +72,7 @@ module Neovim
71
72
  # @return [Client]
72
73
  # @see EventLoop.unix
73
74
  def self.attach_unix(socket_path)
74
- Client.from_event_loop EventLoop.unix(socket_path)
75
+ attach(EventLoop.unix(socket_path))
75
76
  end
76
77
 
77
78
  # Spawn and connect to a child +nvim+ process.
@@ -80,7 +81,7 @@ module Neovim
80
81
  # @return [Client]
81
82
  # @see EventLoop.child
82
83
  def self.attach_child(argv=[executable.path])
83
- Client.from_event_loop EventLoop.child(argv)
84
+ attach(EventLoop.child(argv))
84
85
  end
85
86
 
86
87
  # Placeholder method for exposing the remote plugin DSL. This gets
@@ -116,4 +117,12 @@ module Neovim
116
117
  def self.logger
117
118
  Logging.logger
118
119
  end
120
+
121
+ # @api private
122
+ def self.attach(event_loop)
123
+ Client.from_event_loop(event_loop).tap do |client|
124
+ client.session.notify(:nvim_set_client_info, *ClientInfo.for_client.to_args)
125
+ end
126
+ end
127
+ private_class_method :attach
119
128
  end
data/neovim.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- lib = File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path("lib", __dir__)
2
2
  $:.unshift(lib) unless $:.include?(lib)
3
3
  require "neovim/version"
4
4
 
@@ -8,10 +8,11 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Alex Genco"]
9
9
  spec.email = ["alexgenco@gmail.com"]
10
10
  spec.summary = "A Ruby client for Neovim"
11
- spec.homepage = "https://github.com/alexgenco/neovim-ruby"
11
+ spec.homepage = "https://github.com/neovim/neovim-ruby"
12
12
  spec.license = "MIT"
13
13
 
14
14
  spec.files = `git ls-files -z`.split("\x0")
15
+ spec.bindir = "exe"
15
16
  spec.executables = ["neovim-ruby-host"]
16
17
  spec.test_files = spec.files.grep(%r{^spec/})
17
18
  spec.require_paths = ["lib"]
@@ -21,12 +22,10 @@ Gem::Specification.new do |spec|
21
22
  spec.add_dependency "msgpack", "~> 1.1"
22
23
  spec.add_dependency "multi_json", "~> 1.0"
23
24
 
24
- spec.add_development_dependency "bundler"
25
- spec.add_development_dependency "coveralls"
25
+ spec.add_development_dependency "bundler", "~> 2.0"
26
26
  spec.add_development_dependency "pry"
27
27
  spec.add_development_dependency "pry-byebug"
28
28
  spec.add_development_dependency "rake"
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
30
- spec.add_development_dependency "rubocop", "0.52.1"
31
30
  spec.add_development_dependency "vim-flavor", "2.2.2"
32
31
  end
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -eu
4
+
5
+ : ${RUNNER_OS:?} ${BUILD:?}
6
+
7
+ case "$BUILD" in
8
+ latest)
9
+ URL_PART="latest/download"
10
+ ;;
11
+ nightly)
12
+ URL_PART="download/nightly"
13
+ ;;
14
+ *)
15
+ echo "BUILD must be 'latest' or 'nightly'." >&2
16
+ exit 1
17
+ ;;
18
+ esac
19
+
20
+ case "$(echo "$RUNNER_OS" | tr "[:upper:]" "[:lower:]")" in
21
+ macos)
22
+ wget -nv -P /tmp \
23
+ "https://github.com/neovim/neovim/releases/$URL_PART/nvim-macos.tar.gz"
24
+ tar -C /tmp -xzf /tmp/nvim-macos.tar.gz
25
+ mv /tmp/nvim-osx64 ./_nvim
26
+ ;;
27
+ linux)
28
+ mkdir -p _nvim/bin
29
+ wget -nv -O _nvim/bin/nvim \
30
+ "https://github.com/neovim/neovim/releases/$URL_PART/nvim.appimage"
31
+ ;;
32
+ *)
33
+ echo "Unrecognized \$RUNNER_OS" >&2
34
+ exit 1
35
+ ;;
36
+ esac
37
+
38
+ chmod u+x _nvim/bin/nvim
39
+
40
+ _nvim/bin/nvim --version
data/script/dump_api.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $:.unshift File.expand_path("../../lib", __FILE__)
3
+ $:.unshift File.expand_path("../lib", __dir__)
4
4
 
5
5
  require "neovim"
6
6
  require "json"
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $:.unshift File.expand_path("../../lib", __FILE__)
3
+ $:.unshift File.expand_path("../lib", __dir__)
4
4
 
5
5
  require "neovim"
6
6
  require "pathname"
@@ -19,10 +19,6 @@ buffer_defs = Neovim::Buffer.instance_methods(false)
19
19
  tabpage_defs = Neovim::Tabpage.instance_methods(false)
20
20
  window_defs = Neovim::Window.instance_methods(false)
21
21
 
22
- def add_method(docs, defs, method_name)
23
- return if defs.include?(method_name.to_s)
24
- end
25
-
26
22
  session.request(:nvim_get_api_info)[1]["functions"].each do |func|
27
23
  func_name = func["name"]
28
24
  params = func["parameters"]
@@ -30,16 +26,18 @@ session.request(:nvim_get_api_info)[1]["functions"].each do |func|
30
26
  case func_name
31
27
  when /^nvim_buf_(.+)/
32
28
  method_name = $1
29
+ params.shift
33
30
  next if buffer_defs.include?(method_name.to_sym)
34
31
  when /^nvim_win_(.+)/
35
32
  method_name = $1
33
+ params.shift
36
34
  next if window_defs.include?(method_name.to_sym)
37
35
  when /^nvim_tabpage_(.+)/
38
36
  method_name = $1
37
+ params.shift
39
38
  next if tabpage_defs.include?(method_name.to_sym)
40
39
  when /^nvim_(.+)/
41
40
  method_name = $1
42
- params.shift
43
41
  next if nvim_defs.include?(method_name.to_sym)
44
42
  else
45
43
  next
@@ -72,7 +70,8 @@ session.request(:nvim_get_api_info)[1]["functions"].each do |func|
72
70
  end
73
71
  end
74
72
 
75
- lib_dir = Pathname.new(File.expand_path("../../lib/neovim", __FILE__))
73
+ lib_dir = Pathname.new(File.expand_path("../lib/neovim", __dir__))
74
+
76
75
  {
77
76
  "client.rb" => nvim_docs,
78
77
  "buffer.rb" => buffer_docs,
@@ -5,11 +5,13 @@ require "fileutils"
5
5
  ENV.delete("VIM")
6
6
  ENV.delete("VIMRUNTIME")
7
7
 
8
- acceptance_root = File.expand_path("../../spec/acceptance", __FILE__)
8
+ root = File.expand_path("..", __dir__)
9
+ acceptance_root = File.join(root, "spec/acceptance")
9
10
  themis_rtp = File.join(acceptance_root, "runtime")
10
11
  themis_home = File.join(themis_rtp, "flavors/thinca_vim-themis")
11
12
  manifest = File.join(themis_rtp, "rplugin_manifest.vim")
12
13
  vimrc = File.join(themis_rtp, "init.vim")
14
+ nvim = ENV.fetch("NVIM_EXECUTABLE", "nvim")
13
15
 
14
16
  themis_exe = Gem.win_platform? ?
15
17
  File.join(themis_home, "bin/themis.bat") :
@@ -17,19 +19,21 @@ themis_exe = Gem.win_platform? ?
17
19
 
18
20
  env = {
19
21
  "NVIM_RPLUGIN_MANIFEST" => manifest,
20
- "THEMIS_VIM" => "nvim",
22
+ "THEMIS_VIM" => nvim,
21
23
  "THEMIS_HOME" => themis_home,
22
24
  "THEMIS_ARGS" => "-e -s --headless -u #{vimrc}"
23
25
  }
24
26
 
25
27
  FileUtils.rm_f(manifest)
26
28
 
27
- system(
28
- env,
29
- "nvim",
30
- "-e", "-s", "--headless",
31
- "-u", vimrc,
32
- "+UpdateRemotePlugins", "+qa!"
33
- )
34
-
35
- exec(env, themis_exe, *ARGV)
29
+ Dir.chdir(root) do
30
+ system(
31
+ env,
32
+ nvim,
33
+ "-e", "-s", "--headless",
34
+ "-u", vimrc,
35
+ "+UpdateRemotePlugins", "+qa!"
36
+ )
37
+
38
+ exec(env, themis_exe, *ARGV)
39
+ end
@@ -0,0 +1,42 @@
1
+ let s:suite = themis#suite("Client info")
2
+ let s:expect = themis#helper("expect")
3
+
4
+ function! s:suite.before_each() abort
5
+ call RPluginFunctionArgs(1, 2)
6
+
7
+ let s:client_chans = map(
8
+ \ filter(nvim_list_chans(), "has_key(v:val, 'client')"),
9
+ \ "v:val.client")
10
+ endfunction
11
+
12
+ function! s:suite.get_script_host_client_info() abort
13
+ let client_info = s:client_chans[1]
14
+
15
+ call s:expect(sort(keys(client_info))).to_equal(
16
+ \ ["attributes", "methods", "name", "type", "version"])
17
+
18
+ call s:expect(client_info.attributes).to_be_dict()
19
+ call s:expect(client_info.methods).to_equal({"specs": {"nargs": 1}, "poll": {}})
20
+ call s:expect(client_info.name).to_equal("ruby-script-host")
21
+ call s:expect(client_info.type).to_equal("host")
22
+
23
+ call s:expect(client_info.version.major).to_be_number()
24
+ call s:expect(client_info.version.minor).to_be_number()
25
+ call s:expect(client_info.version.patch).to_be_number()
26
+ endfunction
27
+
28
+ function! s:suite.get_rplugin_client_info() abort
29
+ let client_info = s:client_chans[0]
30
+
31
+ call s:expect(sort(keys(client_info))).to_equal(
32
+ \ ["attributes", "methods", "name", "type", "version"])
33
+
34
+ call s:expect(client_info.attributes).to_be_dict()
35
+ call s:expect(client_info.methods).to_equal({"specs": {"nargs": 1}, "poll": {}})
36
+ call s:expect(client_info.name).to_equal("ruby-rplugin-host")
37
+ call s:expect(client_info.type).to_equal("host")
38
+
39
+ call s:expect(client_info.version.major).to_be_number()
40
+ call s:expect(client_info.version.minor).to_be_number()
41
+ call s:expect(client_info.version.patch).to_be_number()
42
+ endfunction