Giter Site home page Giter Site logo

sublimejedi's Introduction

SublimeJEDI

Build Status Gitter

SublimeJEDI is a Sublime Text 3 and Sublime Text 2 and plugin to the awesome autocomplete library Jedi

Python Version Support

Sublime Jedi Plugin Branch Jedi version Python 2.6.x Python 2.7.x Python >3.3 Python 3.3 Sublime Text 2 Sublime Text 3
>= 0.14.0 master >=0.13.2
>= 0.12.0 master >=0.12.0
< 0.12.0 st2 0.11.1

Please note Jedi does not support Python 3.3 any more.

Installation

with Git

cd ~/.config/sublime-text-2/Packages/
git clone https://github.com/srusskih/SublimeJEDI.git "Jedi - Python autocompletion"
  1. Open command pallet (default: ctrl+shift+p)
  2. Type package control install and select command Package Control: Install Package
  3. Type Jedi and select Jedi - Python autocompletion

Additional info about to use Sublime Package Control you can find here: http://wbond.net/sublime_packages/package_control/usage.

Settings

Python interpreter settings

By default SublimeJEDI will use default Python interpreter from the PATH. Also you can set different interpreter for each Sublime Project.

To set project related Python interpreter you have to edit yours project's settings file. By default file name look like <project name>.sublime-project

You can set Python interpreter, and additional python package directories, using for example the following:

# <project name>.sublime-project
{
    // ...

    "settings": {
        // ...
        "python_virtualenv": "$project_path/../../virtual/",
        "python_interpreter": "$project_path/../../virtual/bin/python",

        "python_package_paths": [
            "$home/.buildout/eggs",
            "$project_path/addons"
        ]
    }
}

NOTE: You can configure python_interpreter and python_virtualen at the same time, no problem with that. If you configure python_interpreter alone, the python_virtualen will be inferred so it will be 2 directories above python_interpreter. If you configure python_virtualen alone, the python_interpreter will be always where ever python_virtualen plus 'bin/python'. If you don't configure any of this then the default Python environment of your system will be used.

NOTE: Please note that Python will goes through the directories from "python_package_paths" to search for modules and files. In other words, each item in "python_package_paths" list is a directory with extra packages and modules, not a direct path to package or module.

When setting paths, Sublime Text Build System Variables and OS environment variables are automatically expanded. Note that using placeholders and substitutions, like in regular Sublime Text Build System paths is not supported.

SublimeREPL integration

By default completion for SublimeREPL turned off. If you want use autocompletion feature of SublimeJEDI in a repl, please set enable_in_sublime_repl: true in User/sublime_jedi.sublime-setting or in your project setting.

Autocomplete on DOT

If you want auto-completion on dot, you can define a trigger in the Sublime User or Python preferences:

# User/Preferences.sublime-settings or User/Python.sublime-settings
{
    // ...
    "auto_complete_triggers": [{"selector": "source.python", "characters": "."}],
}

If you want auto-completion ONLY on dot and not while typing, you can set (additionally to the trigger above):

# User/Preferences.sublime-settings or User/Python.sublime-settings
{
    // ...
    "auto_complete_selector": "-",
}

Autocomplete after only certain characters

If you want Jedi auto-completion only after certain characters, you can use the only_complete_after_regex setting.

For example, if you want Jedi auto-completion only after the . character but don't want to affect auto-completion from other packages, insert the following into User/sublime_jedi.sublime-settings:

{
  "only_complete_after_regex": "\\.",
}

Using this setting in this way means you can remove "auto_complete_selector": "-", from User/Python.sublime-settings, so that the rest of your packages still trigger auto-completion after every keystroke.

Goto / Go Definition

Find function / variable / class definition

Shortcuts: CTRL+SHIFT+G

Mouse binding, was disabled, becase it's hard to keep ST default behavior. Now you can bind CTRL + LeftMouseButton by themself in this way:

# User/Default.sublime-mousemap
[{
    "modifiers": ["ctrl"], "button": "button1",
    "command": "sublime_jedi_goto",
    "press_command": "drag_select"
}]

NOTE: You can configure the behavior of this command by changing the setting follow_imports. If this setting is True (default behavior) you will travel directly to where the term was defined or declared. If you want to travel back step by step the import path of the term then set this to False.

Find Related Names ("Find Usages")

Find function / method / variable / class usage, definition.

Shortcut: ALT+SHIFT+F.

There are two settings related to finding usages:

  • highlight_usages_on_select: highlights usages of symbol in file when symbol is selected (default false)
  • highlight_usages_color: color for highlighted symbols (default "region.bluish")
    • other available options are "region.redish", "region.orangish", "region.yellowish", "region.greenish", "region.bluish", "region.purplish", "region.pinkish", "region.blackish"
    • these colors are actually scopes that were added to Sublime Text around build 3148; these scopes aren't documented, but the BracketHighlighter plugin has an excellent explanation here

Show Python Docstring

