Skip to content

Commit

Permalink
Remove experimental formatter flag (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh authored Oct 24, 2023
1 parent b2c8574 commit d6751db
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions ruff_lsp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,11 @@
logger = logging.getLogger(__name__)

RUFF_LSP_DEBUG = bool(os.environ.get("RUFF_LSP_DEBUG", False))
RUFF_EXPERIMENTAL_FORMATTER = bool(os.environ.get("RUFF_EXPERIMENTAL_FORMATTER", False))

if RUFF_LSP_DEBUG:
log_file = Path(__file__).parent.parent.joinpath("ruff-lsp.log")
logging.basicConfig(filename=log_file, filemode="w", level=logging.DEBUG)
logger.info("RUFF_LSP_DEBUG is active")
if RUFF_EXPERIMENTAL_FORMATTER:
logger.info("RUFF_EXPERIMENTAL_FORMATTER is active")


if sys.platform == "win32" and sys.version_info < (3, 8):
Expand Down Expand Up @@ -729,16 +726,14 @@ async def apply_format(arguments: tuple[TextDocument]):
)


if RUFF_EXPERIMENTAL_FORMATTER:

@LSP_SERVER.feature(TEXT_DOCUMENT_FORMATTING)
async def format_document(
ls: server.LanguageServer,
params: DocumentFormattingParams,
) -> list[TextEdit] | None:
uri = params.text_document.uri
document = ls.workspace.get_text_document(uri)
return await _format_document_impl(document)
@LSP_SERVER.feature(TEXT_DOCUMENT_FORMATTING)
async def format_document(
ls: server.LanguageServer,
params: DocumentFormattingParams,
) -> list[TextEdit] | None:
uri = params.text_document.uri
document = ls.workspace.get_text_document(uri)
return await _format_document_impl(document)


async def _format_document_impl(
Expand Down Expand Up @@ -897,11 +892,6 @@ def initialize(params: InitializeParams) -> None:
params.capabilities
)

# Internal hidden beta feature. We want to have this in the code base, but we
# don't want to expose it to users yet, hence the environment variable. You can
# e.g. use this with VS Code by doing `RUFF_EXPERIMENTAL_FORMATTER=1 code .`
# CLIENT_CAPABILITIES[TEXT_DOCUMENT_FORMATTING] = RUFF_EXPERIMENTAL_FORMATTER

# Extract `settings` from the initialization options.
workspace_settings: list[WorkspaceSettings] | WorkspaceSettings | None = (
params.initialization_options or {}
Expand Down

0 comments on commit d6751db

Please sign in to comment.