diff --git a/README.md b/README.md index bfbd331..c444bae 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A python code completion plugin for gedit. Built with the Jedi auto completion l - Some refactoring tools ## Using -- Firstly, you need to install jedi. You can install it from your distro's package manager(search for python-jedi) or you can install it with pip: +- Firstly, you need to install jedi. You can install it from your distro's package manager(search for python3-jedi) or you can install it with pip: ``` pip install jedi ``` diff --git a/gedi.py b/gedi.py index dbae712..77fef27 100644 --- a/gedi.py +++ b/gedi.py @@ -35,7 +35,7 @@ def __init__(self): def do_activate(self): print("Gedi is activated.") document = self.view.get_buffer() - document.connect("load", self.on_document_load) + document.connect("loaded", self.on_document_load) if document.get_uri_for_display().endswith(self.py_extension): self.completion_provider = GediCompletionProvider() @@ -44,7 +44,7 @@ def do_activate(self): def do_deactivate(self): print("Gedi is deactivated.") - def on_document_load(self, document): + def on_document_load(self, document, p3=None, p4=None, p5=0, p6=0): if document.get_uri_for_display().endswith(self.py_extension): if self.completion_provider is None: self.completion_provider = GediCompletionProvider() @@ -71,9 +71,11 @@ def get_iter_correctly(self, context): return context.get_iter() def do_match(self, context): - #FIXME: check for strings and comments iter = self.get_iter_correctly(context) iter.backward_char() + buffer=iter.get_buffer() + if buffer.get_context_classes_at_iter(iter) != ['no-spell-check']: + return False ch = iter.get_char() if not (ch in ('_', '.') or ch.isalnum()): return False @@ -94,10 +96,14 @@ def do_populate(self, context): for completion in Jedi.get_script(document).completions(): complete = completion.name + if jedi.__version__ <= (0,7,0): + doc=completion.doc + else: + doc=completion.docstring() proposals.append(GtkSource.CompletionItem.new(completion.name, completion.name, self.get_icon_for_type(completion.type), - completion.docstring())) + doc)) context.add_proposals(self, proposals, True)