Python sublime.INHIBIT_EXPLICIT_COMPLETIONS Examples
The following are 13
code examples of sublime.INHIBIT_EXPLICIT_COMPLETIONS().
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: completion.py From R-Box with MIT License | 6 votes |
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)
Example #2
Source File: Completion.py From YcmdCompletion with MIT License | 6 votes |
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()
Example #3
Source File: ksp_plugin.py From SublimeKSP with GNU General Public License v3.0 | 5 votes |
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)
Example #4
Source File: RustAutoComplete.py From RustAutoComplete with MIT License | 5 votes |
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)
Example #5
Source File: graphql.py From Requester with MIT License | 5 votes |
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 )
Example #6
Source File: graphql.py From Requester with MIT License | 5 votes |
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 )
Example #7
Source File: completion.py From LSP with MIT License | 5 votes |
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
Example #8
Source File: autocomplete.py From CppYCM with MIT License | 5 votes |
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()
Example #9
Source File: fuse.py From Fuse.SublimePlugin with MIT License | 4 votes |
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
Example #10
Source File: completion.py From anaconda_rust with GNU General Public License v3.0 | 4 votes |
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 )
Example #11
Source File: autocomplete.py From FlowIDE with MIT License | 4 votes |
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()
Example #12
Source File: completion.py From JavaScriptEnhancements with MIT License | 4 votes |
def on_query_completions(self, view, prefix, locations): if not view.match_selector( locations[0], 'source.js - string - comment' ): return [] scope = view.scope_name(view.sel()[0].begin()-1).strip() # added "keyword.operator.accessor.js" for JavaScript (Babel) support # added "punctuation.dollar.js" and startswith("$") for completions that starts with "$" char # because Sublime Text 3 doesn't recognize it # # force prefix in case of presence of "$" char if scope.endswith(" punctuation.dollar.js"): prefix = "$" elif view.substr(util.word_with_dollar_char(view, view.sel()[0])).startswith("$"): prefix = view.substr(util.word_with_dollar_char(view, view.sel()[0])) self.prefix = prefix self.locations = locations if not prefix and not (scope.endswith(" punctuation.accessor.js") or scope.endswith(" punctuation.dollar.js") or view.substr(util.word_with_dollar_char(view, view.sel()[0].begin()-1)).startswith("$") or scope.endswith(" keyword.operator.accessor.js")) : sublime.active_window().active_view().run_command( 'hide_auto_complete' ) return [] if self.completions_ready and self.completions: self.completions_ready = False # Return the pending completions return self.completions if not self.searching: self.searching = True self.modified = False else: return ([], sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS) sublime.set_timeout_async( lambda: self.on_query_completions_async(view) ) if not self.completions_ready or not self.completions: return ([], sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS)
Example #13
Source File: autocompletion.py From anaconda_go with GNU General Public License v3.0 | 4 votes |
def on_query_completions(self, view, prefix, locations): """Fired directly from Sublime Text 3 events systems """ if not is_code(view, lang='go'): return if not go.ANAGONDA_PRESENT: if go.AVAILABLE: go.init() else: return if self.ready_from_defer is True: completion_flags = 0 if get_settings(view, 'suppress_word_completions', False): completion_flags = sublime.INHIBIT_WORD_COMPLETIONS if get_settings(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]) data = { 'vid': view.id(), 'path': view.file_name(), 'code': code, 'offset': view.text_point(row, col), 'add_params': get_settings( view, 'anaconda_go_add_completion_params', True), 'go_env': { 'GOROOT': go.GOROOT, 'GOPATH': go.GOPATH, 'CGO_ENABLED': go.CGO_ENABLED }, 'method': 'autocomplete', 'handler': 'anaGonda' } Worker.execute( Callback( on_success=self._complete, on_failure=self._on_failure, on_timeout=self._on_timeout ), **data )