Show docstring as tooltip.

For ST2: Show docstring in output panel.

Shortcut: CTRL+ALT+D.

Styling Python Docstring

If available mdpopups is used to display the docstring tooltips. To modify the style please follow mdpopups' styling guide.

Basically a Packages/User/mdpopups.css is required to define your own style.

To specify rules which apply to Jedi tooltips only, use .jedi selector as displayed in the following example.

/* JEDI's python function signature */
.jedi .highlight {
    font-size: 1.1rem;
}

/* JEDI's docstring titles
  
  h6 is used to highlight special keywords in the docstring such as

  Args:
  Return:
*/
.jedi h6 {
    font-weight: bold;
}

mdpopups provides a default.css which might be used as cheat sheet to learn about the available styles.

Jedi Show Calltip

Show calltip in status bar.

Exposed command is sublime_jedi_signature.

Function args fill up on completion

SublimeJEDI allow fill up function parameters by default. Thanks to @krya, now you can turn it off.

Function parameters completion has 3 different behaviors:

  • insert all function arguments on autocomplete

    # complete result
    func(a, b, c, d=True, e=1, f=None)
    
    # sublime_jedi.sublime-settings
    {
        "auto_complete_function_params": "all"
    }
    
  • insert only required arguments that don't have default value (default behavior)

    # complete result
    func(a, b, c)
    
    # sublime_jedi.sublime-settings
    {
        "auto_complete_function_params": "required"
    }
    
  • do not insert any arguments

    # complete result
    func()
    
    # sublime_jedi.sublime-settings
    {
        "auto_complete_function_params": ""
    }
    

More info about auto_complete_function_params

Completion visibility

Sublime Text has a bit strange completion behavior and some times does not adds it's own completion suggestions. Enabling this option to try to bring more comfortable workflow.

  • Suggest only Jedi completion

     # sublime_jedi.sublime-settings
     {
         "sublime_completions_visibility": "jedi"
     }
    

    or

     # sublime_jedi.sublime-settings
     {
         "sublime_completions_visibility": "default"
     }
    
  • Suggest Jedi completion and Sublime completion in the end of the list

     # sublime_jedi.sublime-settings
     {
         "sublime_completions_visibility": "list"
     }
    

Please note, if you are using SublimeAllAutocomplete - you should not care about this option.

Logging

Plugin uses Python logging lib to log everything. It allow collect propper information in right order rather then print()-ing to sublime console. To make logging more usefull I'd suggest ST Plugin Logging Control, it allows stream logs into file/console/etc. On github page you can find great documenation how you can use it.

Here is quickstart config that I'm using for DEBUG purposes:

{
    "logging_enable_on_startup": false,
    "logging_use_basicConfig": false,
    "logging_root_level": "DEBUG",
    "logging_console_enabled": true,
    "logging_console_level": "INFO",     // Only print warning log messages in the console.
    "logging_file_enabled": true,
    "logging_file_level": "DEBUG",
    "logging_file_datefmt": null,
    "logging_file_fmt": "%(asctime)s %(levelname)-6s - %(name)s:%(lineno)s - %(funcName)s() - %(message)s",
    "logging_file_path": "/tmp/sublime_output.log",
    "logging_file_rotating": false,
    "logging_file_clear_on_reset": false
}

By default, detailed (debug) loggin turned off and you would not see any messages in ST console, only exceptions.

If you need get more information about the issue with the plugin:

  1. Install Logging Control
  2. Use quickstart config that was provided above.
  3. Enable logging. Ivoke "Command Pannel" (CMD+SHIFT+P for mac) and start typing “Logging”. Select the "Logging: Enable logging" command to enable logging.
  4. Reproduce the issue.
  5. Check the log file!

Troubleshooting

Auto-complete for import XXXX does not works.

It's a common issue for ST3. All language related settings are stored in Python Package. There is a Completion Rules.tmPreferences file where defined that completion should be cancelled after a keyword (def, class, import & etc.).

To solve this issue Sublime Jedi plugin already has a proper Completion Rules.tmPreferences file for ST2, but ST3 ignores it.

Some workarounds how to update completion rules and fix the issue:

Copy-Paste
  1. Delete your Sublime Text Cache file Cache/Python/Completion Rules.tmPreferences.cache
  2. Download Completion Rules.tmPreferences.cache to User/Packages/Python/
There is package for this...
  1. install Package https://packagecontrol.io/packages/PackageResourceViewer
  2. cmd+shift+p (Command Panel)
  3. type PackageResourceViewer: Open Resource
  4. type python and select Python package
  5. type Completion Rules.tmPreferences
  6. remove import from the regexp.
  7. save

License

MIT

sublimejedi's People

Contributors

