Skip to content

Commit

Permalink
Add deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Feb 3, 2025
1 parent 78a4ab5 commit f3f6139
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
[![image](https://img.shields.io/pypi/pyversions/ruff-lsp.svg)](https://pypi.python.org/pypi/ruff-lsp)
[![Actions status](https://github.com/astral-sh/ruff-lsp/workflows/CI/badge.svg)](https://github.com/astral-sh/ruff-lsp/actions)

> [!WARNING]
>
> **`ruff-lsp` is deprecated. Please switch to the native language server
> (`ruff server`). Refer to the [migration
> guide](https://docs.astral.sh/ruff/editors/migration/) on how to migrate the
> settings and [setup guide](https://docs.astral.sh/ruff/editors/setup/) for
> editor-specific setup instructions.**
> [!NOTE]
>
> **As of Ruff v0.4.5, Ruff ships with a built-in language server written in Rust: ⚡ `ruff server`**
Expand Down
15 changes: 15 additions & 0 deletions ruff_lsp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,15 @@ async def run_path(
@LSP_SERVER.feature(INITIALIZE)
def initialize(params: InitializeParams) -> None:
"""LSP handler for initialize request."""
show_warning(
"`ruff-lsp` is deprecated. Please switch to the native language server "
"(`ruff server`). Refer to the "
"[migration guide](https://docs.astral.sh/ruff/editors/migration/) on how to "
"migrate the settings and "
"[setup guide](https://docs.astral.sh/ruff/editors/setup/) for editor-specific "
"setup instructions."
)

# Extract client capabilities.
CLIENT_CAPABILITIES[CODE_ACTION_RESOLVE] = _supports_code_action_resolve(
params.capabilities
Expand Down Expand Up @@ -1995,6 +2004,12 @@ def show_error(message: str) -> None:
LSP_SERVER.show_message(message, MessageType.Error)


def show_warning(message: str) -> None:
"""Show a pop-up with a warning."""
LSP_SERVER.show_message_log(message, MessageType.Warning)
LSP_SERVER.show_message(message, MessageType.Warning)


def log_warning(message: str) -> None:
LSP_SERVER.show_message_log(message, MessageType.Warning)
if os.getenv("LS_SHOW_NOTIFICATION", "off") in ["onWarning", "always"]:
Expand Down

0 comments on commit f3f6139

Please sign in to comment.