Sha256: d377255e1592a03afdee9ee1dfcaa423ab34939dc1f6b9ef7c39e41bb903714b

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 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 = ProjectScout.scan 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
  arguments
end
  
system *arguments

Version data entries

1 entries across 1 versions & 1 rubygems

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