-
Notifications
You must be signed in to change notification settings - Fork 74
Sublime Usage
- Install the sourcery-cli pypi package
pip install --user sourcery-cli
. Note down the full command path with
which sourcery
. - Open the command palette and run
Package Control: Install Package
, then selectLSP
. - Open
Preferences > Package Settings > LSP > Settings
from the menu and add the following settings:
{
"clients": {
"sourcery": {
"command": [
"<Command to run Sourcery>", // Update this
"lsp"
],
"enabled": true,
"languageId": "python",
"scopes": ["source.python"],
"syntaxes": [
"Packages/Python/Python.sublime-syntax",
"Packages/MagicPython/grammars/MagicPython.tmLanguage",
"Packages/Djaneiro/Syntaxes/Python Django.tmLanguage",
],
"initializationOptions": {
"token": "<Your token here>", // Update this
"extension_version": "sublime lsp",
"editor_version": "sublime"
},
"settings": {
"sourcery": {
"metricsEnabled": true
}
}
}
}
}
Sourcery scans the currently open Python file. If it finds improvements in your code it highlights the relevant lines of code. To show all the Sourcery suggestions run LSP: Toggle Diagnostics Panel
from the command palette. Use F4/shift+F4
to jump to next/previous suggestion.
Hover on a suggestion line to view a description of the refactoring along with a diff. Then you can press super+.
to show options to either make the suggested change or to disable it.
The extension can also show you inline code metrics, giving you an instant view of your code quality. Hover on a function's definition to get an instant view of its code quality. Functions with very low quality will additionally be highlighted as warnings.
See the Sourcery Tutorial for more detailed info.
Please see the Sourcery configuration section for details.
Please visit our newer docs at https://docs.sourcery.ai