当前位置: 首页>>代码示例>>Python>>正文


Python sublime.INHIBIT_WORD_COMPLETIONS属性代码示例

本文整理汇总了Python中sublime.INHIBIT_WORD_COMPLETIONS属性的典型用法代码示例。如果您正苦于以下问题:Python sublime.INHIBIT_WORD_COMPLETIONS属性的具体用法?Python sublime.INHIBIT_WORD_COMPLETIONS怎么用?Python sublime.INHIBIT_WORD_COMPLETIONS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在sublime的用法示例。


在下文中一共展示了sublime.INHIBIT_WORD_COMPLETIONS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: complete_package_objects

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import INHIBIT_WORD_COMPLETIONS [as 别名]
def complete_package_objects(self, view, pt):
        line = self.extract_line(view, pt, truncated=True)
        m = VALIDOBJECT.search(line)
        if not m:
            return []
        pkg, delim, prefix = m.groups()

        if delim == "::":
            completions = self.get_completions_for_package(
                pkg, exported_only=True)
        elif delim == ":::":
            completions = self.get_completions_for_package(
                pkg, exported_only=False)
        else:
            return []

        completions = [(item, ) for item in completions
                       if item.startswith(prefix)]
        return (completions, sublime.INHIBIT_WORD_COMPLETIONS
                | sublime.INHIBIT_EXPLICIT_COMPLETIONS) 
开发者ID:randy3k,项目名称:R-Box,代码行数:22,代码来源:completion.py

示例2: on_query_completions

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import INHIBIT_WORD_COMPLETIONS [as 别名]
def on_query_completions(self, view, prefix, locations):
        '''Sublime Text autocompletion event handler'''
        filetype = lang(view)
        if filetype is None or view.is_scratch():
            return

        print("[YCMD] #### START COMPLETION ####")

        if self.ready_from_defer is True:
            cpl = self.completions
            self.completions = []
            self.ready_from_defer = False
            return (cpl, sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS)

        filepath = get_file_path()
        row, col = view.rowcol(locations[0])
        content = view.substr(sublime.Region(0, view.size()))
        t = Thread(None, complete_func, 'CompleteAsync',
                   [filepath, row, col, content, self._on_errors, self._complete, filetype])
        t.daemon = True
        t.start() 
开发者ID:LuckyGeck,项目名称:YcmdCompletion,代码行数:23,代码来源:Completion.py

示例3: on_query_completions

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import INHIBIT_WORD_COMPLETIONS [as 别名]
def on_query_completions(self, view, prefix, locations):
    if not GoBuffers.is_go_source(view): return
    if not GoToolsSettings.get().autocomplete: return

    # set the lib-path for gocode's lookups
    _, _, rc = ToolRunner.run("gocode", ["set", "lib-path", GoToolsSettings.get().golibpath])

    suggestionsJsonStr, stderr, rc = ToolRunner.run("gocode", ["-f=json", "autocomplete", 
      str(Buffers.offset_at_cursor(view)[0])], stdin=Buffers.buffer_text(view))

    # TODO: restore gocode's lib-path

    suggestionsJson = json.loads(suggestionsJsonStr)

    Logger.log("DEBUG: gocode output: " + suggestionsJsonStr)

    if rc != 0:
      Logger.status("no completions found: " + str(e))
      return []
    
    if len(suggestionsJson) > 0:
      return ([GotoolsSuggestions.build_suggestion(j) for j in suggestionsJson[1]], sublime.INHIBIT_WORD_COMPLETIONS)
    else:
      return [] 
开发者ID:ironcladlou,项目名称:GoTools,代码行数:26,代码来源:gotools_suggestions.py

