Python sublime.version() Examples

The following are 30 code examples of sublime.version(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sublime , or try the search function .
Example #1
Source File: linter.py    From SublimeLinter-contrib-eslint_d with MIT License 6 votes vote down vote up
def communicate(self, cmd, code=None):
        """Run an external executable using stdin to pass code and return its output."""

        if '__RELATIVE_TO_FOLDER__' in cmd:

            relfilename = self.filename
            window = self.view.window()

            # can't get active folder, it will work only if there is one folder in project
            if int(sublime.version()) >= 3080 and len(window.folders()) < 2:

                vars = window.extract_variables()

                if 'folder' in vars:
                    relfilename = os.path.relpath(self.filename, vars['folder'])

            cmd[cmd.index('__RELATIVE_TO_FOLDER__')] = relfilename

        elif not code:
            cmd.append(self.filename)

        return super().communicate(cmd, code) 
Example #2
Source File: minihtml.py    From sublimetext-cfml with MIT License 6 votes vote down vote up
def get_color_scheme(view=None):
    if int(sublime.version()) > 3153:
        return view.style()

    setting = sublime.load_settings("Preferences.sublime-settings").get("color_scheme")
    color_scheme_bytes = sublime.load_binary_resource(setting)
    color_scheme = {"scopes": []}
    for setting in plistlib.readPlistFromBytes(color_scheme_bytes)["settings"]:
        if "scope" in setting:
            this_scope = {"scope": setting["scope"], "style": {}}
            for key in ["foreground", "background"]:
                if key in setting["settings"]:
                    this_scope["style"][key] = setting["settings"][key]
            for key in ["italic", "bold"]:
                this_scope["style"][key] = (
                    "fontStyle" in setting["settings"]
                    and key in setting["settings"]["fontStyle"].lower()
                )
            color_scheme["scopes"].append(this_scope)
        elif "settings" in setting:
            for key in ["foreground", "background"]:
                if key in setting["settings"]:
                    color_scheme[key] = setting["settings"][key]
    return color_scheme 
Example #3
Source File: minihtml.py    From sublimetext-cfml with MIT License 6 votes vote down vote up
def get_selector_style_map(view, selectors):
    styles = {}

    if int(sublime.version()) > 3153:
        for s in selectors:
            styles[s] = view.style_for_scope(s)
    else:
        color_scheme = get_color_scheme()
        top_scores = {}
        for s in selectors:
            for scope in color_scheme["scopes"]:
                score = sublime.score_selector(s, scope["scope"])
                top_score = top_scores.get(s, 0)
                if score > 0 and score >= top_score:
                    top_scores[s] = score
                    styles[s] = scope["style"]
    return styles 
Example #4
Source File: TabNine.py    From tabnine-sublime with MIT License 6 votes vote down vote up
def run_tabnine(inheritStdio=False, additionalArgs=[]):
        binary_dir = os.path.join(TabNineProcess.install_directory, "binaries")
        settings = sublime.load_settings(SETTINGS_PATH)
        tabnine_path = settings.get("custom_binary_path")
        if tabnine_path is None:
            tabnine_path = get_tabnine_path(binary_dir)
        args = [tabnine_path, "--client", "sublime"] + additionalArgs
        log_file_path = settings.get("log_file_path")
        if log_file_path is not None:
            args += ["--log-file-path", log_file_path]
        extra_args = settings.get("extra_args")
        if extra_args is not None:
            args += extra_args
        plugin_version = PACK_MANAGER.get_metadata("TabNine").get('version')
        if not plugin_version:
            plugin_version = "Unknown"
        sublime_version = sublime.version()
        args += ["--client-metadata", "clientVersion=" + sublime_version, "clientApiVersion=" + sublime_version, "pluginVersion=" + plugin_version]
        return subprocess.Popen(
            args,
            stdin=None if inheritStdio else subprocess.PIPE,
            stdout=None if inheritStdio else subprocess.PIPE,
            stderr=subprocess.STDOUT,
            startupinfo=get_startup_info(sublime.platform())) 
Example #5
Source File: gulp.py    From sublime-gulp with MIT License 6 votes vote down vote up
def write_to_cache_without_js(self):
        process = CrossPlatformProcess(self.working_dir)
        (stdout, stderr) = process.run_sync(r'gulp -v')

        if process.failed or not GulpVersion(stdout).supports_tasks_simple():
            raise Exception("Gulp: Could not get the current gulp version or your gulp CLI version is lower than 3.7.0")

        (stdout, stderr) = process.run_sync(r'gulp --tasks-simple')

        gulpfile = self.get_gulpfile_path(self.working_dir)

        if not stdout:
            raise Exception("Gulp: The result of `gulp --tasks-simple` was empty")

        CacheFile(self.working_dir).write({
            gulpfile: {
                "sha1": Hasher.sha1(gulpfile),
                "tasks": dict((task, { "name": task, "dependencies": "" }) for task in stdout.split("\n") if task)
            }
        }) 
Example #6
Source File: TabNine.py    From tabnine-sublime with MIT License 6 votes vote down vote up
def get_tabnine_path(binary_dir):
    def join_path(*args):
        return os.path.join(binary_dir, *args)
    translation = {
        ("linux", "x32"): "i686-unknown-linux-musl/TabNine",
        ("linux", "x64"): "x86_64-unknown-linux-musl/TabNine",
        ("osx", "x32"): "i686-apple-darwin/TabNine",
        ("osx", "x64"): "x86_64-apple-darwin/TabNine",
        ("windows", "x32"): "i686-pc-windows-gnu/TabNine.exe",
        ("windows", "x64"): "x86_64-pc-windows-gnu/TabNine.exe",
    }
    versions = os.listdir(binary_dir)
    versions.sort(key=parse_semver, reverse=True)
    for version in versions:
        key = sublime.platform(), sublime.arch()
        path = join_path(version, translation[key])
        if os.path.isfile(path):
            add_execute_permission(path)
            print("TabNine: starting version", version)
            return path 
Example #7
Source File: main.py    From LSP with MIT License 6 votes vote down vote up
def plugin_loaded() -> None:
    load_settings()
    popups.load_css()
    set_debug_logging(settings.log_debug)
    set_exception_logging(True)
    windows.set_diagnostics_ui(DiagnosticsPresenter)
    windows.set_server_panel_factory(ensure_server_panel)
    windows.set_settings_factory(settings)
    load_handlers()
    sublime.status_message("LSP initialized")
    window = sublime.active_window()
    if window:
        windows.lookup(window).start_active_views()
    if int(sublime.version()) > 4000:
        sublime.error_message(
            """The currently installed version of LSP package is not compatible with Sublime Text 4. """
            """Please remove and reinstall this package to receive a version compatible with ST4. """
            """Remember to restart Sublime Text after.""") 
Example #8
Source File: helpers.py    From anaconda_rust with GNU General Public License v3.0 6 votes vote down vote up
def file_directory():
    """Returns the given file directory
    """

    if int(sublime.version()) >= 3080:
        # extract_variables was added to ST3 rev 3080
        return sublime.active_window().extract_variables().get('file_path')

    folders = sublime.active_window().folders()
    if len(folders) > 0:
        return folders[0]

    return tempfile.gettempdir()


# reuse anaconda helper functions 
Example #9
Source File: st_scheme_template.py    From sublime-markdown-popups with MIT License 6 votes vote down vote up
def get_variables(self):
        """Get variables."""

        if not self.legacy_color_matcher:
            is_dark = self.is_dark()
            return {
                "is_dark": is_dark,
                "is_light": not is_dark,
                "sublime_version": int(sublime.version()),
                "mdpopups_version": ver.version(),
                "color_scheme": self.scheme_file,
                "use_pygments": self.use_pygments,
                "default_style": self.default_style
            }
        else:
            return self._variables 
Example #10
Source File: st_scheme_template.py    From sublime-markdown-popups with MIT License 6 votes vote down vote up
def legacy_parse_global(self):
        """
        Parse global settings.

        LEGACY.
        """

        self.csm = ColorSchemeMatcher(self.scheme_file)

        # Get general theme colors from color scheme file
        self.bground = self.csm.special_colors['background']['color_simulated']
        rgba = RGBA(self.bground)
        self.lums = rgba.get_true_luminance()
        is_dark = self.lums <= LUM_MIDPOINT
        self._variables = {
            "is_dark": is_dark,
            "is_light": not is_dark,
            "sublime_version": int(sublime.version()),
            "mdpopups_version": ver.version(),
            "color_scheme": self.scheme_file,
            "use_pygments": self.use_pygments,
            "default_style": self.default_style
        }
        self.html_border = rgba.get_rgb()
        self.fground = self.csm.special_colors['foreground']['color_simulated'] 
Example #11
Source File: fuse.py    From Fuse.SublimePlugin with MIT License 6 votes vote down vote up
def plugin_loaded():
	log().info("Loading plugin")
	log().info("Sublime version '" + sublime.version() + "'")
	log().info("Fuse plugin version '" + VERSION + "'")
	global gFuse
	gFuse = Fuse()
	fix_osx_path()

	s = sublime.load_settings("Preferences.sublime-settings")
	if getSetting("fuse_open_files_in_same_window"):
		s.set("open_files_in_new_window", False)
	else:
		s.set("open_files_in_new_window", True)

	if getSetting("fuse_show_user_guide_on_start", True):
		sublime.active_window().run_command("open_file", {"file":"${packages}/Fuse/UserGuide.txt"})
		setSetting("fuse_show_user_guide_on_start", False)
	log().info("Plugin loaded successfully") 
Example #12
Source File: GotoWindow.py    From sublime-goto-window with MIT License 6 votes vote down vote up
def _osx_focus(self):
        name = 'Sublime Text'
        if int(sublime.version()) < 3000:
            name = 'Sublime Text 2'

        # This is some magic. I spent many many hours trying to find a
        # workaround for the Sublime Text bug. I found a bunch of ugly
        # solutions, but this was the simplest one I could figure out.
        #
        # Basically you have to activate an application that is not Sublime
        # then wait and then activate sublime. I picked "Dock" because it
        # is always running in the background so it won't screw up your
        # command+tab order. The delay of 1/60 of a second is the minimum
        # supported by Applescript.
        cmd = """
            tell application "System Events"
                activate application "Dock"
                delay 1/60
                activate application "%s"
            end tell""" % name

        Popen(['/usr/bin/osascript', "-e", cmd], stdout=PIPE, stderr=PIPE)

    # Focus a Sublime window using wmctrl. wmctrl takes the title of the window
    # that will be focused, or part of it. 
Example #13
Source File: lightningsave.py    From sublime-lightning with MIT License 5 votes vote down vote up
def get_page_xml_snippet(self, page_name):
        return '<?xml version="1.0" encoding="UTF-8"?>\n' \
            + '<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">\n' \
            + '\t<apiVersion>36.0</apiVersion>\n' \
            + '\t<availableInTouch>false</availableInTouch>\n' \
            + '\t<confirmationTokenRequired>false' \
            + '</confirmationTokenRequired>\n' \
            + '\t<label>' + page_name + '</label>\n' \
            + '</ApexPage>' 
Example #14
Source File: lightningsave.py    From sublime-lightning with MIT License 5 votes vote down vote up
def run(self, dirs):
        """Sample doc string."""
        if (Helper(self.window).meets_forcecli_version("0.22.62")):
            self.dirs = dirs
            self.window.show_input_panel("Page Name:",
                                         "", self.on_done, None, None)
            pass
        else:
            sublime.message_dialog("This feature requires at least version"
                                   " 62 of the Force") 
Example #15
Source File: lightningsave.py    From sublime-lightning with MIT License 5 votes vote down vote up
def run(self, dirs):
        """Sample doc string."""
        if (Helper(self.window).meets_forcecli_version("0.22.62")):
            self.dirs = dirs
            self.window.show_input_panel("Class Name:",
                                         "", self.on_done, None, None)
            pass
        else:
            sublime.message_dialog("This feature requires at least version"
                                   " 62 of the Force") 
Example #16
Source File: lightningsave.py    From sublime-lightning with MIT License 5 votes vote down vote up
def run(self):
        """Sample doc string."""
        version = Helper(self.window).get_forcecli_version()
        print("Checking the aura dir...")
        Helper(self.window).get_aura_dir()
        print("Running version " + version + " of Force CLI!")
        self.window.show_input_panel(
            "Username: ",
            "",
            self.get_password,
            None,
            None)
        pass 
Example #17
Source File: lightningsave.py    From sublime-lightning with MIT License 5 votes vote down vote up
def get_forcecli_version(self):
        """Sample doc string."""
        try:
            p = popen_force_cli(["version"])
            version, err = p.communicate()
            if err:
                sublime.error_message(err.decode("utf-8"))
            else:
                ver = version.decode("utf-8").replace("\n", "")

            if ver != "dev":
                ver = ver[1:]
                if semver.match(ver, "<0.22.26"):
                    message = (u"Sublime Lightning\n\n" +
                               u"You are using version " + ver + " of the " +
                               u"Force CLI.\n\nThis version of Sublime " +
                               u"Lightning" +
                               u" requires version 0.22.26 or greater.\n\n" +
                               u"Please download the latest version from " +
                               u"force-cli.herokuapp.com")
                    sublime.error_message(message)
        except:
            sublime.error_message("Sublime Lightning requires the " +
                                  "Force.com CLI to function.\n\n" +
                                  "Please visit force-cli.herokuapp.com to " +
                                  "install the Force.com CLI.\n\n" +
                                  "If you’ve already installed, make sure " +
                                  "that you saved it or created a " +
                                  "symlink to it in Sublime’s default path.")
        return ver.replace("\n", "") 
Example #18
Source File: lightningsave.py    From sublime-lightning with MIT License 5 votes vote down vote up
def meets_forcecli_version(self, minversion):
        """Sample doc string."""
        version = Helper.get_forcecli_version(self)
        # version = version[1:]
        print("Version: " + version + ", min: " + minversion)
        if version == "dev":
            return version == "dev"
        return semver.match(version, ">=" + minversion) 
Example #19
Source File: __init__.py    From sublime-markdown-popups with MIT License 5 votes vote down vote up
def version():
    """Get the current version."""

    return ver.version() 
Example #20
Source File: lightningsave.py    From sublime-lightning with MIT License 5 votes vote down vote up
def get_xml_snippet(self, md_type):
        return '<?xml version="1.0" encoding="UTF-8"?>\n' \
            + '<' + md_type \
            + ' xmlns="http://soap.sforce.com/2006/04/metadata">\n' \
            + '<apiVersion>38.0</apiVersion>\n' \
            + '<status>Active</status>\n' \
            + '</' + md_type + '>' 
Example #21
Source File: lightningsave.py    From sublime-lightning with MIT License 5 votes vote down vote up
def plugin_loaded():
    """Make me put in a doc string."""
    print("WE ARE TOTALLY LOADED!")
    try:
        p = popen_force_cli(["version"])
        version, err = p.communicate()
        if err:
            sublime.error_message(err.decode("utf-8"))
        else:
            ver = version.decode("utf-8").replace("\n", "")

        if ver != "dev":
            ver = ver[1:]
            if semver.match(ver, "<0.22.26"):
                message = (u"Sublime Lightning\n\n" +
                           u"You are using version " + ver + " of the " +
                           u"Force CLI.\n\nThis version of Sublime Lightning" +
                           u" requires version 0.22.26 or greater.\n\n" +
                           u"Please download the latest version from " +
                           u"force-cli.herokuapp.com")
                sublime.error_message(message)
    except:
        sublime.error_message("Sublime Lightning requires the " +
                              "Force.com CLI to function.\n\n" +
                              "Please visit force-cli.herokuapp.com to " +
                              "install the Force.com CLI.\n\n" +
                              "If you’ve already installed it, make sure " +
                              "that you saved it or created a " +
                              "symlink to it in Sublime’s default path.")
    return 
Example #22
Source File: lightningsave.py    From sublime-lightning with MIT License 5 votes vote down vote up
def run(self, dirs):
        """Sample doc string."""
        self.dirs = dirs
        name = os.path.basename(dirs[0])
        Helper(self.window).make_bundle_file(
            name,
            "",
            "svg",
            '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n'
            '<svg width="120px" height="120px" viewBox="0 0 120 120" '
            'version="1.1" xmlns="http://www.w3.org/2000/svg" '
            'xmlns:xlink="http://www.w3.org/1999/xlink">\n'
            '\t<g stroke="none" stroke-width="1" fill="none" '
            'fill-rule="evenodd">\n'
            '\t\t<path d="M120,108 C120,114.6 114.6,120 108,120 L12,120 '
            'C5.4,120 '
            '0,114.6 0,108 L0,12 C0,5.4 5.4,0 12,0 L108,0 C114.6,0 120,5.4 '
            '120,12 L120,108 L120,108 Z" id="Shape" fill="#2A739E"/>\n'
            '\t\t<path d="M77.7383308,20 L61.1640113,20 '
            'L44.7300055,63.2000173 '
            'L56.0543288,63.2000173 L40,99.623291 L72.7458388,54.5871812 '
            'L60.907727,54.5871812 L77.7383308,20 Z" id="Path-1" '
            'fill="#FFFFFF"/>\n'
            '\t</g>\n'
            '</svg>\n',
            self.dirs) 
Example #23
Source File: test_complete.py    From EasyClangComplete with MIT License 5 votes vote down vote up
def has_libclang():
    """Ensure libclang tests will run only on platforms that support this.

    Returns:
        str: row contents
    """
    # Older version of Sublime Text x64 have ctypes crash bug.
    if platform.system() == "Windows" and sublime.arch() == "x64" and \
            int(sublime.version()) < 3123:
        return False
    return True


# TODO(@kjteske): For now the tests seem to not be working for binary completer 
Example #24
Source File: Plugin.py    From SublimePapyrus with MIT License 5 votes vote down vote up
def plugin_loaded():
	global SUBLIME_VERSION
	SUBLIME_VERSION = int(sublime.version())

# Completion generation 
Example #25
Source File: FlowType.py    From sublime-flowtype with MIT License 5 votes vote down vote up
def plugin_loaded():
    """Raise an error if Sublime Text < 3."""
    if int(sublime.version()) < 3000:
        raise RuntimeError("FlowType plugin works with Sublime Text 3 only.") 
Example #26
Source File: main.py    From JavaScriptEnhancements with MIT License 5 votes vote down vote up
def plugin_loaded():

  if int(sublime.version()) >= 3124 :

    if platform.system() == "Darwin" or platform.system() == "Linux":
      global fixPathSettings
      fixPathSettings = sublime.load_settings("Preferences.sublime-settings")
      fixPathSettings.clear_on_change('fixpath-reload')
      fixPathSettings.add_on_change('fixpath-reload', fixPath)

      # Save the original environ (particularly the original PATH) to restore later
      global fixPathOriginalEnv
      for key in os.environ:
        fixPathOriginalEnv[key] = os.environ[key]

      fixPath()

    debug_mode = javaScriptEnhancements.get("debug_mode")

    if debug_mode:
      print(os.environ)

    sublime.set_timeout_async(delete_temp_files)

    sublime.set_timeout_async(start, 1000)

  else:
    response = sublime.yes_no_cancel_dialog("JavaScript Enhancements plugin requires Sublime Text 3 (build 3124 or newer). Your build is: " + sublime.version() + ". Do you want open the download page?", "Yes, open it", "No")
    if response == sublime.DIALOG_YES:
      sublime.active_window().run_command("open_url", args={"url": "https://www.sublimetext.com/3"}) 
Example #27
Source File: drp.py    From SublimeDiscordRP with MIT License 5 votes vote down vote up
def base_activity():
    activity = {
        'assets': {'large_image': 'sublime3',
                   'large_text': 'Sublime Text 3 v%s' % (sublime.version())},
    }
    if settings.get('send_start_timestamp'):
        activity['timestamps'] = {'start': start_time}
    return activity


# List of icon names that are also language names. 
Example #28
Source File: edit.py    From pawn-sublime-language with MIT License 5 votes vote down vote up
def __exit__(self, type, value, traceback):
        view = self.view
        if sublime.version().startswith('2'):
            edit = view.begin_edit()
            self.run(edit)
            view.end_edit(edit)
        else:
            key = str(hash(tuple(self.steps)))
            sublime.edit_storage[key] = self.run
            view.run_command('apply_edit', {'key': key}) 
Example #29
Source File: getter.py    From SendCode with MIT License 5 votes vote down vote up
def forward_expand(self, s, pattern=r"\S(?=\s*$)", scope="keyword.operator", paren=True):
        level = 0
        row = self.view.rowcol(s.begin())[0]
        lastrow = self.view.rowcol(self.view.size())[0]
        while row <= lastrow:
            line = self.view.line(self.view.text_point(row, 0))
            pt = line.begin()
            while paren:
                # there is a bug in the R syntax of early ST release (see #125)
                if sublime.version() >= '4000':
                    res = self.find_inline(r"[{}\[\]()]", pt, scope="punctuation")
                else:
                    res = self.find_inline(r"[{}\[\]()]", pt)

                if res.begin() == -1:
                    break
                if self.view.substr(res) in ["{", "[", "("]:
                    level += 1
                elif self.view.substr(res) in ["}", "]", ")"]:
                    level -= 1
                pt = res.end()

            if level > 0:
                row = row + 1
            else:
                if not pattern:
                    s = sublime.Region(s.begin(), line.end())
                    break
                else:
                    res = self.find_inline(pattern, pt)
                    if res.begin() != -1 and \
                            self.view.score_selector(res.begin(), scope):
                        row = row + 1
                    else:
                        s = sublime.Region(s.begin(), line.end())
                        break
        if row == lastrow:
            s = sublime.Region(s.begin(), line.end())

        return s 
Example #30
Source File: color_scheme_styles.py    From sublimetext-cfml with MIT License 5 votes vote down vote up
def run(self):
        if int(sublime.version()) < 3176:
            sublime.error_message(
                "Color scheme customization is only available in Sublime Text builds >= 3176"
            )
            return
        toggle()