Skip to content

Commit

Permalink
Merge branch 'pull/30'
Browse files Browse the repository at this point in the history
* pull/30:
  Remove relative line numbers and color columns in the match window
  Extract VIM::exists? method for use outside of the controller

Signed-off-by: Wincent Colaiuta <win@wincent.com>
  • Loading branch information
wincent committed Feb 21, 2012
2 parents c9fad73 + 58cc5b2 commit a240bdf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
12 changes: 4 additions & 8 deletions ruby/command-t/controller.rb
Expand Up @@ -181,25 +181,21 @@ def max_height
@max_height ||= get_number('g:CommandTMaxHeight') || 0
end

def exists? name
::VIM::evaluate("exists(\"#{name}\")").to_i != 0
end

def get_number name
exists?(name) ? ::VIM::evaluate("#{name}").to_i : nil
VIM::exists?(name) ? ::VIM::evaluate("#{name}").to_i : nil
end

def get_bool name
exists?(name) ? ::VIM::evaluate("#{name}").to_i != 0 : nil
VIM::exists?(name) ? ::VIM::evaluate("#{name}").to_i != 0 : nil
end

def get_string name
exists?(name) ? ::VIM::evaluate("#{name}").to_s : nil
VIM::exists?(name) ? ::VIM::evaluate("#{name}").to_s : nil
end

# expect a string or a list of strings
def get_list_or_string name
return nil unless exists?(name)
return nil unless VIM::exists?(name)
list_or_string = ::VIM::evaluate("#{name}")
if list_or_string.kind_of?(Array)
list_or_string.map { |item| item.to_s }
Expand Down
8 changes: 7 additions & 1 deletion ruby/command-t/match_window.rb
@@ -1,4 +1,4 @@
# Copyright 2010-2011 Wincent Colaiuta. All rights reserved.
# Copyright 2010-2012 Wincent Colaiuta. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -80,6 +80,12 @@ def initialize options = {}
'setlocal textwidth=0' # don't hard-wrap (break long lines)
].each { |command| ::VIM::command command }

# don't show the color column
::VIM::command 'setlocal colorcolumn=0' if VIM::exists?('+colorcolumn')

# don't show relative line numbers
::VIM::command 'setlocal norelativenumber' if VIM::exists?('+relativenumber')

# sanity check: make sure the buffer really was created
raise "Can't find GoToFile buffer" unless $curbuf.name.match /GoToFile\z/
@@buffer = $curbuf
Expand Down
6 changes: 5 additions & 1 deletion ruby/command-t/vim.rb
@@ -1,4 +1,4 @@
# Copyright 2010-2011 Wincent Colaiuta. All rights reserved.
# Copyright 2010-2012 Wincent Colaiuta. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -30,6 +30,10 @@ def self.has_syntax?
::VIM::evaluate('has("syntax")').to_i != 0
end

def self.exists? str
::VIM::evaluate(%{exists("#{str}")}).to_i != 0
end

def self.pwd
::VIM::evaluate 'getcwd()'
end
Expand Down

0 comments on commit a240bdf

Please sign in to comment.