Created
December 29, 2021 14:52
-
-
Save alissonbrunosa/4262bc0ecd36b3c4fdd6c09300e7cb96 to your computer and use it in GitHub Desktop.
Open constants and methods in Vim.
This file contains 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 characters
# frozen_string_literal: true | |
if Rails.env.development? | |
ActiveSupport::Reloader.to_prepare do | |
module OpenOnVim | |
def open_method(method_name) | |
file, line = method(method_name.to_sym).source_location | |
vim(file, line) | |
end | |
def open_const(name) | |
file, line = Object.const_source_location(name) | |
vim(file, line) | |
end | |
def vim(file, line) | |
return false if file.nil? || line.nil? | |
system("vimx --remote #{file}") && system("vimx --remote-send ':#{line}<CR>'") | |
end | |
end | |
class Object | |
include OpenOnVim | |
extend OpenOnVim | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment