Anaconda is a python development suite that includes autocompletion, IDE features, linting with PyLint or PyFlakes + pep8, AutoPEP8 , Vagrant and more for Sublime Text 3.
Are you tired of extensions that promise you nice features but make your Sublime Text freezes and blocks while you are typing?. Well, we too, this is why the main goal of anaconda is the performance. Anaconda will never freeze your Sublime Text as everything in anaconda runs asynchronous.
It doesn't matters if you are linting a file with a few hundred or a few thousands of lines, anaconda will work smooth in each situation making you focus in your code and not interrupting your typing each few seconds.
Anaconda was born from my need of use a single plugin to autocomplete and lint python code. There are some other really good plugins for that but them doesn't fully fit my needs so I decided to create my own using the best of them.
Anaconda is an asynchronous client-server
architecture application. It starts a new server instance for any open Sublime Text window that contains Python code.
Because that architecture, anaconda can lint or complete with python interpreters different than the built-in Sublime Text 3 python interpreter (3.3). It can complete all the python code that the configured interpreter can see and lint files for that version of the interpreter.
Anaconda has been tested in Linux, Windows and Mac OS X with excelent results. The status of the plugin in the different platforms is:
- Linux: Stable
- OS X: Stable
- Windows: Stable
You can run the plugin in profiling mode on Windows (Sublime Text doesn't support cProfile in POSIX platforms) setting the user variable anaconda_debug
to profiler
, then you will get a profiling support of where the plugin is spending the processor time.
Those profiles are really helpful for us to fix bugs and solve performance problems on Windows, add it to your issues reports always that you can.
If you change your configured python intrepreter or you just switch your project, anaconda will detect it and reload a new completion/linting/IDE server killing the old one in a total transparent way so you don't need to restart your Sublime Text 3.
- Open Sublime Text Command Pallete and type "install" with no quotes
- Select "Install Package" from the dropdown box
- Type "anaconda" with no quotes, select it and press
<ENTER>
Go to your sublime text 3 packages directory and clone the repo:
git clone https://github.com/DamnWidget/anaconda.git Anaconda
Goto and Find Usages implementations are strongly inspired in SublimeJEDI ones, SublimeJEDI is GNU LGPL v3 licensed, you can read it online.
Anaconda will use your PATH
configured python interpreter by default. You can change it just editing the python_interpreter
user setting in the anaconda's default configuration file:
"python_interpreter": "/usr/bin/pypy-c2.0"
You can of course configure the python interpreter to use in a per-project
basis. To do that, you have to edit your <project_name>.sublime-project
file and override the python_interpreter
user setting there:
{
// ...
"settings": {
"python_interpreter": "/home/damnwidget/.virtualenvs/mamba-pypy/bin/python"
}
}
You can add additional python extra paths that should be used for autocompletion purposes setting a list of paths using the user setting extra_paths
:
{
// ...
"settings": {
"extra_paths":
[
"/opt/sublime_text_3",
"/usr/share/mypythonpackage"
]
}
}
If a valid environment hook config file (called .anaconda
) exists in the root of your working folder
or in any directory level up to drive root folder, it will be used instead of project or general anaconda
configuration. A valid .anaconda
hook file is as follows.
{
"python_interpreter": "pypy-c2.0",
"extra_paths": ["/usr/local/lib/awesome_lib"]
}
Note that only python_interpreter
and extra_paths
can be hooked.
If you want to trigger autocompletion when you write down the dot character you can setup this desirable behaviour editing your Sublime Text 3 Python.sublime-settings
file in Packages/User
(you may have to create this file yourself):
{
// ...
"auto_complete_triggers": [{"selector": "source.python - string - comment - constant.numeric", "characters": "."}]
}
Some developers preffer that SublimeText 3 does not autocomplete by itself so you can disable word and explicit autocompletiond setting suppress_word_completions
and suppress_explicit_completions
as true
.
You can choose to don't show Python snippets in your autocompletion results placing a user setting hide_snippets_on_completion
as true in your settings.
If complete_parameters
is true
, anaconda will add function and class parameters to its completions when you type (
after a completion.
If complete_all_parameters
is true
, it will add all the possible parameters, if it's false, it will add only required parameters
No key binding is needed to use this feature so it doesn't interfere in any way with your Sublime Text 3 normal operations.
With this command you can go to a file where a variable, function or class that your cursor is over is defined.
- Shortcut: Linux
super+g
, Mac OS X and Windowsctrl+alt+g
- Vintage Mode Shortcut (Command Mode):
gd
- Context Menu:
Anaconda > Goto Definition
With this command you can find all the places where a variable, function or class where your cursor is over is being used.
- Shortcut: Linux
super+f
, Mac OS X and Windowsctrl+alt+f
- Context Menu:
Anaconda > Find Usages
With this command you can get the docstring of whatever function or method. You can just write the function call, for example, sys.exit() and then use this command to get the function signature and docstring without lose the cursor focus from the buffer.
- Shortcut: Linux
super+d
, Mac OS X and Windowsctrl+alt+d
- Context Menu:
Anaconda > Show Documentation
note: Context menu only works on Python code (no comments, no docstrings)
note: If you set the option "display_signatures"
as true
, anaconda will display method signatures and other help strings in the status bar while you edit the file.
With this command you can rename the object under the cursor in a project basis scope in a safe way.
- Context Menu:
Anaconda > Rename object under cursor
You can run the McCabe complexity checker tool in whatever python file you want. You can configure it threshold adjusting the option setting mccabe_threshold
in the configuration file or in your project configuration file.
- Context Menu:
Anaconda > McCabe complexity check
Anaconda supports the AutoPEP8 tool and its integrated as part of the plugin itself. You can reformat your files to follow PEP8 automatically using the command palette Anaconda: Autoformat PEP8 Errors
or the same option in the contextual menu. Of course this operation is performed asynchronous but it set your current buffer as read only while the operation is performed, a progress bar is shown at the status bar while working.
Anaconda can fix the following PEP8 errors
Please, take a look at the configuration file to get a list of available options.
Anaconda will add an import <undefined_name>
at the end of your imports block if you use the context menu Autoimport anaconda option using the right mouse click over an undefined name in your buffer. Note that anaconda will NOT check if that is a valid import or not.
Anaconda linting is mainly based/inspired/ported from SublimeLinter because that I added the SublimeLinter LICENSE file in the repo. Although anaconda linter is inspired in SublimeLinter, anaconda linting is much faster for serveral reasons:
- Anaconda does not use a delayed queue to perform the lintin work, instead of that we fire a single call to the linter methods
n
seconds after the last key was pressend by the user while typing. Thosen
seconds can be configured by the user. - Anaconda is totally asynchronous so we should never block the gui, because that, our linting is smooth and flawless.
Just set the user setting anaconda_linting
as false
Sometimes we have to open some file from this mate that all of us have that doesn't seems to know what PEP-8 means and when the teacher spoke about code conventions and readability of the code he was just sick in home and we are just annoyed by the linter marking everyone line of the code.
On this situations we can just disable the linting for this specific file using the command Anaconda: Disable linting on this file
from the command palette.
When our mate learns how to write proper and clean code we can just turn it on again with Anaconda: Enable linting on this file
.
You can disable specific PyFlakes errors (unused import module for example) uncommenting it in the pyflakes_explicit_ignore
list in the configuration file or adding this list to your project configuration and adding there the type of warnings/errors that you want to disable.
You can show a quick panel with all the errors in the file you are currently editing usign the command palette or the contextual menu.
You can use the Anaconda: Next lint error
command from the Command Palette
, from the Context Menu
or just add a shortcut to the anaconda_next_lint_error
to navigate trough the lint errors on the file.
Note: The order is not per line but for error severity in this order: ERRORS, WARNINGS, VIOLATIONS
- Always mode (default) - When
anaconda_linting_behaviour
is set asalways
the linting is performed in the background as you are editing the file you are working on and in load/save events. The linting process is performed in the background in another thread of execution and it doesn't block the Sublime Text GUI. The process is fired when the plugin detected that you stop typying for a period of time, by default is half a second and can be configured editign the value of the user settinganaconda_linter_delay
. - Load and Save mode - When
anaconda_linting_behaviour
is set asload-save
linting is performed on file load and saving only. - Save only mode - When
anaconda_linting_behabiour
is set assave-only
linting is performed on file saving only.
Anaconda supports docsrings linting using pep257 specification. This feature is disabled by default but can be enabled setting pep257
as true
in the configuration file.
Specific errors can be disabled adding them (as string elements into a list) on the pep257_ignore
user settings in the config file. The D209
is disabled by default as it has been deprecated.
If you don't care about pep8 linting (you are terribly wrong) you can disable pep8 linting at all setting the user setting pep8
as false
If what you want to do is just disable some errors like "line too long"
E501
error in pep8 (you are terribly wrong again) you can add it to the pep8_ignore
user setting like:
"pep8_ignore":
[
"E501"
]
There is an equivalen for PyFlakes errors called pyflakes_ignore
, look at the default anaconda configuration file for more details.
Anaconda has full support for PyLint as linter application but some considerations has to be taken before do it.
Due 3rd party dependencies required for PyLint, Anaconda does not add it like do with pep8 and PyFlakes libraries, if you want to use PyLint as your linter you have to donwload and install it yourself.
Anaconda does not use a subprocess to call the PyLint linter like Pylinter plugin does. We just import some files from pylint and run the linter from the jsonserver process capturing the system stdout file descriptor. That means anaconda will use your configured python interpreter (and environment) in order to lint your files with PyLint so it should be installed in your virtualenvironment if you are using virtualenv.
PyLint does not support lint buffers that are not saved yet in the file system so it can't lint files before you save it.
Anaconda uses E, W and V codes to maintain compatibility with PyFlakes and PEP8 linters so the PyLint mapping is as follows:
mapping = {
'C': 'V',
'E': 'E',
'F': 'E',
'I': 'V',
'R': 'W',
'W': 'W'
}
PyLint errors can be ignored using the setting parameter pylint_ignore
.
When you use PyLint, PyFlakes and PEP8 are totally turned off.
Note: PyLint can be really annoying use it at your own risk
If you want to see gutter marks in the linted lines you just have to set as true
the anaconda_gutter_marks
user setting. This will add simple marks to gutter. If you want to add fancy icons you can set anaconda_gutter_theme
user settings. Available options are:
- basic (default)
- alpha
- bright
- dark
- hard
- simple
You can control the way that anaconda mark the error lines in your files adjusting the setting anaconda_linter_mark_style
- If it's set to
outline
(default) anaconda will outline error lines - If it's set to
fill
anconda will fill the lines - If it's set to
none
anaconda will not draw anything on error lines
If you don't want to show the red underline under the errors on the lines, you can set the anaconda_linter_underlines
as false. Note that this option only takes effect when the anaconda_linter_mark_style
is set to none
.
This program is distributed under the terms of the GNU GPL v3. See the LICENSE file for details.
Guide to solve common issues
You have to update your package control version to the version 2.0 or better
Your sublime text can't find the interpreter that you set in your configuration, by default, anaconda set this as python
so it will get your configured Python interpreter in your PATH (if any)
There are several ways to contribute with anaconda.
- By giving feedback about the plugin and how it works in your platform.
- By reporting bugs in the issue tracker
- By sharing your ideas with us
Did you found a bug and you know how to fix it? First of all, thank you very much. You just have to report the bug as a new issue, fork the repository, make your changes and send a new pull request.
So you thougth about a new killer feature to implement in Anaconda?. Great!. Open an issue tagged as "Feature" and we will discuss it with you.
Do you have a Mac OS X box that you don't use anymore and its abandoned in a corner? Just send it to us, put yourself in contact with us and lets talk.
note: this need has been already satisfied
Just donate to maintain this project alive.
[][0] [0]: http://flattr.com/thing/1765332/DamnWidgetanaconda-on-GitHub