diff -Nru ruby-neovim-0.7.1/appveyor.yml ruby-neovim-0.8.1/appveyor.yml --- ruby-neovim-0.7.1/appveyor.yml 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/appveyor.yml 2019-07-01 10:48:04.000000000 +0000 @@ -2,18 +2,22 @@ environment: matrix: + - RUBY_VERSION: 26 - RUBY_VERSION: 25 - RUBY_VERSION: 24 - RUBY_VERSION: 23 - RUBY_VERSION: 22 +cache: + - vendor/bundle + install: - set SSL_CERT_FILE=C:/ruby24-x64/ssl/cert.pem - set PATH=C:\Ruby%RUBY_VERSION%\bin;C:\tools\neovim\Neovim\bin;%PATH% - set NVIM_RUBY_LOG_LEVEL=DEBUG - set NVIM_RUBY_LOG_FILE=%cd%\ci.log - - choco install neovim --pre -fy --ignore-dependencies - - bundle install + - choco install neovim --pre -fy --ignore-dependencies --ignore-checksums + - bundle install --path vendor/bundle build: off @@ -28,4 +32,4 @@ - nvim -v test_script: - - bundle exec rake + - bundle exec rake spec:functional spec:acceptance diff -Nru ruby-neovim-0.7.1/bin/neovim-ruby-host ruby-neovim-0.8.1/bin/neovim-ruby-host --- ruby-neovim-0.7.1/bin/neovim-ruby-host 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/bin/neovim-ruby-host 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -#!/usr/bin/env ruby - -require "neovim/host" - -ARGV.each do |arg| - break if arg == "--" - - if ["--version", "-V"].include?(arg) - puts Neovim::VERSION - exit(0) - end -end - -if STDIN.tty? - abort("Can't run neovim-ruby-host interactively.") -else - Neovim::Host.run(ARGV) -end diff -Nru ruby-neovim-0.7.1/CHANGELOG.md ruby-neovim-0.8.1/CHANGELOG.md --- ruby-neovim-0.7.1/CHANGELOG.md 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/CHANGELOG.md 2019-07-01 10:48:04.000000000 +0000 @@ -1,3 +1,19 @@ +# 0.8.1 + +- Set client info on host and client startup +- Add `Client#channel_id` + +# 0.8.0 + +- Allow `Buffer#append` to take a string with newlines +- Use non-strict line indexing in `:rubydo` to prevent line deletions from + throwing exceptions +- Performance optimizations: + - Cache RPC method lookups and store them in a set + - Only flush writes before reading in the event loop + - Delete request handlers after invoking them + - Refresh provider globals in a single RPC request + # 0.7.1 - Fix `uninitialized constant Neovim::RubyProvider::StringIO` diff -Nru ruby-neovim-0.7.1/.coveralls.yml ruby-neovim-0.8.1/.coveralls.yml --- ruby-neovim-0.7.1/.coveralls.yml 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/.coveralls.yml 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -service_name: travis-ci diff -Nru ruby-neovim-0.7.1/debian/changelog ruby-neovim-0.8.1/debian/changelog --- ruby-neovim-0.7.1/debian/changelog 2018-03-03 23:46:45.000000000 +0000 +++ ruby-neovim-0.8.1/debian/changelog 2019-09-14 18:53:56.000000000 +0000 @@ -1,3 +1,22 @@ +ruby-neovim (0.8.1-1) unstable; urgency=medium + + [ Utkarsh Gupta ] + * Add salsa-ci.yml + + [ Jason Pleau ] + * New upstream release + * Refresh patches + * add .pc/ to gitignore + * Point Vcs-* fields to salsa.debian.org + * Update copyright years + * Update Standards-Version to 4.4.0, no changes + * Remove d/compat and build-depend on debhelper-compat + + [ Antonio Terceiro ] + * debian/watch: update to point to gemwatch.debian.net + + -- Jason Pleau Sat, 14 Sep 2019 14:53:56 -0400 + ruby-neovim (0.7.1-1) unstable; urgency=medium * New upstream release diff -Nru ruby-neovim-0.7.1/debian/compat ruby-neovim-0.8.1/debian/compat --- ruby-neovim-0.7.1/debian/compat 2018-03-03 23:46:45.000000000 +0000 +++ ruby-neovim-0.8.1/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -11 diff -Nru ruby-neovim-0.7.1/debian/control ruby-neovim-0.8.1/debian/control --- ruby-neovim-0.7.1/debian/control 2018-03-03 23:46:45.000000000 +0000 +++ ruby-neovim-0.8.1/debian/control 2019-09-14 18:53:56.000000000 +0000 @@ -3,16 +3,16 @@ Priority: optional Maintainer: Debian Ruby Extras Maintainers Uploaders: Jason Pleau -Build-Depends: debhelper (>= 11), +Build-Depends: debhelper-compat (= 12), gem2deb, neovim, rake, ruby-msgpack (>= 1.0), ruby-rspec, ruby-multi-json -Standards-Version: 4.1.3 -Vcs-Git: https://anonscm.debian.org/git/pkg-ruby-extras/ruby-neovim.git -Vcs-Browser: https://anonscm.debian.org/cgit/pkg-ruby-extras/ruby-neovim.git +Standards-Version: 4.4.0 +Vcs-Git: https://salsa.debian.org/ruby-team/ruby-neovim +Vcs-Browser: https://salsa.debian.org/ruby-team/ruby-neovim Homepage: https://github.com/alexgenco/neovim-ruby Testsuite: autopkgtest-pkg-ruby XS-Ruby-Versions: all diff -Nru ruby-neovim-0.7.1/debian/copyright ruby-neovim-0.8.1/debian/copyright --- ruby-neovim-0.7.1/debian/copyright 2018-03-03 23:46:45.000000000 +0000 +++ ruby-neovim-0.8.1/debian/copyright 2019-09-14 18:53:56.000000000 +0000 @@ -3,11 +3,11 @@ Source: https://github.com/alexgenco/neovim-ruby Files: * -Copyright: 2014 Alex Genco +Copyright: 2014-2019 Alex Genco License: Expat Files: debian/* -Copyright: 2016 Jason Pleau +Copyright: 2016-2019 Jason Pleau License: Expat License: Expat diff -Nru ruby-neovim-0.7.1/debian/patches/remove_coveralls_pry_bundler.patch ruby-neovim-0.8.1/debian/patches/remove_coveralls_pry_bundler.patch --- ruby-neovim-0.7.1/debian/patches/remove_coveralls_pry_bundler.patch 2018-03-03 23:46:45.000000000 +0000 +++ ruby-neovim-0.8.1/debian/patches/remove_coveralls_pry_bundler.patch 2019-09-14 18:53:56.000000000 +0000 @@ -4,23 +4,14 @@ bundler/setup is also not needed since dependencies are already installed from Build-Depends Author: Jason Pleau -Last-Update: 2018-03-03 +Last-Update: 2019-09-14 --- a/spec/helper.rb +++ b/spec/helper.rb -@@ -1,14 +1,14 @@ +@@ -1,9 +1,9 @@ -require "bundler/setup" +#require "bundler/setup" --if ENV["REPORT_COVERAGE"] -- require "coveralls" -- Coveralls.wear! --end -+#if ENV["REPORT_COVERAGE"] -+# require "coveralls" -+# Coveralls.wear! -+#end - require "fileutils" require "msgpack" require "neovim" diff -Nru ruby-neovim-0.7.1/debian/salsa-ci.yml ruby-neovim-0.8.1/debian/salsa-ci.yml --- ruby-neovim-0.7.1/debian/salsa-ci.yml 1970-01-01 00:00:00.000000000 +0000 +++ ruby-neovim-0.8.1/debian/salsa-ci.yml 2019-09-14 18:53:56.000000000 +0000 @@ -0,0 +1,4 @@ +--- +include: + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml diff -Nru ruby-neovim-0.7.1/debian/watch ruby-neovim-0.8.1/debian/watch --- ruby-neovim-0.7.1/debian/watch 2018-03-03 23:46:45.000000000 +0000 +++ ruby-neovim-0.8.1/debian/watch 2019-09-14 18:53:56.000000000 +0000 @@ -1,2 +1,2 @@ version=3 -http://pkg-ruby-extras.alioth.debian.org/cgi-bin/gemwatch/neovim .*/neovim-(.*).tar.gz +https://gemwatch.debian.net/neovim .*/neovim-(.*).tar.gz diff -Nru ruby-neovim-0.7.1/exe/neovim-ruby-host ruby-neovim-0.8.1/exe/neovim-ruby-host --- ruby-neovim-0.7.1/exe/neovim-ruby-host 1970-01-01 00:00:00.000000000 +0000 +++ ruby-neovim-0.8.1/exe/neovim-ruby-host 2019-07-01 10:48:04.000000000 +0000 @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby + +require "neovim/host" + +ARGV.each do |arg| + break if arg == "--" + + if ["--version", "-V"].include?(arg) + puts Neovim::VERSION + exit(0) + end +end + +if STDIN.tty? + abort("Can't run neovim-ruby-host interactively.") +else + Neovim::Host.run(ARGV) +end diff -Nru ruby-neovim-0.7.1/.gitignore ruby-neovim-0.8.1/.gitignore --- ruby-neovim-0.7.1/.gitignore 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/.gitignore 2019-07-01 10:48:04.000000000 +0000 @@ -21,3 +21,5 @@ spec/acceptance/runtime/flavors spec/acceptance/runtime/rplugin_manifest.vim vendor/bundle +bin +.vim-flavor diff -Nru ruby-neovim-0.7.1/lib/neovim/buffer.rb ruby-neovim-0.8.1/lib/neovim/buffer.rb --- ruby-neovim-0.7.1/lib/neovim/buffer.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/buffer.rb 2019-07-01 10:48:04.000000000 +0000 @@ -4,7 +4,7 @@ module Neovim # Class representing an +nvim+ buffer. # - # The methods documented here were generated using NVIM v0.2.2 + # The methods documented here were generated using NVIM v0.3.7 class Buffer < RemoteObject attr_reader :lines @@ -91,7 +91,7 @@ window = @session.request(:nvim_get_current_win) cursor = window.cursor - set_lines(index, index, true, [str]) + set_lines(index, index, true, [*str.split($/)]) window.set_cursor(cursor) str end @@ -135,116 +135,138 @@ # The following methods are dynamically generated. =begin -@method line_count(buffer) +@method line_count See +:h nvim_buf_line_count()+ - @param [Buffer] buffer @return [Integer] -@method get_lines(buffer, start, end, strict_indexing) +@method attach(send_buffer, opts) + See +:h nvim_buf_attach()+ + @param [Boolean] send_buffer + @param [Hash] opts + @return [Boolean] + +@method detach + See +:h nvim_buf_detach()+ + @return [Boolean] + +@method get_lines(start, end, strict_indexing) See +:h nvim_buf_get_lines()+ - @param [Buffer] buffer @param [Integer] start @param [Integer] end @param [Boolean] strict_indexing @return [Array] -@method set_lines(buffer, start, end, strict_indexing, replacement) +@method set_lines(start, end, strict_indexing, replacement) See +:h nvim_buf_set_lines()+ - @param [Buffer] buffer @param [Integer] start @param [Integer] end @param [Boolean] strict_indexing @param [Array] replacement @return [void] -@method get_var(buffer, name) +@method get_offset(index) + See +:h nvim_buf_get_offset()+ + @param [Integer] index + @return [Integer] + +@method get_var(name) See +:h nvim_buf_get_var()+ - @param [Buffer] buffer @param [String] name @return [Object] -@method get_changedtick(buffer) +@method get_changedtick See +:h nvim_buf_get_changedtick()+ - @param [Buffer] buffer @return [Integer] -@method get_keymap(buffer, mode) +@method get_keymap(mode) See +:h nvim_buf_get_keymap()+ - @param [Buffer] buffer @param [String] mode @return [Array] -@method set_var(buffer, name, value) +@method get_commands(opts) + See +:h nvim_buf_get_commands()+ + @param [Hash] opts + @return [Hash] + +@method set_var(name, value) See +:h nvim_buf_set_var()+ - @param [Buffer] buffer @param [String] name @param [Object] value @return [void] -@method del_var(buffer, name) +@method del_var(name) See +:h nvim_buf_del_var()+ - @param [Buffer] buffer @param [String] name @return [void] -@method get_option(buffer, name) +@method get_option(name) See +:h nvim_buf_get_option()+ - @param [Buffer] buffer @param [String] name @return [Object] -@method set_option(buffer, name, value) +@method set_option(name, value) See +:h nvim_buf_set_option()+ - @param [Buffer] buffer @param [String] name @param [Object] value @return [void] -@method get_number(buffer) +@method get_number See +:h nvim_buf_get_number()+ - @param [Buffer] buffer @return [Integer] -@method get_name(buffer) +@method get_name See +:h nvim_buf_get_name()+ - @param [Buffer] buffer @return [String] -@method set_name(buffer, name) +@method set_name(name) See +:h nvim_buf_set_name()+ - @param [Buffer] buffer @param [String] name @return [void] -@method is_valid(buffer) +@method is_loaded + See +:h nvim_buf_is_loaded()+ + @return [Boolean] + +@method is_valid See +:h nvim_buf_is_valid()+ - @param [Buffer] buffer @return [Boolean] -@method get_mark(buffer, name) +@method get_mark(name) See +:h nvim_buf_get_mark()+ - @param [Buffer] buffer @param [String] name @return [Array] -@method add_highlight(buffer, src_id, hl_group, line, col_start, col_end) +@method add_highlight(ns_id, hl_group, line, col_start, col_end) See +:h nvim_buf_add_highlight()+ - @param [Buffer] buffer - @param [Integer] src_id + @param [Integer] ns_id @param [String] hl_group @param [Integer] line @param [Integer] col_start @param [Integer] col_end @return [Integer] -@method clear_highlight(buffer, src_id, line_start, line_end) +@method clear_namespace(ns_id, line_start, line_end) + See +:h nvim_buf_clear_namespace()+ + @param [Integer] ns_id + @param [Integer] line_start + @param [Integer] line_end + @return [void] + +@method clear_highlight(ns_id, line_start, line_end) See +:h nvim_buf_clear_highlight()+ - @param [Buffer] buffer - @param [Integer] src_id + @param [Integer] ns_id @param [Integer] line_start @param [Integer] line_end @return [void] +@method set_virtual_text(ns_id, line, chunks, opts) + See +:h nvim_buf_set_virtual_text()+ + @param [Integer] ns_id + @param [Integer] line + @param [Array] chunks + @param [Hash] opts + @return [Integer] + =end end end diff -Nru ruby-neovim-0.7.1/lib/neovim/client_info.rb ruby-neovim-0.8.1/lib/neovim/client_info.rb --- ruby-neovim-0.7.1/lib/neovim/client_info.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/client_info.rb 2019-07-01 10:48:04.000000000 +0000 @@ -0,0 +1,46 @@ +require "neovim/version" + +module Neovim + # @api private + class ClientInfo + HOST_METHOD_SPEC = {poll: {}, specs: {nargs: 1}}.freeze + + ATTRIBUTES = { + website: "https://github.com/neovim/neovim-ruby", + license: "MIT" + }.freeze + + def self.for_host(host) + name = host.plugins.map(&:script_host?) == [true] ? + "ruby-script-host" : + "ruby-rplugin-host" + + new(name, :host, HOST_METHOD_SPEC, ATTRIBUTES) + end + + def self.for_client + new("ruby-client", :remote, {}, ATTRIBUTES) + end + + def initialize(name, type, method_spec, attributes) + @name = name + @type = type + @method_spec = method_spec + @attributes = attributes + + @version = ["major", "minor", "patch"] + .zip(Neovim::VERSION.segments) + .to_h + end + + def to_args + [ + @name, + @version, + @type, + @method_spec, + @attributes + ] + end + end +end diff -Nru ruby-neovim-0.7.1/lib/neovim/client.rb ruby-neovim-0.8.1/lib/neovim/client.rb --- ruby-neovim-0.7.1/lib/neovim/client.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/client.rb 2019-07-01 10:48:04.000000000 +0000 @@ -1,6 +1,7 @@ require "neovim/api" require "neovim/current" require "neovim/session" +require "set" module Neovim # Client to a running +nvim+ instance. The interface is generated at @@ -8,7 +9,7 @@ # +RemoteObject+ subclasses (i.e. +Buffer+, +Window+, or +Tabpage+), # which similarly have dynamically generated interfaces. # - # The methods documented here were generated using NVIM v0.2.2 + # The methods documented here were generated using NVIM v0.3.7 # # @see Buffer # @see Window @@ -28,6 +29,10 @@ @api = api end + def channel_id + @api.channel_id + end + # Intercept method calls and delegate to appropriate RPC methods. def method_missing(method_name, *args) if (func = @api.function_for_object_method(self, method_name)) @@ -44,7 +49,7 @@ # Extend +methods+ to include RPC methods. def methods(*args) - super | rpc_methods + super | rpc_methods.to_a end # Access to objects belonging to the current +nvim+ context. @@ -104,15 +109,17 @@ private def rpc_methods - @api.functions_for_object(self).map(&:method_name) + @rpc_methods ||= + @api.functions_for_object(self).map(&:method_name).to_set end public # The following methods are dynamically generated. =begin -@method ui_attach(height, options) +@method ui_attach(width, height, options) See +:h nvim_ui_attach()+ + @param [Integer] width @param [Integer] height @param [Hash] options @return [void] @@ -121,120 +128,150 @@ See +:h nvim_ui_detach()+ @return [void] -@method ui_try_resize(height) +@method ui_try_resize(width, height) See +:h nvim_ui_try_resize()+ + @param [Integer] width @param [Integer] height @return [void] -@method ui_set_option(value) +@method ui_set_option(name, value) See +:h nvim_ui_set_option()+ + @param [String] name @param [Object] value @return [void] -@method command +@method command(command) See +:h nvim_command()+ + @param [String] command @return [void] -@method get_hl_by_name(rgb) +@method get_hl_by_name(name, rgb) See +:h nvim_get_hl_by_name()+ + @param [String] name @param [Boolean] rgb @return [Hash] -@method get_hl_by_id(rgb) +@method get_hl_by_id(hl_id, rgb) See +:h nvim_get_hl_by_id()+ + @param [Integer] hl_id @param [Boolean] rgb @return [Hash] -@method feedkeys(mode, escape_csi) +@method feedkeys(keys, mode, escape_csi) See +:h nvim_feedkeys()+ + @param [String] keys @param [String] mode @param [Boolean] escape_csi @return [void] -@method input +@method input(keys) See +:h nvim_input()+ + @param [String] keys @return [Integer] -@method replace_termcodes(from_part, do_lt, special) +@method replace_termcodes(str, from_part, do_lt, special) See +:h nvim_replace_termcodes()+ + @param [String] str @param [Boolean] from_part @param [Boolean] do_lt @param [Boolean] special @return [String] -@method command_output +@method command_output(command) See +:h nvim_command_output()+ + @param [String] command @return [String] -@method eval +@method eval(expr) See +:h nvim_eval()+ + @param [String] expr @return [Object] -@method call_function(args) +@method execute_lua(code, args) + See +:h nvim_execute_lua()+ + @param [String] code + @param [Array] args + @return [Object] + +@method call_function(fn, args) See +:h nvim_call_function()+ + @param [String] fn @param [Array] args @return [Object] -@method execute_lua(args) - See +:h nvim_execute_lua()+ +@method call_dict_function(dict, fn, args) + See +:h nvim_call_dict_function()+ + @param [Object] dict + @param [String] fn @param [Array] args @return [Object] -@method strwidth +@method strwidth(text) See +:h nvim_strwidth()+ + @param [String] text @return [Integer] @method list_runtime_paths See +:h nvim_list_runtime_paths()+ @return [Array] -@method set_current_dir +@method set_current_dir(dir) See +:h nvim_set_current_dir()+ + @param [String] dir @return [void] @method get_current_line See +:h nvim_get_current_line()+ @return [String] -@method set_current_line +@method set_current_line(line) See +:h nvim_set_current_line()+ + @param [String] line @return [void] @method del_current_line See +:h nvim_del_current_line()+ @return [void] -@method get_var +@method get_var(name) See +:h nvim_get_var()+ + @param [String] name @return [Object] -@method set_var(value) +@method set_var(name, value) See +:h nvim_set_var()+ + @param [String] name @param [Object] value @return [void] -@method del_var +@method del_var(name) See +:h nvim_del_var()+ + @param [String] name @return [void] -@method get_vvar +@method get_vvar(name) See +:h nvim_get_vvar()+ + @param [String] name @return [Object] -@method get_option +@method get_option(name) See +:h nvim_get_option()+ + @param [String] name @return [Object] -@method out_write +@method out_write(str) See +:h nvim_out_write()+ + @param [String] str @return [void] -@method err_write +@method err_write(str) See +:h nvim_err_write()+ + @param [String] str @return [void] -@method err_writeln +@method err_writeln(str) See +:h nvim_err_writeln()+ + @param [String] str @return [void] @method list_bufs @@ -245,8 +282,9 @@ See +:h nvim_get_current_buf()+ @return [Buffer] -@method set_current_buf +@method set_current_buf(buffer) See +:h nvim_set_current_buf()+ + @param [Buffer] buffer @return [void] @method list_wins @@ -257,8 +295,9 @@ See +:h nvim_get_current_win()+ @return [Window] -@method set_current_win +@method set_current_win(window) See +:h nvim_set_current_win()+ + @param [Window] window @return [void] @method list_tabpages @@ -269,20 +308,33 @@ See +:h nvim_get_current_tabpage()+ @return [Tabpage] -@method set_current_tabpage +@method set_current_tabpage(tabpage) See +:h nvim_set_current_tabpage()+ + @param [Tabpage] tabpage @return [void] -@method subscribe +@method create_namespace(name) + See +:h nvim_create_namespace()+ + @param [String] name + @return [Integer] + +@method get_namespaces + See +:h nvim_get_namespaces()+ + @return [Hash] + +@method subscribe(event) See +:h nvim_subscribe()+ + @param [String] event @return [void] -@method unsubscribe +@method unsubscribe(event) See +:h nvim_unsubscribe()+ + @param [String] event @return [void] -@method get_color_by_name +@method get_color_by_name(name) See +:h nvim_get_color_by_name()+ + @param [String] name @return [Integer] @method get_color_map @@ -293,18 +345,64 @@ See +:h nvim_get_mode()+ @return [Hash] -@method get_keymap +@method get_keymap(mode) See +:h nvim_get_keymap()+ + @param [String] mode @return [Array] +@method get_commands(opts) + See +:h nvim_get_commands()+ + @param [Hash] opts + @return [Hash] + @method get_api_info See +:h nvim_get_api_info()+ @return [Array] -@method call_atomic +@method set_client_info(name, version, type, methods, attributes) + See +:h nvim_set_client_info()+ + @param [String] name + @param [Hash] version + @param [String] type + @param [Hash] methods + @param [Hash] attributes + @return [void] + +@method get_chan_info(chan) + See +:h nvim_get_chan_info()+ + @param [Integer] chan + @return [Hash] + +@method list_chans + See +:h nvim_list_chans()+ + @return [Array] + +@method call_atomic(calls) See +:h nvim_call_atomic()+ + @param [Array] calls + @return [Array] + +@method parse_expression(expr, flags, highlight) + See +:h nvim_parse_expression()+ + @param [String] expr + @param [String] flags + @param [Boolean] highlight + @return [Hash] + +@method list_uis + See +:h nvim_list_uis()+ @return [Array] +@method get_proc_children(pid) + See +:h nvim_get_proc_children()+ + @param [Integer] pid + @return [Array] + +@method get_proc(pid) + See +:h nvim_get_proc()+ + @param [Integer] pid + @return [Object] + =end end end diff -Nru ruby-neovim-0.7.1/lib/neovim/connection.rb ruby-neovim-0.8.1/lib/neovim/connection.rb --- ruby-neovim-0.7.1/lib/neovim/connection.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/connection.rb 2019-07-01 10:48:04.000000000 +0000 @@ -40,7 +40,8 @@ def write(object) log(:debug) { {object: object} } - @packer.write(object).flush + @packer.write(object) + self end def read @@ -49,6 +50,11 @@ end end + def flush + @packer.flush + self + end + def register_type(id) @unpacker.register_type(id) do |data| index = MessagePack.unpack(data) diff -Nru ruby-neovim-0.7.1/lib/neovim/event_loop.rb ruby-neovim-0.8.1/lib/neovim/event_loop.rb --- ruby-neovim-0.7.1/lib/neovim/event_loop.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/event_loop.rb 2019-07-01 10:48:04.000000000 +0000 @@ -34,8 +34,9 @@ end def shutdown - stop + @running = false @shutdown = true + run end def request(request_id, method, *args) @@ -102,7 +103,7 @@ private def read - array = @connection.read + array = @connection.flush.read Message.from_array(array) end diff -Nru ruby-neovim-0.7.1/lib/neovim/host.rb ruby-neovim-0.8.1/lib/neovim/host.rb --- ruby-neovim-0.7.1/lib/neovim/host.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/host.rb 2019-07-01 10:48:04.000000000 +0000 @@ -1,5 +1,6 @@ require "neovim" require "neovim/client" +require "neovim/client_info" require "neovim/event_loop" require "neovim/host/loader" @@ -78,6 +79,8 @@ def initialize_client(request_id) @session.request_id = request_id + @session.notify(:nvim_set_client_info, *ClientInfo.for_host(self).to_args) + @client = Client.from_event_loop(@event_loop, @session) end diff -Nru ruby-neovim-0.7.1/lib/neovim/message.rb ruby-neovim-0.8.1/lib/neovim/message.rb --- ruby-neovim-0.7.1/lib/neovim/message.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/message.rb 2019-07-01 10:48:04.000000000 +0000 @@ -49,7 +49,7 @@ end def received(handlers) - handlers[request_id].call(self) + handlers.delete(request_id).call(self) end end diff -Nru ruby-neovim-0.7.1/lib/neovim/plugin/dsl.rb ruby-neovim-0.8.1/lib/neovim/plugin/dsl.rb --- ruby-neovim-0.7.1/lib/neovim/plugin/dsl.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/plugin/dsl.rb 2019-07-01 10:48:04.000000000 +0000 @@ -68,6 +68,12 @@ private + # Mark this plugin as the Ruby script host started by nvim. Should only + # be used in +Neovim::RubyProvider+. + def script_host! + @plugin.script_host = true + end + # Register a setup block to run once before the host starts. The block # should expect to receive a single argument, a +Neovim::Client+. # diff -Nru ruby-neovim-0.7.1/lib/neovim/plugin.rb ruby-neovim-0.8.1/lib/neovim/plugin.rb --- ruby-neovim-0.7.1/lib/neovim/plugin.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/plugin.rb 2019-07-01 10:48:04.000000000 +0000 @@ -3,7 +3,7 @@ module Neovim # @api private class Plugin - attr_accessor :handlers, :setup_blocks + attr_accessor :handlers, :setup_blocks, :script_host attr_reader :source def self.from_config_block(source) @@ -13,9 +13,10 @@ end def initialize(source) - @handlers = [] @source = source + @handlers = [] @setup_blocks = [] + @script_host = false end def specs @@ -27,5 +28,9 @@ def setup(client) @setup_blocks.each { |bl| bl.call(client) } end + + def script_host? + !!@script_host + end end end diff -Nru ruby-neovim-0.7.1/lib/neovim/remote_object.rb ruby-neovim-0.8.1/lib/neovim/remote_object.rb --- ruby-neovim-0.7.1/lib/neovim/remote_object.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/remote_object.rb 2019-07-01 10:48:04.000000000 +0000 @@ -1,3 +1,5 @@ +require "set" + module Neovim # @abstract Superclass for all +nvim+ remote objects. # @@ -37,7 +39,7 @@ # Extend +methods+ to include RPC methods def methods(*args) - super | rpc_methods + super | rpc_methods.to_a end # Extend +==+ to only look at class and index. @@ -48,7 +50,8 @@ private def rpc_methods - @api.functions_for_object(self).map(&:method_name) + @rpc_methods ||= + @api.functions_for_object(self).map(&:method_name).to_set end end end diff -Nru ruby-neovim-0.7.1/lib/neovim/ruby_provider/vim.rb ruby-neovim-0.8.1/lib/neovim/ruby_provider/vim.rb --- ruby-neovim-0.7.1/lib/neovim/ruby_provider/vim.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/ruby_provider/vim.rb 2019-07-01 10:48:04.000000000 +0000 @@ -15,7 +15,7 @@ # Delegate all method calls to the underlying +Neovim::Client+ object. def self.method_missing(method, *args, &block) - if @__client.respond_to?(method) + if @__client @__client.public_send(method, *args, &block).tap do __refresh_globals(@__client) end @@ -33,13 +33,14 @@ end def self.__refresh_globals(client) - bufnr = client.evaluate("bufnr('%')") + bufid, winid = client.evaluate("[nvim_get_current_buf(), nvim_get_current_win()]") + session, api = client.session, client.api - $curbuf = @__buffer_cache.fetch(bufnr) do - @__buffer_cache[bufnr] = client.get_current_buf + $curbuf = @__buffer_cache.fetch(bufid) do + @__buffer_cache[bufid] = Buffer.new(bufid, session, api) end - $curwin = client.get_current_win + $curwin = Window.new(winid, session, api) end end diff -Nru ruby-neovim-0.7.1/lib/neovim/ruby_provider.rb ruby-neovim-0.8.1/lib/neovim/ruby_provider.rb --- ruby-neovim-0.7.1/lib/neovim/ruby_provider.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/ruby_provider.rb 2019-07-01 10:48:04.000000000 +0000 @@ -14,6 +14,8 @@ Thread.abort_on_exception = true Neovim.plugin do |plug| + plug.__send__(:script_host!) + __define_setup(plug) __define_ruby_execute(plug) __define_ruby_execute_file(plug) @@ -134,9 +136,9 @@ def self.__update_lines_in_chunks(buffer, start, stop, size) (start..stop).each_slice(size) do |linenos| start, stop = linenos[0] - 1, linenos[-1] - lines = buffer.get_lines(start, stop, true) + lines = buffer.get_lines(start, stop, false) - buffer.set_lines(start, stop, true, yield(lines)) + buffer.set_lines(start, stop, false, yield(lines)) end end private_class_method :__update_lines_in_chunks diff -Nru ruby-neovim-0.7.1/lib/neovim/session.rb ruby-neovim-0.8.1/lib/neovim/session.rb --- ruby-neovim-0.7.1/lib/neovim/session.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/session.rb 2019-07-01 10:48:04.000000000 +0000 @@ -11,6 +11,13 @@ attr_writer :request_id + # @api private + class Exited < RuntimeError + def initialize + super("nvim process exited") + end + end + def initialize(event_loop) @event_loop = event_loop @main_thread = Thread.current @@ -60,7 +67,10 @@ @event_loop.request(@request_id, method, *args) response = blocking ? blocking_response : yielding_response - response.error ? raise(response.error) : response.value + + raise(Exited) if response.nil? + raise(response.error) if response.error + response.value end end diff -Nru ruby-neovim-0.7.1/lib/neovim/tabpage.rb ruby-neovim-0.8.1/lib/neovim/tabpage.rb --- ruby-neovim-0.7.1/lib/neovim/tabpage.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/tabpage.rb 2019-07-01 10:48:04.000000000 +0000 @@ -3,47 +3,40 @@ module Neovim # Class representing an +nvim+ tabpage. # - # The methods documented here were generated using NVIM v0.2.2 + # The methods documented here were generated using NVIM v0.3.7 class Tabpage < RemoteObject # The following methods are dynamically generated. =begin -@method list_wins(tabpage) +@method list_wins See +:h nvim_tabpage_list_wins()+ - @param [Tabpage] tabpage @return [Array] -@method get_var(tabpage, name) +@method get_var(name) See +:h nvim_tabpage_get_var()+ - @param [Tabpage] tabpage @param [String] name @return [Object] -@method set_var(tabpage, name, value) +@method set_var(name, value) See +:h nvim_tabpage_set_var()+ - @param [Tabpage] tabpage @param [String] name @param [Object] value @return [void] -@method del_var(tabpage, name) +@method del_var(name) See +:h nvim_tabpage_del_var()+ - @param [Tabpage] tabpage @param [String] name @return [void] -@method get_win(tabpage) +@method get_win See +:h nvim_tabpage_get_win()+ - @param [Tabpage] tabpage @return [Window] -@method get_number(tabpage) +@method get_number See +:h nvim_tabpage_get_number()+ - @param [Tabpage] tabpage @return [Integer] -@method is_valid(tabpage) +@method is_valid See +:h nvim_tabpage_is_valid()+ - @param [Tabpage] tabpage @return [Boolean] =end diff -Nru ruby-neovim-0.7.1/lib/neovim/version.rb ruby-neovim-0.8.1/lib/neovim/version.rb --- ruby-neovim-0.7.1/lib/neovim/version.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/version.rb 2019-07-01 10:48:04.000000000 +0000 @@ -1,3 +1,3 @@ module Neovim - VERSION = Gem::Version.new("0.7.1") + VERSION = Gem::Version.new("0.8.1") end diff -Nru ruby-neovim-0.7.1/lib/neovim/window.rb ruby-neovim-0.8.1/lib/neovim/window.rb --- ruby-neovim-0.7.1/lib/neovim/window.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim/window.rb 2019-07-01 10:48:04.000000000 +0000 @@ -3,7 +3,7 @@ module Neovim # Class representing an +nvim+ window. # - # The methods documented here were generated using NVIM v0.2.2 + # The methods documented here were generated using NVIM v0.3.7 class Window < RemoteObject # Get the buffer displayed in the window # @@ -64,94 +64,83 @@ # The following methods are dynamically generated. =begin -@method get_buf(window) +@method get_buf See +:h nvim_win_get_buf()+ - @param [Window] window @return [Buffer] -@method get_cursor(window) +@method set_buf(buffer) + See +:h nvim_win_set_buf()+ + @param [Buffer] buffer + @return [void] + +@method get_cursor See +:h nvim_win_get_cursor()+ - @param [Window] window @return [Array] -@method set_cursor(window, pos) +@method set_cursor(pos) See +:h nvim_win_set_cursor()+ - @param [Window] window @param [Array] pos @return [void] -@method get_height(window) +@method get_height See +:h nvim_win_get_height()+ - @param [Window] window @return [Integer] -@method set_height(window, height) +@method set_height(height) See +:h nvim_win_set_height()+ - @param [Window] window @param [Integer] height @return [void] -@method get_width(window) +@method get_width See +:h nvim_win_get_width()+ - @param [Window] window @return [Integer] -@method set_width(window, width) +@method set_width(width) See +:h nvim_win_set_width()+ - @param [Window] window @param [Integer] width @return [void] -@method get_var(window, name) +@method get_var(name) See +:h nvim_win_get_var()+ - @param [Window] window @param [String] name @return [Object] -@method set_var(window, name, value) +@method set_var(name, value) See +:h nvim_win_set_var()+ - @param [Window] window @param [String] name @param [Object] value @return [void] -@method del_var(window, name) +@method del_var(name) See +:h nvim_win_del_var()+ - @param [Window] window @param [String] name @return [void] -@method get_option(window, name) +@method get_option(name) See +:h nvim_win_get_option()+ - @param [Window] window @param [String] name @return [Object] -@method set_option(window, name, value) +@method set_option(name, value) See +:h nvim_win_set_option()+ - @param [Window] window @param [String] name @param [Object] value @return [void] -@method get_position(window) +@method get_position See +:h nvim_win_get_position()+ - @param [Window] window @return [Array] -@method get_tabpage(window) +@method get_tabpage See +:h nvim_win_get_tabpage()+ - @param [Window] window @return [Tabpage] -@method get_number(window) +@method get_number See +:h nvim_win_get_number()+ - @param [Window] window @return [Integer] -@method is_valid(window) +@method is_valid See +:h nvim_win_is_valid()+ - @param [Window] window @return [Boolean] =end diff -Nru ruby-neovim-0.7.1/lib/neovim.rb ruby-neovim-0.8.1/lib/neovim.rb --- ruby-neovim-0.7.1/lib/neovim.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/lib/neovim.rb 2019-07-01 10:48:04.000000000 +0000 @@ -1,4 +1,5 @@ require "neovim/client" +require "neovim/client_info" require "neovim/session" require "neovim/event_loop" require "neovim/executable" @@ -62,7 +63,7 @@ # @return [Client] # @see EventLoop.tcp def self.attach_tcp(host, port) - Client.from_event_loop EventLoop.tcp(host, port) + attach(EventLoop.tcp(host, port)) end # Connect to a running +nvim+ instance over a UNIX domain socket. @@ -71,7 +72,7 @@ # @return [Client] # @see EventLoop.unix def self.attach_unix(socket_path) - Client.from_event_loop EventLoop.unix(socket_path) + attach(EventLoop.unix(socket_path)) end # Spawn and connect to a child +nvim+ process. @@ -80,7 +81,7 @@ # @return [Client] # @see EventLoop.child def self.attach_child(argv=[executable.path]) - Client.from_event_loop EventLoop.child(argv) + attach(EventLoop.child(argv)) end # Placeholder method for exposing the remote plugin DSL. This gets @@ -116,4 +117,12 @@ def self.logger Logging.logger end + + # @api private + def self.attach(event_loop) + Client.from_event_loop(event_loop).tap do |client| + client.session.notify(:nvim_set_client_info, *ClientInfo.for_client.to_args) + end + end + private_class_method :attach end diff -Nru ruby-neovim-0.7.1/neovim.gemspec ruby-neovim-0.8.1/neovim.gemspec --- ruby-neovim-0.7.1/neovim.gemspec 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/neovim.gemspec 2019-07-01 10:48:04.000000000 +0000 @@ -1,4 +1,4 @@ -lib = File.expand_path("../lib", __FILE__) +lib = File.expand_path("lib", __dir__) $:.unshift(lib) unless $:.include?(lib) require "neovim/version" @@ -8,10 +8,11 @@ spec.authors = ["Alex Genco"] spec.email = ["alexgenco@gmail.com"] spec.summary = "A Ruby client for Neovim" - spec.homepage = "https://github.com/alexgenco/neovim-ruby" + spec.homepage = "https://github.com/neovim/neovim-ruby" spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0") + spec.bindir = "exe" spec.executables = ["neovim-ruby-host"] spec.test_files = spec.files.grep(%r{^spec/}) spec.require_paths = ["lib"] @@ -22,11 +23,10 @@ spec.add_dependency "multi_json", "~> 1.0" spec.add_development_dependency "bundler" - spec.add_development_dependency "coveralls" spec.add_development_dependency "pry" spec.add_development_dependency "pry-byebug" spec.add_development_dependency "rake" spec.add_development_dependency "rspec", "~> 3.0" - spec.add_development_dependency "rubocop", "0.52.1" + spec.add_development_dependency "rubocop", "0.56.0" spec.add_development_dependency "vim-flavor", "2.2.2" end diff -Nru ruby-neovim-0.7.1/Rakefile ruby-neovim-0.8.1/Rakefile --- ruby-neovim-0.7.1/Rakefile 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/Rakefile 2019-07-01 10:48:04.000000000 +0000 @@ -16,7 +16,9 @@ namespace :acceptance do desc "Install acceptance spec dependencies" task :deps do - sh "bundle exec vim-flavor update --vimfiles-path=spec/acceptance/runtime" + Bundler.with_clean_env do + sh "bundle exec vim-flavor update --vimfiles-path=spec/acceptance/runtime" + end end end end @@ -33,8 +35,21 @@ end end -task default: [:style, "spec:functional", "spec:acceptance", "docs:validate"] +namespace :scripts do + desc "Validate script syntax" + task :validate do + sh "ruby -c #{File.expand_path("script/*.rb", __dir__)}" + end +end + +task default: [ + :style, + :"docs:validate", + :"scripts:validate", + :"spec:functional", + :"spec:acceptance" +] def run_script(script_name, *args) - ruby File.expand_path("../script/#{script_name}.rb", __FILE__), *args + ruby File.expand_path("script/#{script_name}.rb", __dir__), *args end diff -Nru ruby-neovim-0.7.1/README.md ruby-neovim-0.8.1/README.md --- ruby-neovim-0.7.1/README.md 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/README.md 2019-07-01 10:48:04.000000000 +0000 @@ -1,12 +1,9 @@ # Neovim Ruby -[![Travis](https://travis-ci.org/alexgenco/neovim-ruby.svg?branch=master)](https://travis-ci.org/alexgenco/neovim-ruby) -[![Build status](https://ci.appveyor.com/api/projects/status/wp7agvgcxxcguj6h/branch/master?svg=true)](https://ci.appveyor.com/project/alexgenco/neovim-ruby/branch/master) -[![Coverage Status](https://coveralls.io/repos/alexgenco/neovim-ruby/badge.svg)](https://coveralls.io/r/alexgenco/neovim-ruby) -[![Code Climate](https://codeclimate.com/github/alexgenco/neovim-ruby/badges/gpa.svg)](https://codeclimate.com/github/alexgenco/neovim-ruby) +[![Travis](https://travis-ci.org/neovim/neovim-ruby.svg?branch=master)](https://travis-ci.org/neovim/neovim-ruby) +[![Build status](https://ci.appveyor.com/api/projects/status/y44k25tcdvvuq0ee?svg=true)](https://ci.appveyor.com/project/alexgenco/neovim-ruby) [![Gem Version](https://badge.fury.io/rb/neovim.svg)](https://badge.fury.io/rb/neovim) -[![Dependency Status](https://gemnasium.com/badges/github.com/alexgenco/neovim-ruby.svg)](https://gemnasium.com/github.com/alexgenco/neovim-ruby) -[![Inline docs](http://inch-ci.org/github/alexgenco/neovim-ruby.svg?branch=master)](http://inch-ci.org/github/alexgenco/neovim-ruby) +[![Inline docs](http://inch-ci.org/github/neovim/neovim-ruby.svg?branch=master)](http://inch-ci.org/github/neovim/neovim-ruby) Ruby bindings for [Neovim](https://github.com/neovim/neovim). @@ -41,7 +38,7 @@ client = Neovim.attach_unix("/tmp/nvim.sock") ``` -Refer to the [`Neovim` docs](http://www.rubydoc.info/github/alexgenco/neovim-ruby/master/Neovim) for other ways to connect to `nvim`, and the [`Neovim::Client` docs](http://www.rubydoc.info/github/alexgenco/neovim-ruby/master/Neovim/Client) for a summary of the client interface. +Refer to the [`Neovim` docs](http://www.rubydoc.info/github/neovim/neovim-ruby/master/Neovim) for other ways to connect to `nvim`, and the [`Neovim::Client` docs](http://www.rubydoc.info/github/neovim/neovim-ruby/master/Neovim/Client) for a summary of the client interface. ### Plugins @@ -73,7 +70,7 @@ When you add or update a plugin, you will need to call `:UpdateRemotePlugins` to update the remote plugin manifest. See `:help remote-plugin-manifest` for more information. -Refer to the [`Neovim::Plugin::DSL` docs](http://www.rubydoc.info/github/alexgenco/neovim-ruby/master/Neovim/Plugin/DSL) for a more complete overview of the `Neovim.plugin` DSL. +Refer to the [`Neovim::Plugin::DSL` docs](http://www.rubydoc.info/github/neovim/neovim-ruby/master/Neovim/Plugin/DSL) for a more complete overview of the `Neovim.plugin` DSL. ### Vim Plugin Support @@ -81,16 +78,16 @@ ## Links -* Source: -* Bugs: -* CI: +* Source: +* Bugs: +* CI: * Documentation: * Latest Gem: - * Master: + * Master: ## Contributing -1. Fork it (http://github.com/alexgenco/neovim-ruby/fork) +1. Fork it (http://github.com/neovim/neovim-ruby/fork) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) diff -Nru ruby-neovim-0.7.1/.rubocop.yml ruby-neovim-0.8.1/.rubocop.yml --- ruby-neovim-0.7.1/.rubocop.yml 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/.rubocop.yml 2019-07-01 10:48:04.000000000 +0000 @@ -2,12 +2,17 @@ Exclude: - _neovim/**/* - spec/acceptance/**/* + - spec/workspace/**/* - vendor/**/* - script/**/* + - bin/**/* Layout/EndOfLine: EnforcedStyle: lf +Layout/MultilineMethodCallIndentation: + EnforcedStyle: indented + Layout/SpaceAroundEqualsInParameterDefault: EnforcedStyle: no_space @@ -69,6 +74,9 @@ Exclude: - lib/neovim/client.rb +Naming/UncommunicativeMethodParamName: + Enabled: false + Security/Eval: Exclude: - lib/neovim/ruby_provider.rb @@ -95,6 +103,9 @@ - lib/neovim/ruby_provider/vim.rb - spec/neovim/ruby_provider/vim_spec.rb +Style/MultilineTernaryOperator: + Enabled: false + Style/ParallelAssignment: Enabled: false @@ -107,6 +118,9 @@ Style/StringLiterals: EnforcedStyle: double_quotes +Style/StringLiteralsInInterpolation: + EnforcedStyle: double_quotes + Style/SymbolArray: EnforcedStyle: brackets diff -Nru ruby-neovim-0.7.1/script/dump_api.rb ruby-neovim-0.8.1/script/dump_api.rb --- ruby-neovim-0.7.1/script/dump_api.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/script/dump_api.rb 2019-07-01 10:48:04.000000000 +0000 @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift File.expand_path("../../lib", __FILE__) +$:.unshift File.expand_path("../lib", __dir__) require "neovim" require "json" diff -Nru ruby-neovim-0.7.1/script/generate_docs.rb ruby-neovim-0.8.1/script/generate_docs.rb --- ruby-neovim-0.7.1/script/generate_docs.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/script/generate_docs.rb 2019-07-01 10:48:04.000000000 +0000 @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$:.unshift File.expand_path("../../lib", __FILE__) +$:.unshift File.expand_path("../lib", __dir__) require "neovim" require "pathname" @@ -19,10 +19,6 @@ tabpage_defs = Neovim::Tabpage.instance_methods(false) window_defs = Neovim::Window.instance_methods(false) -def add_method(docs, defs, method_name) - return if defs.include?(method_name.to_s) -end - session.request(:nvim_get_api_info)[1]["functions"].each do |func| func_name = func["name"] params = func["parameters"] @@ -30,16 +26,18 @@ case func_name when /^nvim_buf_(.+)/ method_name = $1 + params.shift next if buffer_defs.include?(method_name.to_sym) when /^nvim_win_(.+)/ method_name = $1 + params.shift next if window_defs.include?(method_name.to_sym) when /^nvim_tabpage_(.+)/ method_name = $1 + params.shift next if tabpage_defs.include?(method_name.to_sym) when /^nvim_(.+)/ method_name = $1 - params.shift next if nvim_defs.include?(method_name.to_sym) else next @@ -72,7 +70,8 @@ end end -lib_dir = Pathname.new(File.expand_path("../../lib/neovim", __FILE__)) +lib_dir = Pathname.new(File.expand_path("../lib/neovim", __dir__)) + { "client.rb" => nvim_docs, "buffer.rb" => buffer_docs, diff -Nru ruby-neovim-0.7.1/script/run_acceptance.rb ruby-neovim-0.8.1/script/run_acceptance.rb --- ruby-neovim-0.7.1/script/run_acceptance.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/script/run_acceptance.rb 2019-07-01 10:48:04.000000000 +0000 @@ -5,7 +5,7 @@ ENV.delete("VIM") ENV.delete("VIMRUNTIME") -acceptance_root = File.expand_path("../../spec/acceptance", __FILE__) +acceptance_root = File.expand_path("../spec/acceptance", __dir__) themis_rtp = File.join(acceptance_root, "runtime") themis_home = File.join(themis_rtp, "flavors/thinca_vim-themis") manifest = File.join(themis_rtp, "rplugin_manifest.vim") diff -Nru ruby-neovim-0.7.1/script/validate_docs.rb ruby-neovim-0.8.1/script/validate_docs.rb --- ruby-neovim-0.7.1/script/validate_docs.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/script/validate_docs.rb 2019-07-01 10:48:04.000000000 +0000 @@ -15,7 +15,7 @@ release_version = response["name"][/NVIM v?(.+)$/, 1] client_file = File.read( - File.expand_path("../../lib/neovim/client.rb", __FILE__) + File.expand_path("../lib/neovim/client.rb", __dir__) ) docs_version = client_file[ /The methods documented here were generated using NVIM v?(.+)$/, diff -Nru ruby-neovim-0.7.1/spec/acceptance/client_info_spec.vim ruby-neovim-0.8.1/spec/acceptance/client_info_spec.vim --- ruby-neovim-0.7.1/spec/acceptance/client_info_spec.vim 1970-01-01 00:00:00.000000000 +0000 +++ ruby-neovim-0.8.1/spec/acceptance/client_info_spec.vim 2019-07-01 10:48:04.000000000 +0000 @@ -0,0 +1,42 @@ +let s:suite = themis#suite("Client info") +let s:expect = themis#helper("expect") + +function! s:suite.before_each() abort + call RPluginFunctionArgs(1, 2) + + let s:client_chans = map( + \ filter(nvim_list_chans(), "has_key(v:val, 'client')"), + \ "v:val.client") +endfunction + +function! s:suite.get_script_host_client_info() abort + let client_info = s:client_chans[1] + + call s:expect(sort(keys(client_info))).to_equal( + \ ["attributes", "methods", "name", "type", "version"]) + + call s:expect(client_info.attributes).to_be_dict() + call s:expect(client_info.methods).to_equal({"specs": {"nargs": 1}, "poll": {}}) + call s:expect(client_info.name).to_equal("ruby-script-host") + call s:expect(client_info.type).to_equal("host") + + call s:expect(client_info.version.major).to_be_number() + call s:expect(client_info.version.minor).to_be_number() + call s:expect(client_info.version.patch).to_be_number() +endfunction + +function! s:suite.get_rplugin_client_info() abort + let client_info = s:client_chans[0] + + call s:expect(sort(keys(client_info))).to_equal( + \ ["attributes", "methods", "name", "type", "version"]) + + call s:expect(client_info.attributes).to_be_dict() + call s:expect(client_info.methods).to_equal({"specs": {"nargs": 1}, "poll": {}}) + call s:expect(client_info.name).to_equal("ruby-rplugin-host") + call s:expect(client_info.type).to_equal("host") + + call s:expect(client_info.version.major).to_be_number() + call s:expect(client_info.version.minor).to_be_number() + call s:expect(client_info.version.patch).to_be_number() +endfunction diff -Nru ruby-neovim-0.7.1/spec/acceptance/rubydo_spec.vim ruby-neovim-0.8.1/spec/acceptance/rubydo_spec.vim --- ruby-neovim-0.7.1/spec/acceptance/rubydo_spec.vim 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/acceptance/rubydo_spec.vim 2019-07-01 10:48:04.000000000 +0000 @@ -42,6 +42,15 @@ call s:expect(getline(1, 4)).to_equal(["ONE", "TWO", "THREE", "FOUR"]) endfunction +function! s:suite.ignores_line_deletion() abort + " Just ensure `Index out of bounds` exception isn't raised. + " + " Deleting or adding lines inside `:rubydo` is documented as not supported. + " Therefore this will remain inconsistent with Vim, which deletes all but + " the first line (?) + %rubydo Vim.command("%d") +endfunction + function! s:suite.handles_standard_error() abort try 1rubydo raise "BOOM" diff -Nru ruby-neovim-0.7.1/spec/acceptance/rubyfile/curbuf_ivar_get.rb ruby-neovim-0.8.1/spec/acceptance/rubyfile/curbuf_ivar_get.rb --- ruby-neovim-0.7.1/spec/acceptance/rubyfile/curbuf_ivar_get.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/acceptance/rubyfile/curbuf_ivar_get.rb 2019-07-01 10:48:04.000000000 +0000 @@ -1 +1 @@ -Vim.command("let g:foo = #{$curbuf.instance_variable_get(:@foo)}") +Vim.command("let s:var = #{$curbuf.instance_variable_get(:@var)}") diff -Nru ruby-neovim-0.7.1/spec/acceptance/rubyfile/curbuf_ivar_set.rb ruby-neovim-0.8.1/spec/acceptance/rubyfile/curbuf_ivar_set.rb --- ruby-neovim-0.7.1/spec/acceptance/rubyfile/curbuf_ivar_set.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/acceptance/rubyfile/curbuf_ivar_set.rb 2019-07-01 10:48:04.000000000 +0000 @@ -1 +1 @@ -$curbuf.instance_variable_set(:@foo, 123) +$curbuf.instance_variable_set(:@var, 123) diff -Nru ruby-neovim-0.7.1/spec/acceptance/rubyfile/define_foo.rb ruby-neovim-0.8.1/spec/acceptance/rubyfile/define_foo.rb --- ruby-neovim-0.7.1/spec/acceptance/rubyfile/define_foo.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/acceptance/rubyfile/define_foo.rb 2019-07-01 10:48:04.000000000 +0000 @@ -1,3 +1,3 @@ def foo - Vim.command("let g:called = 1") + Vim.command("let s:var = 1") end diff -Nru ruby-neovim-0.7.1/spec/acceptance/rubyfile/nested_inner.rb ruby-neovim-0.8.1/spec/acceptance/rubyfile/nested_inner.rb --- ruby-neovim-0.7.1/spec/acceptance/rubyfile/nested_inner.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/acceptance/rubyfile/nested_inner.rb 2019-07-01 10:48:04.000000000 +0000 @@ -1 +1 @@ -Vim.command("let g:ruby_nested = 123") +Vim.command("let s:var = 123") diff -Nru ruby-neovim-0.7.1/spec/acceptance/rubyfile/set_pwd_after.rb ruby-neovim-0.8.1/spec/acceptance/rubyfile/set_pwd_after.rb --- ruby-neovim-0.7.1/spec/acceptance/rubyfile/set_pwd_after.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/acceptance/rubyfile/set_pwd_after.rb 2019-07-01 10:48:04.000000000 +0000 @@ -1 +1 @@ -Vim.command("let g:pwd_after = '#{Dir.pwd}'") +Vim.command("call add(s:var, '#{Dir.pwd}')") diff -Nru ruby-neovim-0.7.1/spec/acceptance/rubyfile/set_pwd_before.rb ruby-neovim-0.8.1/spec/acceptance/rubyfile/set_pwd_before.rb --- ruby-neovim-0.7.1/spec/acceptance/rubyfile/set_pwd_before.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/acceptance/rubyfile/set_pwd_before.rb 2019-07-01 10:48:04.000000000 +0000 @@ -1 +1 @@ -Vim.command("let g:pwd_before = '#{Dir.pwd.sub(/^C:/, '')}'") +Vim.command("let s:var = ['#{Dir.pwd.sub(/^C:/, '')}']") diff -Nru ruby-neovim-0.7.1/spec/acceptance/rubyfile_spec.vim ruby-neovim-0.8.1/spec/acceptance/rubyfile_spec.vim --- ruby-neovim-0.7.1/spec/acceptance/rubyfile_spec.vim 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/acceptance/rubyfile_spec.vim 2019-07-01 10:48:04.000000000 +0000 @@ -2,12 +2,13 @@ let s:expect = themis#helper("expect") function! s:suite.before() abort - let g:return_pwd = getcwd() + let s:pwd = getcwd() cd spec/acceptance/rubyfile + unlet! s:var endfunction function! s:suite.after() abort - execute("cd " . g:return_pwd) + execute("cd " . s:pwd) endfunction function! s:suite.before_each() abort @@ -23,42 +24,43 @@ rubyfile ./define_foo.rb rubyfile ./call_foo.rb - call s:expect(g:called).to_equal(1) + call s:expect(s:var).to_equal(1) endfunction function! s:suite.persists_curbuf_state() abort rubyfile ./curbuf_ivar_set.rb rubyfile ./curbuf_ivar_get.rb - call s:expect(g:foo).to_equal(123) + call s:expect(s:var).to_equal(123) endfunction function! s:suite.updates_working_directory() abort - let g:rubyfile = getcwd() . "/set_pwd_before.rb" + let s:rubyfile = getcwd() . "/set_pwd_before.rb" cd / - exec "rubyfile " . g:rubyfile + exec "rubyfile " . s:rubyfile cd - - call s:expect(g:pwd_before).to_equal("/") + call s:expect(s:var).to_equal(["/"]) endfunction function! s:suite.updates_working_directory_implicitly() abort - let g:before_file = getcwd() . "/set_pwd_before.rb" - let g:after_file = getcwd() . "/set_pwd_after.rb" + let s:before_file = getcwd() . "/set_pwd_before.rb" + let s:after_file = getcwd() . "/set_pwd_after.rb" split | lcd / - exec "rubyfile " . g:before_file + exec "rubyfile " . s:before_file wincmd p - exec "rubyfile " . g:after_file + exec "rubyfile " . s:after_file wincmd p | lcd - - call s:expect(g:pwd_before).not.to_equal(g:pwd_after) + call s:expect(len(s:var)).to_equal(2) + call s:expect(s:var[0]).not.to_equal(s:var[1]) endfunction function! s:suite.supports_nesting() abort rubyfile ./nested.rb - call s:expect(g:ruby_nested).to_equal(123) + call s:expect(s:var).to_equal(123) endfunction function! s:suite.handles_standard_error() abort diff -Nru ruby-neovim-0.7.1/spec/acceptance/ruby_spec.vim ruby-neovim-0.8.1/spec/acceptance/ruby_spec.vim --- ruby-neovim-0.7.1/spec/acceptance/ruby_spec.vim 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/acceptance/ruby_spec.vim 2019-07-01 10:48:04.000000000 +0000 @@ -4,6 +4,7 @@ function! s:suite.before_each() abort 1,$delete call append(0, ["one", "two"]) + unlet! s:var endfunction function! s:suite.has_nvim() abort @@ -11,41 +12,42 @@ endfunction function! s:suite.defines_a_ruby_method() abort - ruby def foo; Vim.command("let g:called = 1"); end + ruby def foo; Vim.command("let s:var = 1"); end ruby foo - call s:expect(g:called).to_equal(1) + call s:expect(s:var).to_equal(1) endfunction function! s:suite.persists_curbuf_state() abort ruby $curbuf.instance_variable_set(:@foo, 123) - ruby Vim.command("let g:foo = #{$curbuf.instance_variable_get(:@foo)}") + ruby Vim.command("let s:var = #{$curbuf.instance_variable_get(:@foo)}") - call s:expect(g:foo).to_equal(123) + call s:expect(s:var).to_equal(123) endfunction function! s:suite.updates_working_directory() abort cd / - ruby Vim.command("let g:ruby_pwd = '#{Dir.pwd.sub(/^C:/, "")}'") + ruby Vim.command("let s:var = '#{Dir.pwd.sub(/^C:/, "")}'") cd - - call s:expect(g:ruby_pwd).to_equal("/") + call s:expect(s:var).to_equal("/") endfunction function! s:suite.updates_working_directory_implicitly() abort split | lcd / - ruby Vim.command("let g:before_pwd = '#{Dir.pwd}'") + ruby Vim.command("let s:var = ['#{Dir.pwd}']") wincmd p - ruby Vim.command("let g:after_pwd = '#{Dir.pwd}'") + ruby Vim.command("call add(s:var, '#{Dir.pwd}')") wincmd p | lcd - - call s:expect(g:before_pwd).not.to_equal(g:after_pwd) + call s:expect(len(s:var)).to_equal(2) + call s:expect(s:var[0]).not.to_equal(s:var[1]) endfunction function! s:suite.supports_nesting() abort - ruby Vim.command("ruby Vim.command('let g:ruby_nested = 123')") + ruby Vim.command("ruby Vim.command('let s:var = 123')") - call s:expect(g:ruby_nested).to_equal(123) + call s:expect(s:var).to_equal(123) endfunction function! s:suite.handles_standard_error() abort diff -Nru ruby-neovim-0.7.1/spec/acceptance/runtime/init.vim ruby-neovim-0.8.1/spec/acceptance/runtime/init.vim --- ruby-neovim-0.7.1/spec/acceptance/runtime/init.vim 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/acceptance/runtime/init.vim 2019-07-01 10:48:04.000000000 +0000 @@ -1,7 +1,7 @@ let s:lib_path = getcwd() . "/lib" -let s:bin_path = getcwd() . "/bin/neovim-ruby-host" +let s:exe_path = getcwd() . "/exe/neovim-ruby-host" let g:acceptance_rtp = getcwd() . "/spec/acceptance/runtime" -let g:ruby_host_prog = printf("ruby -I %s %s", s:lib_path, s:bin_path) +let g:ruby_host_prog = printf("ruby -I %s %s", s:lib_path, s:exe_path) ruby require "rspec/expectations" ruby include ::RSpec::Matchers.dup diff -Nru ruby-neovim-0.7.1/spec/helper.rb ruby-neovim-0.8.1/spec/helper.rb --- ruby-neovim-0.7.1/spec/helper.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/helper.rb 2019-07-01 10:48:04.000000000 +0000 @@ -1,10 +1,5 @@ require "bundler/setup" -if ENV["REPORT_COVERAGE"] - require "coveralls" - Coveralls.wear! -end - require "fileutils" require "msgpack" require "neovim" @@ -14,7 +9,7 @@ require "stringio" require "timeout" -require File.expand_path("../support.rb", __FILE__) +require File.expand_path("support.rb", __dir__) RSpec.configure do |config| config.expect_with :rspec do |exp| diff -Nru ruby-neovim-0.7.1/spec/neovim/buffer_spec.rb ruby-neovim-0.8.1/spec/neovim/buffer_spec.rb --- ruby-neovim-0.7.1/spec/neovim/buffer_spec.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/neovim/buffer_spec.rb 2019-07-01 10:48:04.000000000 +0000 @@ -124,6 +124,12 @@ end.to change { buffer.lines.to_a }.to(["first", "one", "two"]) end + it "allows newlines" do + expect do + buffer.append(0, "first\nsecond") + end.to change { buffer.lines.to_a }.to(["first", "second", "one", "two"]) + end + it "doesn't move the cursor" do expect do buffer.append(0, "first") diff -Nru ruby-neovim-0.7.1/spec/neovim/client_info_spec.rb ruby-neovim-0.8.1/spec/neovim/client_info_spec.rb --- ruby-neovim-0.7.1/spec/neovim/client_info_spec.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-neovim-0.8.1/spec/neovim/client_info_spec.rb 2019-07-01 10:48:04.000000000 +0000 @@ -0,0 +1,77 @@ +require "neovim/client_info" +require "neovim/host" +require "neovim/plugin" + +module Neovim + RSpec.describe ClientInfo do + describe "#to_args" do + context ".for_host" do + it "returns script-host info" do + plugin = double(Plugin, script_host?: true) + host = double(Host, plugins: [plugin]) + info = ClientInfo.for_host(host) + + expect(info.to_args).to match( + [ + "ruby-script-host", + { + "major" => duck_type(:to_int), + "minor" => duck_type(:to_int), + "patch" => duck_type(:to_int) + }, + :host, + { + poll: {}, + specs: {nargs: 1} + }, + duck_type(:to_hash) + ] + ) + end + + it "returns rplugin info" do + plugin = double(Plugin, script_host?: false) + host = double(Host, plugins: [plugin]) + info = ClientInfo.for_host(host) + + expect(info.to_args).to match( + [ + "ruby-rplugin-host", + { + "major" => duck_type(:to_int), + "minor" => duck_type(:to_int), + "patch" => duck_type(:to_int) + }, + :host, + { + poll: {}, + specs: {nargs: 1} + }, + duck_type(:to_hash) + ] + ) + end + end + + context ".for_client" do + it "returns remote client info" do + info = ClientInfo.for_client + + expect(info.to_args).to match( + [ + "ruby-client", + { + "major" => duck_type(:to_int), + "minor" => duck_type(:to_int), + "patch" => duck_type(:to_int) + }, + :remote, + {}, + duck_type(:to_hash) + ] + ) + end + end + end + end +end diff -Nru ruby-neovim-0.7.1/spec/neovim/client_spec.rb ruby-neovim-0.8.1/spec/neovim/client_spec.rb --- ruby-neovim-0.7.1/spec/neovim/client_spec.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/neovim/client_spec.rb 2019-07-01 10:48:04.000000000 +0000 @@ -25,6 +25,13 @@ end end + describe "#shutdown" do + it "causes nvim to exit" do + client.shutdown + expect { client.strwidth("hi") }.to raise_error(Neovim::Session::Exited) + end + end + describe "#respond_to?" do it "returns true for vim functions" do expect(client).to respond_to(:strwidth) diff -Nru ruby-neovim-0.7.1/spec/neovim/connection_spec.rb ruby-neovim-0.8.1/spec/neovim/connection_spec.rb --- ruby-neovim-0.7.1/spec/neovim/connection_spec.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/neovim/connection_spec.rb 2019-07-01 10:48:04.000000000 +0000 @@ -7,11 +7,31 @@ describe "#write" do it "writes msgpack to the underlying file descriptor" do rd, wr = IO.pipe - connection = Connection.new(nil_io, wr) - connection.write("some data") + Connection.new(nil_io, wr).write("some data").flush + data = rd.readpartial(1024) + + expect(MessagePack.unpack(data)).to eq("some data") + end + end + + describe "#flush" do + it "flushes writes to the underlying file descriptor" do + rd, wr = IO.pipe + connection = Connection.new(nil_io, wr).write("some data") + + expect { rd.read_nonblock(16) }.to raise_error(IO::WaitReadable) + + connection.flush + + expect(rd.read_nonblock(16)).to eq(MessagePack.pack("some data")) + end + + it "throws an exception when the file is closed" do + _, wr = IO.pipe + connection = Connection.new(nil_io, wr).write("some data") wr.close - expect(MessagePack.unpack(rd.read)).to eq("some data") + expect { connection.flush }.to raise_error(IOError) end end @@ -19,11 +39,19 @@ it "reads msgpack from the underlying file descriptor" do rd, wr = IO.pipe wr.write(MessagePack.pack("some data")) - wr.close + wr.flush connection = Connection.new(rd, nil_io) expect(connection.read).to eq("some data") end + + it "throws an exception when the file is closed" do + rd, wr = IO.pipe + wr.close + + connection = Connection.new(rd, nil_io) + expect { connection.read }.to raise_error(EOFError) + end end describe "#register_type" do diff -Nru ruby-neovim-0.7.1/spec/neovim/event_loop_spec.rb ruby-neovim-0.8.1/spec/neovim/event_loop_spec.rb --- ruby-neovim-0.7.1/spec/neovim/event_loop_spec.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/neovim/event_loop_spec.rb 2019-07-01 10:48:04.000000000 +0000 @@ -16,7 +16,9 @@ describe "#request" do it "writes a msgpack request" do event_loop.request(1, :method, 1, 2) + connection.flush message = server_rd.readpartial(1024) + expect(message).to eq(MessagePack.pack([0, 1, "method", [1, 2]])) end end @@ -24,7 +26,9 @@ describe "#respond" do it "writes a msgpack response" do event_loop.respond(2, "value", "error") + connection.flush message = server_rd.readpartial(1024) + expect(message).to eq(MessagePack.pack([1, 2, "error", "value"])) end end @@ -32,7 +36,9 @@ describe "#notify" do it "writes a msgpack notification" do event_loop.notify(:method, 1, 2) + connection.flush message = server_rd.readpartial(1024) + expect(message).to eq(MessagePack.pack([2, "method", [1, 2]])) end end diff -Nru ruby-neovim-0.7.1/spec/neovim/host_spec.rb ruby-neovim-0.8.1/spec/neovim/host_spec.rb --- ruby-neovim-0.7.1/spec/neovim/host_spec.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/neovim/host_spec.rb 2019-07-01 10:48:04.000000000 +0000 @@ -47,16 +47,17 @@ end context "poll" do - it "initializes a client and responds 'ok'" do + it "initializes a client, sets client info, and responds 'ok'" do nvim_wr.write([0, 1, :poll, []]).flush - type, reqid, method = nvim_rd.read - expect(type).to eq(0) - expect(reqid).to eq(2) - expect(method).to eq("nvim_get_api_info") + expect(nvim_rd.read).to match([2, "nvim_set_client_info", duck_type(:to_ary)]) + + type, reqid, method = nvim_rd.read + expect([type, reqid, method]).to match([0, duck_type(:to_int), "nvim_get_api_info"]) api_info = [0, {"types" => {}, "functions" => {}}] nvim_wr.write([1, reqid, nil, api_info]).flush + expect(nvim_rd.read).to eq([1, 1, nil, "ok"]) end end @@ -64,14 +65,20 @@ context "after poll" do before do nvim_wr.write([0, 1, :poll, []]).flush - _, reqid, = nvim_rd.read + + expect(nvim_rd.read[1]).to eq("nvim_set_client_info") + + _, reqid, method = nvim_rd.read + + expect(method).to eq("nvim_get_api_info") session = Session.new(EventLoop.child(Support.child_argv)) api_info = session.request(:nvim_get_api_info) session.shutdown nvim_wr.write([1, reqid, nil, api_info]).flush - nvim_rd.read + + expect(nvim_rd.read[3]).to eq("ok") end it "responds with specs to the 'specs' request" do diff -Nru ruby-neovim-0.7.1/spec/neovim/session_spec.rb ruby-neovim-0.8.1/spec/neovim/session_spec.rb --- ruby-neovim-0.7.1/spec/neovim/session_spec.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/neovim/session_spec.rb 2019-07-01 10:48:04.000000000 +0000 @@ -24,6 +24,12 @@ expect(session.request(:nvim_get_current_line)).to eq(large_str) end + it "raises an exception when a command causes nvim to exit" do + expect do + session.request(:nvim_command, "qa!") + end.to raise_error(Neovim::Session::Exited, /exited/) + end + it "fails outside of the main thread", :silence_thread_exceptions do expect do Thread.new { session.request(:nvim_strwidth, "foo") }.join diff -Nru ruby-neovim-0.7.1/spec/neovim_spec.rb ruby-neovim-0.8.1/spec/neovim_spec.rb --- ruby-neovim-0.7.1/spec/neovim_spec.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/neovim_spec.rb 2019-07-01 10:48:04.000000000 +0000 @@ -1,24 +1,52 @@ require "helper" RSpec.describe Neovim do + shared_context "attached client" do + it "establishes an RPC connection" do + expect(client.strwidth("hi")).to eq(2) + end + + it "sets appropriate client info" do + chan_info = client.evaluate("nvim_get_chan_info(#{client.channel_id})") + + expect(chan_info).to match( + "client" => { + "name" => "ruby-client", + "version" => { + "major" => duck_type(:to_int), + "minor" => duck_type(:to_int), + "patch" => duck_type(:to_int) + }, + "type" => "remote", + "methods" => {}, + "attributes" => duck_type(:to_hash) + }, + "id" => duck_type(:to_int), + "mode" => "rpc", + "stream" => stream + ) + end + end + describe ".attach_tcp" do - it "attaches to a TCP socket" do - port = Support.tcp_port - env = {"NVIM_LISTEN_ADDRESS" => "127.0.0.1:#{port}"} - pid = Process.spawn(env, *Support.child_argv, [:out, :err] => File::NULL) - - begin - client = Neovim.attach_tcp("127.0.0.1", port) - rescue Errno::ECONNREFUSED - retry + include_context "attached client" do + let(:port) { Support.tcp_port } + let(:stream) { "socket" } + + let!(:nvim_pid) do + env = {"NVIM_LISTEN_ADDRESS" => "127.0.0.1:#{port}"} + Process.spawn(env, *Support.child_argv, [:out, :err] => File::NULL) end - begin - expect(client.strwidth("hi")).to eq(2) - ensure - Support.kill(pid) - Process.waitpid(pid) + let(:client) do + begin + Neovim.attach_tcp("127.0.0.1", port) + rescue Errno::ECONNREFUSED + retry + end end + + after { Support.kill(nvim_pid) } end end @@ -27,35 +55,37 @@ skip("Not supported on this platform") if Support.windows? end - it "attaches to a UNIX socket" do - socket_path = Support.socket_path - env = {"NVIM_LISTEN_ADDRESS" => socket_path} - pid = Process.spawn(env, *Support.child_argv, [:out, :err] => File::NULL) - - begin - client = Neovim.attach_unix(socket_path) - rescue Errno::ENOENT, Errno::ECONNREFUSED - retry + include_context "attached client" do + let(:socket_path) { Support.socket_path } + let(:stream) { "socket" } + + let!(:nvim_pid) do + env = {"NVIM_LISTEN_ADDRESS" => socket_path} + Process.spawn(env, *Support.child_argv, [:out, :err] => File::NULL) end - begin - expect(client.strwidth("hi")).to eq(2) - ensure - Support.kill(pid) - Process.waitpid(pid) + let(:client) do + begin + Neovim.attach_unix(socket_path) + rescue Errno::ENOENT, Errno::ECONNREFUSED + retry + end end + + after { Support.kill(nvim_pid) } end end describe ".attach_child" do - it "spawns and attaches to a child process" do - begin - client = Neovim.attach_child(Support.child_argv) - expect(client.strwidth("hi")).to eq(2) - ensure - client.shutdown + include_context "attached client" do + let(:stream) { "stdio" } + + let(:client) do + Neovim.attach_child(Support.child_argv) end end + + after { client.shutdown } end describe ".executable" do diff -Nru ruby-neovim-0.7.1/spec/support.rb ruby-neovim-0.8.1/spec/support.rb --- ruby-neovim-0.7.1/spec/support.rb 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/spec/support.rb 2019-07-01 10:48:04.000000000 +0000 @@ -4,7 +4,7 @@ end def self.workspace - File.expand_path("../workspace", __FILE__) + File.expand_path("workspace", __dir__) end def self.socket_path @@ -43,6 +43,7 @@ def self.kill(pid) windows? ? Process.kill(:KILL, pid) : Process.kill(:TERM, pid) + Process.waitpid(pid) end begin diff -Nru ruby-neovim-0.7.1/.travis.yml ruby-neovim-0.8.1/.travis.yml --- ruby-neovim-0.7.1/.travis.yml 2018-03-05 04:31:27.000000000 +0000 +++ ruby-neovim-0.8.1/.travis.yml 2019-07-01 10:48:04.000000000 +0000 @@ -1,4 +1,5 @@ language: ruby +cache: bundler sudo: false dist: trusty @@ -10,13 +11,15 @@ - 2.3 - 2.4 - 2.5 + - 2.6 - ruby-head before_install: - eval "$(curl --connect-timeout 30 --retry 3 -Ss https://raw.githubusercontent.com/neovim/bot-ci/master/scripts/travis-setup.sh) nightly-x64" - - gem update --system - - gem update bundler + - gem update --system --conservative || (gem install "rubygems-update:~>2.7" --no-document && update_rubygems) + - gem install --remote bundler || gem install --remote bundler -v "1.17.3" + - gem install --user-install executable-hooks - bundle --version -env: REPORT_COVERAGE=1 NVIM_RUBY_LOG_LEVEL=DEBUG NVIM_RUBY_LOG_FILE=ci.log +env: NVIM_RUBY_LOG_LEVEL=DEBUG NVIM_RUBY_LOG_FILE=ci.log script: bundle exec rake --trace