示例4: on_query_completions

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import INHIBIT_WORD_COMPLETIONS [as 别名]
def on_query_completions(self, view, prefix, locations):
        # parts of the code inspired by: https://github.com/agibsonsw/AndyPython/blob/master/PythonCompletions.py
        global builtin_compl_vars, builtin_compl_funcs, magic_control_pars
        if not view.match_selector(locations[0], 'source.ksp -string -comment -constant'):
            return []
        pt = locations[0] # - len(prefix) - 1
        line_start_pos = view.line(sublime.Region(pt, pt)).begin()
        line = view.substr(sublime.Region(line_start_pos, pt))    # the character before the trigger

        if re.match(r' *declare .*', line) and ':=' not in line:
            compl = []
        elif re.match(r'.*-> ?[a-zA-Z_]*$', line): # if the line ends with something like '->' or '->valu'
            compl = magic_control_pars
        else:
            compl = self._extract_completions(view, prefix, pt)
            compl = [(item + "\tdefault", item.replace('$', '\\$', 1)) for item in compl
                     if len(item) > 3 and item not in all_builtins]
            if '.' not in prefix:
                bc = []
                bc.extend(builtin_compl_vars)
                bc.extend(builtin_compl_funcs)
                compl.extend(bc)
        compl = self.unique(compl)

        return (compl, sublime.INHIBIT_WORD_COMPLETIONS |
                sublime.INHIBIT_EXPLICIT_COMPLETIONS) 
开发者ID:nojanath,项目名称:SublimeKSP,代码行数:28,代码来源:ksp_plugin.py

示例5: on_query_completions

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import INHIBIT_WORD_COMPLETIONS [as 别名]
def on_query_completions(self, view, prefix, locations):
        # Check if this is a Rust source file. This check
        # relies on the Rust syntax formatting extension
        # being installed - https://github.com/jhasse/sublime-rust
        if view.match_selector(locations[0], "source.rust"):
            # Get the buffer location in correct format for racer
            row, col = view.rowcol(locations[0])
            row += 1

            try:
                raw_results = run_racer(view, ["complete-with-snippet", str(row), str(col)])
            except FileNotFoundError:
                print("Unable to find racer executable (check settings)")
                return

            results = []
            lalign = 0;
            ralign = 0;
            for result in raw_results:
                result.middle = "{0} ({1})".format(result.type, os.path.basename(result.path))
                lalign = max(lalign,len(result.completion)+len(result.middle))
                ralign = max(ralign, len(result.context))

            for result in raw_results:
                context = result.context
                result = "{0} {1:>{3}} : {2:{4}}".format(result.completion, result.middle, result.context, lalign - len(result.completion), ralign), result.snippet
                results.append(result)
            if len(results) > 0:
                # return list(set(results))
                return (list(set(results)),
                        sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS) 
开发者ID:defuz,项目名称:RustAutoComplete,代码行数:33,代码来源:RustAutoComplete.py

示例6: on_query_completions

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import INHIBIT_WORD_COMPLETIONS [as 别名]
def on_query_completions(self, view, prefix, locations):
        """Runs on all views, but is NOOP unless view is response view or history
        view. Inside gql query string, only completions returned by this method
        are shown.
        """
        response_view = view.settings().get('requester.response_view', False)
        history_view = view.settings().get('requester.history_view', False)
        if not response_view and not history_view:
            return None

        content = view.substr(sublime.Region(0, view.size()))
        m = re.search(r'\bgql\s*=\s*("|\')+', content)
        if m is None:
            return None

        offset, idx = m.end(), view.sel()[0].begin()

        try:
            request = parse_requests(content, n=1)[0]

            if getattr(view, '_env', None) is None:
                view._env = RequestCommandMixin.get_env_dict_from_string(
                    view.settings().get('requester.env_string', None)
                )
            req = prepare_request(request, view._env, 1)

            schema = view.settings().get('requester.gql_schema', None)
            if not schema:  # let user know schema is being retrieved
                set_graphql_schema_on_view(view, req)
                raise Exception('Loading GraphQL schema info')

            gql = req.skwargs['gql']
            completions = get_completions(gql, idx-offset, schema)
            return completions
        except Exception as e:
            print('GraphQL Error:')
            traceback.print_exc(file=sys.stdout)
            return (
                [[str(e), ' '], ['...', ' ']],
                sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS
            ) 
开发者ID:kylebebak,项目名称:Requester,代码行数:43,代码来源:graphql.py

