{"id":51689075,"url":"https://github.com/stort0/cpp-lsp-api","last_synced_at":"2026-07-16T00:05:47.069Z","repository":{"id":344567855,"uuid":"1182253365","full_name":"stort0/cpp-lsp-api","owner":"stort0","description":null,"archived":false,"fork":false,"pushed_at":"2026-04-17T21:03:09.000Z","size":208,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-17T21:31:15.019Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stort0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-15T09:00:44.000Z","updated_at":"2026-04-17T21:03:13.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/stort0/cpp-lsp-api","commit_stats":null,"previous_names":["stort0/cpp-lsp-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stort0/cpp-lsp-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stort0%2Fcpp-lsp-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stort0%2Fcpp-lsp-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stort0%2Fcpp-lsp-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stort0%2Fcpp-lsp-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stort0","download_url":"https://codeload.github.com/stort0/cpp-lsp-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stort0%2Fcpp-lsp-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35524911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-15T02:00:06.706Z","response_time":131,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-16T00:05:46.296Z","updated_at":"2026-07-16T00:05:47.059Z","avatar_url":"https://github.com/stort0.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C++ LSP API\n\nWrapper of the `glaze` json library for use with `lsp` server and client.\nThe library uses `C++23`.\n\n## Language Server\n\nThe `LSP::LanguageServer` class takes a template type which uses to parse and\nhandle the client requests. The server features are checked through **concepts**.\n\n\u003e The `FileT` template is used as a const variable and is **never** mutated. The\n\u003e server will **replace** the old one when the file is updated.\n\u003e All functions used by the `LanguageServer` **must** be `const`.\n\n\u003e If a `TokenT` type token spans across multiple lines, the method `split()` is\n\u003e required for semantic tokens (otherwise token will be skipped).\n\n### Disable catch of exception\n\nTo forward all exception that happen during the language server execution,\ndefine `CPP_LSP_API_DISABLE_CATCH` or `CPP_LSP_API_DISABLE_CATCH_DEBUG` to only\ndisable it during debug mode.\n\n### Complete implementation of a file parser\n\n```c++\nclass MyTokenType {\npublic:\n        /*\n         * Required elements\n         */\n        auto range() const -\u003e Range;\n\n        /*\n         * Required for semantic tokens\n         */\n        static const uinteger invalid_type;\n        auto operator\u003c=\u003e (Position pos) const -\u003e std::weak_ordering;  // == means the position is inside range()\n        auto type() const -\u003e uinteger;\n        auto modifier() const -\u003e uinteger;\n        auto split() const -\u003e std::vector\u003cMyTokenType\u003e;  // optional\n    \n};\n\nclass MyRefactorContext {\n\n};\n\nclass MyLanguageFile {\npublic:\n        /*\n         * Required elements\n         */\n        using TokenT    = MyTokenType;  // MUST BE A BASIC TYPE (NO CVREF)\n        using TokenPtrT = const MyTokenType *;\n\n        static auto parse(const std::string \u0026text) -\u003e std::unique_ptr\u003cMyLanguageFile\u003e;\n\n        /*\n         * Required for notebook parsing\n         */\n        static const NotebookDocumentSyncOptions::_NotebookSelector notebook_selector;\n        static auto parse(const std::string \u0026text, NotebookCellKind kind, const std::vector\u003cMyLanguageFile *\u003e \u0026previousCells) -\u003e std::unique_ptr\u003cMyLanguageFile\u003e;\n\n        /*\n         * Required for edits on file save\n         */\n        auto save() const -\u003e std::vector\u003cTextEdit\u003e;\n\n        /*\n         * Required for call/type/implementation resolution\n         */\n        auto resolve(Position pos) const -\u003e TokenPtrT;\n\n        /*\n         * Required for element references\n         */\n        auto references(Position pos) const -\u003e std::vector\u003cTokenPtrT\u003e;\n\n        /*\n         * Required for semantic tokens\n         */\n        static const std::vector\u003cstring\u003e token_types;\n        static const std::vector\u003cstring\u003e token_modifiers;\n        auto visibleTokens() const -\u003e std::ranges::input_range;  // Any range with value_type == Token\n        // optional, should be set to true if visibleTokens() returns a sorted array\n        // based on the token Range.    \n        static const bool ordered_visible_tokens;\n    \n        /*\n         * Required for hover\n         */\n        auto hover(Position pos) const -\u003e std::optional\u003cMarkupContent\u003e;\n\n        /*\n         * Required for code lenses\n         */\n        auto codeLenses() const -\u003e std::vector\u003cCodeLens\u003e;\n\n        /*\n         * Required for code diagnostics\n         */\n        static const bool diagnostic_internal_dependencies;\n        auto diagnostics() const -\u003e std::vector\u003cDiagnostic\u003e;\n\n        /*\n         * Required for call/type hierarchy\n         */\n        auto roots(Position pos) const -\u003e std::vector\u003cLSP::HierarchyItem\u003e;\n        auto children(const std::optional\u003cLSPAny\u003e \u0026data) const -\u003e std::vector\u003cLSP::HierarchyItem\u003e;\n        auto parents(const std::optional\u003cLSPAny\u003e \u0026data) const -\u003e std::vector\u003cLSP::HierarchyItem\u003e;\n\n        /*\n         * Required for highlights\n         */\n        auto highlights(Position pos) const -\u003e std::vector\u003cDocumentHighlight\u003e;\n\n        /*\n         * Required for links\n         */\n        auto links() const -\u003e std::vector\u003cLSP::Link\u003e;\n\n        /*\n         * Required for folding ranges\n         */\n        auto foldingRanges() const -\u003e std::vector\u003cLSP::Fold\u003e;\n\n        /*\n         * Required for selection ranges\n         */\n        auto selectionRanges(Position pos) const -\u003e std::vector\u003cRange\u003e;  // RANGES MUST BE INCREASINGLY BIGGER,\n                                                                         // ELEMENTS MUST CONTAIN THE PREVIOUS ONES\n\n        /*\n         * Required for symbols\n         */\n        auto symbols() const -\u003e std::vector\u003cDocumentSymbol\u003e;\n\n        /*\n         * Required for inlay hints\n         */\n        auto hints(const Range \u0026range) const -\u003e std::vector\u003cInlayHint\u003e;\n\n        /*\n         * Required for inlay hints\n         */\n        auto inlineValues(const Range \u0026range, const InlineValueContext \u0026ctx) const -\u003e std::vector\u003cInlineValue\u003e;\n\n        /*\n         * Required for completions\n         */\n        auto completions(Position pos) const -\u003e std::vector\u003cCompletionItem\u003e;\n\n        /*\n         * Required for signature help\n         */\n        auto signatureHelp(Position pos) const -\u003e std::optional\u003cSignatureHelp\u003e;\n\n        /*\n         * Required for code actions\n         */\n        auto actions(const Range \u0026range, std::optional\u003cCodeActionKind\u003e kind) const -\u003e std::vector\u003cstd::variant\u003cCommand, CodeAction\u003e\u003e;\n\n        /*\n         * Required for colors\n         */\n        auto colors() const -\u003e std::vector\u003cColorInformation\u003e;\n        auto placeColor(const Color \u0026color, const Range \u0026range) const -\u003e std::vector\u003cColorPresentation\u003e;\n\n        /*\n         * Required for format\n         */\n        auto format(const FormattingOptions \u0026opts, const std::optional\u003cRange\u003e \u0026range) const -\u003e std::vector\u003cTextEdit\u003e;\n\n        /*\n         * Required for on type formatting\n         */\n        static const std::vector\u003cstring\u003e on_type_trigger_chars;\n        auto format(const FormattingOptions \u0026opts, Position pos) const -\u003e std::vector\u003cTextEdit\u003e;\n\n        /*\n         * Required for element rename\n         */\n        using RefactorContextT = MyRefactorContext;  // MUST BE A BASIC TYPE (NO CVREF)\n        auto createRenameCtx(Position pos, const string \u0026newName) const -\u003e RefactorContextT;\n        auto rename(const RefactorContextT \u0026ctx) const -\u003e std::vector\u003cTextEdit\u003e;\n        \n        /*\n         * Required rename check\n         */\n        auto canRename(Position pos) const -\u003e std::expected\u003cRange, string\u003e;\n        \n        /*\n         * Required linked editing ranges\n         */\n        auto editingRanges(Position pos) const -\u003e LinkedEditingRanges;\n        \n        /*\n         * Required inline completions\n         */\n        auto inlineCompletions(Position pos) const -\u003e std::vector\u003cInlineCompletionItem\u003e;\n        \n};\n```\n\n## Language client\n\n\u003e TODO\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstort0%2Fcpp-lsp-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstort0%2Fcpp-lsp-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstort0%2Fcpp-lsp-api/lists"}