Skip to content

Commit

Permalink
golang: better support on Komodo 8 and Komodo Edit versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Todd Whiteman committed Mar 13, 2015
1 parent ea6cc0f commit 60bbf35
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions components/koGoLanguage.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ class koGoLanguage(KoLanguageBase, KoLanguageBaseDedentMixin):
% (name)
_reg_clsid_ = "{2d6ed8b6-f079-441a-8b5a-10ef781cb989}"
_reg_categories_ = [("komodo-language", name)]
_com_interfaces_ = KoLanguageBase._com_interfaces_ + \
[components.interfaces.koIInterpolationCallback]
# Copy the base interfaces.
_com_interfaces_ = KoLanguageBase._com_interfaces_[:]
# Add koIInterpolationCallback - but it's only available in version 9 and
# above - so catch the exception for earlier versions.
try:
_com_interfaces_.append(components.interfaces.koIInterpolationCallback)
except:
log.warn("koIInterpolationCallback does not exist")

modeNames = ['go']
primary = 1
Expand Down Expand Up @@ -98,21 +104,22 @@ def __init__(self):

# Add the go formatter.
if not globalPrefs.getBoolean("haveInstalledGoFormatter", False):
formatters = globalPrefs.getPref("configuredFormatters")
go_formatter_prefset = components.classes['@activestate.com/koPreferenceSet;1'].createInstance(components.interfaces.koIPreferenceSet)
uuid = "{cf500001-ec59-4047-86e7-369d257f4b80}"
go_formatter_prefset.id = uuid
go_formatter_prefset.setStringPref("lang", "Go")
go_formatter_prefset.setStringPref("name", "GoFmt")
go_formatter_prefset.setStringPref("uuid", uuid)
go_formatter_prefset.setStringPref("formatter_name", "generic")
args_prefset = components.classes['@activestate.com/koPreferenceSet;1'].createInstance(components.interfaces.koIPreferenceSet)
args_prefset.id = "genericFormatterPrefs"
args_prefset.setStringPref("executable", "%(go)")
args_prefset.setStringPref("arguments", "fmt")
go_formatter_prefset.setPref("genericFormatterPrefs", args_prefset)
formatters.appendString(uuid)
globalPrefs.setPref(uuid, go_formatter_prefset)
if globalPrefs.hasPref("configuredFormatters"):
formatters = globalPrefs.getPref("configuredFormatters")
go_formatter_prefset = components.classes['@activestate.com/koPreferenceSet;1'].createInstance(components.interfaces.koIPreferenceSet)
uuid = "{cf500001-ec59-4047-86e7-369d257f4b80}"
go_formatter_prefset.id = uuid
go_formatter_prefset.setStringPref("lang", "Go")
go_formatter_prefset.setStringPref("name", "GoFmt")
go_formatter_prefset.setStringPref("uuid", uuid)
go_formatter_prefset.setStringPref("formatter_name", "generic")
args_prefset = components.classes['@activestate.com/koPreferenceSet;1'].createInstance(components.interfaces.koIPreferenceSet)
args_prefset.id = "genericFormatterPrefs"
args_prefset.setStringPref("executable", "%(go)")
args_prefset.setStringPref("arguments", "fmt")
go_formatter_prefset.setPref("genericFormatterPrefs", args_prefset)
formatters.appendString(uuid)
globalPrefs.setPref(uuid, go_formatter_prefset)
globalPrefs.setBoolean("haveInstalledGoFormatter", True)

# Add extensible items (available in komodo 9 and higher).
Expand Down Expand Up @@ -251,4 +258,8 @@ def lint_with_text(self, request, text):
columnEnd=columnEnd)
results.addResult(result)
return results


# Komodo 8 and earlier registration call:
def registerLanguage(registry):
log.debug("Registering language Go")
registry.registerLanguage(koGoLanguage())

0 comments on commit 60bbf35

Please sign in to comment.