示例7: get_completions

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import INHIBIT_WORD_COMPLETIONS [as 别名]
def get_completions(gql, idx, schema):
    """Creates AST from `gql` query string, finds out exactly where cursor is in
    string, and uses `schema` to get appropriate completions. Doesn't protect
    against exceptions. They should be handled by calling code.
    """
    start, end = slurp_word(gql, idx)
    gql_parser = GraphQLParser()
    ast = gql_parser.parse(gql[:start] + placeholder + gql[end:], lexer=GraphQLLexer())

    for query in ast.definitions:  # get path if it exists
        path = placeholder_path(query, placeholder)
        if path is not None:
            break

    query_type, types = schema
    t = resolve_type(path, types, query_type)
    fields = types[t]['fields']

    completions = []
    for f in fields.values():
        name = f['name']
        args = [a['name'] + ':' for a in f['args']]
        args_string = '({})'.format(', '.join(args)) if args else ''
        type_name = resolve_field_type(f)
        completions.append([
            '{}{}\t{}'.format(name, args_string, type_name),
            '{}{}'.format(name, args_string),
        ])

    return (
        completions,
        sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS
    ) 
开发者ID:kylebebak,项目名称:Requester,代码行数:35,代码来源:graphql.py

示例8: on_query_completions

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import INHIBIT_WORD_COMPLETIONS [as 别名]
def on_query_completions(self, view, prefix, locations):
        """ Called by SublimeText when auto-complete pop-up box appears. """

        if SYNTAX not in view.settings().get('syntax'):
            return None
        if not all(self.should_trigger(view, loc) for loc in locations):
            return None

        local_attrs = (
            (attr, 'local') for attr, lno in self.declared_attrs(view)
            if attr not in builtin_attrs and min(cursors_line_num(view)) > lno)

        return (filter_completions(prefix, local_attrs, builtin_attrs),
                sublime.INHIBIT_WORD_COMPLETIONS) 
开发者ID:asciidoctor,项目名称:sublimetext-asciidoc,代码行数:16,代码来源:completions.py

示例9: on_query_completions

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import INHIBIT_WORD_COMPLETIONS [as 别名]
def on_query_completions(self, prefix: str, locations: List[int]) -> Optional[Tuple[List[Tuple[str, str]], int]]:
        if not self.initialized:
            self.initialize()

        flags = 0
        if settings.only_show_lsp_completions:
            flags |= sublime.INHIBIT_WORD_COMPLETIONS
            flags |= sublime.INHIBIT_EXPLICIT_COMPLETIONS

        if self.enabled:
            if not self.match_selector(locations[0]):
                return ([], flags)

            reuse_completion = self.is_same_completion(prefix, locations)
            if self.state == CompletionState.IDLE:
                if not reuse_completion:
                    self.last_prefix = prefix
                    self.last_location = locations[0]
                    self.do_request(prefix, locations)
                    self.completions = []

            elif self.state in (CompletionState.REQUESTING, CompletionState.CANCELLING):
                if not reuse_completion:
                    self.next_request = (prefix, locations)
                    self.state = CompletionState.CANCELLING

            elif self.state == CompletionState.APPLYING:
                self.state = CompletionState.IDLE

            return (self.completions, flags)

        return None 
开发者ID:sublimelsp,项目名称:LSP,代码行数:34,代码来源:completion.py

示例10: on_query_completions

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import INHIBIT_WORD_COMPLETIONS [as 别名]
def on_query_completions(self, view, prefix, locations):
        '''
        Sublime Text autocompletion event handler.
        '''
        if not is_cpp(view) or view.is_scratch():
            return

        # if completion should begin
        leftchar = view.substr(locations[0] - 2)
        thischar = view.substr(locations[0] - 1)
        if thischar == '>' and leftchar != '-':
            return
        if thischar == ':' and leftchar != ':':
            return

        print("[C++YouCompleteMe] Start completing.")

        if self.ready_from_defer is True:
            cpl = self.completions
            self.completions = []
            self.ready_from_defer = False
            return (cpl, sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS)

        filepath = get_file_path(view.file_name())
        contents = view.substr(sublime.Region(0, view.size()))

        # get 1-based location
        row, col = get_row_col(view, locations[0])

        # start code-completion thread
        t = Thread(None, complete_func, 'CompleteAsync',
                   [server(), filepath, contents, row, col, self._complete])
        t.daemon = True
        t.start() 
