graph LR
LSP_Communication_Core["LSP Communication Core"]
Document_URI_Resolver["Document & URI Resolver"]
Configuration_Manager["Configuration Manager"]
Ruff_Process_Orchestrator["Ruff Process Orchestrator"]
Linting_Diagnostic_Adapter["Linting & Diagnostic Adapter"]
Code_Action_Fix_Adapter["Code Action & Fix Adapter"]
Formatting_Adapter["Formatting Adapter"]
LSP_Client["LSP Client"]
Ruff_Binary_External_["Ruff Binary (External)"]
LSP_Client -- "Initiates LSP requests" --> LSP_Communication_Core
LSP_Communication_Core -- "Requests standardized file paths and document content" --> Document_URI_Resolver
LSP_Communication_Core -- "Retrieves Ruff-specific settings and workspace configurations" --> Configuration_Manager
Document_URI_Resolver -- "Provides resolved document context" --> Linting_Diagnostic_Adapter
Document_URI_Resolver -- "Provides resolved document context" --> Code_Action_Fix_Adapter
Document_URI_Resolver -- "Provides resolved document context" --> Formatting_Adapter
Configuration_Manager -- "Supplies Ruff configuration and operational parameters" --> Ruff_Process_Orchestrator
Configuration_Manager -- "Supplies Ruff configuration and operational parameters" --> Linting_Diagnostic_Adapter
Configuration_Manager -- "Supplies Ruff configuration and operational parameters" --> Code_Action_Fix_Adapter
Configuration_Manager -- "Supplies Ruff configuration and operational parameters" --> Formatting_Adapter
LSP_Communication_Core -- "Triggers linting" --> Linting_Diagnostic_Adapter
LSP_Communication_Core -- "Requests code actions or fixes" --> Code_Action_Fix_Adapter
LSP_Communication_Core -- "Initiates document formatting" --> Formatting_Adapter
Linting_Diagnostic_Adapter -- "Commands Ruff to perform linting" --> Ruff_Process_Orchestrator
Code_Action_Fix_Adapter -- "Commands Ruff to generate fixes or code actions" --> Ruff_Process_Orchestrator
Formatting_Adapter -- "Commands Ruff to format the document" --> Ruff_Process_Orchestrator
Ruff_Process_Orchestrator -- "Executes Ruff commands" --> Ruff_Binary_External_
Ruff_Binary_External_ -- "Returns raw output" --> Ruff_Process_Orchestrator
Ruff_Process_Orchestrator -- "Returns raw Ruff output for parsing" --> Linting_Diagnostic_Adapter
Ruff_Process_Orchestrator -- "Returns raw Ruff output for parsing" --> Code_Action_Fix_Adapter
Ruff_Process_Orchestrator -- "Returns raw Ruff output for parsing" --> Formatting_Adapter
Linting_Diagnostic_Adapter -- "Publishes LSP diagnostics" --> LSP_Communication_Core
Code_Action_Fix_Adapter -- "Provides LSP workspace edits" --> LSP_Communication_Core
Formatting_Adapter -- "Provides LSP text edits" --> LSP_Communication_Core
LSP_Communication_Core -- "Sends LSP responses" --> LSP_Client
click LSP_Communication_Core href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/ruff-lsp/LSP_Communication_Core.md" "Details"
click Configuration_Manager href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/ruff-lsp/Configuration_Manager.md" "Details"
click LSP_Client href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/ruff-lsp/LSP_Client.md" "Details"
The ruff-lsp project functions as a Language Server Protocol (LSP) server, bridging external LSP clients (like code editors) with the Ruff linter and formatter binary. The core LSP Communication Core manages all client interactions, dispatching requests to specialized adapters. The Document & URI Resolver standardizes document inputs, while the Configuration Manager centralizes Ruff settings. Linting, code actions, and formatting are handled by dedicated adapters (Linting & Diagnostic Adapter, Code Action & Fix Adapter, Formatting Adapter), all orchestrating the Ruff Process Orchestrator to interact with the Ruff Binary (External). This modular design ensures clear separation of concerns, enabling efficient processing of LSP requests and robust integration with Ruff.
LSP Communication Core [Expand]
The central hub for all Language Server Protocol (LSP) interactions. It manages the server's lifecycle, parses incoming LSP requests, dispatches them to appropriate handlers, and sends responses and notifications back to the LSP client.
Related Classes/Methods:
ruff_lsp/server.py:initializeruff_lsp/server.py:did_openruff_lsp/server.py:did_changeruff_lsp/server.py:hoverruff_lsp/server.py:code_actionruff_lsp/server.py:format_document
Standardizes various LSP document and URI formats (e.g., text documents, notebook cells) into internal representations, primarily file paths, that Ruff can process. Ensures consistent data handling across different document types.
Related Classes/Methods:
ruff_lsp/server.py:from_uriruff_lsp/server.py:from_text_documentruff_lsp/server.py:from_notebook_document
Configuration Manager [Expand]
Manages the loading, updating, and retrieval of Ruff-specific settings. It consolidates configurations from global defaults, workspace settings, and document-specific overrides, providing a unified view to other components.
Related Classes/Methods:
ruff_lsp/server.py:_update_workspace_settingsruff_lsp/server.py:_get_settings_by_documentruff_lsp/settings.py:lint_run
Abstracts the complexities of discovering, executing, and managing the external Ruff binary. It handles subprocess creation, command-line argument construction, and version checking, ensuring Ruff commands are executed correctly.
Related Classes/Methods:
ruff_lsp/server.py:_find_ruff_binaryruff_lsp/server.py:_executable_versionruff_lsp/server.py:run_path
Orchestrates the linting process. It invokes the Ruff Process Orchestrator to run Ruff for linting, then parses Ruff's raw output into structured LSP diagnostic messages (severity, codes, tags) for client consumption.
Related Classes/Methods:
Manages the generation and application of code actions and fixes provided by Ruff. It transforms Ruff's fix suggestions into LSP-compliant workspace edits, enabling automated code modifications in the client.
Related Classes/Methods:
ruff_lsp/server.py:_fix_document_implruff_lsp/server.py:_result_to_workspace_editruff_lsp/server.py:_create_workspace_edit
Handles document formatting requests by invoking Ruff's formatting capabilities. It processes the formatted source code returned by Ruff and converts it into LSP text edits, which are then applied by the client.
Related Classes/Methods:
LSP Client [Expand]
External Language Server Protocol client (e.g., a code editor).
Related Classes/Methods: None
The external Ruff linter and formatter executable.
Related Classes/Methods: None