amezin avatar antoineleclair avatar astrac avatar aukaost avatar beards avatar berendkleinhaneveld avatar bergtholdt avatar bystroushaak avatar chicken-suop avatar deathaxe avatar eddiejessup avatar edelvalle avatar hadisfr avatar hickford avatar kkujawinski avatar klonuo avatar krya avatar kylebebak avatar magnetikonline avatar naereen avatar quarnster avatar schlamar avatar shura1oplot avatar smartmanoj avatar srusskih avatar svaiter avatar szastupov avatar tannewt avatar vishen avatar vshotarov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sublimejedi's Issues

Interesting output in the sublime repl

I followed your instructions to install, but all completions raise this exception:

Traceback (most recent call last):
File "./sublime_plugin.py", line 236, in on_query_completions
File "./sublime_jedi.py", line 238, in on_query_completions
File "./sublime_jedi.py", line 263, in get_completions
File "/home/accounts/nfaggian/.config/sublime-text-2/Packages/SublimeJEDI/jedi/jedi/api.py", line 253, in complete
call_def = self.get_in_function_call()
File "/home/accounts/nfaggian/.config/sublime-text-2/Packages/SublimeJEDI/jedi/jedi/api.py", line 465, in get_in_function_call
call, index = check_cache()
File "/home/accounts/nfaggian/.config/sublime-text-2/Packages/SublimeJEDI/jedi/jedi/api.py", line 446, in check_cache
part_parser = self.module.get_part_parser()
File "/home/accounts/nfaggian/.config/sublime-text-2/Packages/SublimeJEDI/jedi/jedi/modules.py", line 210, in get_part_parser
line_offset=offset)
File "/home/accounts/nfaggian/.config/sublime-text-2/Packages/SublimeJEDI/jedi/jedi/parsing.py", line 1140, in init
self.parse()
File "/home/accounts/nfaggian/.config/sublime-text-2/Packages/SublimeJEDI/jedi/jedi/parsing.py", line 1607, in parse
token_type, tok = self.next()
File "/home/accounts/nfaggian/.config/sublime-text-2/Packages/SublimeJEDI/jedi/jedi/parsing.py", line 1574, in next
self.parserline = self._current_full
AttributeError: 'PyFuzzyParser' object has no attribute '_current_full'

Incorrect GoTo behavioir

# imports goes here ....

class Place(models.Model):
    title = models.CharField(_(u'title'), max_length=200)

    def __unicode__(self):
        return self.ti<cursor>tle

Press "Ctrl+Shift+g"

Expect

# imports goes here ....

class Place(models.Model):
    <cursor>title = models.CharField(_(u'title'), max_length=200)

    def __unicode__(self):
        return self.title

Actual
django CharField definition opened

Make "Find Usages" relative to the project root

"Find Usages" returns absolute paths, which with a deeply nested directory structure results in path truncation. As the prefix to the project root is not helpful it would be clearer to return the paths trimmed to the project root of the various folder paths in .sublime-project.

Stacktrace after git pull

Traceback (most recent call last):
File "/home/accounts/nfaggian/Desktop/sublime_text_3/sublime_plugin.py", line 357, in on_query_completions
res = callback.on_query_completions(v, prefix, locations)
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/sublime_jedi.py", line 224, in on_query_completions
completions = self.get_completions(view, locations)
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/sublime_jedi.py", line 242, in get_completions
self.completions_from_script(script, insert_funcargs)
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/sublime_jedi.py", line 196, in completions_from_script
completions = script.complete()
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/api_classes.py", line 44, in wrapper
result = func(_args, *_kwds)
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/api.py", line 94, in complete
scopes = list(self._prepare_goto(path, True))
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/api.py", line 189, in _prepare_goto
scopes = evaluate.follow_statement(stmt)
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/recursion.py", line 31, in call
result = self.func(stmt, _args, *_kwargs)
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/cache.py", line 100, in wrapper
rv = function(_args, *_kwargs)
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/evaluate.py", line 584, in follow_statement
result = follow_call_list(commands)
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/common.py", line 55, in wrapper
return func(_args, *_kwds)
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/evaluate.py", line 657, in follow_call_list
result += follow_call(call)
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/evaluate.py", line 675, in follow_call
return follow_call_path(path, s.parent, s.start_pos)
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/evaluate.py", line 698, in follow_call_path
result = imports.strip_imports(scopes)
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/imports.py", line 321, in strip_imports
result += ImportPath(s).follow()
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/imports.py", line 188, in follow
scope, rest = self._follow_file_system()
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/imports.py", line 258, in _follow_file_system
sys_path_mod = list(self.sys_path_with_modifications())
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/imports.py", line 176, in sys_path_with_modifications
return in_path + modules.sys_path_with_modifications(module)
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/cache.py", line 100, in wrapper
rv = function(_args, *_kwargs)
File "/home/accounts/nfaggian/.config/sublime-text-3/Packages/SublimeJEDI/jedi/modules.py", line 350, in sys_path_with_modifications
curdir = os.path.abspath(os.curdir)
File "X/posixpath.py", line 383, in abspath
FileNotFoundError: [Errno 2] No such file or directory