开发者ID:glymehrvrd,项目名称:CppYCM,代码行数:36,代码来源:autocomplete.py

示例11: on_query_completions

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import INHIBIT_WORD_COMPLETIONS [as 别名]
def on_query_completions(self, view, prefix, locations):
		if self.IsValidScope(view):
			settings = SublimePapyrus.GetSettings()
			if settings and settings.get("intelligent_code_completion", True):
				if self.completionRunning:
					return
				elif self.linterRunning:
					return
				self.completionRunning = True
				#start = time.time() #DEBUG
				completions = None
				if not view.find("scriptname", 0, sublime.IGNORECASE):
					path = view.file_name()
					if path:
						_, name = os.path.split(path)
						completions = [("scriptname\tscript header", "ScriptName %s" % name[:name.rfind(".")],)]
					else:
						completions = [("scriptname\tscript header", "ScriptName ",)]
				else:					
					completions = self.Completions(view, prefix, locations)
				if completions:
					completions = list(set(completions))
				elif completions == None:
					completions = []
				completions = (completions, sublime.INHIBIT_WORD_COMPLETIONS|sublime.INHIBIT_EXPLICIT_COMPLETIONS,)
				#print("Completions: Finished in %f milliseconds and releasing lock..." % ((time.time()-start)*1000.0)) #DEBUG
				self.completionRunning = False
				return completions 
开发者ID:Kapiainen,项目名称:SublimePapyrus,代码行数:30,代码来源:Plugin.py

示例12: onQueryCompletion

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import INHIBIT_WORD_COMPLETIONS [as 别名]
def onQueryCompletion(self, view):
		if getSetting("fuse_completion") == False:
		 	return

		syntaxName = getSyntax(view)
		if not isSupportedSyntax(syntaxName):
		 	return

		self.doCompleteAttribs = getSetting("fuse_ux_attrib_completion")
		self.foldUXNameSpaces = getSetting("fuse_ux_attrib_folding")
		self.completionSyntax = syntaxName

		if self.lastResponse is None:
			self.requestAutoComplete(view, syntaxName, lambda res: self.responseAutoComplete(view, res))
			return ([("", "")], sublime.INHIBIT_WORD_COMPLETIONS)

		response = self.lastResponse
		self.lastResponse = None

		if response.status != "Success":
		 	return

		caret = view.sel()[0].a
		vstr = view.substr(caret)
		self.wordAtCaret = view.substr(view.word(caret)).strip()

		if vstr == "(" or vstr == "=" or vstr == "\"": 
			self.useShortCompletion = True
		else:
			self.useShortCompletion = False

		self.handleCodeSuggestion(response.data)
		
		data = (self.items, sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS)
		if len(self.items) == 0:
		 	if self.isUpdatingCache == True:
		 		return ([("Updating suggestion cache...", "_"), ("", "")], sublime.INHIBIT_WORD_COMPLETIONS)

		 	if getSetting("fuse_if_no_completion_use_sublime") == False:				
		 		return ([("", "")], sublime.INHIBIT_WORD_COMPLETIONS)
		 	else:
		 		return

		self.items = []
		return data 
开发者ID:fuse-open,项目名称:Fuse.SublimePlugin,代码行数:47,代码来源:fuse.py

