Skip to content

Commit

Permalink
refactor: use ruff as the server (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfcherng authored Jul 22, 2024
1 parent 5867105 commit d94ddfb
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 52 deletions.
36 changes: 22 additions & 14 deletions LSP-ruff.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,31 @@
"settings": {
// same as globalSettings
},
// See https://docs.astral.sh/ruff/editors/settings/
"globalSettings": {
// Custom arguments passed to ruff.
// See ruff documentation at https://github.com/charliermarsh/ruff/blob/main/README.md#configuration
"lint.args": [],
// Run Ruff on every keystroke (onType) or on save (onSave).
"lint.run": "onType",
// Path to a ruff.toml or pyproject.toml file to use for configuration.
// By default, Ruff will discover configuration for each project from the filesystem, mirroring the behavior of the Ruff CLI.
"configuration": null,
// The strategy to use when resolving settings across editor and the filesystem. By default, editor configuration is prioritized over ruff.toml and pyproject.toml files.
"configurationPreference": "editorFirst",
// A list of file patterns to exclude from linting and formatting. See the documentation for more details.
"exclude": null,
// Whether to enable Ruff's preview mode when formatting.
"format.preview": null,
// The line length to use for the linter and formatter.
"lineLength": null,
// Whether to enable linting. Set to false to use Ruff exclusively as a formatter.
"lint.enable": true,
// Additional command-line arguments to pass to `ruff format`.
"format.args": [],
// Rules to enable by default. See the documentation.
"lint.select": null,
// Rules to enable in addition to those in lint.select.
"lint.extendSelect": null,
// Rules to disable by default. See the documentation.
"lint.ignore": null,
// Whether to enable Ruff's preview mode when linting.
"lint.preview": null,
// Sets the tracing level for the extension.
"logLevel": "error",
// Setting to provide custom ruff executables, to try in order.
"path": [],
// Path to a Python interpreter to use to run the linter server.
"interpreter": [],
// Setting to control when a notification is shown.
"showNotification": "off",
// Whether to register Ruff as capable of handling source.organizeImports actions.
Expand All @@ -29,12 +38,11 @@
"codeAction.fixViolation.enable": true,
// Whether to display Quick Fix actions to disable rules via noqa suppression comments.
"codeAction.disableRuleComment.enable": true,
// Whether to ignore files that are inferred to be part of the Python standard library.
"ignoreStandardLibrary": true,
},
},
"command": [
"$server_path"
"$server_path",
"server"
],
"schemes": [
"file", // regular files
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# LSP-ruff

This is a helper package that automatically installs and updates [ruff-lsp](https://github.com/charliermarsh/ruff-lsp) for you. Ruff is an extremely fast Python linter and code transformation tool, written in Rust.
This is a helper package that automatically installs and updates [ruff](https://github.com/astral-sh/ruff) for you. Ruff is an extremely fast Python linter and code transformation tool, written in Rust.

## Requirements

Expand Down
2 changes: 1 addition & 1 deletion plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class RuffLsp(PipClientHandler):
package_name = __package__
requirements_txt_path = "requirements.txt"
server_filename = "ruff-lsp"
server_filename = "ruff"


def plugin_loaded() -> None:
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[tool.ruff]
ignore = []
line-length = 88

[tool.ruff.lint]
ignore = []
select = [
"E",
"F",
"W",
]
]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruff-lsp==0.0.54
ruff==0.5.4
99 changes: 66 additions & 33 deletions sublime-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,77 @@
"LspRuffSettings": {
"additionalProperties": false,
"properties": {
"lint.args": {
"type": "array",
"default": [],
"markdownDescription": "Custom arguments passed to ruff. See [ruff documentation](https://github.com/charliermarsh/ruff/blob/main/README.md#configuration)."
"configuration": {
"type": ["string", "null"],
"default": null,
"markdownDescription": "Path to a `ruff.toml` or `pyproject.toml` file to use for configuration. By default, Ruff will discover configuration for each project from the filesystem, mirroring the behavior of the Ruff CLI."
},
"configurationPreference": {
"type": "string",
"default": "editorFirst",
"enum": [
"editorFirst",
"filesystemFirst",
"editorOnly"
],
"enumDescriptions": [
"Editor settings take priority over configuration files present in the workspace.",
"Configuration files present in the workspace takes priority over editor settings.",
"Ignore configuration files entirely i.e., only use editor settings."
],
"markdownDescription": "The strategy to use when resolving settings across editor and the filesystem. By default, editor configuration is prioritized over `ruff.toml` and `pyproject.toml` files."
},
"exclude": {
"type": ["array", "null"],
"default": null,
"items": {
"type": "string"
},
"description": "A list of file patterns to exclude from linting and formatting. See the documentation for more details."
},
"format.preview": {
"type": ["null", "boolean"],
"default": null,
"description": "Whether to enable Ruff's preview mode when formatting."
},
"lint.enable": {
"type": "boolean",
"default": true,
"markdownDescription": "Whether to enable linting. Set to false to use Ruff exclusively as a formatter."
},
"lint.run": {
"type": "string",
"default": "onType",
"enum": [
"onType",
"onSave"
],
"description": "Run Ruff on every keystroke (onType) or on save (onSave)."
"lineLength": {
"type": ["null", "integer"],
"default": null,
"description": "The line length to use for the linter and formatter."
},
"lint.select": {
"type": ["array", "null"],
"default": null,
"items": {
"type": "string"
},
"description": "Rules to enable by default. See the documentation."
},
"lint.extendSelect": {
"type": ["array", "null"],
"default": null,
"items": {
"type": "string"
},
"markdownDescription": "Rules to enable in addition to those in `lint.select`."
},
"format.args": {
"type": "array",
"default": [],
"markdownDescription": "Additional command-line arguments to pass to `ruff format`, e.g., `\"args\": [\"--config=/path/to/pyproject.toml\"]`. Supports a subset of Ruff's command-line arguments, ignoring those that are required to operate the LSP, like `--force-exclude` and `--verbose`."
"lint.ignore": {
"type": ["array", "null"],
"default": null,
"items": {
"type": "string"
},
"description": "Rules to disable by default. See the documentation."
},
"lint.preview": {
"type": ["null", "boolean"],
"default": null,
"description": "Whether to enable Ruff's preview mode when linting."
},
"logLevel": {
"type": "string",
Expand All @@ -47,16 +95,6 @@
],
"description": "Sets the tracing level for the extension."
},
"path": {
"type": "array",
"default": [],
"description": "Setting to provide custom ruff executables, to try in order."
},
"interpreter": {
"type": "array",
"default": [],
"description": "Path to a Python interpreter to use to run the linter server."
},
"showNotification": {
"type": "string",
"default": "off",
Expand All @@ -65,12 +103,12 @@
"organizeImports": {
"type": "boolean",
"default": true,
"description": "Whether to register Ruff as capable of handling source.organizeImports actions."
"markdownDescription": "Whether to register Ruff as capable of handling `source.organizeImports` actions."
},
"fixAll": {
"type": "boolean",
"default": true,
"description": "Whether to register Ruff as capable of handling source.fixAll actions."
"markdownDescription": "Whether to register Ruff as capable of handling `source.fixAll` actions."
},
"codeAction.fixViolation.enable": {
"type": "boolean",
Expand All @@ -81,11 +119,6 @@
"type": "boolean",
"default": true,
"description": "Whether to display Quick Fix actions to disable rules via noqa suppression comments."
},
"ignoreStandardLibrary": {
"type": "boolean",
"default": true,
"description": "Whether to ignore files that are inferred to be part of the Python standard library."
}
},
},
Expand Down

0 comments on commit d94ddfb

Please sign in to comment.