PermissionError: [WinError 5] Access is denied

I'm getting this error whenever I type anything, no JEDI auto-completion working.

Traceback (most recent call last):
  File "X/subprocess.py", line 1090, in _execute_child
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 358, in on_query_completions
    res = callback.on_query_completions(v, prefix, locations)
  File "C:\Users\Mitch\AppData\Roaming\Sublime Text 3\Packages\Jedi - Python autocompetion\sublime_jedi.py", line 180, in on_query_completions
    ask_daemon(view, self.show_completions, 'autocomplete', locations[0])
  File "C:\Users\Mitch\AppData\Roaming\Sublime Text 3\Packages\Jedi - Python autocompetion\sublime_jedi.py", line 59, in ask_daemon
    complete_funcargs=get_settings_param(view, 'auto_complete_function_params', 'all'),
  File "C:\Users\Mitch\AppData\Roaming\Sublime Text 3\Packages\Jedi - Python autocompetion\utils.py", line 127, in start_daemon
    process = subprocess.Popen(sub_args, **sub_kwargs)
  File "X/subprocess.py", line 818, in __init__
  File "X/subprocess.py", line 1096, in _execute_child
PermissionError: [WinError 5] Access is denied

SublimeJEDI won't work with ST3 3047

I've installed sublimeJEDI, but haven't been able to make it work, it won't complete on import statements nor on function calls.

My sublime_jedi.sublime-settings file look like this:

{
    // we will use it to get PYTHONPATH for interpreter
    // You cat set a path to your virtualenv
    "python_interpreter_path": "/Library/Frameworks/Python.framework/Versions/2.7/bin/python",

    // additional python package path list
     "python_package_paths": ["/Users/eldeveloper/git_sw/qiime/",
                                "/Users/eldeveloper/git_sw/emperor/",
                                "/Users/eldeveloper/git_sw/pynast/",
                                "/Users/eldeveloper/git_sw/evident/",
                                "/Users/eldeveloper/svn_sw/PyCogent/",
                                "/Users/eldeveloper/git_sw/biom-format/python-code"
],

    // "all" - insert all function arguments on autocomplete
    // "required" - insert arguments that dont have default value (e.g. required)
    // "" - dont insert any arguments
    "auto_complete_function_params": "required"

}

Default.sublime-keymap

[
    {"command": "sublime_jedi_goto", "keys": ["ctrl+shift+g"]},
    {"command": "sublime_jedi_find_usages", "keys": ["alt+shift+f"]},
    {"command": "sublime_jedi_params_autocomplete", "keys": ["("]}
]

Default.sublime-mousemap

[
    {
        "modifiers": ["ctrl"], "button": "button1", 
        "command": "sublime_jedi_goto",
        "press_command": "drag_select"
    }
]

I'm running OSX 10.8.4. If this is because I'm missing something, I apologize in advance.


I also haven't found any documentation on how the package is supposed to work, would be good to have something, but that's a separate issue.

OSError: [Errno 2]

Autocomplete/go to definition fails with:

Traceback (most recent call last):
  File "./sublime_plugin.py", line 362, in run_
  File "./sublime_jedi.py", line 102, in run
  File "./sublime_jedi.py", line 59, in ask_daemon
  File "./utils.py", line 127, in start_daemon
  File ".\subprocess.py", line 633, in __init__
  File ".\subprocess.py", line 1139, in _execute_child
OSError: [Errno 2] File/Path Not Found

SublimeText: 2.0.2 / build 2221
Python: 2.7.3
SublimeJEDI: 0.6.4

IndexError in Jedi

2013-06-21 10:33:21,639: ERROR   : failed to process line
Traceback (most recent call last):
  File "jedi_daemon.py", line 292, in <module>
    process_line(line)
  File "jedi_daemon.py", line 231, in process_line
    action_type: JediFacade(**data).get(action_type)
  File "jedi_daemon.py", line 111, in get
    return getattr(self, 'get_' + action)()
  File "jedi_daemon.py", line 115, in get_goto
    return self._goto()
  File "jedi_daemon.py", line 172, in _goto
    definitions = self.script.goto_assignments()
  File "/storage/PythonProjects/SublimeJEDI/jedi/api_classes.py", line 44, in wrapper
    result = func(*args, **kwds)
  File "/storage/PythonProjects/SublimeJEDI/jedi/api.py", line 340, in goto_assignments
    d = [api_classes.Definition(d) for d in set(self._goto()[0])]
  File "/storage/PythonProjects/SublimeJEDI/jedi/api.py", line 366, in _goto
    if next(context) in ('class', 'def'):
  File "/storage/PythonProjects/SublimeJEDI/jedi/modules.py", line 222, in get_context
    while pos[1] > 0 and line[pos[1] - 1].isspace():
IndexError: string index out of range

Pycharm like autocomplete description

Screen Shot 2013-01-05 at 4 36 17 PM
Screen Shot 2013-01-05 at 4 38 09 PM

