Last active
July 21, 2025 00:08
-
-
Save mctaylorpants/04a9353583681f48d90d4ac9f58d3485 to your computer and use it in GitHub Desktop.
Revisions
-
mctaylorpants revised this gist
Nov 6, 2022 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,13 +5,16 @@ # with multiple lines selected, type :EvalRuby. # # Installation: # 1. Install neovim-ruby: https://github.com/neovim/neovim-ruby # # 2. Put this file in your plugins directory # (Default: ~/.config/nvim/rplugin/ruby) # # 3. Run :UpdateRemotePlugins to register the # new plugin. # # 4. Restart Neovim. # Neovim.plugin do |plug| plug.command(:EvalRuby, range: true) do |nvim, range_start, range_end| ruby_code = nvim -
mctaylorpants created this gist
Nov 6, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ # EvalRuby: Run Ruby without leaving Neovim # # Usage: # - While on a line of Ruby, or in Visual mode # with multiple lines selected, type :EvalRuby. # # Installation: # 1. Put this file in your plugins directory # (Default: ~/.config/nvim/rplugin/ruby) # # 2. Run :UpdateRemotePlugins to register the # new plugin. # # 3. Restart Neovim. Neovim.plugin do |plug| plug.command(:EvalRuby, range: true) do |nvim, range_start, range_end| ruby_code = nvim .get_current_buf .lines[(range_start - 1)..(range_end - 1)] .join("\n") result = begin eval ruby_code rescue => e "! #{e.message} (#{e.class})" end nvim.get_current_buf.append(range_end, "# => #{result.inspect}") end end