Sha256: 066da4f64e7019b5941b83d51e82516a5697f02ba926dac858e712624dbd38cd

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

#!/usr/bin/env ruby
spackle_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(spackle_dir) unless $LOAD_PATH.include?(spackle_dir)

require 'spackle/helpers/ruby_project_root'

# Load a Vim Quickfix file in an active vim session.
#
# Usage:
# spackle-vim-load-quickfix [servername] quickfix_file
#
# If servername is specified, try to use it as the vim
# server. Otherwise, assume the name for the vim server
# is the from ruby-project-root -basename, if
# successful. If no Ruby project root was found, use
# DEFAULT as the servername.
#
# If the server doesn't exist, we'll create a new
# gvim session.
#

def servername_from_arguments
  ARGV.count.times do |index|
    if ARGV[index] == "--servername"
      ARGV.delete_at index
      return ARGV.delete_at_index
    end
  end
  nil
end

def servername_from_project_root
  project_root = Spackle::Helpers::RubyProjectRoot.search Dir.pwd
  File.basename(project_root) if project_root
end

def servername
  servername_from_arguments || servername_from_project_root || "DEFAULT"
end

def arguments
  arguments = ['gvim', '--servername', servername]
  unless ARGV.empty?
    arguments << "--remote-silent"
    arguments += ARGV
  end
end
  
system *arguments

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spackle-0.0.1 bin/spackle-vim-open