In Pycharm I like only autocomplete. So, would be nice, if we export some cool feature from it.

When I type "ma" I see "management", but don't really understand, where I've got it.
In Pycharm I see "django.core".

In jedi I found only next:

In [9]: script.get_definition()
Out[9]: [<Definition module management>, <Definition keyword import>]

In [10]: aaa = script.get_definition()[0]

In [11]: aaa
Out[11]: <Definition module management>

In [12]: aaa.
aaa.column             aaa.full_name          aaa.module_path
aaa.definition         aaa.in_builtin_module  aaa.path
aaa.desc_with_module   aaa.is_keyword         aaa.raw_doc
aaa.description        aaa.line_nr            aaa.start_pos
aaa.doc                aaa.module_name        aaa.type

In [12]: aaa.full_name
Out[12]: 'management'

P.S. I've removed SublimeCodeIntel for pure testing SublimeJEDI.

Error Appeared after #51

Traceback (most recent call last):
  File "jedi_daemon.py", line 287, in <module>
    process_line(line)
  File "jedi_daemon.py", line 226, in process_line
    action_type: JediFacade(**data).get(action_type)
  File "jedi_daemon.py", line 105, in get
    return getattr(self, 'get_' + action)()
  File "jedi_daemon.py", line 109, in get_goto
    return self._goto()
  File "jedi_daemon.py", line 169, in _goto
    if definitions[0].type == 'import':
IndexError: list index out of range

Auto-complete class' __init__ params

Just like method params are completed.

class Foo(object):
    def __init__(self, bar):
        self.bar = bar

x = Foo<caret>
# ↓ <input '('>
x = Foo(bar=<caret>)

Add Auto Import Feature

It would be nice after auto completing something to have the option to auto import it as well.

Add support for extra python path entries.

It would be good to be able to provide (through config) a list of extra paths to be searched during completion and goto.

This would make things more similar to the "intellisense" port for sublime.

How to install and use SublimeJedi ?

Could we have a step by step tutorial to have it working ?

So far I did:

git clone https://github.com/svaiter/SublimeJEDI.git /home/sam/.config/sublime-text-2/Packages/
cd SublimeJedit
git submodule init
git submodule update

Then I added this to my sublime-project file:

"settings": 
{
    "auto_complete_on_dot": true,
    "python_interpreter_path": "/home/sam/.virtualenvs/test/bin/python"
}

I do see SublimeJedi in the "Preferences > Packages settings" menu so I assume it's loaded.

However, typing "." does not trigger anything.

I'm on Ubuntu 12.04

SublimeJEDI disables adding parentheses around highlighted text