示例13: on_query_completions

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import INHIBIT_WORD_COMPLETIONS [as 别名]
def on_query_completions(self, view, prefix, locations):
        # match inside a CSS document and
        # match inside the style attribute of HTML tags, incl. just before the quote that closes the attribute value
        css_selector_scope = "source.css - meta.selector.css"
        html_style_selector_scope = "text.html meta.attribute-with-value.style.html " + \
                                    "string.quoted - punctuation.definition.string.begin.html"
        selector_scope = css_selector_scope + ', ' + html_style_selector_scope
        prop_name_scope = "meta.property-name.css"
        prop_value_scope = "meta.property-value.css"
        loc = locations[0]

        # When not inside CSS, don’t trigger
        if not view.match_selector(loc, selector_scope):
            return []

        if not self.props:
            self.props = parse_css_data()
            self.regex = re.compile(r"([a-zA-Z-]+):\s*$")

        l = []
        if (view.match_selector(loc, prop_value_scope) or
            # This will catch scenarios like .foo {font-style: |}
            view.match_selector(loc - 1, prop_value_scope)):

            alt_loc = loc - len(prefix)
            line = view.substr(sublime.Region(view.line(alt_loc).begin(), alt_loc))

            match = re.search(self.regex, line)
            if match:
                prop_name = match.group(1)
                if prop_name in self.props:
                    values = self.props[prop_name]

                    add_semi_colon = view.substr(sublime.Region(loc, loc + 1)) != ';'

                    for value in values:
                        desc = value
                        snippet = value

                        if add_semi_colon:
                            snippet += ";"

                        if snippet.find("$1") != -1:
                            desc = desc.replace("$1", "")

                        l.append((desc, snippet))

                    return (l, sublime.INHIBIT_WORD_COMPLETIONS)

            return None
        else:
            add_colon = not view.match_selector(loc, prop_name_scope)

            for prop in self.props:
                if add_colon:
                    l.append((prop, prop + ": "))
                else:
                    l.append((prop, prop))

            return (l, sublime.INHIBIT_WORD_COMPLETIONS) 
开发者ID:floydawong,项目名称:wxapp,代码行数:62,代码来源:wxss_completions.py

示例14: on_query_completions

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import INHIBIT_WORD_COMPLETIONS [as 别名]
def on_query_completions(self, view, prefix, locations):
        """Sublime Text autocompletion event handler
        """

        if not is_code(view, lang='rust'):
            return

        if self.ready_from_defer is True:
            completion_flags = 0

            if ags(view, 'suppress_word_completions', False):
                completion_flags = sublime.INHIBIT_WORD_COMPLETIONS

            if ags(view, 'suppress_explicit_completions', False):
                completion_flags = sublime.INHIBIT_EXPLICIT_COMPLETIONS

            cpl = self.completions
            self.completions = []
            self.ready_from_defer = False

            return (cpl, completion_flags)

        code = view.substr(sublime.Region(0, view.size()))
        row, col = view.rowcol(locations[0])
        racer = get_settings(view, 'racer_binary_path', 'racer')
        if racer == '':
            racer = 'racer'

        data = {
            'vid': view.id(),
            'filename': view.file_name(),
            'settings': {
                'racer_binary_path': racer,
                'rust_src_path': get_settings(view, 'rust_src_path'),
                'row': row,
                'col': col,
                'source': code,
            },
            'method': 'autocomplete',
            'handler': 'racer'
        }
        Worker().execute(
            Callback(
                on_success=self._complete,
                on_failure=self._on_failure,
                on_timeout=self._on_timeout
            ),
            **data
        ) 
开发者ID:DamnWidget,项目名称:anaconda_rust,代码行数:51,代码来源:completion.py

示例15: on_query_completions_async

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import INHIBIT_WORD_COMPLETIONS [as 别名]
def on_query_completions_async(self, view, prefix, locations):
        self.completions = None

        flow_settings = find_flow_settings(view.window().project_data())
        autocomplete_flags = sublime.INHIBIT_WORD_COMPLETIONS | \
            sublime.INHIBIT_EXPLICIT_COMPLETIONS
        if flow_settings.get('show_sublime_autocomplete_suggestions'):
            autocomplete_flags = 0

        result = None
        try:
            result = CLI(view).autocomplete()
        except InvalidContext:
            pass
        except Exception as e:
            display_unknown_error(self.view, e)

        if not result:
            return

        self.completions = (
            [
                (
                    # matching text
                    match['name'] + '\t' + match['type'],
                    # inserted text
                    build_snippet(
                        match['name'],
                        match.get('func_details')['params']
                    )
                    if (
                        match.get('func_details') and
                        not flow_settings.get('omit_function_parameters')
                    )
                    else match['name']
                )
                for match in result['result']
            ],
            autocomplete_flags
        )
        self.completions_ready = True
        sublime.active_window().active_view().run_command(
            'hide_auto_complete'
        )
        self.run_auto_complete() 
开发者ID:tptee,项目名称:FlowIDE,代码行数:47,代码来源:autocomplete.py


注:本文中的sublime.INHIBIT_WORD_COMPLETIONS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。