Skip to content

Commit

Permalink
add cplns visibility option
Browse files Browse the repository at this point in the history
  • Loading branch information
krya committed Dec 14, 2013
1 parent 8eceba4 commit 4ea4270
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
12 changes: 9 additions & 3 deletions sublime_jedi.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
// "required" - insert arguments that dont have default value (e.g. required)
// "" - dont insert any arguments
"auto_complete_function_params": "required",

// "debug", "error", "info"
"logging_level": "debug"

// "debug", "error", "info"
"logging_level": "debug",

// what to show in completion list
// all - show all completions ( both jedi's and sublime's )
// jedi - only jedi's
// default - only jedi's in case it has something to show else sublime's
"sublime_completions_visibility": "default"
}
20 changes: 18 additions & 2 deletions sublime_jedi/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from .utils import is_python_scope, ask_daemon
from .console_logging import getLogger
from .settings import get_settings_param

logger = getLogger(__name__)
FOLLOWING_CHARS = set(["\r", "\n", "\t", " ", ")", "]", ";", "}", "\x00"])
Expand Down Expand Up @@ -46,7 +47,7 @@ def _insert_characters(self, edit, open_pair, close_pair):
If sublime option `auto_match_enabled` turned on, next behavior have to be:
when none selection
when none selection
`( => (<caret>)`
`<caret>1 => ( => (<caret>1`
Expand All @@ -57,7 +58,7 @@ def _insert_characters(self, edit, open_pair, close_pair):
In other case:
when none selection
when none selection
`( => (<caret>`
Expand Down Expand Up @@ -109,6 +110,14 @@ class Autocomplete(sublime_plugin.EventListener):

completions = []
cplns_ready = None
cplns_mode = None

def on_load(self, view):
self.cplns_mode = get_settings_param(
view,
'sublime_completions_visibility',
default='default'
)

def on_query_completions(self, view, prefix, locations):
""" Sublime autocomplete event handler
Expand Down Expand Up @@ -137,6 +146,11 @@ def on_query_completions(self, view, prefix, locations):
self.cplns_ready = None
if self.completions:
cplns, self.completions = self.completions, []
if self.cplns_mode in ('default', 'jedi'):
return (
[tuple(i) for i in cplns],
sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS
)
return [tuple(i) for i in cplns]
return

Expand All @@ -153,6 +167,8 @@ def on_query_completions(self, view, prefix, locations):
if self.cplns_ready is None:
ask_daemon(view, self.show_completions, 'autocomplete', locations[0])
self.cplns_ready = False
if self.cplns_mode == 'jedi':
view.run_command("hide_auto_complete")
return

def show_completions(self, view, completions):
Expand Down

0 comments on commit 4ea4270

Please sign in to comment.