I'm not sure if this is related to #65 or not, but I've noticed that when I have SublimeJEDI enabled I cannot highlight text, hit (, and then have ST3 surround the text in parentheses like you normally can. Instead, SublimeJEDI inserts a matched pair of parentheses at the end of the highlighted text. I ended up disabling SublimeJEDI because I use this feature of ST so frequently and couldn't figure out a quick workaround for it.

Highlighting and then pressing [ or { works as expected.

Better key-binding for "goto" command

@nfaggian noted that "ctrl+b" is a bit bad choice for "goto" command, and I had same thoughts about this too.

So I have couple ideas for new key-bindings.

Please vote up for options that you like. If you have own thoughts, please, wrote them below

Can not install througth Package Manager

Hi

I'm trying to install SublimeJEDI through Packager Manager, but without success.
Here is the Console ouput:

ignored packages updated to: [Vintage, SublimeJEDI]
found 1 files for base name Default.sublime-theme
reloading /C/Users/yeradis/AppData/Roaming/Sublime Text 2/Packages/User/Preferences.sublime-settings
theme loaded
found 1 files for base name Default.sublime-theme
theme loaded
Exception in thread Thread-20:
Traceback (most recent call last):
File ".\threading.py", line 532, in __bootstrap_inner
File ".\Package Control.py", line 4032, in run
File ".\Package Control.py", line 3181, in install_package
File ".\Package Control.py", line 2695, in download_url
File ".\Package Control.py", line 1683, in download
File ".\Package Control.py", line 1414, in check_certs
File ".\Package Control.py", line 1451, in locate_cert
File ".\Package Control.py", line 1478, in download_cert
NameError: global name 'domain' is not defined

ignored packages updated to: [Vintage]
found 1 files for base name Default.sublime-theme
reloading /C/Users/yeradis/AppData/Roaming/Sublime Text 2/Packages/User/Preferences.sublime-settings
theme loaded
found 1 files for base name Default.sublime-theme
theme loaded

Regards

Find Usage Error:jedi.api.NotFoundError

Actually , i can't use the 'Find Usage' at all

Traceback (most recent call last):
File "./sublime_plugin.py", line 362, in run_
File "./python_go_to.py", line 149, in run
usages = self.find_usages()
File "./python_go_to.py", line 154, in find_usages
return related_names(self.view)
File "./python_go_to.py", line 50, in related_names
related_names = script.related_names()
File "/home/pan/.config/sublime-text-2/Packages/SublimeJEDI/jedi/api_classes.py", line 44, in wrapper
result = func(_args, *_kwds)
File "/home/pan/.config/sublime-text-2/Packages/SublimeJEDI/jedi/api.py", line 351, in related_names
definitions, search_name = self._goto(add_import_name=True)
File "/home/pan/.config/sublime-text-2/Packages/SublimeJEDI/jedi/api.py", line 328, in _goto
stmt = self._get_under_cursor_stmt(goto_path)
File "/home/pan/.config/sublime-text-2/Packages/SublimeJEDI/jedi/api.py", line 198, in _get_under_cursor_stmt
raise NotFoundError()
jedi.api.NotFoundError

The plugin disables ST's buitin snippet's auto-completion

When I disable the plugin and start typing def, a quick dropdown list appears from which I get to automatically choose the def snippet and insert the following and then proceed to fill out the place-holders in it:

    def function():
        pass

But with the plugin enabled, the above snippet seems to be masked and it does not appear in the quick drop-down list!
This is tested in ST3

UnicodeEncodeError

2013-06-21 10:47:41,101: ERROR   : failed to process line
Traceback (most recent call last):
  File "jedi_daemon.py", line 292, in <module>
    process_line(line)
  File "jedi_daemon.py", line 231, in process_line
    action_type: JediFacade(**data).get(action_type)
  File "jedi_daemon.py", line 111, in get
    return getattr(self, 'get_' + action)()
  File "jedi_daemon.py", line 127, in get_autocomplete
    data = self._parameters_for_completion() or []
  File "jedi_daemon.py", line 138, in _parameters_for_completion
    in_call = self.script.call_signatures()[0]
  File "/storage/PythonProjects/SublimeJEDI/jedi/api_classes.py", line 44, in wrapper
    result = func(*args, **kwds)
  File "/storage/PythonProjects/SublimeJEDI/jedi/api.py", line 448, in call_signatures
    call, index = self._func_call_and_param_index()
  File "/storage/PythonProjects/SublimeJEDI/jedi/api.py", line 464, in _func_call_and_param_index
    user_stmt = self._parser.user_stmt
  File "/storage/PythonProjects/SublimeJEDI/jedi/api.py", line 75, in _parser
    return self._module.parser
  File "/storage/PythonProjects/SublimeJEDI/jedi/modules.py", line 116, in parser
    self.position)
  File "/storage/PythonProjects/SublimeJEDI/jedi/fast_parser.py", line 73, in __call__
    p.update(source, user_position)
  File "/storage/PythonProjects/SublimeJEDI/jedi/fast_parser.py", line 224, in update
    self._parse(code)
  File "/storage/PythonProjects/SublimeJEDI/jedi/fast_parser.py", line 333, in _parse
    line_offset, nodes, not is_first)
  File "/storage/PythonProjects/SublimeJEDI/jedi/fast_parser.py", line 396, in _get_parser
    no_docstr=no_docstr)
  File "/storage/PythonProjects/SublimeJEDI/jedi/parsing.py", line 68, in __init__
    self._parse()
  File "/storage/PythonProjects/SublimeJEDI/jedi/parsing.py", line 671, in _parse
    stmt, tok = self._parse_statement(self.current)
  File "/storage/PythonProjects/SublimeJEDI/jedi/parsing.py", line 366, in _parse_statement
    n, token_type, tok = self._parse_dot_name(self.current)
  File "/storage/PythonProjects/SublimeJEDI/jedi/parsing.py", line 151, in _parse_dot_name
    n = pr.Name(self.module, names, first_pos, self.end_pos) if names \
  File "/storage/PythonProjects/SublimeJEDI/jedi/parsing_representation.py", line 1344, in __init__
    NamePart(n[0], self, n[1]) for n in names)
  File "/storage/PythonProjects/SublimeJEDI/jedi/parsing_representation.py", line 1344, in <genexpr>
    NamePart(n[0], self, n[1]) for n in names)
  File "/storage/PythonProjects/SublimeJEDI/jedi/parsing_representation.py", line 1314, in __new__
    self = super(NamePart, cls).__new__(cls, s)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0434' in position 10: ordinal not in range(128)

Somehow display the docstring during autcomplete.

This is a nice feature in the vim plugin that would be amazing to have in sublime text.

Not sure if the current sublime API is too limiting though - i.e. as a user steps through auto-complete options is there a callback that could update the view?

function kwargs completion improvement

Does parameter name required in completion?

func(param1=<caret>, param2=, param3=None)

Maybe better drop parameter name for required params ?

func(<caret>, , param3=None)

or keep parameters' names in selection block

func(<selection "param1">, param2, param3=None)

Exception in daemon on ST2

