mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 15:24:46 +08:00
added an option to do case sensitive completion and removed get_vim_type
This commit is contained in:
28
functions.py
28
functions.py
@@ -1,5 +1,6 @@
|
|||||||
import re
|
import re
|
||||||
import weakref
|
import weakref
|
||||||
|
import os
|
||||||
|
|
||||||
import parsing
|
import parsing
|
||||||
import dynamic # must be before evaluate, because it needs to be loaded first.
|
import dynamic # must be before evaluate, because it needs to be loaded first.
|
||||||
@@ -7,7 +8,7 @@ import evaluate
|
|||||||
import modules
|
import modules
|
||||||
import debug
|
import debug
|
||||||
import imports
|
import imports
|
||||||
import os
|
import settings
|
||||||
|
|
||||||
__all__ = ['complete', 'goto', 'get_definitions',
|
__all__ = ['complete', 'goto', 'get_definitions',
|
||||||
'NotFoundError', 'set_debug_function']
|
'NotFoundError', 'set_debug_function']
|
||||||
@@ -48,27 +49,6 @@ class Completion(object):
|
|||||||
def get_type(self):
|
def get_type(self):
|
||||||
return type(self.name.parent())
|
return type(self.name.parent())
|
||||||
|
|
||||||
def get_vim_type(self):
|
|
||||||
"""
|
|
||||||
This is the only function, which is vim specific, it returns the vim
|
|
||||||
type, see help(complete-items)
|
|
||||||
"""
|
|
||||||
typ = self.get_type()
|
|
||||||
if typ == parsing.Statement:
|
|
||||||
return 'v' # variable
|
|
||||||
elif typ == parsing.Function:
|
|
||||||
return 'f' # function / method
|
|
||||||
elif typ in [parsing.Class, evaluate.Instance]:
|
|
||||||
return 't' # typedef -> abused as class
|
|
||||||
elif typ == parsing.Import:
|
|
||||||
return 'd' # define -> abused as import
|
|
||||||
if typ == parsing.Param:
|
|
||||||
return 'm' # member -> abused as param
|
|
||||||
else:
|
|
||||||
debug.dbg('other python type: ', typ)
|
|
||||||
|
|
||||||
return ''
|
|
||||||
|
|
||||||
|
|
||||||
class Definition(object):
|
class Definition(object):
|
||||||
def __init__(self, definition):
|
def __init__(self, definition):
|
||||||
@@ -197,7 +177,9 @@ def complete(source, line, column, source_path):
|
|||||||
completions += s.get_defined_names()
|
completions += s.get_defined_names()
|
||||||
|
|
||||||
completions = [c for c in completions
|
completions = [c for c in completions
|
||||||
if c.names[-1].lower().startswith(like.lower())]
|
if settings.case_insensitive_completion
|
||||||
|
and c.names[-1].lower().startswith(like.lower())
|
||||||
|
or c.names[-1].startswith(like)]
|
||||||
|
|
||||||
needs_dot = not dot and path
|
needs_dot = not dot and path
|
||||||
c = [Completion(c, needs_dot, len(like)) for c in set(completions)]
|
c = [Completion(c, needs_dot, len(like)) for c in set(completions)]
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ if 1:
|
|||||||
# stuff directly behind the completion
|
# stuff directly behind the completion
|
||||||
menu=PythonToVimStr(c.description),
|
menu=PythonToVimStr(c.description),
|
||||||
info=PythonToVimStr(c.doc), # docstr
|
info=PythonToVimStr(c.doc), # docstr
|
||||||
kind=c.get_vim_type(), # completion type
|
|
||||||
icase=1, # case insensitive
|
icase=1, # case insensitive
|
||||||
dup=1 # allow duplicates (maybe later remove this)
|
dup=1 # allow duplicates (maybe later remove this)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
# ----------------
|
||||||
|
# completion output settings
|
||||||
|
# ----------------
|
||||||
|
|
||||||
|
case_insensitive_completion = True
|
||||||
|
|
||||||
# ----------------
|
# ----------------
|
||||||
# dynamic stuff
|
# dynamic stuff
|
||||||
# ----------------
|
# ----------------
|
||||||
|
|||||||
Reference in New Issue
Block a user