Skip to content

BiomeServer

Base classes

Name Children Inherits
LSPServerInfo
anyenv.lsp_servers._base
Static configuration for an LSP server.

⋔ Inheritance diagram

graph TD
  2453208089["js_ts_lsps.BiomeServer"]
  514706066["_base.LSPServerInfo"]
  2751680898["builtins.object"]
  514706066 --> 2453208089
  2751680898 --> 514706066

🛈 DocStrings

Bases: LSPServerInfo

Biome linter/formatter with JSON diagnostic parsing.

Source code in src/anyenv/lsp_servers/_servers/js_ts_lsps.py
@dataclass
class BiomeServer(LSPServerInfo):
    """Biome linter/formatter with JSON diagnostic parsing."""

    def _parse_json_diagnostics(self, output: str) -> list[Diagnostic]:
        """Parse biome JSON output."""
        import anyenv

        diagnostics: list[Diagnostic] = []

        try:
            # Find JSON in output (biome may print extra text)
            json_start = output.find("{")
            if json_start == -1:
                return diagnostics

            data = anyenv.load_json(output[json_start:], return_type=dict)
            for diag in data.get("diagnostics", []):
                location = diag.get("location", {})
                span = location.get("span", [0, 0])
                # Biome uses byte offsets, not line/column directly
                # For now, use offset as approximation (would need source to convert)
                path_info = location.get("path", {})
                file_path = path_info.get("file", "") if isinstance(path_info, dict) else ""

                diagnostics.append(
                    Diagnostic(
                        file=file_path,
                        line=1,  # Would need source text to calculate
                        column=span[0] if span else 1,
                        severity=severity_from_string(diag.get("severity", "error")),
                        message=diag.get("description", ""),
                        code=diag.get("category"),
                        source=self.id,
                    )
                )
        except anyenv.JsonLoadError:
            pass

        return diagnostics

:fa-brands-github: Show source on GitHub