Exception in thread Thread-2:
Traceback (most recent call last):
  File ".\threading.py", line 532, in __bootstrap_inner
  File ".\utils.py", line 44, in run
    self.call_callback(data)
  File ".\utils.py", line 56, in call_callback
    for window in sublime.windows():
RuntimeError: Must call on main thread, consider using sublime.set_timeout(function, timeout)

Better README

It's would be great if some one could improve/rewrite README file

Thanks!

Package Control installation in ST3

I am just updating Package Control to the official ST3 version and tried to install this package as it is nice to have for my Python work. However, you guys aren't showing up in the Package Control repo anywhere. I ended up having to install the plugin manually.

Is this a bug?

Numpy doesn't auto complete

Hi there,

SublimeJEDI is A great plugin. Love it! Thanks for creating it.

I encounter a problem with numpy when using SublimeJEDI, it doesn't auto complete on dot. Other libraries such as pandas does do complete, it's just numpy doesn't work.

So far I've tried quite a few things. I tested jedi library alone, it seems working for me on numpy.
I also tested the jedi library comes with the plugin, it also works.
Not exactly sure what else to try, hopefully I can get some ideas here.

I am using Mac OS 10.8.3 with SublimeText 2. Plugin version 0.6.1 and Jedi version is 0.6.0. I have Python 3 installed in a VirtualEnv. I've update the build system to use the Python3 interpreter directly.

This is the screenshot showing pandas autocompletion is working.
screen shot 2013-06-04 at 1 26 03 am

and this is showing numpy not working.
screen shot 2013-06-04 at 1 27 48 am

jedi.common.UncaughtAttributeError: 'NoneType' object has no attribute 'isinstance'

Traceback (most recent call last):
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/common.py", line 55, in wrapper
    return func(*args, **kwds)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/evaluate.py", line 657, in follow_call_list
    result += follow_call(call)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/evaluate.py", line 673, in follow_call
    while not s.parent.isinstance(pr.IsScope):
AttributeError: 'NoneType' object has no attribute 'isinstance'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/patrys/Apps/sublime_text_3/sublime_plugin.py", line 358, in on_query_completions
    res = callback.on_query_completions(v, prefix, locations)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/sublime_jedi.py", line 291, in on_query_completions
    completions = self.get_completions(view, locations)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/sublime_jedi.py", line 307, in get_completions
    completions = self.completions_from_script(script, view) +\
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/sublime_jedi.py", line 201, in completions_from_script
    completions = script.complete()
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/api_classes.py", line 44, in wrapper
    result = func(*args, **kwds)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/api.py", line 94, in complete
    scopes = list(self._prepare_goto(path, True))
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/api.py", line 189, in _prepare_goto
    scopes = evaluate.follow_statement(stmt)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/recursion.py", line 31, in __call__
    result = self.func(stmt, *args, **kwargs)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/cache.py", line 100, in wrapper
    rv = function(*args, **kwargs)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/evaluate.py", line 584, in follow_statement
    result = follow_call_list(commands)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/common.py", line 58, in wrapper
    reraise(UncaughtAttributeError(exc_info[1]), exc_info[2])
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/_compatibility.py", line 145, in reraise
    raise exception.with_traceback(traceback)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/common.py", line 55, in wrapper
    return func(*args, **kwds)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/evaluate.py", line 657, in follow_call_list
    result += follow_call(call)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/evaluate.py", line 673, in follow_call
    while not s.parent.isinstance(pr.IsScope):
jedi.common.UncaughtAttributeError: 'NoneType' object has no attribute 'isinstance'

import modules autocomplete in unnamed file

When trying to autocomplete an import statement (i.e. getting the list of importable modules) in an unnamed file the plugin raises an AttributeError in the function sys_path_with_modifications in the jedi/imports.py file because self.file_path is None.

incorrect parameters completion

def test(a1, a2, a3):
    pass


def test2(b1, b2):
    pass

