Skip to content

Commit

Permalink
Require ‘gocode’ via TextMate 2’s required command system
Browse files Browse the repository at this point in the history
This leads to a better user experience and allow the user to set TM_GOCODE instead of updating PATH.
  • Loading branch information
sorbits committed Jul 3, 2013
1 parent cbcaaf6 commit d092aba
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Commands/Complete.tmCommand
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ require ENV['TM_SUPPORT_PATH'] + "/lib/tm/require_cmd.rb"
require ENV['TM_SUPPORT_PATH'] + "/lib/tm/htmloutput.rb"
require ENV['TM_SUPPORT_PATH'] + "/lib/web_preview"
TextMate.require_cmd("gocode")
# current document
document = []
File.open(ENV['TM_FILEPATH'], "r+") do |file|
Expand All @@ -22,7 +20,7 @@ end
# byte offset of cursor position from the beginning of file
cursor = document[ 0, ENV['TM_LINE_NUMBER'].to_i - 1].join().length + ENV['TM_LINE_INDEX'].to_i
output = `gocode -f=csv -in=#{e_sh ENV['TM_FILEPATH']} autocomplete #{cursor}`
output = `$TM_GOCODE -f=csv -in=#{e_sh ENV['TM_FILEPATH']} autocomplete #{cursor}`
# quit if no completions found
TextMate.exit_show_tool_tip("No completions found.") if output.length == 0
Expand Down Expand Up @@ -129,6 +127,17 @@ end</string>
<string>text</string>
<key>outputLocation</key>
<string>atCaret</string>
<key>requiredCommands</key>
<array>
<dict>
<key>command</key>
<string>gocode</string>
<key>moreInfoURL</key>
<string>https://github.com/nsf/gocode</string>
<key>variable</key>
<string>TM_GOCODE</string>
</dict>
</array>
<key>scope</key>
<string>source.go</string>
<key>uuid</key>
Expand Down

0 comments on commit d092aba

Please sign in to comment.