Skip to content

AstroServer

Base classes

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

⋔ Inheritance diagram

graph TD
  338176860["js_ts_lsps.AstroServer"]
  514706066["_base.LSPServerInfo"]
  2751680898["builtins.object"]
  514706066 --> 338176860
  2751680898 --> 514706066

🛈 DocStrings

Bases: LSPServerInfo

Astro language server with TypeScript SDK detection.

Source code in src/anyenv/lsp_servers/_servers/js_ts_lsps.py
@dataclass
class AstroServer(LSPServerInfo):
    """Astro language server with TypeScript SDK detection."""

    async def resolve_initialization(self, root: str, fs: AsyncFileSystem) -> dict[str, Any]:
        """Detect TypeScript SDK path for Astro."""
        init = await super().resolve_initialization(root, fs)
        tsserver = posixpath.join(root, "node_modules", "typescript", "lib", "tsserver.js")
        try:
            if await fs._exists(tsserver):  # noqa: SLF001
                init["typescript"] = {"tsdk": posixpath.dirname(tsserver)}
        except Exception:  # noqa: BLE001
            pass

        return init

resolve_initialization async

resolve_initialization(root: str, fs: AsyncFileSystem) -> dict[str, Any]

Detect TypeScript SDK path for Astro.

Source code in src/anyenv/lsp_servers/_servers/js_ts_lsps.py
async def resolve_initialization(self, root: str, fs: AsyncFileSystem) -> dict[str, Any]:
    """Detect TypeScript SDK path for Astro."""
    init = await super().resolve_initialization(root, fs)
    tsserver = posixpath.join(root, "node_modules", "typescript", "lib", "tsserver.js")
    try:
        if await fs._exists(tsserver):  # noqa: SLF001
            init["typescript"] = {"tsdk": posixpath.dirname(tsserver)}
    except Exception:  # noqa: BLE001
        pass

    return init

:fa-brands-github: Show source on GitHub