After ( presed

test(a1, a2, a3)

selected a1 replaced on test2(

Actual:

test(test2(a1, a2, a3), a2, a3)

Ecpected:

test(test2(b1, b2), a2, a3)

Parenthesis auto match

My parenthesis seem to auto match if I have the following in my jedy .sublime-keymap file:

    {"command": "sublime_jedi_params_autocomplete", "keys": ["("]}

It is kinda annoying because this triggers the auto complete (which is ultra awesome and works great) but for any and every parenthesis this will trigger an auto match i. e. if I'm writting and type ( automatically it will become ().

Is there any way around this?

Unable to use package after install (Fix inside)

Hi. I tested to install this package from the instructions in the README and the install part is ok and i can find the SublimeJEDI package in my sublime-text-2\Packages folder.
When i try to use any of the functionality (Ctrl + B or . autocompletion) the sublime console/log says the following

Traceback (most recent call last):
File "./sublime_plugin.py", line 236, in on_query_completions
File "./sublime_jedi.py", line 254, in on_query_completions
File "./sublime_jedi.py", line 278, in get_completions
File "./sublime_jedi.py", line 77, in get_script
ImportError: No module named jedi
Traceback (most recent call last):
File "./sublime_jedi.py", line 218, in delayed_complete
File "./sublime_jedi.py", line 77, in get_script
ImportError: No module named jedi

After some digging the issue could be the set path with sublime2

If you try in a python interpreter python 2.7.3

import sys
sys.path.append("/home/$USER$/.config/sublime-text-2/Packages/SublimeJEDI/jedi")
import jedi
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named jedi

How to fix this is to change the path that is set to 1 folder above the currently set path

import sys
sys.path.append("/home/$USER$/.config/sublme-text-2/Packages/SublimeJEDI/")
import jedi

Now the import is working proper and i can use the functionality of SublimeJEDI

Nothing happen and no error reported

Hello,

I installed SublimeJedi through Package Control but it seems like the plugin is doing nothing.

No matter what I try to set in the settings, the plugin simply stay silent, don't work and don't report errors either...

Is there something I can do to at least get some logs or error and trying to understand what is going wrong?

I'm a windows 7 and I trying to autocomplete with python2.6

Plugin fails to load if folder named other than 'SublimeJEDI'

I downloaded package from GitHub zip which called folder SublimeJEDI-master. This broke the package

 File "C:\Users\Matt\AppData\Roaming\Sublime Text 3\Packages\SublimeJEDI-master\python_go_to.py", line 7, in   <module>
    from sublime_jedi import get_script, JediEnvMixin
ImportError: No module named 'sublime_jedi'

Autocomplit

Plugin show window only for type 2 or more chars.
How to change this behavior to zero ?
Type dot and get list of all methods and variables for module

Windows popup windows

Hi,

on Windows your plugin pops console windows while working, and this is standard workaround:

--- sublime_jedi.bak
+++ sublime_jedi.py
@@ -25,8 +25,14 @@ def get_sys_path(python_interpreter):

         :return: list
     """
-    command = [python_interpreter, '-c', "import sys; print sys.path"]
-    process = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE)
+    command = [python_interpreter, '-c', "import sys; print(sys.path)"]
+    if sys.platform == "win32":
+        startupinfo = subprocess.STARTUPINFO()
+        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
+        process = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE,
+                                   startupinfo=startupinfo)
+    else:
+        process = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE)
     out = process.communicate()[0]
     sys_path = json.loads(out.replace("'", '"'))
     return sys_path

AttributeError: 'NoneType' object has no attribute 'get_parent_until'

Using Sublime Text 3 I got the following exception:

Traceback (most recent call last):
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/api.py", line 196, in _get_under_cursor_stmt
    stmt = r.module.statements[0]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/api.py", line 94, in complete
    scopes = list(self._prepare_goto(path, True))
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/api.py", line 188, in _prepare_goto
    stmt = self._get_under_cursor_stmt(goto_path)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/api.py", line 198, in _get_under_cursor_stmt
    raise NotFoundError()
jedi.api.NotFoundError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/patrys/Apps/sublime_text_3/sublime_plugin.py", line 358, in on_query_completions
    res = callback.on_query_completions(v, prefix, locations)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/sublime_jedi.py", line 291, in on_query_completions
    completions = self.get_completions(view, locations)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/sublime_jedi.py", line 307, in get_completions
    completions = self.completions_from_script(script, view) +\
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/sublime_jedi.py", line 201, in completions_from_script
    completions = script.complete()
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/api_classes.py", line 44, in wrapper
    result = func(*args, **kwds)
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/api.py", line 100, in complete
    for scope, name_list in scope_generator:
  File "/home/patrys/.config/sublime-text-3/Packages/SublimeJEDI/jedi/evaluate.py", line 160, in get_names_of_scope
    non_flow = scope.get_parent_until(pr.Flow, reverse=True)
AttributeError: 'NoneType' object has no attribute 'get_parent_until'

Can't multi-select using Ctrl+LeftClick/LeftDblClick after installing SublimeJEDI

The default setting in ~/.config/sublime-text-3/Packages/SublimeJEDI/Default.sublime-mousemap, disables the ability of multi-selections using the mouse. I can't find a way to "unset" this "mousemap" setting.

[
    {
        "modifiers": ["ctrl"], "button": "button1", 
        "command": "sublime_jedi_goto",
        "press_command": "drag_select"
    }
]

Commenting this enables multiselection by clicking again.

trigger indexing

It seems I can only get the plugin to work if I have a ST project setup.
Is there any manual way of triggering JEDI to work without having to setup a project in Sublime?

Jumpt to definition only gives results from system python when working on python itself.

While testing jedi on a cpython clone I noticed that I only get results from my system python installation, and not from the clone I was working on.

The file tried was cpython/Lib/distutils/dir_util.py

For the first call to is_linlk function from this module I don't even get the system suggestions.

On the other hand F12 gives me good suggestions.

Also, find usages seems to have problems with public functions, because I only get usages for private ones.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.