def plugin_loaded():
  global arghints_enabled, renderer, tern_command, tern_arguments
  global arg_completion_enabled
  arghints_enabled = get_setting("tern_argument_hints", False)
  arg_completion_enabled = get_setting("tern_argument_completion", False)

  if "show_popup" in dir(sublime.View):
    default_output_style = "tooltip"
  else:
    default_output_style = "status"
  output_style = get_setting("tern_output_style", get_setting("tern_argument_hints_type", default_output_style))
  renderer = create_renderer(output_style)
  tern_arguments = get_setting("tern_arguments", [])
  if not isinstance(tern_arguments, list):
    tern_arguments = [tern_arguments]
  tern_command = get_setting("tern_command", None)
  if tern_command is None:
    if not os.path.isdir(os.path.join(plugin_dir, "node_modules/tern")):
      if sublime.ok_cancel_dialog(
          "It appears Tern has not been installed. Do you want tern_for_sublime to try and install it? "
          "(Note that this will only work if you already have node.js and npm installed on your system.)"
          "\n\nTo get rid of this dialog, either uninstall tern_for_sublime, or set the tern_command setting.",
          "Yes, install."):
        try:
          if hasattr(subprocess, "check_output"):
            subprocess.check_output(["npm", "install"], cwd=plugin_dir)
          else:
            subprocess.check_call(["npm", "install"], cwd=plugin_dir)
        except (IOError, OSError) as e:
          msg = "Installation failed. Try doing 'npm install' manually in " + plugin_dir + "."
          if hasattr(e, "output"):
            msg += " Error message was:\n\n" + e.output
          sublime.error_message(msg)
          return
    tern_command = ["node",  os.path.join(plugin_dir, "node_modules/tern/bin/tern"), "--no-port-file"]
Example #2
0
def plugin_loaded():
  global arghints_enabled, renderer, tern_command, tern_arguments
  global arg_completion_enabled
  arghints_enabled = get_setting("tern_argument_hints", False)
  arg_completion_enabled = get_setting("tern_argument_completion", False)

  if "show_popup" in dir(sublime.View):
    default_output_style = "tooltip"
  else:
    default_output_style = "status"
  output_style = get_setting("tern_output_style", get_setting("tern_argument_hints_type", default_output_style))
  renderer = create_renderer(output_style)
  tern_arguments = get_setting("tern_arguments", [])
  if not isinstance(tern_arguments, list):
    tern_arguments = [tern_arguments]
  tern_command = get_setting("tern_command", None)
  if tern_command is None:
    if not os.path.isdir(os.path.join(plugin_dir, "node_modules/tern")):
      if sublime.ok_cancel_dialog(
          "It appears Tern has not been installed. Do you want tern_for_sublime to try and install it? "
          "(Note that this will only work if you already have node.js and npm installed on your system.)"
          "\n\nTo get rid of this dialog, either uninstall tern_for_sublime, or set the tern_command setting.",
          "Yes, install."):
        try:
          if hasattr(subprocess, "check_output"):
            subprocess.check_output(["npm", "install"], cwd=plugin_dir)
          else:
            subprocess.check_call(["npm", "install"], cwd=plugin_dir)
        except (IOError, OSError) as e:
          msg = "Installation failed. Try doing 'npm install' manually in " + plugin_dir + "."
          if hasattr(e, "output"):
            msg += " Error message was:\n\n" + e.output
          sublime.error_message(msg)
          return
    tern_command = ["node",  os.path.join(plugin_dir, "node_modules/tern/bin/tern"), "--no-port-file"]