├── .github └── workflows │ ├── gh-pages.yml │ └── main.yml ├── .gitignore ├── .gitmodules ├── .ocamlformat ├── CHANGES.md ├── Makefile ├── README.md ├── dune ├── dune-project ├── example ├── template-eio │ ├── dune │ └── main.ml └── template-lwt │ ├── dune │ └── main.ml ├── linol-eio.opam ├── linol-lwt.opam ├── linol.opam ├── src ├── blocking_IO.ml ├── blocking_IO.mli ├── common_.ml ├── dune ├── eio │ ├── dune │ └── linol_eio.ml ├── jsonrpc2.ml ├── jsonrpc2.mli ├── linol.ml ├── log.ml ├── lwt │ ├── dune │ └── linol_lwt.ml ├── server.ml └── sigs.ml ├── thirdparty └── lsp │ ├── .editorconfig │ ├── .git-blame-ignore-revs │ ├── .github │ ├── dependabot.yml │ └── workflows │ │ ├── build-and-test.yml │ │ ├── changelog.yml │ │ ├── nix.yml │ │ └── update-flake-lock.yml │ ├── .gitignore │ ├── .ocamlformat │ ├── .ocamlformat-ignore │ ├── CHANGES.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── LICENSE.md │ ├── Makefile │ ├── README.md │ ├── biome.json │ ├── dune │ ├── dune-project │ ├── fiber-test │ ├── dune │ ├── fiber_test.ml │ └── fiber_test.mli │ ├── flake.lock │ ├── flake.nix │ ├── jsonrpc-fiber │ ├── src │ │ ├── dune │ │ ├── import.ml │ │ ├── jsonrpc_fiber.ml │ │ └── jsonrpc_fiber.mli │ └── test │ │ ├── dune │ │ ├── jsonrpc_fiber_tests.ml │ │ └── jsonrpc_fiber_tests.mli │ ├── jsonrpc.opam │ ├── jsonrpc │ └── src │ │ ├── dune │ │ ├── import.ml │ │ ├── jsonrpc.ml │ │ └── jsonrpc.mli │ ├── lsp-fiber │ ├── src │ │ ├── client.ml │ │ ├── client.mli │ │ ├── dune │ │ ├── fiber_io.ml │ │ ├── fiber_io.mli │ │ ├── import.ml │ │ ├── lazy_fiber.ml │ │ ├── lazy_fiber.mli │ │ ├── lsp_fiber.ml │ │ ├── rpc.ml │ │ ├── rpc.mli │ │ ├── server.ml │ │ └── server.mli │ └── test │ │ ├── dune │ │ ├── lsp_fiber_test.ml │ │ └── lsp_fiber_test.mli │ ├── lsp.opam │ ├── lsp.opam.template │ ├── lsp │ ├── bin │ │ ├── cinaps.ml │ │ ├── cinaps.mli │ │ ├── dune │ │ ├── import.ml │ │ ├── lsp_gen.ml │ │ ├── metamodel │ │ │ ├── dune │ │ │ ├── metaModel.json │ │ │ ├── metamodel.ml │ │ │ └── metamodel.mli │ │ ├── named.ml │ │ ├── ocaml │ │ │ ├── json_gen.ml │ │ │ ├── json_gen.mli │ │ │ ├── ml.ml │ │ │ ├── ml.mli │ │ │ ├── ml_create.ml │ │ │ ├── ml_create.mli │ │ │ ├── ml_kind.ml │ │ │ ├── ocaml.ml │ │ │ ├── ocaml.mli │ │ │ ├── w.ml │ │ │ └── w.mli │ │ ├── test_metamodel.ml │ │ └── typescript │ │ │ ├── ts_types.ml │ │ │ ├── ts_types.mli │ │ │ ├── typescript.ml │ │ │ └── typescript.mli │ ├── src │ │ ├── array_view.ml │ │ ├── array_view.mli │ │ ├── cancel_request.ml │ │ ├── cancel_request.mli │ │ ├── cli.ml │ │ ├── cli.mli │ │ ├── client_notification.ml │ │ ├── client_notification.mli │ │ ├── client_request.ml │ │ ├── client_request.mli │ │ ├── diff.ml │ │ ├── diff.mli │ │ ├── dune │ │ ├── extension.ml │ │ ├── extension.mli │ │ ├── header.ml │ │ ├── header.mli │ │ ├── import.ml │ │ ├── io.ml │ │ ├── io.mli │ │ ├── lsp.ml │ │ ├── position.ml │ │ ├── progress.ml │ │ ├── progress.mli │ │ ├── server_notification.ml │ │ ├── server_notification.mli │ │ ├── server_request.ml │ │ ├── server_request.mli │ │ ├── snippet.ml │ │ ├── snippet.mli │ │ ├── string_zipper.ml │ │ ├── string_zipper.mli │ │ ├── substring.ml │ │ ├── substring.mli │ │ ├── text_document.ml │ │ ├── text_document.mli │ │ ├── types.ml │ │ ├── types.mli │ │ ├── uri0.ml │ │ ├── uri0.mli │ │ ├── uri_lexer.mli │ │ └── uri_lexer.mll │ └── test │ │ ├── diff_tests.ml │ │ ├── dune │ │ ├── string_zipper_tests.ml │ │ ├── substring_tests.ml │ │ ├── text_document_tests.ml │ │ └── uri_tests.ml │ ├── ocaml-lsp-server.opam │ ├── ocaml-lsp-server │ ├── bench │ │ ├── documents.ml │ │ ├── dune │ │ └── ocaml_lsp_bench.ml │ ├── bin │ │ ├── dune │ │ ├── main.ml │ │ └── main.mli │ ├── docs │ │ └── ocamllsp │ │ │ ├── config.md │ │ │ ├── construct-spec.md │ │ │ ├── getDocumentation-spec.md │ │ │ ├── hoverExtended-spec.md │ │ │ ├── inferIntf-spec.md │ │ │ ├── merlinCallCompatible-specs.md │ │ │ ├── merlinJump-spec.md │ │ │ ├── switchImplIntf-spec.md │ │ │ ├── typeEnclosing-spec.md │ │ │ ├── typeSearch-spec.md │ │ │ ├── typedHoles-spec.md │ │ │ └── wrappingAstNode-spec.md │ ├── dune │ ├── src │ │ ├── bin.ml │ │ ├── bin.mli │ │ ├── check_for_comments.ml │ │ ├── check_for_comments.mli │ │ ├── client.ml │ │ ├── client.mli │ │ ├── code_actions.ml │ │ ├── code_actions.mli │ │ ├── code_actions │ │ │ ├── action_add_rec.ml │ │ │ ├── action_add_rec.mli │ │ │ ├── action_construct.ml │ │ │ ├── action_construct.mli │ │ │ ├── action_destruct.ml │ │ │ ├── action_destruct.mli │ │ │ ├── action_destruct_line.ml │ │ │ ├── action_destruct_line.mli │ │ │ ├── action_extract.ml │ │ │ ├── action_extract.mli │ │ │ ├── action_inferred_intf.ml │ │ │ ├── action_inferred_intf.mli │ │ │ ├── action_inline.ml │ │ │ ├── action_inline.mli │ │ │ ├── action_jump.ml │ │ │ ├── action_jump.mli │ │ │ ├── action_mark_remove_unused.ml │ │ │ ├── action_mark_remove_unused.mli │ │ │ ├── action_open_related.ml │ │ │ ├── action_open_related.mli │ │ │ ├── action_refactor_open.ml │ │ │ ├── action_refactor_open.mli │ │ │ ├── action_remove_type_annotation.ml │ │ │ ├── action_remove_type_annotation.mli │ │ │ ├── action_type_annotate.ml │ │ │ ├── action_type_annotate.mli │ │ │ ├── action_update_signature.ml │ │ │ ├── code_action.ml │ │ │ ├── code_action.mli │ │ │ └── diagnostic_util.ml │ │ ├── compl.ml │ │ ├── compl.mli │ │ ├── config_data.ml │ │ ├── configuration.ml │ │ ├── configuration.mli │ │ ├── custom_requests │ │ │ ├── custom_request.ml │ │ │ ├── custom_request.mli │ │ │ ├── req_construct.ml │ │ │ ├── req_construct.mli │ │ │ ├── req_get_documentation.ml │ │ │ ├── req_get_documentation.mli │ │ │ ├── req_hover_extended.ml │ │ │ ├── req_hover_extended.mli │ │ │ ├── req_infer_intf.ml │ │ │ ├── req_infer_intf.mli │ │ │ ├── req_merlin_call_compatible.ml │ │ │ ├── req_merlin_call_compatible.mli │ │ │ ├── req_merlin_jump.ml │ │ │ ├── req_merlin_jump.mli │ │ │ ├── req_switch_impl_intf.ml │ │ │ ├── req_switch_impl_intf.mli │ │ │ ├── req_type_enclosing.ml │ │ │ ├── req_type_enclosing.mli │ │ │ ├── req_type_search.ml │ │ │ ├── req_type_search.mli │ │ │ ├── req_typed_holes.ml │ │ │ ├── req_typed_holes.mli │ │ │ ├── req_wrapping_ast_node.ml │ │ │ ├── req_wrapping_ast_node.mli │ │ │ ├── util.ml │ │ │ └── util.mli │ │ ├── definition_query.ml │ │ ├── definition_query.mli │ │ ├── diagnostics.ml │ │ ├── diagnostics.mli │ │ ├── doc_to_md.ml │ │ ├── doc_to_md.mli │ │ ├── document.ml │ │ ├── document.mli │ │ ├── document_store.ml │ │ ├── document_store.mli │ │ ├── document_symbol.ml │ │ ├── document_symbol.mli │ │ ├── document_text_command.ml │ │ ├── document_text_command.mli │ │ ├── dune │ │ ├── dune.ml │ │ ├── dune.mli │ │ ├── env_vars.ml │ │ ├── folding_range.ml │ │ ├── folding_range.mli │ │ ├── hover_req.ml │ │ ├── hover_req.mli │ │ ├── import.ml │ │ ├── inference.ml │ │ ├── inference.mli │ │ ├── inlay_hints.ml │ │ ├── inlay_hints.mli │ │ ├── merlin_config.ml │ │ ├── merlin_config.mli │ │ ├── merlin_config_command.ml │ │ ├── merlin_config_command.mli │ │ ├── metrics.ml │ │ ├── metrics.mli │ │ ├── ocaml_lsp_server.ml │ │ ├── ocaml_lsp_server.mli │ │ ├── ocamlformat.ml │ │ ├── ocamlformat.mli │ │ ├── ocamlformat_rpc.ml │ │ ├── ocamlformat_rpc.mli │ │ ├── position.ml │ │ ├── position.mli │ │ ├── prefix_parser.ml │ │ ├── prefix_parser.mli │ │ ├── progress.ml │ │ ├── progress.mli │ │ ├── range.ml │ │ ├── range.mli │ │ ├── rename.ml │ │ ├── rename.mli │ │ ├── semantic_highlighting.ml │ │ ├── semantic_highlighting.mli │ │ ├── signature_help.ml │ │ ├── signature_help.mli │ │ ├── state.ml │ │ ├── state.mli │ │ ├── testing.ml │ │ ├── typed_hole.ml │ │ ├── typed_hole.mli │ │ ├── version.ml │ │ ├── version.mli │ │ ├── workspace_symbol.ml │ │ ├── workspace_symbol.mli │ │ ├── workspaces.ml │ │ └── workspaces.mli │ ├── test │ │ ├── dune │ │ ├── e2e-new │ │ │ ├── action_extract.ml │ │ │ ├── action_inline.ml │ │ │ ├── action_mark_remove.ml │ │ │ ├── code_actions.ml │ │ │ ├── code_actions.mli │ │ │ ├── completion.ml │ │ │ ├── completions.ml │ │ │ ├── construct.ml │ │ │ ├── doc_to_md.ml │ │ │ ├── document_flow.ml │ │ │ ├── documentation.ml │ │ │ ├── dune │ │ │ ├── exit_notification.ml │ │ │ ├── for_pp.ml │ │ │ ├── for_ppx.ml │ │ │ ├── helpers.ml │ │ │ ├── helpers.mli │ │ │ ├── hover_extended.ml │ │ │ ├── inlay_hints.ml │ │ │ ├── lsp_helpers.ml │ │ │ ├── lsp_helpers.mli │ │ │ ├── merlin_call_compatible.ml │ │ │ ├── merlin_jump.ml │ │ │ ├── metrics.ml │ │ │ ├── semantic_hl_data.ml │ │ │ ├── semantic_hl_helpers.ml │ │ │ ├── semantic_hl_helpers.mli │ │ │ ├── semantic_hl_tests.ml │ │ │ ├── start_stop.ml │ │ │ ├── syntax_doc_tests.ml │ │ │ ├── test.ml │ │ │ ├── type_enclosing.ml │ │ │ ├── type_search.ml │ │ │ ├── with_pp.ml │ │ │ ├── with_ppx.ml │ │ │ └── workspace_change_config.ml │ │ ├── e2e │ │ │ ├── __tests__ │ │ │ │ ├── Lifecycle.test.ts │ │ │ │ ├── Request.Debug.test.ts │ │ │ │ ├── TextDocument.test.ts │ │ │ │ ├── completionItem-resolve.test.ts │ │ │ │ ├── declaration_files │ │ │ │ │ ├── dune │ │ │ │ │ ├── dune-project │ │ │ │ │ ├── lib.ml │ │ │ │ │ ├── lib.mli │ │ │ │ │ └── main.ml │ │ │ │ ├── ocamllsp-hoverExtended.ts │ │ │ │ ├── ocamllsp-inferIntf.ts │ │ │ │ ├── ocamllsp-switchImplIntf.ts │ │ │ │ ├── ocamllsp-typedHoles.ts │ │ │ │ ├── ocamllsp-wrappingAstNode.test.ts │ │ │ │ ├── textDocument-codeAction.test.ts │ │ │ │ ├── textDocument-codeLens.test.ts │ │ │ │ ├── textDocument-declaration.test.ts │ │ │ │ ├── textDocument-definition.test.ts │ │ │ │ ├── textDocument-diagnostics.ts │ │ │ │ ├── textDocument-documentHighlight.test.ts │ │ │ │ ├── textDocument-documentSymbol.ts │ │ │ │ ├── textDocument-foldingRange.test.ts │ │ │ │ ├── textDocument-formatting.test.ts │ │ │ │ ├── textDocument-hover.test.ts │ │ │ │ ├── textDocument-references.test.ts │ │ │ │ ├── textDocument-rename.test.ts │ │ │ │ ├── textDocument-selectionRange.test.ts │ │ │ │ ├── textDocument-signatureHelp.ts │ │ │ │ ├── textDocument-typeDefinition.test.ts │ │ │ │ ├── workspace-symbol.test.ts │ │ │ │ ├── workspace_symbol_A │ │ │ │ │ ├── bin │ │ │ │ │ │ ├── a.ml │ │ │ │ │ │ ├── dune │ │ │ │ │ │ └── main.ml │ │ │ │ │ ├── dune-project │ │ │ │ │ ├── lib.opam │ │ │ │ │ ├── lib │ │ │ │ │ │ ├── LibTypes.mli │ │ │ │ │ │ ├── dune │ │ │ │ │ │ ├── lib.ml │ │ │ │ │ │ └── lib.mli │ │ │ │ │ ├── main.opam │ │ │ │ │ └── vendor │ │ │ │ │ │ └── vendored_lib.ml │ │ │ │ └── workspace_symbol_B │ │ │ │ │ ├── dune │ │ │ │ │ ├── dune-project │ │ │ │ │ └── main.ml │ │ │ ├── jest.config.js │ │ │ ├── jest.setup.ts │ │ │ ├── package.json │ │ │ ├── src │ │ │ │ ├── LanguageServer.ts │ │ │ │ ├── Ocamlformat.js │ │ │ │ ├── Refmt.js │ │ │ │ └── utils.ts │ │ │ └── tsconfig.json │ │ ├── ocaml_lsp_tests.ml │ │ ├── position_prefix_tests.ml │ │ └── run_test_e2e.ml │ └── vendor │ │ └── cmarkit │ │ ├── LICENSE.md │ │ ├── cmarkit.ml │ │ ├── cmarkit.mli │ │ ├── cmarkit_base.ml │ │ ├── cmarkit_base.mli │ │ ├── cmarkit_commonmark.ml │ │ ├── cmarkit_commonmark.mli │ │ ├── cmarkit_data.ml │ │ ├── cmarkit_data.mli │ │ ├── cmarkit_data_html.ml │ │ ├── cmarkit_data_uchar.ml │ │ ├── cmarkit_html.ml │ │ ├── cmarkit_html.mli │ │ ├── cmarkit_latex.ml │ │ ├── cmarkit_latex.mli │ │ ├── cmarkit_renderer.ml │ │ ├── cmarkit_renderer.mli │ │ └── dune │ ├── ocamlformat.nix │ ├── package.json │ ├── submodules │ └── lev │ │ ├── .github │ │ └── workflows │ │ │ └── workflow.yml │ │ ├── .gitignore │ │ ├── .gitrepo │ │ ├── .ocamlformat │ │ ├── README.cpp.md │ │ ├── README.md │ │ ├── dune │ │ ├── dune-project │ │ ├── lev-fiber-csexp.opam │ │ ├── lev-fiber-csexp │ │ ├── src │ │ │ ├── dune │ │ │ ├── lev_fiber_csexp.ml │ │ │ └── lev_fiber_csexp.mli │ │ └── test │ │ │ ├── dune │ │ │ ├── lev_fiber_csexp_rpc_tests.ml │ │ │ └── lev_fiber_csexp_rpc_tests.mli │ │ ├── lev-fiber.opam │ │ ├── lev-fiber │ │ ├── bench │ │ │ ├── dune │ │ │ ├── ping_pong.ml │ │ │ └── ping_pong.mli │ │ ├── src │ │ │ ├── dune │ │ │ ├── lev_fiber.ml │ │ │ ├── lev_fiber.mli │ │ │ └── util │ │ │ │ ├── bip_buffer.ml │ │ │ │ ├── bip_buffer.mli │ │ │ │ ├── channel.ml │ │ │ │ ├── channel.mli │ │ │ │ ├── dune │ │ │ │ ├── removable_queue.ml │ │ │ │ ├── removable_queue.mli │ │ │ │ ├── worker.ml │ │ │ │ └── worker.mli │ │ └── test │ │ │ ├── basic.ml │ │ │ ├── dune │ │ │ ├── lev_fiber_threads.ml │ │ │ ├── lev_fiber_threads.mli │ │ │ ├── process.ml │ │ │ ├── reader_writer.ml │ │ │ ├── reader_writer.mli │ │ │ ├── sockets.ml │ │ │ ├── sockets.mli │ │ │ ├── timers.ml │ │ │ ├── timers.mli │ │ │ └── util │ │ │ ├── bip_buffer_tests.ml │ │ │ ├── bip_buffer_tests.mli │ │ │ ├── channel_tests.ml │ │ │ ├── channel_tests.mli │ │ │ ├── dune │ │ │ ├── removable_queue_tests.ml │ │ │ └── removable_queue_tests.mli │ │ ├── lev.opam │ │ └── lev │ │ ├── bench │ │ ├── dune │ │ ├── ping_pong.ml │ │ └── ping_pong.mli │ │ ├── dune │ │ ├── examples │ │ ├── dune │ │ └── readme.ml │ │ ├── src │ │ ├── LICENSE.md │ │ ├── config.h │ │ ├── dune │ │ ├── lev.ml │ │ ├── lev.mli │ │ └── lev_stubs.c │ │ ├── test │ │ ├── dune │ │ ├── lev_tests.ml │ │ ├── lev_tests_signals.ml │ │ ├── lev_tests_unix.ml │ │ └── sockets.ml │ │ └── vendor │ │ ├── Changes │ │ ├── LICENSE │ │ ├── Makefile.am │ │ ├── README │ │ ├── README.embed │ │ ├── Symbols.ev │ │ ├── Symbols.event │ │ ├── autogen.sh │ │ ├── configure.ac │ │ ├── ev++.h │ │ ├── ev.3 │ │ ├── ev.c │ │ ├── ev.h │ │ ├── ev.pod │ │ ├── ev_epoll.c │ │ ├── ev_iouring.c │ │ ├── ev_kqueue.c │ │ ├── ev_linuxaio.c │ │ ├── ev_poll.c │ │ ├── ev_port.c │ │ ├── ev_select.c │ │ ├── ev_vars.h │ │ ├── ev_win32.c │ │ ├── ev_wrap.h │ │ ├── event.c │ │ ├── event.h │ │ ├── event_compat.h │ │ ├── import_libevent │ │ ├── libev.m4 │ │ ├── update_ev_c │ │ ├── update_ev_wrap │ │ └── update_symbols │ ├── vendor │ ├── lev-fiber │ │ ├── .gitkeep │ │ └── util │ │ │ └── .gitkeep │ ├── lev │ │ └── .gitkeep │ ├── odoc-parser │ │ ├── LICENSE │ │ └── src │ │ │ ├── ast.ml │ │ │ ├── compat.ml │ │ │ ├── compat.mli │ │ │ ├── dune │ │ │ ├── lexer.mli │ │ │ ├── lexer.mll │ │ │ ├── loc.ml │ │ │ ├── loc.mli │ │ │ ├── odoc_parser.ml │ │ │ ├── odoc_parser.mli │ │ │ ├── parse_error.ml │ │ │ ├── syntax.ml │ │ │ ├── syntax.mli │ │ │ ├── token.ml │ │ │ └── warning.ml │ └── update-odoc-parser.sh │ └── yarn.lock └── vendor ├── jsonrpc └── dune └── lsp └── dune /.github/workflows/gh-pages.yml: -------------------------------------------------------------------------------- 1 | name: github pages 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | deploy: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@main 13 | with: 14 | submodules: 'recursive' 15 | - uses: ocaml/setup-ocaml@v3 16 | with: 17 | ocaml-compiler: '5.2' 18 | dune-cache: true 19 | allow-prerelease-opam: true 20 | 21 | - name: Deps 22 | run: opam install odig linol linol-lwt 23 | 24 | - name: Build 25 | run: opam exec -- odig odoc --cache-dir=_doc/ linol linol-lwt || (odig log -e ; exit 1) 26 | 27 | - name: Deploy 28 | uses: peaceiris/actions-gh-pages@v3 29 | with: 30 | github_token: ${{ secrets.GITHUB_TOKEN }} 31 | publish_dir: ./_doc/html 32 | enable_jekyll: false 33 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | jobs: 8 | build4: 9 | strategy: 10 | matrix: 11 | os: 12 | - ubuntu-latest 13 | ocaml-compiler: 14 | - 4.14.x 15 | runs-on: ${{ matrix.os }} 16 | steps: 17 | - uses: actions/checkout@main 18 | with: 19 | submodules: 'recursive' 20 | - uses: ocaml/setup-ocaml@v3 21 | with: 22 | ocaml-compiler: ${{ matrix.ocaml-compiler }} 23 | dune-cache: true 24 | allow-prerelease-opam: true 25 | - run: opam pin -n . 26 | - run: opam depext -yt linol linol-lwt 27 | - run: opam install linol linol-lwt --deps-only -t 28 | - run: opam exec -- dune build -p linol,linol-lwt 29 | - run: opam exec -- dune runtest -p linol,linol-lwt 30 | if: ${{ matrix.os == 'ubuntu-latest' }} 31 | build5: 32 | strategy: 33 | matrix: 34 | os: 35 | - ubuntu-latest 36 | #- macos-latest 37 | #- windows-latest 38 | ocaml-compiler: 39 | - 5.1.x 40 | - 5.2.x 41 | - 5.3.x 42 | runs-on: ${{ matrix.os }} 43 | steps: 44 | - uses: actions/checkout@main 45 | with: 46 | submodules: 'recursive' 47 | - uses: ocaml/setup-ocaml@v3 48 | with: 49 | ocaml-compiler: ${{ matrix.ocaml-compiler }} 50 | dune-cache: true 51 | allow-prerelease-opam: true 52 | - run: opam pin -n . 53 | - run: opam depext -yt linol linol-lwt linol-eio 54 | - run: opam install -t . --deps-only 55 | - run: opam exec -- dune build 56 | - run: opam exec -- dune runtest 57 | if: ${{ matrix.os == 'ubuntu-latest' }} 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | _opam 3 | .merlin 4 | *.install 5 | target 6 | *.so 7 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/.gitmodules -------------------------------------------------------------------------------- /.ocamlformat: -------------------------------------------------------------------------------- 1 | version = 0.27.0 2 | profile=conventional 3 | margin=80 4 | if-then-else=k-r 5 | parens-ite=true 6 | parens-tuple=multi-line-only 7 | sequence-style=terminator 8 | type-decl=sparse 9 | break-cases=toplevel 10 | cases-exp-indent=2 11 | field-space=tight-decl 12 | leading-nested-match-parens=true 13 | module-item-spacing=compact 14 | quiet=true 15 | ocaml-version=4.08.0 16 | -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | 2 | # 0.10 3 | 4 | - use `git subtree` to vendor lsp+jsonrpc, so that they 5 | are not dependencies anymore and do not conflict with 6 | other users 7 | - Add `filter_text_document` to ignore some documents 8 | 9 | # 0.9 10 | 11 | - Drop redundant dependency on atomic 12 | - Add support for lsp 1.22 13 | 14 | # 0.8 15 | 16 | - move to LSP 1.19 and 1.20 17 | 18 | # 0.7 19 | 20 | - Handle `End_of_file` by exiting 21 | - Fix: make server requests thread safe 22 | - Use positionEncoding advertised by clients 23 | - Use IO.catch in async 24 | - Log exceptions in async notification handler 25 | - Add more error handlers and logging around notif/request handlers 26 | - Add on_req_shutdown 27 | 28 | # 0.6 29 | 30 | - Support textDocument/didSave notification 31 | - advertise inlay hints server capability 32 | - Implement Eio backend in `linol-eio` 33 | - jsonrpc2: add ?on_received/?on_sent 34 | - drop redundant dependency on atomic 35 | 36 | # 0.5 37 | 38 | - api break: put `spawn` in the server itself, not `IO` 39 | 40 | - require OCaml 4.14 41 | - migrate to lsp 1.17 42 | - support inlay hints 43 | - internal tracing with `trace` 44 | - [#24] Expose get_uri for notify_back 45 | - expose log source 46 | - [#22] Threat shutdown and exit requests correctly 47 | - [#20] Handle messages with null value for "params" field 48 | - Handle server requests 49 | - handle workDoneTokens 50 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @dune build @all 3 | 4 | watch: 5 | @dune build @all -w 6 | 7 | test: 8 | @dune runtest --force --no-buffer 9 | 10 | clean: 11 | @dune clean 12 | 13 | doc: 14 | @dune build @doc 15 | 16 | fmt: 17 | @dune build @fmt --auto-promote 18 | 19 | update-submodules: 20 | @git submodule update --init 21 | 22 | VERSION=$(shell awk '/^version:/ {print $$2}' linol.opam) 23 | 24 | update_next_tag: 25 | @echo "update version to $(VERSION)..." 26 | sed -i "s/NEXT_RELEASE/$(VERSION)/g" $(wildcard src/*.ml) $(wildcard src/*.mli) $(wildcard src/**/*.ml) $(wildcard src/**/*.mli) 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Linol [![build](https://github.com/c-cube/linol/actions/workflows/main.yml/badge.svg)](https://github.com/c-cube/linol/actions/workflows/main.yml) 3 | 4 | This is a wrapper around the `lsp` library, which provides base types for the protocol. Linol ("linol is not ocaml-lsp") provides an object abstraction so that users can override only the methods they provide, and a Lwt/Eio implementation of the jsonrpc wire protocol. 5 | 6 | ## License 7 | 8 | MIT license. 9 | -------------------------------------------------------------------------------- /dune: -------------------------------------------------------------------------------- 1 | (data_only_dirs thirdparty) 2 | -------------------------------------------------------------------------------- /dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 2.0) 2 | 3 | ;(implicit_transitive_deps false) 4 | 5 | (generate_opam_files true) 6 | 7 | (using menhir 2.0) 8 | 9 | (name linol) 10 | 11 | (version 0.10) 12 | 13 | (license MIT) 14 | 15 | (authors "Simon Cruanes") 16 | 17 | (maintainers "Simon Cruanes") 18 | 19 | (source 20 | (github c-cube/linol)) 21 | 22 | (package 23 | (name linol) 24 | (synopsis "LSP server library") 25 | (depends 26 | ("yojson" 27 | (>= "1.6")) 28 | "logs" 29 | ("trace" 30 | (>= "0.4")) 31 | ("ocaml" 32 | (>= "4.14")) 33 | ("odoc" :with-doc) 34 | ; The following dependencies are needed for lsp, which we vendor 35 | (uutf 36 | (>= 1.0.2)) 37 | (ppx_yojson_conv_lib 38 | (>= "v0.14")))) 39 | 40 | (package 41 | (name linol-lwt) 42 | (synopsis "LSP server library (with Lwt for concurrency)") 43 | (depends 44 | ("yojson" 45 | (>= "1.6")) 46 | ("linol" 47 | (= :version)) 48 | base-unix 49 | ("lwt" 50 | (and 51 | (>= "5.1") 52 | (< "6.0"))) 53 | ("odoc" :with-doc))) 54 | 55 | (package 56 | (name linol-eio) 57 | (authors "Nick Hu") 58 | (synopsis "LSP server library (with Eio for concurrency)") 59 | (depends 60 | ("yojson" 61 | (>= "1.6")) 62 | ("linol" 63 | (= :version)) 64 | base-unix 65 | ("eio" 66 | (and 67 | (>= "1.0") 68 | (< "2.0"))) 69 | (eio_main :with-test) 70 | ("odoc" :with-doc))) 71 | -------------------------------------------------------------------------------- /example/template-eio/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name main) 3 | (libraries 4 | ; Deps on linol + Eio backend 5 | linol 6 | linol-eio 7 | eio_main)) 8 | -------------------------------------------------------------------------------- /example/template-lwt/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name main) 3 | (libraries 4 | ; Deps on linol + LWT backend 5 | linol 6 | linol-lwt)) 7 | -------------------------------------------------------------------------------- /linol-eio.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | version: "0.10" 4 | synopsis: "LSP server library (with Eio for concurrency)" 5 | maintainer: ["Simon Cruanes"] 6 | authors: ["Nick Hu"] 7 | license: "MIT" 8 | homepage: "https://github.com/c-cube/linol" 9 | bug-reports: "https://github.com/c-cube/linol/issues" 10 | depends: [ 11 | "dune" {>= "2.0"} 12 | "yojson" {>= "1.6"} 13 | "linol" {= version} 14 | "base-unix" 15 | "eio" {>= "1.0" & < "2.0"} 16 | "eio_main" {with-test} 17 | "odoc" {with-doc} 18 | ] 19 | build: [ 20 | ["dune" "subst"] {pinned} 21 | [ 22 | "dune" 23 | "build" 24 | "-p" 25 | name 26 | "-j" 27 | jobs 28 | "@install" 29 | "@runtest" {with-test} 30 | "@doc" {with-doc} 31 | ] 32 | ] 33 | dev-repo: "git+https://github.com/c-cube/linol.git" 34 | -------------------------------------------------------------------------------- /linol-lwt.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | version: "0.10" 4 | synopsis: "LSP server library (with Lwt for concurrency)" 5 | maintainer: ["Simon Cruanes"] 6 | authors: ["Simon Cruanes"] 7 | license: "MIT" 8 | homepage: "https://github.com/c-cube/linol" 9 | bug-reports: "https://github.com/c-cube/linol/issues" 10 | depends: [ 11 | "dune" {>= "2.0"} 12 | "yojson" {>= "1.6"} 13 | "linol" {= version} 14 | "base-unix" 15 | "lwt" {>= "5.1" & < "6.0"} 16 | "odoc" {with-doc} 17 | ] 18 | build: [ 19 | ["dune" "subst"] {pinned} 20 | [ 21 | "dune" 22 | "build" 23 | "-p" 24 | name 25 | "-j" 26 | jobs 27 | "@install" 28 | "@runtest" {with-test} 29 | "@doc" {with-doc} 30 | ] 31 | ] 32 | dev-repo: "git+https://github.com/c-cube/linol.git" 33 | -------------------------------------------------------------------------------- /linol.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | version: "0.10" 4 | synopsis: "LSP server library" 5 | maintainer: ["Simon Cruanes"] 6 | authors: ["Simon Cruanes"] 7 | license: "MIT" 8 | homepage: "https://github.com/c-cube/linol" 9 | bug-reports: "https://github.com/c-cube/linol/issues" 10 | depends: [ 11 | "dune" {>= "2.0"} 12 | "yojson" {>= "1.6"} 13 | "logs" 14 | "trace" {>= "0.4"} 15 | "ocaml" {>= "4.14"} 16 | "odoc" {with-doc} 17 | "uutf" {>= "1.0.2"} 18 | "ppx_yojson_conv_lib" {>= "v0.14"} 19 | ] 20 | build: [ 21 | ["dune" "subst"] {pinned} 22 | [ 23 | "dune" 24 | "build" 25 | "-p" 26 | name 27 | "-j" 28 | jobs 29 | "@install" 30 | "@runtest" {with-test} 31 | "@doc" {with-doc} 32 | ] 33 | ] 34 | dev-repo: "git+https://github.com/c-cube/linol.git" 35 | -------------------------------------------------------------------------------- /src/blocking_IO.ml: -------------------------------------------------------------------------------- 1 | open Common_ 2 | 3 | type 'a t = 'a 4 | type env = unit 5 | type nonrec in_channel = in_channel 6 | type nonrec out_channel = out_channel 7 | 8 | let ( let+ ) x f = f x 9 | let ( let* ) x f = f x 10 | let ( and+ ) a b = a, b 11 | let return x = x 12 | let failwith = failwith 13 | let fail = Printexc.raise_with_backtrace 14 | let stdin () = stdin 15 | let stdout () = stdout 16 | 17 | let default_spawn f = 18 | let run () = 19 | let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "linol.spawn" in 20 | try f () 21 | with e -> 22 | Log.err (fun k -> 23 | k "uncaught exception in `spawn`:\n%s\n%!" (Printexc.to_string e)); 24 | raise e 25 | in 26 | ignore (Thread.create run ()) 27 | 28 | let catch f g = 29 | try f () 30 | with e -> 31 | let bt = Printexc.get_raw_backtrace () in 32 | g e bt 33 | 34 | let n_bytes_written = Atomic.make 0 35 | let n_bytes_read = Atomic.make 0 36 | 37 | let rec read ic buf i len = 38 | if len > 0 then ( 39 | let n = input ic buf i len in 40 | ignore (Atomic.fetch_and_add n_bytes_read n : int); 41 | read ic buf (i + n) (len - n) 42 | ) 43 | 44 | let read_line ic = 45 | let l = input_line ic in 46 | ignore (Atomic.fetch_and_add n_bytes_read (String.length l) : int); 47 | l 48 | 49 | let write oc b i len = 50 | output oc b i len; 51 | ignore (Atomic.fetch_and_add n_bytes_written len : int); 52 | flush oc 53 | 54 | let write_string oc s = 55 | output_string oc s; 56 | ignore (Atomic.fetch_and_add n_bytes_written (String.length s) : int); 57 | flush oc 58 | -------------------------------------------------------------------------------- /src/blocking_IO.mli: -------------------------------------------------------------------------------- 1 | (** Blocking IO with a new thread for each [spawn]. *) 2 | 3 | include 4 | Sigs.IO 5 | with type 'a t = 'a 6 | and type env = unit 7 | and type in_channel = in_channel 8 | and type out_channel = out_channel 9 | 10 | val n_bytes_written : int Atomic.t 11 | (** @since 0.5 *) 12 | 13 | val n_bytes_read : int Atomic.t 14 | (** @since 0.5 *) 15 | 16 | val default_spawn : (unit -> unit) -> unit 17 | (** Start a new thread. 18 | @since 0.5 *) 19 | -------------------------------------------------------------------------------- /src/common_.ml: -------------------------------------------------------------------------------- 1 | module Lsp = Linol_lsp.Lsp 2 | module Jsonrpc = Linol_jsonrpc.Jsonrpc 3 | module Trace = Trace_core 4 | 5 | let ( let@ ) = ( @@ ) 6 | let spf = Printf.sprintf 7 | -------------------------------------------------------------------------------- /src/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name linol) 3 | (public_name linol) 4 | (private_modules log) 5 | (flags :standard -warn-error -a+8) 6 | (libraries 7 | yojson 8 | logs 9 | threads 10 | trace.core 11 | (re_export linol.lsp) 12 | (re_export linol.jsonrpc))) 13 | -------------------------------------------------------------------------------- /src/eio/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name linol_eio) 3 | (public_name linol-eio) 4 | (libraries eio eio.unix linol linol.lsp linol.jsonrpc) 5 | (flags :standard -warn-error -a)) 6 | -------------------------------------------------------------------------------- /src/eio/linol_eio.ml: -------------------------------------------------------------------------------- 1 | open struct 2 | module Lsp = Linol_lsp.Lsp 3 | end 4 | 5 | module type IO = Linol.IO 6 | 7 | module IO_eio : 8 | IO 9 | with type 'a t = 'a 10 | and type env = Eio_unix.Stdenv.base 11 | and type in_channel = Eio.Buf_read.t 12 | and type out_channel = Eio_unix.sink_ty Eio.Std.r = struct 13 | type 'a t = 'a 14 | 15 | let ( let+ ) x f = f x 16 | let ( let* ) x f = f x 17 | let ( and+ ) a b = a, b 18 | let return x = x 19 | let failwith = failwith 20 | let fail = raise 21 | 22 | let catch f handler = 23 | try f () 24 | with exn -> 25 | let bt = Printexc.get_raw_backtrace () in 26 | handler exn bt 27 | 28 | let stdin env = 29 | Eio.Buf_read.of_flow ~max_size:1_000_000 (Eio.Stdenv.stdin env) 30 | 31 | let stdout = Eio.Stdenv.stdout 32 | 33 | type env = Eio_unix.Stdenv.base 34 | type in_channel = Eio.Buf_read.t 35 | type out_channel = Eio_unix.sink_ty Eio.Std.r 36 | 37 | let write_string out_ch str = Eio.Flow.copy_string str out_ch 38 | 39 | let write out_ch bytes off len = 40 | Eio.Buf_write.with_flow out_ch @@ fun w -> 41 | Eio.Buf_write.bytes w ~off ~len bytes 42 | 43 | let read in_ch bytes off len = 44 | let str = Eio.Buf_read.take len in_ch in 45 | Bytes.blit_string str off bytes 0 len 46 | 47 | let read_line in_ch = Eio.Buf_read.line in_ch 48 | end 49 | 50 | (** Spawn function. *) 51 | let spawn f = 52 | let promise, resolver = Eio.Promise.create () in 53 | (try 54 | f (); 55 | Eio.Promise.resolve_ok resolver () 56 | with exn -> 57 | Printf.eprintf "uncaught exception in `spawn`:\n%s\n%!" 58 | (Printexc.to_string exn); 59 | Eio.Promise.resolve_error resolver exn); 60 | 61 | Eio.Promise.await_exn promise 62 | 63 | include Lsp.Types 64 | include IO_eio 65 | 66 | type doc_state = Linol.Server.doc_state 67 | 68 | module Jsonrpc2 = Linol.Jsonrpc2.Make (IO_eio) 69 | -------------------------------------------------------------------------------- /src/jsonrpc2.mli: -------------------------------------------------------------------------------- 1 | (** Simple JSON-RPC2 implementation. 2 | 3 | See {{:https://www.jsonrpc.org/specification} the spec} *) 4 | 5 | open Common_ 6 | 7 | type json = Yojson.Safe.t 8 | 9 | module type IO = Sigs.IO 10 | 11 | module type S = sig 12 | module IO : IO 13 | 14 | type t 15 | (** A jsonrpc2 connection. *) 16 | 17 | include module type of Server.Make (IO) 18 | 19 | val create : 20 | ?on_received:(json -> unit) -> 21 | ?on_sent:(json -> unit) -> 22 | ic:IO.in_channel -> 23 | oc:IO.out_channel -> 24 | server -> 25 | t 26 | (** Create a connection from the pair of channels *) 27 | 28 | val create_stdio : 29 | ?on_received:(json -> unit) -> 30 | ?on_sent:(json -> unit) -> 31 | env:IO.env -> 32 | server -> 33 | t 34 | (** Create a connection using stdin/stdout *) 35 | 36 | val send_server_notification : t -> Lsp.Server_notification.t -> unit IO.t 37 | (** Send a notification from the server. 38 | @since 0.5 *) 39 | 40 | val send_server_request : 41 | t -> 42 | 'from_server Lsp.Server_request.t -> 43 | (('from_server, Jsonrpc.Response.Error.t) result -> unit IO.t) -> 44 | Req_id.t IO.t 45 | (** Send a request from the server, and pass a callback that will be called 46 | with the result in the future. 47 | @since 0.5 *) 48 | 49 | val run : ?shutdown:(unit -> bool) -> t -> unit IO.t 50 | (** Listen for incoming messages and responses. 51 | @param shutdown if true, tells the server to shut down *) 52 | end 53 | 54 | module Make (IO : IO) : S with module IO = IO 55 | -------------------------------------------------------------------------------- /src/linol.ml: -------------------------------------------------------------------------------- 1 | (** Linol. 2 | 3 | Abstraction over The "Lsp" library, to make it easier to develop LSP servers 4 | in OCaml (but not necessarily {b for} OCaml). *) 5 | 6 | module type IO = Sigs.IO 7 | 8 | (** {2 Re-export from vendored lsp} *) 9 | 10 | module Lsp = Linol_lsp.Lsp 11 | module Jsonrpc = Linol_jsonrpc.Jsonrpc 12 | 13 | (** {2 Main modules} *) 14 | 15 | module Jsonrpc2 = Jsonrpc2 16 | module Server = Server 17 | module Blocking_IO = Blocking_IO 18 | module Log = Log 19 | module Make = Jsonrpc2.Make 20 | 21 | let logs_src = Log.src 22 | -------------------------------------------------------------------------------- /src/log.ml: -------------------------------------------------------------------------------- 1 | let src = Logs.Src.create ~doc:"linol (LSP library)" "linol" 2 | 3 | include (val Logs.src_log src) 4 | -------------------------------------------------------------------------------- /src/lwt/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name linol_lwt) 3 | (public_name linol-lwt) 4 | (libraries yojson lwt lwt.unix linol linol.lsp linol.jsonrpc) 5 | (flags :standard -warn-error -a)) 6 | -------------------------------------------------------------------------------- /src/lwt/linol_lwt.ml: -------------------------------------------------------------------------------- 1 | open struct 2 | module Lsp = Linol_lsp.Lsp 3 | end 4 | 5 | module type IO = Linol.IO 6 | 7 | module IO_lwt : 8 | IO 9 | with type 'a t = 'a Lwt.t 10 | and type env = unit 11 | and type in_channel = Lwt_io.input Lwt_io.channel 12 | and type out_channel = Lwt_io.output Lwt_io.channel = struct 13 | type 'a t = 'a Lwt.t 14 | 15 | let ( let+ ) = Lwt.( >|= ) 16 | let ( let* ) = Lwt.( >>= ) 17 | 18 | let ( and+ ) a b = 19 | let open Lwt in 20 | a >>= fun x -> 21 | b >|= fun y -> x, y 22 | 23 | let return = Lwt.return 24 | let failwith = Lwt.fail_with 25 | let stdin () = Lwt_io.stdin 26 | let stdout () = Lwt_io.stdout 27 | 28 | type env = unit 29 | type in_channel = Lwt_io.input Lwt_io.channel 30 | type out_channel = Lwt_io.output Lwt_io.channel 31 | 32 | let write_string = Lwt_io.write 33 | let write = Lwt_io.write_from_exactly 34 | let read = Lwt_io.read_into_exactly 35 | let read_line = Lwt_io.read_line 36 | 37 | let catch f g = 38 | let bt = Printexc.get_callstack 10 in 39 | Lwt.catch f (fun exn -> g exn bt) 40 | 41 | let fail e _bt = Lwt.fail e 42 | end 43 | 44 | (** Spawn function. 45 | @since 0.5 *) 46 | let spawn f = 47 | Lwt.async (fun () -> 48 | Lwt.catch f (fun exn -> 49 | Printf.eprintf "uncaught exception in `spawn`:\n%s\n%!" 50 | (Printexc.to_string exn); 51 | Lwt.return ())) 52 | 53 | include Lsp.Types 54 | include IO_lwt 55 | 56 | type doc_state = Linol.Server.doc_state 57 | 58 | module Jsonrpc2 = Linol.Jsonrpc2.Make (IO_lwt) 59 | 60 | let run = Lwt_main.run 61 | -------------------------------------------------------------------------------- /src/sigs.ml: -------------------------------------------------------------------------------- 1 | (** {2 Parametrized IO Interface} *) 2 | module type IO = sig 3 | type 'a t 4 | 5 | val return : 'a -> 'a t 6 | val failwith : string -> 'a t 7 | val ( let+ ) : 'a t -> ('a -> 'b) -> 'b t 8 | val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t 9 | val ( and+ ) : 'a t -> 'b t -> ('a * 'b) t 10 | 11 | type env 12 | type in_channel 13 | type out_channel 14 | 15 | val stdin : env -> in_channel 16 | val stdout : env -> out_channel 17 | val read : in_channel -> bytes -> int -> int -> unit t 18 | val read_line : in_channel -> string t 19 | val write : out_channel -> bytes -> int -> int -> unit t 20 | val write_string : out_channel -> string -> unit t 21 | val fail : exn -> Printexc.raw_backtrace -> unit t 22 | val catch : (unit -> 'a t) -> (exn -> Printexc.raw_backtrace -> 'a t) -> 'a t 23 | end 24 | -------------------------------------------------------------------------------- /thirdparty/lsp/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [Makefile] 11 | indent_style = tab 12 | -------------------------------------------------------------------------------- /thirdparty/lsp/.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # To understand why we need this file, see https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame 2 | 3 | # add ocamlformat config `wrap-fun-args=false` 4 | 5 | 75504946eaa6f817550b649df508d61dde12bbda 6 | # Upgrade to OCamlformat 0.26.0 7 | ab49baa5873e7f0b9181dbed3ad89681f1e4bcee 8 | # Upgrade to OCamlformat 0.26.1 9 | 1a6419bac3ce012deb9c6891e6b25e2486c33388 10 | # Upgrade to OCamlformat 0.27.0 11 | 2ccbee5dd691690228307d3636e2f82c8cdb3902 12 | -------------------------------------------------------------------------------- /thirdparty/lsp/.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: / 5 | schedule: 6 | interval: weekly 7 | labels: 8 | - dependencies 9 | - no changelog 10 | - package-ecosystem: npm 11 | directory: / 12 | schedule: 13 | interval: daily 14 | labels: 15 | - dependencies 16 | - no changelog 17 | -------------------------------------------------------------------------------- /thirdparty/lsp/.github/workflows/changelog.yml: -------------------------------------------------------------------------------- 1 | name: Changelog check 2 | 3 | on: 4 | pull_request: 5 | branches: [master] 6 | types: [opened, synchronize, reopened, labeled, unlabeled] 7 | 8 | jobs: 9 | Changelog-Entry-Check: 10 | name: Check Changelog Action 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: tarides/changelog-check-action@v3 14 | -------------------------------------------------------------------------------- /thirdparty/lsp/.github/workflows/nix.yml: -------------------------------------------------------------------------------- 1 | name: "Nix" 2 | on: 3 | pull_request: 4 | push: 5 | branches: 6 | - master 7 | jobs: 8 | # tests: 9 | # runs-on: ubuntu-latest 10 | # steps: 11 | # - name: Checkout tree 12 | # uses: actions/checkout@v4 13 | # with: 14 | # submodules: true 15 | # - name: nix 16 | # uses: cachix/install-nix-action@v30 17 | # with: 18 | # nix_path: nixpkgs=channel:nixos-unstable 19 | # - run: nix develop .#check -c make nix-tests 20 | fmt: 21 | runs-on: ubuntu-latest 22 | steps: 23 | - name: Checkout tree 24 | uses: actions/checkout@v4 25 | with: 26 | submodules: true 27 | - name: nix 28 | uses: cachix/install-nix-action@v30 29 | with: 30 | nix_path: nixpkgs=channel:nixos-unstable 31 | - run: nix develop .#fmt -c make nix-fmt 32 | -------------------------------------------------------------------------------- /thirdparty/lsp/.github/workflows/update-flake-lock.yml: -------------------------------------------------------------------------------- 1 | name: Update Nix Flake Lock 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: 0 0 * * 0 7 | 8 | jobs: 9 | lockfile: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout code 13 | uses: actions/checkout@v4 14 | - uses: cachix/install-nix-action@v30 15 | with: 16 | nix_path: nixpkgs=channel:nixos-unstable 17 | - uses: DeterminateSystems/update-flake-lock@v24 18 | with: 19 | pr-labels: | 20 | dependencies 21 | no changelog 22 | -------------------------------------------------------------------------------- /thirdparty/lsp/.gitignore: -------------------------------------------------------------------------------- 1 | _build/ 2 | _opam/ 3 | .idea/ 4 | .log/ 5 | .vscode/ 6 | node_modules/ 7 | tmp/ 8 | .DS_Store 9 | .merlin 10 | *.install 11 | *.log 12 | result 13 | -------------------------------------------------------------------------------- /thirdparty/lsp/.ocamlformat: -------------------------------------------------------------------------------- 1 | version=0.27.0 2 | profile=janestreet 3 | ocaml-version=4.14.0 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/.ocamlformat-ignore: -------------------------------------------------------------------------------- 1 | vendor 2 | _opam 3 | _esy 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | This project has adopted the [OCaml Code of Conduct](https://github.com/ocaml/code-of-conduct/blob/main/CODE_OF_CONDUCT.md). 4 | 5 | # Enforcement 6 | 7 | This project follows the OCaml Code of Conduct 8 | [enforcement policy](https://github.com/ocaml/code-of-conduct/blob/main/CODE_OF_CONDUCT.md#enforcement). 9 | To report any violations, please contact: 10 | 11 | - Sonja Heinze 12 | - Ulysse Gérard 13 | - Xavier Van de Woestyne 14 | -------------------------------------------------------------------------------- /thirdparty/lsp/LICENSE.md: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (X) 2018-2019, the [ocaml-lsp 4 | contributors](https://github.com/ocaml/ocaml-lsp/graphs/contributors) 5 | 6 | Permission to use, copy, modify, and distribute this software for any 7 | purpose with or without fee is hereby granted, provided that the above 8 | copyright notice and this permission notice appear in all copies. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | -------------------------------------------------------------------------------- /thirdparty/lsp/biome.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "node_modules/@biomejs/biome/configuration_schema.json", 3 | "formatter": { 4 | "enabled": true, 5 | "ignore": ["lsp/bin/metamodel/metaModel.json", "package.json"], 6 | "useEditorconfig": true 7 | }, 8 | "linter": { 9 | "enabled": true, 10 | "ignore": ["ocaml-lsp-server/test/e2e/**"], 11 | "rules": { 12 | "recommended": true 13 | } 14 | }, 15 | "organizeImports": { 16 | "enabled": true 17 | }, 18 | "vcs": { 19 | "clientKind": "git", 20 | "enabled": true, 21 | "useIgnoreFile": true 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /thirdparty/lsp/dune: -------------------------------------------------------------------------------- 1 | (vendored_dirs vendor) 2 | 3 | (data_only_dirs submodules) 4 | 5 | (rule 6 | (copy lsp.opam.template jsonrpc.opam.template)) 7 | 8 | (rule 9 | (copy lsp.opam.template ocaml-lsp-server.opam.template)) 10 | 11 | (env 12 | (_ 13 | (flags :standard -alert -unstable -w -58))) 14 | -------------------------------------------------------------------------------- /thirdparty/lsp/fiber-test/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name fiber_test) 3 | (libraries fiber stdune dyn pp)) 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/fiber-test/fiber_test.ml: -------------------------------------------------------------------------------- 1 | open Stdune 2 | 3 | let print pp = Format.printf "%a@." Pp.to_fmt pp 4 | let print_dyn dyn = print (Dyn.pp dyn) 5 | 6 | module Scheduler : sig 7 | type t 8 | 9 | exception Never 10 | 11 | val create : unit -> t 12 | val run : t -> 'a Fiber.t -> 'a 13 | end = struct 14 | type t = unit Fiber.Ivar.t Queue.t 15 | 16 | let t_var = Fiber.Var.create () 17 | let create () = Queue.create () 18 | 19 | exception Never 20 | 21 | let run t fiber = 22 | let fiber = Fiber.Var.set t_var t (fun () -> fiber) in 23 | Fiber.run fiber ~iter:(fun () -> 24 | let next = 25 | match Queue.pop t with 26 | | None -> raise Never 27 | | Some e -> Fiber.Fill (e, ()) 28 | in 29 | Nonempty_list.[ next ]) 30 | ;; 31 | end 32 | 33 | let test ?(expect_never = false) to_dyn f = 34 | let never_raised = ref false in 35 | let f = 36 | let on_error exn = 37 | Format.eprintf "%a@." Exn_with_backtrace.pp_uncaught exn; 38 | Exn_with_backtrace.reraise exn 39 | in 40 | Fiber.with_error_handler f ~on_error 41 | in 42 | (try Scheduler.run (Scheduler.create ()) f |> to_dyn |> print_dyn with 43 | | Scheduler.Never -> never_raised := true); 44 | match !never_raised, expect_never with 45 | | false, false -> 46 | (* We don't raise in this case b/c we assume something else is being 47 | tested *) 48 | () 49 | | true, true -> print_endline "[PASS] Never raised as expected" 50 | | false, true -> print_endline "[FAIL] expected Never to be raised but it wasn't" 51 | | true, false -> print_endline "[FAIL] unexpected Never raised" 52 | ;; 53 | -------------------------------------------------------------------------------- /thirdparty/lsp/fiber-test/fiber_test.mli: -------------------------------------------------------------------------------- 1 | val test : ?expect_never:bool -> ('a -> Dyn.t) -> (unit -> 'a Fiber.t) -> unit 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/jsonrpc-fiber/src/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name jsonrpc_fiber) 3 | (libraries fiber dyn jsonrpc ppx_yojson_conv_lib stdune yojson) 4 | (instrumentation 5 | (backend bisect_ppx))) 6 | -------------------------------------------------------------------------------- /thirdparty/lsp/jsonrpc-fiber/test/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name jsonrpc_fiber_tests) 3 | (enabled_if 4 | (>= %{ocaml_version} 4.08)) 5 | (inline_tests) 6 | (libraries 7 | base 8 | dyn 9 | fiber 10 | fiber_test 11 | jsonrpc 12 | jsonrpc_fiber 13 | ;; This is because of the (implicit_transitive_deps false) 14 | ;; in dune-project 15 | ppx_expect 16 | ppx_expect.config 17 | ppx_expect.config_types 18 | ppx_inline_test.config 19 | stdune 20 | yojson) 21 | (preprocess 22 | (pps ppx_expect))) 23 | -------------------------------------------------------------------------------- /thirdparty/lsp/jsonrpc-fiber/test/jsonrpc_fiber_tests.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/jsonrpc-fiber/test/jsonrpc_fiber_tests.mli -------------------------------------------------------------------------------- /thirdparty/lsp/jsonrpc.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | synopsis: "Jsonrpc protocol implemenation" 4 | description: "See https://www.jsonrpc.org/specification" 5 | maintainer: ["Rudi Grinberg "] 6 | authors: [ 7 | "Andrey Popp <8mayday@gmail.com>" 8 | "Rusty Key " 9 | "Louis Roché " 10 | "Oleksiy Golovko " 11 | "Rudi Grinberg " 12 | "Sacha Ayoun " 13 | "cannorin " 14 | "Ulugbek Abdullaev " 15 | "Thibaut Mattio " 16 | "Max Lantas " 17 | ] 18 | license: "ISC" 19 | homepage: "https://github.com/ocaml/ocaml-lsp" 20 | bug-reports: "https://github.com/ocaml/ocaml-lsp/issues" 21 | depends: [ 22 | "dune" {>= "3.0"} 23 | "ocaml" {>= "4.08"} 24 | "odoc" {with-doc} 25 | ] 26 | dev-repo: "git+https://github.com/ocaml/ocaml-lsp.git" 27 | build: [ 28 | ["dune" "subst"] {dev} 29 | [ 30 | "dune" 31 | "build" 32 | "-p" 33 | name 34 | "-j" 35 | jobs 36 | "@install" 37 | "@doc" {with-doc} 38 | ] 39 | ] 40 | 41 | x-maintenance-intent: [ "(latest)" "(latest)-414" ] 42 | -------------------------------------------------------------------------------- /thirdparty/lsp/jsonrpc/src/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (public_name jsonrpc) 3 | (instrumentation 4 | (backend bisect_ppx))) 5 | -------------------------------------------------------------------------------- /thirdparty/lsp/jsonrpc/src/import.ml: -------------------------------------------------------------------------------- 1 | module List = ListLabels 2 | 3 | module Option = struct 4 | let map t ~f = 5 | match t with 6 | | None -> None 7 | | Some x -> Some (f x) 8 | ;; 9 | end 10 | 11 | module Json = struct 12 | type t = 13 | [ `Assoc of (string * t) list 14 | | `Bool of bool 15 | | `Float of float 16 | | `Int of int 17 | | `Intlit of string 18 | | `List of t list 19 | | `Null 20 | | `String of string 21 | | `Tuple of t list 22 | | `Variant of string * t option 23 | ] 24 | 25 | exception Of_json of (string * t) 26 | 27 | let () = 28 | Printexc.register_printer (function 29 | | Of_json (msg, _) -> Some ("Jsonrpc: json conversion failed: " ^ msg) 30 | | _ -> None) 31 | ;; 32 | 33 | let error msg json = raise (Of_json (msg, json)) 34 | 35 | module Jsonable = struct 36 | module type S = sig 37 | type json 38 | type t 39 | 40 | val yojson_of_t : t -> json 41 | val t_of_yojson : json -> t 42 | end 43 | with type json := t 44 | end 45 | 46 | let field fields name conv = List.assoc_opt name fields |> Option.map ~f:conv 47 | 48 | let field_exn fields name conv = 49 | match field fields name conv with 50 | | Some f -> f 51 | | None -> error ("missing field " ^ name) (`Assoc fields) 52 | ;; 53 | 54 | module Conv = struct 55 | let string_of_yojson = function 56 | | `String s -> s 57 | | json -> error "expected string" json 58 | ;; 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp-fiber/src/client.ml: -------------------------------------------------------------------------------- 1 | include Rpc.Client 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp-fiber/src/client.mli: -------------------------------------------------------------------------------- 1 | include module type of Rpc.Client 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp-fiber/src/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name lsp_fiber) 3 | (libraries 4 | dyn 5 | fiber 6 | lev_fiber 7 | jsonrpc 8 | jsonrpc_fiber 9 | lsp 10 | ppx_yojson_conv_lib 11 | stdune 12 | yojson) 13 | (instrumentation 14 | (backend bisect_ppx))) 15 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp-fiber/src/fiber_io.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | open Fiber.O 3 | module Lio = Lev_fiber.Io 4 | 5 | type t = Lio.input Lio.t * Lio.output Lio.t * Fiber.Mutex.t 6 | 7 | module Io = 8 | Io.Make 9 | (struct 10 | include Fiber 11 | 12 | let raise exn = raise exn 13 | end) 14 | (struct 15 | type input = Lio.Reader.t 16 | type output = Lio.Writer.t 17 | 18 | let read_line ic = 19 | let+ res = Lio.Reader.read_line ic in 20 | match res with 21 | | Ok s -> Some s 22 | | Error (`Partial_eof _) -> None 23 | ;; 24 | 25 | let read_exactly ic len = 26 | let+ res = Lio.Reader.read_exactly ic len in 27 | match res with 28 | | Ok s -> Some s 29 | | Error (`Partial_eof _) -> None 30 | ;; 31 | 32 | let write oc strings = 33 | Fiber.of_thunk (fun () -> 34 | List.iter strings ~f:(Lio.Writer.add_string oc); 35 | Fiber.return ()) 36 | ;; 37 | end) 38 | 39 | let send (_, oc, m) packets = 40 | Fiber.Mutex.with_lock m ~f:(fun () -> 41 | Lio.with_write oc ~f:(fun writer -> 42 | let* () = Fiber.sequential_iter packets ~f:(Io.write writer) in 43 | Lio.Writer.flush writer)) 44 | ;; 45 | 46 | let recv (ic, _, _) = Lio.with_read ic ~f:Io.read 47 | let make ic oc = ic, oc, Fiber.Mutex.create () 48 | 49 | let close (ic, oc, _) what = 50 | Fiber.of_thunk (fun () -> 51 | (match what with 52 | | `Write -> Lio.close oc 53 | | `Read -> Lio.close ic); 54 | Fiber.return ()) 55 | ;; 56 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp-fiber/src/fiber_io.mli: -------------------------------------------------------------------------------- 1 | (** Reprsents a bi-directional jsonrpc packet stream read in dedicated threads. 2 | 3 | TODO Nothing here is specific to jsonrpc *) 4 | open! Import 5 | 6 | type t 7 | 8 | val close : t -> [ `Read | `Write ] -> unit Fiber.t 9 | val send : t -> Jsonrpc.Packet.t list -> unit Fiber.t 10 | val recv : t -> Jsonrpc.Packet.t option Fiber.t 11 | val make : Lev_fiber.Io.input Lev_fiber.Io.t -> Lev_fiber.Io.output Lev_fiber.Io.t -> t 12 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp-fiber/src/lazy_fiber.ml: -------------------------------------------------------------------------------- 1 | type 'a t = 2 | { value : 'a Fiber.Ivar.t 3 | ; mutable f : (unit -> 'a Fiber.t) option 4 | } 5 | 6 | let create f = { f = Some f; value = Fiber.Ivar.create () } 7 | 8 | let force t = 9 | let open Fiber.O in 10 | match t.f with 11 | | None -> Fiber.Ivar.read t.value 12 | | Some f -> 13 | Fiber.of_thunk (fun () -> 14 | t.f <- None; 15 | let* v = f () in 16 | let+ () = Fiber.Ivar.fill t.value v in 17 | v) 18 | ;; 19 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp-fiber/src/lazy_fiber.mli: -------------------------------------------------------------------------------- 1 | type 'a t 2 | 3 | val create : (unit -> 'a Fiber.t) -> 'a t 4 | val force : 'a t -> 'a Fiber.t 5 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp-fiber/src/lsp_fiber.ml: -------------------------------------------------------------------------------- 1 | module Fiber_io = Fiber_io 2 | module Lazy_fiber = Lazy_fiber 3 | module Rpc = Rpc 4 | module Client = Client 5 | module Server = Server 6 | module Json = Import.Json 7 | 8 | module Private = struct 9 | module Log = Import.Log 10 | module Fdecl = Import.Fdecl 11 | end 12 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp-fiber/src/server.ml: -------------------------------------------------------------------------------- 1 | include Rpc.Server 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp-fiber/src/server.mli: -------------------------------------------------------------------------------- 1 | open! Import 2 | include module type of Rpc.Server 3 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp-fiber/test/dune: -------------------------------------------------------------------------------- 1 | ; we cannot use the normal test alias because cinaps overtakes it 2 | 3 | (library 4 | (name lsp_fiber_tests) 5 | (inline_tests) 6 | (preprocess 7 | (pps ppx_expect)) 8 | (enabled_if 9 | (>= %{ocaml_version} 4.08)) 10 | (libraries 11 | base 12 | fiber 13 | fiber_test 14 | lev 15 | lev_fiber 16 | jsonrpc 17 | jsonrpc_fiber 18 | lsp 19 | lsp_fiber 20 | ;; This is because of the (implicit_transitive_deps false) 21 | ;; in dune-project 22 | ppx_expect 23 | ppx_expect.config 24 | ppx_expect.config_types 25 | ppx_inline_test.config 26 | ppx_yojson_conv_lib 27 | stdune 28 | threads.posix 29 | yojson)) 30 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp-fiber/test/lsp_fiber_test.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/lsp-fiber/test/lsp_fiber_test.mli -------------------------------------------------------------------------------- /thirdparty/lsp/lsp.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | synopsis: "LSP protocol implementation in OCaml" 4 | description: """ 5 | 6 | Implementation of the LSP protocol in OCaml. It is designed to be as portable as 7 | possible and does not make any assumptions about IO. 8 | """ 9 | maintainer: ["Rudi Grinberg "] 10 | authors: [ 11 | "Andrey Popp <8mayday@gmail.com>" 12 | "Rusty Key " 13 | "Louis Roché " 14 | "Oleksiy Golovko " 15 | "Rudi Grinberg " 16 | "Sacha Ayoun " 17 | "cannorin " 18 | "Ulugbek Abdullaev " 19 | "Thibaut Mattio " 20 | "Max Lantas " 21 | ] 22 | license: "ISC" 23 | homepage: "https://github.com/ocaml/ocaml-lsp" 24 | bug-reports: "https://github.com/ocaml/ocaml-lsp/issues" 25 | depends: [ 26 | "dune" {>= "3.0"} 27 | "jsonrpc" {= version} 28 | "yojson" 29 | "ppx_yojson_conv_lib" {>= "v0.14"} 30 | "cinaps" {with-test} 31 | "ppx_expect" {>= "v0.17.0" & with-test} 32 | "uutf" {>= "1.0.2"} 33 | "odoc" {with-doc} 34 | "ocaml" {>= "4.14"} 35 | "ppx_yojson_conv" {with-dev-setup} 36 | ] 37 | dev-repo: "git+https://github.com/ocaml/ocaml-lsp.git" 38 | build: [ 39 | ["dune" "subst"] {dev} 40 | [ 41 | "dune" 42 | "build" 43 | "-p" 44 | name 45 | "-j" 46 | jobs 47 | "@install" 48 | "@doc" {with-doc} 49 | ] 50 | ] 51 | 52 | x-maintenance-intent: [ "(latest)" "(latest)-414" ] 53 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp.opam.template: -------------------------------------------------------------------------------- 1 | build: [ 2 | ["dune" "subst"] {dev} 3 | [ 4 | "dune" 5 | "build" 6 | "-p" 7 | name 8 | "-j" 9 | jobs 10 | "@install" 11 | "@doc" {with-doc} 12 | ] 13 | ] 14 | 15 | x-maintenance-intent: [ "(latest)" "(latest)-414" ] 16 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/bin/cinaps.mli: -------------------------------------------------------------------------------- 1 | val print_ml : unit -> unit 2 | val print_mli : unit -> unit 3 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/bin/dune: -------------------------------------------------------------------------------- 1 | (include_subdirs unqualified) 2 | 3 | (test 4 | (name test_metamodel) 5 | (modules test_metamodel) 6 | (libraries stdune yojson lsp_gen) 7 | (deps metamodel/metaModel.json) 8 | (action 9 | (run ./test_metamodel.exe %{deps}))) 10 | 11 | (library 12 | (name lsp_gen) 13 | (instrumentation 14 | (backend bisect_ppx)) 15 | (modules :standard \ test_metamodel) 16 | (libraries stdune dyn pp yojson)) 17 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/bin/import.ml: -------------------------------------------------------------------------------- 1 | include struct 2 | open Stdune 3 | module List = List 4 | module Id = Id 5 | module String = String 6 | module Code_error = Code_error 7 | module Comparable = Comparable 8 | module Top_closure = Top_closure 9 | module Poly = Poly 10 | module Option = Option 11 | 12 | let sprintf = sprintf 13 | end 14 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/bin/lsp_gen.ml: -------------------------------------------------------------------------------- 1 | module Typescript = Typescript 2 | module Ocaml = Ocaml 3 | module Cinaps = Cinaps 4 | module Metamodel = Metamodel 5 | 6 | let print_ml = Cinaps.print_ml 7 | let print_mli = Cinaps.print_mli 8 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/bin/metamodel/dune: -------------------------------------------------------------------------------- 1 | ; get rid of this gross hack once dune has proper crunch support 2 | 3 | (rule 4 | (with-stdout-to 5 | metamodel_lsp.ml 6 | (progn 7 | (echo "let t () = Metamodel.t @@ Yojson.Safe.from_string {json|") 8 | (echo "%{read:metaModel.json}") 9 | (echo "|json}")))) 10 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/bin/named.ml: -------------------------------------------------------------------------------- 1 | type 'a t = 2 | { name : string 3 | ; data : 'a 4 | } 5 | 6 | let make ~name data = { name; data } 7 | let data t = t.data 8 | let name t = t.name 9 | let map t ~f = { t with data = f t.data } 10 | let set_data t data = { t with data } 11 | 12 | let to_dyn f { name; data } = 13 | let open Dyn in 14 | record [ "name", String name; "data", f data ] 15 | ;; 16 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/bin/ocaml/json_gen.mli: -------------------------------------------------------------------------------- 1 | val json_t : Ml.Type.t 2 | val add_json_conv_for_t : Ml.Module.sig_ Ml.Module.t -> Ml.Module.sig_ Ml.Module.t 3 | 4 | module Enum : sig 5 | val conv 6 | : allow_other:bool 7 | -> poly:bool 8 | -> (string * Ts_types.Literal.t) list Named.t 9 | -> Ml.Expr.toplevel Named.t list 10 | end 11 | 12 | module Poly_variant : sig 13 | val of_json : Ml.Type.constr list Named.t -> Ml.Expr.toplevel Named.t 14 | val to_json : Ml.Type.constr list Named.t -> Ml.Expr.toplevel Named.t 15 | end 16 | 17 | val make_literal_wrapper_conv 18 | : field_name:string 19 | -> literal_value:string 20 | -> type_name:string 21 | -> Ml.Module.impl Named.t list 22 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/bin/ocaml/ml_create.mli: -------------------------------------------------------------------------------- 1 | (* Generate create functions with optional/labeled arguments *) 2 | val intf_of_type : Ml.Type.decl Named.t -> Ml.Module.sig_ Named.t list 3 | val impl_of_type : Ml.Type.decl Named.t -> Ml.Module.impl Named.t list 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/bin/ocaml/ml_kind.ml: -------------------------------------------------------------------------------- 1 | open! Import 2 | 3 | type 'a t = 4 | { intf : 'a 5 | ; impl : 'a 6 | } 7 | 8 | type kind = 9 | | Impl 10 | | Intf 11 | 12 | let get { intf; impl } = function 13 | | Impl -> impl 14 | | Intf -> intf 15 | ;; 16 | 17 | let make_both a = { intf = a; impl = a } 18 | 19 | let iter { intf; impl } ~f = 20 | f intf; 21 | f impl 22 | ;; 23 | 24 | let map { intf; impl } ~f = { intf = f intf; impl = f impl } 25 | 26 | let both (type a b) (x : a t) (y : b t) : (a * b) t = 27 | { intf = x.intf, y.intf; impl = x.impl, y.impl } 28 | ;; 29 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/bin/ocaml/ocaml.mli: -------------------------------------------------------------------------------- 1 | module Module : sig 2 | type t = (Ml.Module.sig_ Ml.Module.t, Ml.Module.impl Ml.Module.t) Ml.Kind.pair 3 | 4 | val pp : t -> unit Pp.t Ml.Kind.Map.t 5 | end 6 | 7 | val of_typescript : Ts_types.Unresolved.t list -> Module.t list 8 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/bin/ocaml/w.mli: -------------------------------------------------------------------------------- 1 | (** Helpers to generate OCaml code. Consider merging with ML *) 2 | 3 | type t = unit Pp.t 4 | type w = t 5 | 6 | val surround : [ `Curly | `Paren | `Square ] -> 'a Pp.t -> 'a Pp.t 7 | 8 | module Json : sig 9 | val invalid_pat : string -> w * w 10 | val typ : string 11 | 12 | module Literal : sig 13 | val str : string -> string 14 | val int : int -> string 15 | val null : string 16 | val bool : bool -> string 17 | end 18 | 19 | val str : string -> string 20 | val int : string -> string 21 | val bool : string -> string 22 | end 23 | 24 | module Attr : sig 25 | type t 26 | 27 | val make : string -> unit Pp.t list -> t 28 | end 29 | 30 | module Type : sig 31 | val string : w 32 | val int : w 33 | val bool : w 34 | val name : string -> w 35 | val and_ : string -> w -> w 36 | val decl : string -> w -> w 37 | val record : (string * w) list -> w 38 | val field_attrs : field:w -> attrs:Attr.t list -> w 39 | val rec_decls : (string * w) list -> w 40 | val var : string -> w 41 | val poly : (string * w list) list -> w 42 | val app : w -> w list -> w 43 | val tuple : w list -> w 44 | val deriving : w -> record:bool -> w 45 | val opt_attr : w 46 | val opt_field : w -> w 47 | val default : w -> string -> w 48 | val key : string -> w 49 | val variant : (string * w list) list -> w 50 | end 51 | 52 | module Sig : sig 53 | val module_ : string -> w -> w 54 | val include_ : string -> (w * w) list -> w 55 | val val_ : string -> w list -> w 56 | val assoc : w -> w -> w 57 | end 58 | 59 | val warnings : string -> w 60 | val module_ : string -> w -> w 61 | val opens : string list -> w 62 | val record : (string * w) list -> w 63 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/bin/test_metamodel.ml: -------------------------------------------------------------------------------- 1 | module Metamodel = Lsp_gen.Metamodel 2 | 3 | let file = Sys.argv.(1) 4 | 5 | let () = 6 | let read = open_in file in 7 | let s = really_input_string read (in_channel_length read) in 8 | let json = Yojson.Safe.from_string s in 9 | let (_ : Metamodel.t) = Metamodel.t json in 10 | close_in read 11 | ;; 12 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/bin/typescript/typescript.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val of_metamodel : Metamodel.t -> Ts_types.Unresolved.t list 4 | 5 | val resolve_all 6 | : Ts_types.Unresolved.t list 7 | -> Ts_types.Resolved.t list * Ts_types.Ident.t String.Map.t 8 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/array_view.mli: -------------------------------------------------------------------------------- 1 | type 'a t 2 | 3 | (** [make arr ~pos ~len] can be thought of a new array for which the 0-th 4 | element is [arr.(pos)] and has length [len] if specified. If [len] is 5 | omitted, [Array.length arr - pos] is taken as the length. Importantly, the 6 | "new array" does not copy but simply references [arr]. Hence, creating views 7 | is constant time. However, keep in mind that since a view references an 8 | array, the array will be alive in memory as long as the view is alive. 9 | 10 | @raise Invalid_argument 11 | if [pos + len > Array.length arr] or [pos < 0 || pos >= Array.length arr]*) 12 | val make : ?len:int -> 'a array -> pos:int -> 'a t 13 | 14 | val get : 'a t -> int -> 'a 15 | val set : 'a t -> int -> 'a -> unit 16 | val is_empty : 'a t -> bool 17 | val length : 'a t -> int 18 | val common_suffix_len : 'a t -> 'a t -> int 19 | val fold_left : 'a t -> init:'acc -> f:('acc -> 'a -> 'acc) -> 'acc 20 | val iteri : 'a t -> f:(int -> 'a -> unit) -> unit 21 | val sub : 'a t -> pos:int -> len:int -> 'a t 22 | val blit : 'a t -> 'a array -> pos:int -> unit 23 | val copy : 'a t -> 'a array 24 | val backing_array_pos : _ t -> int -> int 25 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/cancel_request.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | let meth_ = "$/cancelRequest" 4 | 5 | let t_of_yojson json = 6 | match json with 7 | | `Assoc fields -> Json.field_exn fields "id" Jsonrpc.Id.t_of_yojson 8 | | _ -> Json.error "invalid id" json 9 | ;; 10 | 11 | let yojson_of_t id = `Assoc [ "id", Jsonrpc.Id.yojson_of_t id ] 12 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/cancel_request.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val meth_ : string 4 | 5 | include Json.Jsonable.S with type t := Jsonrpc.Id.t 6 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/cli.mli: -------------------------------------------------------------------------------- 1 | (** Handling of standard lsp server command line arguments *) 2 | 3 | module Channel : sig 4 | (** The channel the server shold use to listen for connections *) 5 | 6 | type t = 7 | | Stdio 8 | | Pipe of string (** A path to the unix domain socket or windows pipe *) 9 | | Socket of int (** A tcp connection on localhost with the port number *) 10 | end 11 | 12 | module Arg : sig 13 | (** Parsing of the standard commnad line arguments using [Stdlib.Arg] *) 14 | 15 | type t 16 | 17 | (** [create ()] create a new record for arguments *) 18 | val create : unit -> t 19 | 20 | (** [spec t] returns the spec that should be provided to [Stdlib.Arg] to 21 | populate [t] using the interpreted cli args *) 22 | val spec : t -> (string * Arg.spec * string) list 23 | 24 | (** [channel t] return the channel if correctly supplied. An error if the 25 | arguments were provided incorrectly. *) 26 | val channel : t -> (Channel.t, string) result 27 | 28 | (** Return the process id of the client used to run the lsp server if it was 29 | provided *) 30 | val clientProcessId : t -> int option 31 | end 32 | 33 | (** generate command line arguments that can be used to spawn an lsp client *) 34 | val args : ?channel:Channel.t -> ?clientProcessId:int -> unit -> string list 35 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/client_notification.mli: -------------------------------------------------------------------------------- 1 | open! Import 2 | open Types 3 | 4 | type t = 5 | | TextDocumentDidOpen of DidOpenTextDocumentParams.t 6 | | TextDocumentDidClose of DidCloseTextDocumentParams.t 7 | | TextDocumentDidChange of DidChangeTextDocumentParams.t 8 | | DidSaveTextDocument of DidSaveTextDocumentParams.t 9 | | WillSaveTextDocument of WillSaveTextDocumentParams.t 10 | | DidChangeWatchedFiles of DidChangeWatchedFilesParams.t 11 | | DidCreateFiles of CreateFilesParams.t 12 | | DidDeleteFiles of DeleteFilesParams.t 13 | | DidRenameFiles of RenameFilesParams.t 14 | | ChangeWorkspaceFolders of DidChangeWorkspaceFoldersParams.t 15 | | ChangeConfiguration of DidChangeConfigurationParams.t 16 | | Initialized 17 | | Exit 18 | | CancelRequest of Jsonrpc.Id.t 19 | | WorkDoneProgressCancel of WorkDoneProgressCancelParams.t 20 | | SetTrace of SetTraceParams.t 21 | | WorkDoneProgress of Progress.t ProgressParams.t 22 | | NotebookDocumentDidOpen of DidOpenNotebookDocumentParams.t 23 | | NotebookDocumentDidChange of DidChangeNotebookDocumentParams.t 24 | | NotebookDocumentDidSave of DidSaveNotebookDocumentParams.t 25 | | NotebookDocumentDidClose of DidCloseNotebookDocumentParams.t 26 | | UnknownNotification of Jsonrpc.Notification.t 27 | 28 | val of_jsonrpc : Jsonrpc.Notification.t -> (t, string) result 29 | val to_jsonrpc : t -> Jsonrpc.Notification.t 30 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/diff.mli: -------------------------------------------------------------------------------- 1 | val edit : from:string -> to_:string -> Types.TextEdit.t list 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/dune: -------------------------------------------------------------------------------- 1 | (include_subdirs unqualified) 2 | 3 | (library 4 | (name lsp) 5 | (public_name lsp) 6 | (libraries jsonrpc ppx_yojson_conv_lib uutf yojson) 7 | (lint 8 | (pps ppx_yojson_conv)) 9 | (instrumentation 10 | (backend bisect_ppx))) 11 | 12 | (cinaps 13 | (files types.ml types.mli) 14 | (libraries lsp_gen)) 15 | 16 | (ocamllex uri_lexer) 17 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/extension.mli: -------------------------------------------------------------------------------- 1 | (** Protocol extensions that aren't part of the spec *) 2 | 3 | open Import 4 | 5 | module DebugEcho : sig 6 | module Params : sig 7 | type t = { message : string } 8 | 9 | include Json.Jsonable.S with type t := t 10 | end 11 | 12 | module Result : sig 13 | type t = Params.t = { message : string } 14 | 15 | include Json.Jsonable.S with type t := t 16 | end 17 | end 18 | 19 | module DebugTextDocumentGet : sig 20 | module Params : sig 21 | include module type of Types.TextDocumentPositionParams 22 | end 23 | 24 | module Result : sig 25 | type t = string option 26 | 27 | include Json.Jsonable.S with type t := t 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/header.ml: -------------------------------------------------------------------------------- 1 | type t = 2 | { content_length : int 3 | ; content_type : string 4 | } 5 | 6 | let content_type t = t.content_type 7 | let content_length t = t.content_length 8 | 9 | module Private = struct 10 | module Key = struct 11 | let content_length = "Content-Length" 12 | let content_type = "Content-Type" 13 | end 14 | end 15 | 16 | open Private 17 | 18 | let crlf = "\r\n" 19 | 20 | let to_string { content_length; content_type } = 21 | let b = Buffer.create 64 in 22 | let add = Buffer.add_string b in 23 | let line k v = 24 | add k; 25 | add ": "; 26 | add v; 27 | add crlf 28 | in 29 | line Key.content_length (string_of_int content_length); 30 | line Key.content_type content_type; 31 | add crlf; 32 | Buffer.contents b 33 | ;; 34 | 35 | let default_content_type = "application/vscode-jsonrpc; charset=utf-8" 36 | 37 | let create ?(content_type = default_content_type) ~content_length () = 38 | { content_length; content_type } 39 | ;; 40 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/header.mli: -------------------------------------------------------------------------------- 1 | open! Import 2 | 3 | type t 4 | 5 | val content_length : t -> int 6 | val content_type : t -> string 7 | val create : ?content_type:string -> content_length:int -> unit -> t 8 | val to_string : t -> string 9 | 10 | module Private : sig 11 | module Key : sig 12 | val content_length : string 13 | val content_type : string 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/io.mli: -------------------------------------------------------------------------------- 1 | (** Low level module for sending/receiving jsonrpc packets across channels *) 2 | 3 | exception Error of string 4 | 5 | module Make 6 | (Io : sig 7 | type 'a t 8 | 9 | val return : 'a -> 'a t 10 | val raise : exn -> 'a t 11 | 12 | module O : sig 13 | val ( let+ ) : 'a t -> ('a -> 'b) -> 'b t 14 | val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t 15 | end 16 | end) 17 | (Chan : sig 18 | type input 19 | type output 20 | 21 | val read_line : input -> string option Io.t 22 | val read_exactly : input -> int -> string option Io.t 23 | val write : output -> string list -> unit Io.t 24 | end) : sig 25 | val read : Chan.input -> Jsonrpc.Packet.t option Io.t 26 | val write : Chan.output -> Jsonrpc.Packet.t -> unit Io.t 27 | end 28 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/lsp.ml: -------------------------------------------------------------------------------- 1 | module Progress = Progress 2 | module Client_notification = Client_notification 3 | module Client_request = Client_request 4 | module Extension = Extension 5 | module Header = Header 6 | module Import = Import 7 | module Server_notification = Server_notification 8 | module Server_request = Server_request 9 | module Snippet = Snippet 10 | module Text_document = Text_document 11 | module Types = Types 12 | module Uri = Uri0 13 | module Io = Io 14 | module Cli = Cli 15 | module Diff = Diff 16 | 17 | module Private = struct 18 | module Array_view = Array_view 19 | module Substring = Substring 20 | module String_zipper = String_zipper 21 | end 22 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/position.ml: -------------------------------------------------------------------------------- 1 | include Types.Position 2 | 3 | let zero = create ~line:0 ~character:0 4 | let is_zero (t : t) = t.line = zero.line && t.character = zero.character 5 | 6 | let compare t { line; character } = 7 | match Int.compare t.line line with 8 | | 0 -> Int.compare t.character character 9 | | n -> n 10 | ;; 11 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/progress.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | open Types 3 | 4 | type t = 5 | | Begin of WorkDoneProgressBegin.t 6 | | Report of WorkDoneProgressReport.t 7 | | End of WorkDoneProgressEnd.t 8 | 9 | let yojson_of_t = function 10 | | Begin b -> WorkDoneProgressBegin.yojson_of_t b 11 | | Report r -> WorkDoneProgressReport.yojson_of_t r 12 | | End e -> WorkDoneProgressEnd.yojson_of_t e 13 | ;; 14 | 15 | let t_of_yojson json = 16 | Json.Of.untagged_union 17 | "Progress" 18 | [ (fun j -> Begin (WorkDoneProgressBegin.t_of_yojson j)) 19 | ; (fun j -> Report (WorkDoneProgressReport.t_of_yojson j)) 20 | ; (fun j -> End (WorkDoneProgressEnd.t_of_yojson j)) 21 | ] 22 | json 23 | ;; 24 | 25 | let method_ = "$/progress" 26 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/progress.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | open Types 3 | 4 | type t = 5 | | Begin of WorkDoneProgressBegin.t 6 | | Report of WorkDoneProgressReport.t 7 | | End of WorkDoneProgressEnd.t 8 | 9 | val yojson_of_t : t -> Json.t 10 | val t_of_yojson : Json.t -> t 11 | val method_ : string 12 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/server_notification.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | open Types 3 | 4 | type t = 5 | | PublishDiagnostics of PublishDiagnosticsParams.t 6 | | ShowMessage of ShowMessageParams.t 7 | | LogMessage of LogMessageParams.t 8 | | LogTrace of LogTraceParams.t 9 | | TelemetryNotification of Json.t 10 | | CancelRequest of Jsonrpc.Id.t 11 | | WorkDoneProgress of Progress.t ProgressParams.t 12 | | UnknownNotification of Jsonrpc.Notification.t 13 | 14 | val to_jsonrpc : t -> Jsonrpc.Notification.t 15 | val of_jsonrpc : Jsonrpc.Notification.t -> (t, string) Result.t 16 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/server_request.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | open Types 3 | 4 | type _ t = 5 | | WorkspaceApplyEdit : ApplyWorkspaceEditParams.t -> ApplyWorkspaceEditResult.t t 6 | | WorkspaceFolders : WorkspaceFolder.t list t 7 | | WorkspaceConfiguration : ConfigurationParams.t -> Json.t list t 8 | | ClientRegisterCapability : RegistrationParams.t -> unit t 9 | | ClientUnregisterCapability : UnregistrationParams.t -> unit t 10 | | ShowMessageRequest : ShowMessageRequestParams.t -> MessageActionItem.t option t 11 | | ShowDocumentRequest : ShowDocumentParams.t -> ShowDocumentResult.t t 12 | | WorkDoneProgressCreate : WorkDoneProgressCreateParams.t -> unit t 13 | | CodeLensRefresh : unit t 14 | | SemanticTokensRefresh : unit t 15 | | WorkspaceDiagnosticRefresh : unit t 16 | | WorkspaceFoldingRangeRefresh : unit t 17 | | WorkspaceInlayHintRefresh : unit t 18 | | WorkspaceInlineValueRefresh : unit t 19 | | UnknownRequest : string * Jsonrpc.Structured.t option -> Json.t t 20 | 21 | type packed = E : 'r t -> packed 22 | 23 | val yojson_of_result : 'a t -> 'a -> Json.t 24 | val to_jsonrpc_request : _ t -> id:Jsonrpc.Id.t -> Jsonrpc.Request.t 25 | val of_jsonrpc : Jsonrpc.Request.t -> (packed, string) Result.t 26 | val response_of_json : 'a t -> Json.t -> 'a 27 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/snippet.mli: -------------------------------------------------------------------------------- 1 | open! Import 2 | 3 | module Var : sig 4 | type t = 5 | | TM_SELECTED_TEXT 6 | | TM_CURRENT_LINE 7 | | TM_CURRENT_WORD 8 | | TM_LINE_INDEX 9 | | TM_LINE_NUMBER 10 | | TM_FILENAME 11 | | TM_FILENAME_BASE 12 | | TM_DIRECTORY 13 | | TM_FILEPATH 14 | end 15 | 16 | type variable_transform = 17 | { regex : string 18 | ; format_string : string 19 | ; regex_options : string option 20 | } 21 | 22 | type t 23 | 24 | val tabstop : int -> t 25 | val placeholder : ?index:int -> t -> t 26 | val choice : ?index:int -> string list -> t 27 | 28 | val variable 29 | : ?opt:[ `Placeholder of t | `Transform of variable_transform | `None ] 30 | -> Var.t 31 | -> t 32 | 33 | val variable_transform 34 | : regex:string 35 | -> ?regex_options:string 36 | -> format_string:string 37 | -> unit 38 | -> variable_transform 39 | 40 | val text : string -> t 41 | 42 | module O : sig 43 | val ( ^^ ) : t -> t -> t 44 | val ( @+ ) : string -> t -> t 45 | val ( +@ ) : t -> string -> t 46 | end 47 | 48 | val concat : ?sep:t -> t list -> t 49 | val to_string : t -> string 50 | val pp : Format.formatter -> t -> unit 51 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/string_zipper.mli: -------------------------------------------------------------------------------- 1 | type t 2 | 3 | type invalid_utf = 4 | | Malformed of string 5 | | Insufficient_input 6 | 7 | exception Invalid_utf of invalid_utf 8 | 9 | val of_string : string -> t 10 | val squash : t -> t * string 11 | val to_string : t -> string 12 | val to_string_debug : t -> string 13 | 14 | (* [insert t s] right of the current position *) 15 | val insert : t -> string -> t 16 | val goto_line : t -> int -> t 17 | val goto_position : t -> Position.t -> [ `UTF16 | `UTF8 ] -> t 18 | val add_buffer_between : Buffer.t -> t -> t -> unit 19 | val goto_end : t -> t 20 | val drop_until : t -> t -> t 21 | val apply_change : t -> Types.Range.t -> [ `UTF16 | `UTF8 ] -> replacement:string -> t 22 | val offset : t -> int 23 | 24 | module Private : sig 25 | type zipper := t 26 | 27 | type nonrec t = 28 | { left : Substring.t list 29 | ; rel_pos : int 30 | ; abs_pos : int 31 | ; current : Substring.t 32 | ; line : int 33 | ; right : Substring.t list 34 | } 35 | 36 | val reflect : zipper -> t 37 | end 38 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/substring.mli: -------------------------------------------------------------------------------- 1 | type t 2 | 3 | val of_slice : string -> pos:int -> len:int -> t 4 | val of_string : string -> t 5 | val compare : t -> t -> int 6 | val concat : t Array_view.t -> string 7 | val take : t -> int -> t 8 | val drop : t -> int -> t 9 | val to_string : t -> string 10 | val length : t -> int 11 | val add_buffer : t -> Buffer.t -> unit 12 | val split_at : t -> int -> t * t 13 | val rsplit_at : t -> int -> t * t 14 | val index_from : t -> pos:int -> char -> int option 15 | val rindex : t -> char -> int option 16 | val rindex_from : t -> pos:int -> char -> int option 17 | val get_exn : t -> int -> char 18 | 19 | type move = 20 | { newlines : int 21 | ; consumed : int 22 | } 23 | 24 | val move_left : t -> pos:int -> len:int -> move 25 | val move_right : t -> pos:int -> len:int -> move 26 | val blit : t -> dst:bytes -> dst_pos:int -> unit 27 | 28 | module Uutf : sig 29 | val src : t -> pos:int -> Uutf.decoder -> unit 30 | end 31 | 32 | module Map : MoreLabels.Map.S with type key = t 33 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/text_document.mli: -------------------------------------------------------------------------------- 1 | open Types 2 | 3 | type t 4 | 5 | type encoding := 6 | [ `UTF8 7 | | `UTF16 8 | ] 9 | 10 | val make : position_encoding:encoding -> DidOpenTextDocumentParams.t -> t 11 | val languageId : t -> string 12 | val documentUri : t -> Uri0.t 13 | val position_encoding : t -> encoding 14 | val version : t -> int 15 | val text : t -> string 16 | 17 | type invalid_utf = 18 | | Malformed of string 19 | | Insufficient_input 20 | 21 | exception Invalid_utf of invalid_utf 22 | 23 | val apply_content_changes 24 | : ?version:int 25 | -> t 26 | -> TextDocumentContentChangeEvent.t list 27 | -> t 28 | 29 | val set_version : t -> version:int -> t 30 | 31 | (** Apply a list of non overlapping text edits. The order of application matters 32 | when multiple inserts are done in the same position. All the offsets are 33 | interpreted relative to the original document. *) 34 | val apply_text_document_edits : t -> TextEdit.t list -> t 35 | 36 | (** [absolute_position t pos] returns the absolute position of [pos] inside 37 | [text t]. If the position is outside the bounds of the document, the offset 38 | returned will be the length of the document. [pos] is interpreted with 39 | [position_encoding t] *) 40 | val absolute_position : t -> Position.t -> int 41 | 42 | (* [absolute_range t range] same as [(absolute_position t range.start , 43 | absolute_position t range.end_)] but possibly faster *) 44 | val absolute_range : t -> Range.t -> int * int 45 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/uri0.mli: -------------------------------------------------------------------------------- 1 | open! Import 2 | 3 | type t 4 | 5 | include Json.Jsonable.S with type t := t 6 | 7 | val compare : t -> t -> int 8 | val equal : t -> t -> bool 9 | val hash : t -> int 10 | val to_path : t -> string 11 | val of_path : string -> t 12 | val to_string : t -> string 13 | val of_string : string -> t 14 | val query : t -> string option 15 | val fragment : t -> string option 16 | 17 | module Private : sig 18 | val win32 : bool ref 19 | end 20 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/src/uri_lexer.mli: -------------------------------------------------------------------------------- 1 | type t = 2 | { scheme : string 3 | ; authority : string 4 | ; path : string 5 | ; query : string option 6 | ; fragment : string option 7 | } 8 | 9 | val of_string : string -> t 10 | val of_path : string -> t 11 | -------------------------------------------------------------------------------- /thirdparty/lsp/lsp/test/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name lsp_tests) 3 | (enabled_if 4 | (>= %{ocaml_version} 4.08)) 5 | (inline_tests) 6 | (libraries 7 | stdune 8 | lsp 9 | yojson 10 | dyn 11 | ;; This is because of the (implicit_transitive_deps false) 12 | ;; in dune-project 13 | base 14 | ppx_expect 15 | ppx_expect.config 16 | ppx_expect.config_types 17 | ppx_inline_test.config) 18 | (preprocess 19 | (pps ppx_expect))) 20 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/bench/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names ocaml_lsp_bench) 3 | (enabled_if 4 | (= %{profile} bench)) 5 | (libraries 6 | ocaml_lsp_server 7 | core_unix.command_unix 8 | merlin-lib.kernel 9 | base 10 | core 11 | core_bench) 12 | (preprocess 13 | (pps ppx_bench))) 14 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/bench/ocaml_lsp_bench.ml: -------------------------------------------------------------------------------- 1 | open Ocaml_lsp_server 2 | open Core 3 | open Core_bench 4 | 5 | let () = 6 | let open Documents in 7 | let long_document = long_document_text |> Merlin_kernel.Msource.make in 8 | let position = `Logical (3, 15) in 9 | let long_position = `Logical (92, 41) in 10 | Command_unix.run 11 | (Bench.make_command 12 | [ Bench.Test.create ~name:"get_prefix" (fun _ -> 13 | Testing.Compl.prefix_of_position ~short_path:false document position |> ignore) 14 | ; Bench.Test.create ~name:"get_prefix_long" (fun _ -> 15 | Testing.Compl.prefix_of_position ~short_path:false long_document long_position 16 | |> ignore) 17 | ; Bench.Test.create ~name:"get_offset_long" (fun _ -> 18 | Merlin_kernel.Msource.get_offset long_document long_position |> ignore) 19 | ]) 20 | ;; 21 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/bin/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name main) 3 | (package ocaml-lsp-server) 4 | (public_name ocamllsp) 5 | (libraries dune-build-info stdune lsp ocaml_lsp_server) 6 | (instrumentation 7 | (backend bisect_ppx))) 8 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/bin/main.ml: -------------------------------------------------------------------------------- 1 | open Stdune 2 | module Cli = Lsp.Cli 3 | 4 | let () = 5 | Printexc.record_backtrace true; 6 | let version = ref false in 7 | let read_dot_merlin = ref false in 8 | let arg = Lsp.Cli.Arg.create () in 9 | let spec = 10 | [ "--version", Arg.Set version, "print version" 11 | ; ( "--fallback-read-dot-merlin" 12 | , Arg.Set read_dot_merlin 13 | , "read Merlin config from .merlin files. The `dot-merlin-reader` package must be \ 14 | installed" ) 15 | ] 16 | @ Cli.Arg.spec arg 17 | in 18 | let usage = 19 | "ocamllsp [ --stdio | --socket PORT | --port PORT | --pipe PIPE ] [ \ 20 | --clientProcessId pid ]" 21 | in 22 | Arg.parse spec (fun _ -> raise @@ Arg.Bad "anonymous arguments aren't allowed") usage; 23 | let channel = 24 | match Cli.Arg.channel arg with 25 | | Ok c -> c 26 | | Error s -> 27 | Format.eprintf "%s@.%!" s; 28 | Arg.usage spec usage; 29 | exit 1 30 | in 31 | let version = !version in 32 | if version 33 | then ( 34 | let version = Ocaml_lsp_server.Version.get () in 35 | print_endline version) 36 | else 37 | let module Exn_with_backtrace = Stdune.Exn_with_backtrace in 38 | match 39 | Exn_with_backtrace.try_with 40 | (Ocaml_lsp_server.run channel ~read_dot_merlin:!read_dot_merlin) 41 | with 42 | | Ok () -> () 43 | | Error exn -> 44 | Format.eprintf "%a@." Exn_with_backtrace.pp_uncaught exn; 45 | exit 1 46 | ;; 47 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/bin/main.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/ocaml-lsp-server/bin/main.mli -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/docs/ocamllsp/config.md: -------------------------------------------------------------------------------- 1 | # Configuration 2 | 3 | The ocamllsp support the following configurations. 4 | 5 | These configurations are sent through the 6 | [`didChangeConfiguration`](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_didChangeConfiguration) 7 | notification. 8 | 9 | ```ts 10 | interface config { 11 | /** 12 | * Enable/Disable Extended Hover 13 | * @default false 14 | * @since 1.16 15 | */ 16 | extendedHover: { enable : boolean } 17 | 18 | /** 19 | * Enable/Disable CodeLens 20 | * @default false 21 | * @since 1.16 22 | */ 23 | codelens: { enable : boolean } 24 | 25 | /** 26 | * Enable/Disable Dune diagnostics 27 | * @default true 28 | * @since 1.18 29 | */ 30 | duneDiagnostics: { enable : boolean } 31 | 32 | /** 33 | * Enable/Disable Inlay Hints 34 | * @default false 35 | * @since 1.18 36 | */ 37 | inlayHints: { enable : boolean } 38 | 39 | /** 40 | * Enable/Disable Syntax Documentation 41 | * @default false 42 | * @since 1.18 43 | */ 44 | syntaxDocumentation: { enable : boolean } 45 | 46 | /** 47 | * Enable/Disable Merlin Jump code actions 48 | * @default true 49 | * @since 1.19 50 | */ 51 | merlinJumpCodeActions: { enable : boolean } 52 | } 53 | ``` 54 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/docs/ocamllsp/construct-spec.md: -------------------------------------------------------------------------------- 1 | # Construct Request 2 | 3 | ## Description 4 | 5 | Provides commands to fill typed holes (`_`). Such holes sometimes 6 | appear in the result of other commands like `destruct` and can also be inserted 7 | manually in the source. The command is already accessible via a completion hook, 8 | however, in certain situations, invoking `construct` on a hole via a request 9 | allows more control. 10 | 11 | ## Client Capability 12 | 13 | There is no client capability relative to this request. 14 | 15 | ## Server capability 16 | 17 | - property name: `handleConstruct` 18 | - property type: `boolean` 19 | 20 | ## Request 21 | 22 | - method: `ocamllsp/construct` 23 | - params: 24 | 25 | ```json 26 | { 27 | "uri": TextDocumentIdentifier, 28 | "position": Position 29 | "depth?": uinteger (default value: 0) 30 | "withValues?": <"local" | "none">, 31 | } 32 | ``` 33 | 34 | The `depth` parameter allows to recursively construct terms. Note that 35 | when `depth > 1` partial results of inferior depth will not be 36 | returned. The `withValues` parameter enables the use of values from 37 | the environment (`local`) or not (`none`), It defaults to `none`. 38 | 39 | ## Response 40 | 41 | ```json 42 | { 43 | "position": Range, 44 | "result": string[] 45 | } 46 | ``` 47 | 48 | The result contains the range (`position`) to be replaced (describing the hole) 49 | and the list of possible substitution values (`result`). 50 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/docs/ocamllsp/hoverExtended-spec.md: -------------------------------------------------------------------------------- 1 | #### Hover Extended 2 | 3 | Alternative hover command providing additional information. 4 | 5 | This command has support for variable verbosity. 6 | 7 | ```ocaml 8 | type t = int 9 | let x : t = 1 10 | ``` 11 | 12 | With the cursor on the value `x`, a call with a verbosity of 0 or lower would 13 | return `t` making it equivalent to a call to `textDocument/hover`. A call with 14 | a verbosity of 1 would return `int`. 15 | 16 | When the verbosity is omitted, the server picks a number based on previous 17 | calls. It starts with 0. Further calls at the same position will improve the 18 | verbosity of the displayed type, by expanding aliases. If the position changes, 19 | the verbosity goes back to 0. This behavior is similar to `type-enclosing` in 20 | merlin. 21 | 22 | ##### Client capability 23 | 24 | nothing that should be noted 25 | 26 | ##### Server capability 27 | 28 | property name: `handleHoverExtended` 29 | property type: `boolean` 30 | 31 | ##### Request 32 | 33 | - method: `ocamllsp/hoverExtended` 34 | - params: 35 | 36 | ```typescript 37 | { 38 | textDocument: TextDocumentIdentifier, 39 | position: Position, 40 | verbosity?: integer 41 | } 42 | ``` 43 | 44 | ##### Response 45 | 46 | The response is similar to the one of `textDocument/hover` 47 | 48 | ```typescript 49 | /** 50 | * The hover's content 51 | */ 52 | contents: MarkedString | MarkedString[] | MarkupContent; 53 | /** 54 | * An optional range is a range inside a text document 55 | * that is used to visualize a hover, e.g. by changing the background color. 56 | */ 57 | range?: Range; 58 | ``` 59 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/docs/ocamllsp/inferIntf-spec.md: -------------------------------------------------------------------------------- 1 | # Infer Interface Request 2 | 3 | Infer Interface Request is sent from the client to the server to get the infered 4 | interface for a given module implementation. 5 | 6 | The document URI in the request has to be open before sending a the request. 7 | 8 | If the file cannot be found in the document store, an error will be returned. 9 | 10 | Warning: this custom request is meant to be consumed by `ocaml-vscode-platform` exclusively, 11 | it can be removed any time and should not be relied on. 12 | 13 | ## Client capability 14 | 15 | nothing that should be noted 16 | 17 | ## Server capability 18 | 19 | property name: `handleInferIntf` 20 | property type: `boolean` 21 | 22 | ## Request 23 | 24 | - method: `ocamllsp/inferIntf` 25 | - params: `DocumentUri` (see [`DocumentUri`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#uri) in LSP specification) 26 | 27 | ## Response 28 | 29 | - result: String 30 | - error: code and message set in case an exception happens during the processing of the request. 31 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/docs/ocamllsp/merlinJump-spec.md: -------------------------------------------------------------------------------- 1 | # Merlin Jump Request 2 | 3 | ## Description 4 | 5 | This custom request allows Merlin-type code navigation in a source buffer. 6 | 7 | ## Server capability 8 | 9 | - propert name: `handleJump` 10 | - property type: `boolean` 11 | 12 | ## Request 13 | 14 | - method: `ocamllsp/jump` 15 | - params: `JumpParams` extends [TextDocumentPositionParams](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentPositionParams) and is defined as follows: 16 | 17 | ```js 18 | export interface JumpParams extends TextDocumentPositionParams 19 | { 20 | /** 21 | * The requested target of the jump, one of `fun`, `let`, `module`, 22 | * `module-type`, `match`, `match-next-case`, `match-prev-case`. 23 | * 24 | * If omitted, all valid targets will be considered. 25 | */ 26 | target?: string; 27 | } 28 | ``` 29 | 30 | ## Response 31 | 32 | - result: `Jump` 33 | 34 | ```js 35 | 36 | export interface TargetPosition { 37 | /** 38 | * The target's kind. 39 | */ 40 | target: string; 41 | 42 | /** 43 | * The corresponding position in the request's document. 44 | */ 45 | position: Position; 46 | } 47 | 48 | export interface Jump { 49 | /** 50 | * The list of possible targets to jump-to. 51 | */ 52 | jumps: TargetPosition[] 53 | } 54 | ``` 55 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/docs/ocamllsp/switchImplIntf-spec.md: -------------------------------------------------------------------------------- 1 | # Switch Implementation/Interface Request 2 | 3 | Switch Implementation/Interface Request is sent from client to server to get 4 | URI(s) of the file(s) that the current file can switch to, e.g., if the user 5 | has "foo.ml" and "foo.mli" files, the client, who want to switch from one to 6 | the other, sends this request. 7 | 8 | If there are one or more files, to which the currently open file can switch to, 9 | exist in the same folder, then URIs of all those existing files are returned. 10 | In case there is no file to switch to in that folder, the most likely candidate 11 | for creation is returned, e.g., if a user wants to switch from "foo.ml", but no 12 | files already exist in the project that could be returned, a URI for "foo.mli" 13 | is returned. 14 | 15 | ## Client capability 16 | 17 | nothing that should be noted 18 | 19 | ## Server capability 20 | 21 | property name: `handleSwitchImplIntf` 22 | 23 | property type: `boolean` 24 | 25 | ## Request 26 | 27 | - method: `ocamllsp/switchImplIntf` 28 | - params: `DocumentUri` (see [`DocumentUri`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#uri) in LSP specification) 29 | 30 | ## Response 31 | 32 | - result: DocumentUri[] (non-empty) 33 | - error: code and message set in case an exception happens during the `ocamllsp/switchImplIntf` request. 34 | 35 | 36 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/docs/ocamllsp/typedHoles-spec.md: -------------------------------------------------------------------------------- 1 | # Typed Holes Request 2 | 3 | ## Description 4 | 5 | ### A note on stability: 6 | 7 | OCaml-LSP does not guarantee stability for this custom request, meaning the core 8 | contributors may change or remove this custom request, as they see necessary. 9 | 10 | ### What typed holes are 11 | 12 | Merlin has a concept of "typed holes" that are syntactically represented as `_`. Files 13 | that incorporate typed holes are not considered valid OCaml, but Merlin and OCaml-LSP 14 | support them. One example when such typed holes can occur is when on "destructs" a value, 15 | e.g., destructing `(Some 1)` will generate code `match Some 1 with Some _ -> _ | None -> 16 | _`. While the first underscore is a valid "match-all"/wildcard pattern, the rest of 17 | underscores are typed holes. 18 | 19 | ### Why this custom request needed 20 | 21 | It is reasonable that user wants to jump around such typed holes to be able to edit them. 22 | This custom request allows clients to know where these holes are and enable jumping around 23 | them. 24 | 25 | ## Client capability 26 | 27 | nothing that should be noted 28 | 29 | ## Server capability 30 | 31 | property name: `handleTypedHoles` 32 | 33 | property type: `boolean` 34 | 35 | ## Request 36 | 37 | - method: `ocamllsp/typedHoles` 38 | - params: 39 | 40 | ```json 41 | { 42 | "uri": DocumentUri, 43 | } 44 | ``` 45 | 46 | ## Response 47 | 48 | - result: `Range[]` 49 | - empty array if no holes found in the file at the given `URI` 50 | - error: code and message set in case an exception happens during the 51 | `ocamllsp/typedHoles` request. 52 | - in case of any errors in finding holes in the file, the handler throws an exception, 53 | which is returned from the language server. 54 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/dune: -------------------------------------------------------------------------------- 1 | (vendored_dirs vendor) 2 | 3 | (subdir 4 | vendor 5 | (subdir 6 | lev-fiber-csexp 7 | (library 8 | (name lev_fiber_csexp) 9 | (libraries fiber csexp stdune dyn lev_fiber)) 10 | (copy_files# %{project_root}/submodules/lev/lev-fiber-csexp/src/*.{ml,mli})) 11 | (subdir 12 | lev-fiber 13 | (subdir 14 | util 15 | (copy_files# %{project_root}/submodules/lev/lev-fiber/src/util/*.{ml,mli}) 16 | (library 17 | (name lev_fiber_util) 18 | (libraries stdune threads.posix))) 19 | (copy_files# %{project_root}/submodules/lev/lev-fiber/src/*.{ml,mli}) 20 | (library 21 | (name lev_fiber) 22 | (libraries unix dyn stdune threads.posix fiber lev lev_fiber_util))) 23 | (subdir 24 | lev 25 | (copy_files# %{project_root}/submodules/lev/lev/vendor/*.c) 26 | (copy_files# 27 | %{project_root}/submodules/lev/lev/vendor/{ev,ev_vars,ev_wrap}.h) 28 | (copy_files# %{project_root}/submodules/lev/lev/src/*.{ml,mli,c,h}) 29 | (library 30 | (name lev) 31 | (synopsis "libev bindings") 32 | (libraries unix) 33 | (foreign_stubs 34 | (language c) 35 | (extra_deps 36 | ev_kqueue.c 37 | ev_epoll.c 38 | ev_iouring.c 39 | ev_poll.c 40 | ev_port.c 41 | ev_select.c 42 | ev_win32.c) 43 | (names lev_stubs ev))))) 44 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/bin.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | module Bin = Stdune.Bin 3 | 4 | let _PATH = 5 | lazy (Bin.parse_path (Option.value ~default:"" (Unix_env.get Unix_env.initial "PATH"))) 6 | ;; 7 | 8 | let which x = Bin.which ~path:(Lazy.force _PATH) x |> Option.map ~f:Stdune.Path.to_string 9 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/bin.mli: -------------------------------------------------------------------------------- 1 | val which : string -> string option 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/check_for_comments.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | let position_in_comment ~position ~merlin = 4 | let loc_contains_position (_, (loc : Loc.t)) = 5 | let start = Position.of_lexical_position loc.loc_start in 6 | let end_ = Position.of_lexical_position loc.loc_end in 7 | match Option.both start end_ with 8 | | Some (start, end_) -> 9 | let range = Range.create ~start ~end_ in 10 | (match Position.compare_inclusion position range with 11 | | `Inside -> true 12 | | `Outside _ -> false) 13 | | None -> false 14 | in 15 | Document.Merlin.with_pipeline_exn ~name:"get-comments" merlin (fun pipeline -> 16 | Mpipeline.reader_comments pipeline |> List.exists ~f:loc_contains_position) 17 | ;; 18 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/check_for_comments.mli: -------------------------------------------------------------------------------- 1 | (** Returns [true] if [position] occurs inside a comment in the document *) 2 | val position_in_comment : position:Position.t -> merlin:Document.Merlin.t -> bool Fiber.t 3 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/client.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | module Experimental_capabilities = struct 4 | type t = bool 5 | 6 | let of_opt_json (json : Json.t option) = 7 | match json with 8 | | Some (`Assoc fields) -> 9 | Json.field fields "jumpToNextHole" Json.Conv.bool_of_yojson 10 | |> Option.value ~default:false 11 | | _ -> false 12 | ;; 13 | 14 | let supportsJumpToNextHole t = t 15 | end 16 | 17 | module Vscode = struct 18 | module Commands = struct 19 | let triggerSuggest = 20 | Command.create ~title:"Trigger Suggest" ~command:"editor.action.triggerSuggest" () 21 | ;; 22 | end 23 | end 24 | 25 | module Custom_commands = struct 26 | let next_hole ?in_range ~notify_if_no_hole () = 27 | let arguments = 28 | let arg_obj_fields = 29 | let notif_json = Some ("shouldNotifyIfNoHole", Json.bool notify_if_no_hole) in 30 | let in_range_json = 31 | Option.map in_range ~f:(fun r -> "inRange", Range.yojson_of_t r) 32 | in 33 | List.filter_opt [ in_range_json; notif_json ] 34 | in 35 | match arg_obj_fields with 36 | | [] -> [] (* no arguments -- the extension uses defaults *) 37 | | fields -> 38 | (* the use of a (json) object as the first and single argument to the 39 | command is intended *) 40 | [ `Assoc fields ] 41 | in 42 | Command.create ~title:"Jump to Next Hole" ~command:"ocaml.next-hole" ~arguments () 43 | ;; 44 | end 45 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/client.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | (** This module is a collection of client-specific functionality (client = 4 | editor) *) 5 | 6 | module Experimental_capabilities : sig 7 | (** Module to store experimental client capabilities *) 8 | 9 | type t 10 | 11 | val of_opt_json : Json.t option -> t 12 | val supportsJumpToNextHole : t -> bool 13 | end 14 | 15 | module Vscode : sig 16 | (** A collection of VS Code editor commands. 17 | 18 | Reference for VS Code built-in commands: 19 | https://code.visualstudio.com/api/references/commands *) 20 | module Commands : sig 21 | (** [editor.action.triggerSuggest] is a vscode-specific command, which 22 | triggers the completion request on all completion providers *) 23 | val triggerSuggest : Command.t 24 | end 25 | end 26 | 27 | (** Represents custom commands, i.e., commands added by a certain extension. *) 28 | module Custom_commands : sig 29 | (** Request client cursor to jump to the next hole. 30 | 31 | See the documentation for this command in [vscode-ocaml-platform] for 32 | details. 33 | 34 | @param in_range 35 | to pick a hole only in a given range; if omitted, the whole document is 36 | used 37 | @param notify_if_no_hole 38 | specifies whether we want the client to show the user a message if there 39 | is no hole to jump to *) 40 | val next_hole : ?in_range:Range.t -> notify_if_no_hole:bool -> unit -> Command.t 41 | end 42 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val compute 4 | : State.t Server.t 5 | -> CodeActionParams.t 6 | -> ([> `CodeAction of CodeAction.t ] list option Reply.t * State.t) Fiber.t 7 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/action_add_rec.mli: -------------------------------------------------------------------------------- 1 | val t : Code_action.t 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/action_construct.mli: -------------------------------------------------------------------------------- 1 | val t : Code_action.t 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/action_destruct.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val kind : CodeActionKind.t 4 | val t : State.t -> Code_action.t 5 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/action_extract.mli: -------------------------------------------------------------------------------- 1 | val local : Code_action.t 2 | val function_ : Code_action.t 3 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/action_inferred_intf.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | open Fiber.O 3 | 4 | let action_kind = "inferred_intf" 5 | 6 | let code_action_of_intf doc intf range = 7 | let edit : WorkspaceEdit.t = 8 | let edit = 9 | let textedit : TextEdit.t = { range; newText = intf } in 10 | let textDocument = 11 | let uri = Document.uri doc in 12 | let version = Document.version doc in 13 | OptionalVersionedTextDocumentIdentifier.create ~uri ~version () 14 | in 15 | TextDocumentEdit.create ~textDocument ~edits:[ `TextEdit textedit ] 16 | in 17 | WorkspaceEdit.create ~documentChanges:[ `TextDocumentEdit edit ] () 18 | in 19 | let title = String.capitalize_ascii "Insert inferred interface" in 20 | CodeAction.create 21 | ~title 22 | ~kind:(CodeActionKind.Other action_kind) 23 | ~edit 24 | ~isPreferred:false 25 | () 26 | ;; 27 | 28 | let code_action (state : State.t) doc (params : CodeActionParams.t) = 29 | match Document.kind doc with 30 | | `Other -> Fiber.return None 31 | | `Merlin m when Document.Merlin.kind m = Impl -> Fiber.return None 32 | | `Merlin _ -> 33 | let* intf = Inference.infer_intf state doc in 34 | (match intf with 35 | | None -> Fiber.return None 36 | | Some intf -> 37 | let+ formatted_intf = 38 | Ocamlformat_rpc.format_type state.ocamlformat_rpc ~typ:intf 39 | in 40 | let intf = 41 | match formatted_intf with 42 | | Ok formatted_intf -> formatted_intf 43 | | Error _ -> intf 44 | in 45 | Some (code_action_of_intf doc intf params.range)) 46 | ;; 47 | 48 | let kind = CodeActionKind.Other action_kind 49 | let t state = { Code_action.kind; run = `Non_batchable (code_action state) } 50 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/action_inferred_intf.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val kind : CodeActionKind.t 4 | val t : State.t -> Code_action.t 5 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/action_inline.mli: -------------------------------------------------------------------------------- 1 | val t : Code_action.t 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/action_jump.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val command_name : string 4 | val available : ShowDocumentClientCapabilities.t option -> bool 5 | val command_run : 'a Server.t -> ExecuteCommandParams.t -> Json.t Fiber.t 6 | 7 | val code_actions 8 | : Document.t 9 | -> CodeActionParams.t 10 | -> ShowDocumentClientCapabilities.t option 11 | -> CodeAction.t list Fiber.t 12 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/action_mark_remove_unused.mli: -------------------------------------------------------------------------------- 1 | val mark : Code_action.t 2 | val remove : Code_action.t 3 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/action_open_related.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val command_name : string 4 | val available : ShowDocumentClientCapabilities.t option -> bool 5 | val command_run : _ Server.t -> ExecuteCommandParams.t -> Json.t Fiber.t 6 | val for_uri : ShowDocumentClientCapabilities.t option -> Document.t -> CodeAction.t list 7 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/action_refactor_open.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | let code_action 4 | (mode : [ `Qualify | `Unqualify ]) 5 | (action_kind : string) 6 | pipeline 7 | _ 8 | (params : CodeActionParams.t) 9 | = 10 | let res = 11 | let command = 12 | let pos_start = Position.logical params.range.start in 13 | Query_protocol.Refactor_open (mode, pos_start) 14 | in 15 | Query_commands.dispatch pipeline command 16 | in 17 | match res with 18 | | [] -> None 19 | | changes -> 20 | let code_action = 21 | let edit : WorkspaceEdit.t = 22 | let edits = 23 | List.map changes ~f:(fun (newText, loc) -> 24 | { TextEdit.newText; range = Range.of_loc loc }) 25 | in 26 | let uri = params.textDocument.uri in 27 | WorkspaceEdit.create ~changes:[ uri, edits ] () 28 | in 29 | let kind = CodeActionKind.Other action_kind in 30 | let title = String.capitalize_ascii action_kind in 31 | CodeAction.create ~title ~kind ~edit ~isPreferred:false () 32 | in 33 | Some code_action 34 | ;; 35 | 36 | let unqualify = 37 | let action_kind = "remove module name from identifiers" in 38 | Code_action.batchable (Other action_kind) (code_action `Unqualify action_kind) 39 | ;; 40 | 41 | let qualify = 42 | let action_kind = "put module name in identifiers" in 43 | Code_action.batchable (Other action_kind) (code_action `Qualify action_kind) 44 | ;; 45 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/action_refactor_open.mli: -------------------------------------------------------------------------------- 1 | (** code action for Merlin command refactor-open-unqualify *) 2 | val unqualify : Code_action.t 3 | 4 | (** code action for Merlin command refactor-open-qualify *) 5 | val qualify : Code_action.t 6 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/action_remove_type_annotation.mli: -------------------------------------------------------------------------------- 1 | val t : Code_action.t 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/action_type_annotate.mli: -------------------------------------------------------------------------------- 1 | val t : Code_action.t 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/action_update_signature.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | open Fiber.O 3 | 4 | let action_kind = "update_intf" 5 | 6 | let code_action_of_intf doc text_edits = 7 | let edit : WorkspaceEdit.t = 8 | let doc_edit = 9 | let edits = List.map text_edits ~f:(fun e -> `TextEdit e) in 10 | let textDocument = 11 | let uri = Document.uri doc in 12 | let version = Document.version doc in 13 | OptionalVersionedTextDocumentIdentifier.create ~uri ~version () 14 | in 15 | TextDocumentEdit.create ~textDocument ~edits 16 | in 17 | WorkspaceEdit.create ~documentChanges:[ `TextDocumentEdit doc_edit ] () 18 | in 19 | let title = String.capitalize_ascii "update signature(s) to match implementation" in 20 | CodeAction.create 21 | ~title 22 | ~kind:(CodeActionKind.Other action_kind) 23 | ~edit 24 | ~isPreferred:false 25 | () 26 | ;; 27 | 28 | let code_action (state : State.t) doc (params : CodeActionParams.t) = 29 | match Document.kind doc with 30 | | `Other -> Fiber.return None 31 | | `Merlin m when Document.Merlin.kind m = Impl -> Fiber.return None 32 | | `Merlin intf_merlin -> 33 | let* text_edits = 34 | Inference.update_signatures ~state ~doc ~range:params.range ~intf_merlin 35 | in 36 | (match text_edits with 37 | | [] -> Fiber.return None 38 | | _ -> Fiber.return (Some (code_action_of_intf doc text_edits))) 39 | ;; 40 | 41 | let kind = CodeActionKind.Other action_kind 42 | let t state = { Code_action.kind; run = `Non_batchable (code_action state) } 43 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/code_action.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | (* TODO: 4 | 5 | - split the "needs merlin" part of the action out so that all actions can be 6 | batched *) 7 | 8 | type t = 9 | { kind : CodeActionKind.t 10 | ; run : 11 | [ `Batchable of 12 | Mpipeline.t -> Document.t -> CodeActionParams.t -> CodeAction.t option 13 | | `Non_batchable of Document.t -> CodeActionParams.t -> CodeAction.t option Fiber.t 14 | ] 15 | } 16 | 17 | let batchable kind run = { kind; run = `Batchable run } 18 | let non_batchable kind run = { kind; run = `Non_batchable run } 19 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/code_action.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | type t = 4 | { kind : CodeActionKind.t 5 | ; run : 6 | [ `Batchable of 7 | Mpipeline.t -> Document.t -> CodeActionParams.t -> CodeAction.t option 8 | | `Non_batchable of Document.t -> CodeActionParams.t -> CodeAction.t option Fiber.t 9 | ] 10 | (** A code action is either "batchable" or "non-batchable". Batchable 11 | actions do not use fibers internally, so they can be safely run 12 | inside a [with_pipeline] context. Non-batchable actions can use 13 | fibers. *) 14 | } 15 | 16 | val batchable 17 | : CodeActionKind.t 18 | -> (Mpipeline.t -> Document.t -> CodeActionParams.t -> CodeAction.t option) 19 | -> t 20 | 21 | val non_batchable 22 | : CodeActionKind.t 23 | -> (Document.t -> CodeActionParams.t -> CodeAction.t option Fiber.t) 24 | -> t 25 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/code_actions/diagnostic_util.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | let is_unused_var_warning s = 4 | String.is_prefix s ~prefix:"Error (warning 26)" 5 | || String.is_prefix s ~prefix:"Error (warning 27)" 6 | ;; 7 | 8 | let is_deprecated_warning s = String.is_prefix s ~prefix:"Error (alert deprecated)" 9 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/compl.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | module Resolve : sig 4 | type t 5 | 6 | val uri : t -> Uri.t 7 | 8 | (** if the completion item doesn't have [data] field, then we don't resolve 9 | but return it *) 10 | val of_completion_item : CompletionItem.t -> t option 11 | 12 | include Json.Jsonable.S with type t := t 13 | end 14 | 15 | val complete 16 | : State.t 17 | -> CompletionParams.t 18 | -> [> `CompletionList of CompletionList.t ] option Fiber.t 19 | 20 | (** creates a server response for ["completionItem/resolve"] *) 21 | val resolve 22 | : Document.Merlin.t 23 | -> CompletionItem.t 24 | -> Resolve.t 25 | -> (Document.Merlin.t -> [> `Logical of int * int ] -> string option Fiber.t) 26 | -> markdown:bool 27 | -> CompletionItem.t Fiber.t 28 | 29 | (** [prefix_of_position ~short_path source position] computes prefix before 30 | given [position]. A prefix is essentially a piece of code that refers to one 31 | thing eg a single infix operator "|>", a single reference to a function or 32 | variable: "List.map" a keyword "let" etc If there is semantically irrelivent 33 | whitespace it is removed eg "List. map"->"List.map" 34 | 35 | @param short_path 36 | determines whether we want full prefix or cut at ["."], e.g. 37 | [List.m] returns ["m"] when [short_path] is set vs ["List.m"] when 38 | not. 39 | @return prefix of [position] in [source] and its length *) 40 | val prefix_of_position : short_path:bool -> Msource.t -> [< Msource.position ] -> string 41 | 42 | (** [reconstruct_ident source position] returns the identifier at [position]. 43 | Note: [position] can be in the middle of the identifier. 44 | 45 | @return identifier unless none is found *) 46 | val reconstruct_ident : Msource.t -> [< Msource.position ] -> string option 47 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/configuration.ml: -------------------------------------------------------------------------------- 1 | open! Import 2 | open Fiber.O 3 | 4 | type t = 5 | { wheel : Lev_fiber.Timer.Wheel.t 6 | ; data : Config_data.t 7 | } 8 | 9 | let wheel t = t.wheel 10 | 11 | let default () = 12 | let+ wheel = 13 | let delay = 14 | match Env_vars._TEST () with 15 | | None -> 0.25 16 | | Some _ -> 0.0 17 | in 18 | Lev_fiber.Timer.Wheel.create ~delay 19 | in 20 | let data = Config_data.default in 21 | { wheel; data } 22 | ;; 23 | 24 | let update t { DidChangeConfigurationParams.settings } = 25 | let* wheel = 26 | match 27 | match settings with 28 | | `Assoc xs -> 29 | (match List.assoc xs "diagnostics_delay" with 30 | | Some (`Float f) -> Some f 31 | | Some (`Int i) -> Some (float_of_int i) 32 | | None -> None 33 | | _ -> 34 | Jsonrpc.Response.Error.raise 35 | (Jsonrpc.Response.Error.make 36 | ~code:InvalidRequest 37 | ~message:"invalid value for diagnostics_delay" 38 | ())) 39 | | _ -> None 40 | with 41 | | None -> Fiber.return t.wheel 42 | | Some delay -> 43 | if Float.equal delay (Lev_fiber.Timer.Wheel.delay t.wheel) 44 | then Fiber.return t.wheel 45 | else 46 | let* () = Lev_fiber.Timer.Wheel.set_delay t.wheel ~delay in 47 | Fiber.return t.wheel 48 | in 49 | let data = Config_data.t_of_yojson settings in 50 | Fiber.return { wheel; data } 51 | ;; 52 | 53 | let report_dune_diagnostics t = 54 | match t.data.dune_diagnostics with 55 | | Some { enable = true } | None -> true 56 | | Some { enable = false } -> false 57 | ;; 58 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/configuration.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | type t = 4 | { wheel : Lev_fiber.Timer.Wheel.t 5 | ; data : Config_data.t 6 | } 7 | 8 | val default : unit -> t Fiber.t 9 | val wheel : t -> Lev_fiber.Timer.Wheel.t 10 | val update : t -> DidChangeConfigurationParams.t -> t Fiber.t 11 | val report_dune_diagnostics : t -> bool 12 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/custom_request.ml: -------------------------------------------------------------------------------- 1 | module Construct = Req_construct 2 | module Hover_extended = Req_hover_extended 3 | module Infer_intf = Req_infer_intf 4 | module Merlin_call_compatible = Req_merlin_call_compatible 5 | module Switch_impl_intf = Req_switch_impl_intf 6 | module Typed_holes = Req_typed_holes 7 | module Type_enclosing = Req_type_enclosing 8 | module Wrapping_ast_node = Req_wrapping_ast_node 9 | module Get_documentation = Req_get_documentation 10 | module Type_search = Req_type_search 11 | module Merlin_jump = Req_merlin_jump 12 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/custom_request.mli: -------------------------------------------------------------------------------- 1 | (** {1 Exposed Custom Request} *) 2 | 3 | module Construct = Req_construct 4 | module Hover_extended = Req_hover_extended 5 | module Infer_intf = Req_infer_intf 6 | module Merlin_call_compatible = Req_merlin_call_compatible 7 | module Switch_impl_intf = Req_switch_impl_intf 8 | module Typed_holes = Req_typed_holes 9 | module Type_enclosing = Req_type_enclosing 10 | module Wrapping_ast_node = Req_wrapping_ast_node 11 | module Get_documentation = Req_get_documentation 12 | module Type_search = Req_type_search 13 | module Merlin_jump = Req_merlin_jump 14 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/req_construct.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | module Request_params : sig 4 | type t 5 | 6 | val create 7 | : ?with_values:[ `None | `Local ] 8 | -> ?depth:int 9 | -> text_document:Lsp.Types.TextDocumentIdentifier.t 10 | -> position:Position.t 11 | -> unit 12 | -> t 13 | 14 | val yojson_of_t : t -> Json.t 15 | end 16 | 17 | type t 18 | 19 | val t_of_yojson : Json.t -> t 20 | val capability : string * Json.t 21 | val meth : string 22 | val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t 23 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/req_get_documentation.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | module Request_params : sig 4 | type t 5 | 6 | val yojson_of_t : t -> Json.t 7 | 8 | val create 9 | : text_document:TextDocumentIdentifier.t 10 | -> position:Position.t 11 | -> ?identifier:string option 12 | -> ?contentFormat:MarkupKind.t option 13 | -> unit 14 | -> t 15 | end 16 | 17 | type t 18 | 19 | val t_of_yojson : Json.t -> t 20 | val meth : string 21 | val capability : string * [> `Bool of bool ] 22 | val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t 23 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/req_hover_extended.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | module Request_params : sig 4 | type t 5 | 6 | val create 7 | : ?verbosity:int 8 | -> text_document:Lsp.Types.TextDocumentIdentifier.t 9 | -> cursor_position:Position.t 10 | -> unit 11 | -> t 12 | 13 | val yojson_of_t : t -> Json.t 14 | end 15 | 16 | type t 17 | 18 | val t_of_yojson : Json.t -> t 19 | val capability : string * Json.t 20 | val meth : string 21 | val on_request : params:Jsonrpc.Structured.t option -> State.t Server.t -> Json.t Fiber.t 22 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/req_infer_intf.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | open Fiber.O 3 | 4 | let capability = "handleInferIntf", `Bool true 5 | let meth = "ocamllsp/inferIntf" 6 | 7 | let on_request ~(params : Jsonrpc.Structured.t option) (state : State.t) = 8 | Fiber.of_thunk (fun () -> 9 | match params with 10 | | Some (`List [ json_uri ]) -> 11 | let json_uri = DocumentUri.t_of_yojson json_uri in 12 | (match Document_store.get_opt state.store json_uri with 13 | | None -> 14 | Jsonrpc.Response.Error.raise 15 | (Jsonrpc.Response.Error.make 16 | ~code:InvalidParams 17 | ~message: 18 | "ocamllsp/inferIntf received a URI for an unloaded file. Load the file \ 19 | first." 20 | ()) 21 | | Some impl -> 22 | let+ intf = Inference.infer_intf_for_impl impl in 23 | Json.t_of_yojson (`String intf)) 24 | | Some json -> 25 | Jsonrpc.Response.Error.raise 26 | (Jsonrpc.Response.Error.make 27 | ~code:InvalidRequest 28 | ~message:"The input parameter for ocamllsp/inferIntf is invalid" 29 | ~data:(`Assoc [ "param", (json :> Json.t) ]) 30 | ()) 31 | | None -> 32 | Jsonrpc.Response.Error.raise 33 | (Jsonrpc.Response.Error.make 34 | ~code:InvalidRequest 35 | ~message:"ocamllsp/inferIntf must receive param: DocumentUri.t" 36 | ())) 37 | ;; 38 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/req_infer_intf.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val capability : string * Json.t 4 | val meth : string 5 | val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t 6 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/req_merlin_call_compatible.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | module Request_params : sig 4 | type t 5 | 6 | val create 7 | : text_document:TextDocumentIdentifier.t 8 | -> result_as_sexp:bool 9 | -> command:string 10 | -> args:string list 11 | -> t 12 | 13 | val yojson_of_t : t -> Json.t 14 | end 15 | 16 | type t 17 | 18 | val t_of_yojson : Json.t -> t 19 | val capability : string * Json.t 20 | val meth : string 21 | val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t 22 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/req_merlin_jump.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | module Request_params : sig 4 | type t 5 | 6 | val yojson_of_t : t -> Json.t 7 | val create : uri:DocumentUri.t -> position:Position.t -> target:string option -> t 8 | end 9 | 10 | type t 11 | 12 | val meth : string 13 | val capability : string * [> `Bool of bool ] 14 | val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t 15 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/req_switch_impl_intf.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | let capability = "handleSwitchImplIntf", `Bool true 4 | let meth = "ocamllsp/switchImplIntf" 5 | 6 | (** see the spec for [ocamllsp/switchImplIntf] *) 7 | let switch merlin_doc (param : DocumentUri.t) : Json.t = 8 | let files_to_switch_to = Document.get_impl_intf_counterparts merlin_doc param in 9 | Json.yojson_of_list Uri.yojson_of_t files_to_switch_to 10 | ;; 11 | 12 | let on_request ~(params : Jsonrpc.Structured.t option) (state : State.t) = 13 | match params with 14 | | Some (`List [ json_uri ]) -> 15 | let uri = DocumentUri.t_of_yojson json_uri in 16 | (match Document_store.get_opt state.store uri with 17 | | Some doc -> 18 | (match Document.kind doc with 19 | | `Merlin merlin_doc -> switch (Some merlin_doc) uri 20 | | `Other -> 21 | Jsonrpc.Response.Error.raise 22 | (Jsonrpc.Response.Error.make 23 | ~code:InvalidRequest 24 | ~message: 25 | "Document with this URI is not supported by ocamllsp/switchImplIntf" 26 | ~data:(`Assoc [ "param", (json_uri :> Json.t) ]) 27 | ())) 28 | | None -> switch None uri) 29 | | Some json -> 30 | Jsonrpc.Response.Error.raise 31 | (Jsonrpc.Response.Error.make 32 | ~code:InvalidRequest 33 | ~message:"The input parameter for ocamllsp/switchImplIntf is invalid" 34 | ~data:(`Assoc [ "param", (json :> Json.t) ]) 35 | ()) 36 | | None -> 37 | Jsonrpc.Response.Error.raise 38 | (Jsonrpc.Response.Error.make 39 | ~code:InvalidRequest 40 | ~message:"ocamllsp/switchImplIntf must receive param: DocumentUri.t" 41 | ()) 42 | ;; 43 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/req_switch_impl_intf.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val capability : string * Json.t 4 | val meth : string 5 | val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t 6 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/req_type_enclosing.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | module Request_params : sig 4 | type t 5 | 6 | val create 7 | : ?verbosity:int 8 | -> text_document:Lsp.Types.TextDocumentIdentifier.t 9 | -> at:[ `Position of Position.t | `Range of Range.t ] 10 | -> index:int 11 | -> unit 12 | -> t 13 | 14 | val yojson_of_t : t -> Json.t 15 | end 16 | 17 | type t 18 | 19 | val t_of_yojson : Json.t -> t 20 | val capability : string * Json.t 21 | val meth : string 22 | val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t 23 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/req_type_search.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | module Request_params : sig 4 | type t 5 | 6 | val yojson_of_t : t -> Json.t 7 | 8 | val create 9 | : TextDocumentIdentifier.t 10 | -> Position.t 11 | -> int 12 | -> string 13 | -> bool 14 | -> MarkupKind.t option 15 | -> t 16 | end 17 | 18 | type t 19 | 20 | val meth : string 21 | val capability : string * [> `Bool of bool ] 22 | val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t 23 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/req_typed_holes.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | module Request_params : sig 4 | type t 5 | 6 | val create : Uri.t -> t 7 | val yojson_of_t : t -> Json.t 8 | end 9 | 10 | type t 11 | 12 | val t_of_yojson : Json.t -> t 13 | val capability : string * Json.t 14 | val meth : string 15 | val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t 16 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/req_wrapping_ast_node.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val capability : string * Json.t 4 | val meth : string 5 | val on_request : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t 6 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/util.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | type 't req_params_spec = 4 | { params_schema : Jsonrpc.Structured.t 5 | ; of_jsonrpc_params : Jsonrpc.Structured.t -> 't option 6 | } 7 | 8 | let of_jsonrpc_params_exn spec params = 9 | let raise_invalid_params ?data ~message () = 10 | Jsonrpc.Response.Error.raise 11 | @@ Jsonrpc.Response.Error.make 12 | ?data 13 | ~code:Jsonrpc.Response.Error.Code.InvalidParams 14 | ~message 15 | () 16 | in 17 | match params with 18 | | None -> raise_invalid_params ~message:"Expected params but received none" () 19 | | Some params -> 20 | (match spec.of_jsonrpc_params params with 21 | | Some t -> t 22 | | None -> 23 | let error_json = 24 | `Assoc 25 | [ "params_expected", (spec.params_schema :> Json.t) 26 | ; "params_received", (params :> Json.t) 27 | ] 28 | in 29 | raise_invalid_params ~message:"Unexpected parameter format" ~data:error_json ()) 30 | ;; 31 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/custom_requests/util.mli: -------------------------------------------------------------------------------- 1 | type 't req_params_spec = 2 | { params_schema : Jsonrpc.Structured.t 3 | (** used to document the structure of the params; example: 4 | [`Assoc [ "uri" , `String "" ]]; *) 5 | ; of_jsonrpc_params : Jsonrpc.Structured.t -> 't option 6 | (** parses given structured JSON if it's of the expected schema; 7 | otherwise, return [None] *) 8 | } 9 | 10 | val of_jsonrpc_params_exn 11 | : 'req_params req_params_spec 12 | -> Jsonrpc.Structured.t option 13 | -> 'req_params 14 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/definition_query.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val run 4 | : [ `Definition | `Declaration | `Type_definition ] 5 | -> State.t 6 | -> Uri.t 7 | -> Position.t 8 | -> [> `Location of Import.Location.t list ] option Fiber.t 9 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/diagnostics.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val ocamllsp_source : string 4 | val dune_source : string 5 | 6 | type t 7 | 8 | val create 9 | : PublishDiagnosticsClientCapabilities.t option 10 | -> (PublishDiagnosticsParams.t list -> unit Fiber.t) 11 | -> report_dune_diagnostics:bool 12 | -> t 13 | 14 | val send : t -> [ `All | `One of Uri.t ] -> unit Fiber.t 15 | 16 | module Dune : sig 17 | type t 18 | 19 | val gen : Pid.t -> t 20 | end 21 | 22 | val set 23 | : t 24 | -> [ `Dune of Dune.t * Drpc.Diagnostic.Id.t * Uri.t * Diagnostic.t 25 | | `Merlin of Uri.t * Diagnostic.t list 26 | ] 27 | -> unit 28 | 29 | val remove : t -> [ `Dune of Dune.t * Drpc.Diagnostic.Id.t | `Merlin of Uri.t ] -> unit 30 | val disconnect : t -> Dune.t -> unit 31 | 32 | val tags_of_message 33 | : t 34 | -> src:[< `Dune | `Merlin ] 35 | -> string 36 | -> DiagnosticTag.t list option 37 | 38 | val merlin_diagnostics : t -> Document.Merlin.t -> unit Fiber.t 39 | val set_report_dune_diagnostics : t -> report_dune_diagnostics:bool -> unit Fiber.t 40 | 41 | (** Exposed for testing *) 42 | 43 | val equal_message : string -> string -> bool 44 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/doc_to_md.mli: -------------------------------------------------------------------------------- 1 | type t = 2 | | Raw of string 3 | | Markdown of string 4 | 5 | val translate : string -> t 6 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/document_store.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | type t 4 | 5 | type semantic_tokens_cache = 6 | { resultId : string 7 | ; tokens : int array 8 | } 9 | 10 | val make : _ Server.t Fdecl.t -> Fiber.Pool.t -> t 11 | val open_document : t -> Document.t -> unit Fiber.t 12 | val change_document : t -> Uri.t -> f:(Document.t -> Document.t) -> Document.t 13 | val get : t -> Uri.t -> Document.t 14 | val get_opt : t -> Uri.t -> Document.t option 15 | val unregister_promotions : t -> Uri.t list -> unit Fiber.t 16 | val register_promotions : t -> Uri.t list -> unit Fiber.t 17 | 18 | val update_semantic_tokens_cache 19 | : t 20 | -> Uri.t 21 | -> resultId:string 22 | -> tokens:int array 23 | -> unit 24 | 25 | val get_semantic_tokens_cache : t -> Uri.t -> semantic_tokens_cache option 26 | val close_document : t -> Uri.t -> unit Fiber.t 27 | val fold : t -> init:'acc -> f:(Document.t -> 'acc -> 'acc) -> 'acc 28 | val parallel_iter : t -> f:(Document.t -> unit Fiber.t) -> unit Fiber.t 29 | val close_all : t -> unit Fiber.t 30 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/document_symbol.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val run 4 | : ClientCapabilities.t 5 | -> Document.t 6 | -> Uri.t 7 | -> [> `DocumentSymbol of DocumentSymbol.t list 8 | | `SymbolInformation of SymbolInformation.t list 9 | ] 10 | option 11 | Fiber.t 12 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/document_text_command.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | open Fiber.O 3 | 4 | let command_name = "ocamllsp/show-document-text" 5 | 6 | let command_run server store args = 7 | let uri = 8 | match args with 9 | | Some [ `String arg ] -> arg 10 | | _ -> assert false 11 | in 12 | let doc = Document_store.get store (Uri.t_of_yojson (`String uri)) |> Document.text in 13 | let uri, chan = 14 | Filename.open_temp_file 15 | (sprintf "ocamllsp-document.%d" (Unix.getpid ())) 16 | (Filename.extension uri) 17 | in 18 | output_string chan doc; 19 | close_out_noerr chan; 20 | let req = 21 | let uri = Uri.of_path uri in 22 | Server_request.ShowDocumentRequest (ShowDocumentParams.create ~uri ~takeFocus:true ()) 23 | in 24 | let+ { ShowDocumentResult.success = _ } = Server.request server req in 25 | () 26 | ;; 27 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/document_text_command.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val command_name : string 4 | val command_run : _ Server.t -> Document_store.t -> Json.t list option -> unit Fiber.t 5 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name ocaml_lsp_server) 3 | (libraries 4 | dyn 5 | xdg 6 | unix 7 | dune-build-info 8 | fiber 9 | chrome-trace 10 | lev 11 | lev_fiber 12 | lev_fiber_csexp 13 | jsonrpc 14 | spawn 15 | lsp 16 | lsp_fiber 17 | merlin-lib.dot_protocol 18 | merlin-lib.analysis 19 | merlin-lib.kernel 20 | merlin-lib.ocaml_parsing 21 | merlin-lib.query_commands 22 | merlin-lib.query_protocol 23 | merlin-lib.ocaml_merlin_specific 24 | merlin-lib.ocaml_typing 25 | merlin-lib.ocaml_utils 26 | merlin-lib.utils 27 | merlin-lib.extend 28 | merlin-lib.commands 29 | cmarkit 30 | odoc_parser 31 | ppx_yojson_conv_lib 32 | re 33 | stdune 34 | ordering 35 | csexp 36 | yojson 37 | dune-rpc 38 | ocamlformat-rpc-lib 39 | ocamlc-loc 40 | base) 41 | (lint 42 | (pps ppx_yojson_conv)) 43 | (instrumentation 44 | (backend bisect_ppx))) 45 | 46 | (include_subdirs unqualified) 47 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/dune.mli: -------------------------------------------------------------------------------- 1 | open! Import 2 | 3 | module Instance : sig 4 | type t 5 | 6 | val format_dune_file : t -> Document.t -> string Fiber.t 7 | end 8 | 9 | type t 10 | 11 | val view_promotion_capability : string * Json.t 12 | val run : t -> unit Fiber.t 13 | 14 | val create 15 | : Workspaces.t 16 | -> ClientCapabilities.t 17 | -> Diagnostics.t 18 | -> Progress.t 19 | -> Document_store.t 20 | -> log:(type_:MessageType.t -> message:string -> unit Fiber.t) 21 | -> t 22 | 23 | val update_workspaces : t -> Workspaces.t -> unit 24 | val stop : t -> unit Fiber.t 25 | val commands : string list 26 | val on_command : t -> ExecuteCommandParams.t -> Json.t Fiber.t 27 | val code_actions : t -> Uri.t -> CodeAction.t list 28 | val for_doc : t -> Document.t -> Instance.t list 29 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/env_vars.ml: -------------------------------------------------------------------------------- 1 | open Stdune.Option.O 2 | 3 | let _TEST () : bool option = 4 | let+ v = Sys.getenv_opt "OCAMLLSP_TEST" in 5 | match v with 6 | | "true" -> true 7 | | "false" -> false 8 | | unexpected_val -> 9 | Format.eprintf 10 | "invalid value %S for OCAMLLSP_TEST ignored. Only true or false are allowed@." 11 | unexpected_val; 12 | false 13 | ;; 14 | 15 | let _IS_HOVER_EXTENDED () : bool option = 16 | let* v = Sys.getenv_opt "OCAMLLSP_HOVER_IS_EXTENDED" in 17 | match v with 18 | | "true" | "1" -> Some true 19 | | _ -> Some false 20 | ;; 21 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/folding_range.mli: -------------------------------------------------------------------------------- 1 | (** This module is responsible for computing the folding range for OCaml source *) 2 | 3 | open Import 4 | 5 | (** Compute the folding range *) 6 | val compute : State.t -> FoldingRangeParams.t -> FoldingRange.t list option Fiber.t 7 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/hover_req.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | (** This module contains functionality to handle `textDocument/hover` LSP 4 | request. *) 5 | 6 | type mode = 7 | | Default 8 | | Extended_fixed of int 9 | | Extended_variable 10 | 11 | (** [handle server hover_params] provides a response for LSP request 12 | `textDocument/hover` *) 13 | val handle : State.t Server.t -> HoverParams.t -> mode -> Hover.t option Fiber.t 14 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/inference.mli: -------------------------------------------------------------------------------- 1 | val infer_intf_for_impl : Document.t -> string Fiber.t 2 | 3 | (** Called by the code action "insert inferred interface". Gets the Merlin 4 | typer_result for both the implementation and interface documents, and uses 5 | the diff between them to produce the updated interface. Any names present in 6 | the existing interface are omitted from the inserted code (regardless of 7 | whether their signatures have changed). *) 8 | val infer_missing_intf_for_impl 9 | : Document.t (** implementation *) 10 | -> Document.t (** interface *) 11 | -> string Fiber.t 12 | (** code to be inserted in the interface *) 13 | 14 | val infer_intf : State.t -> Document.t -> string option Fiber.t 15 | 16 | (** Called by the code action "update signature(s) to match implementation". 17 | Compares signatures found in the selected range of the interface document 18 | with ones inferred from the corresponding implementation document, and 19 | produces text edits for any that can be updated. *) 20 | val update_signatures 21 | : state:State.t 22 | -> intf_merlin:Document.Merlin.t 23 | -> doc:Document.t 24 | -> range:Range.t 25 | -> Import.TextEdit.t list Fiber.t 26 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/inlay_hints.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val compute : State.t -> InlayHintParams.t -> InlayHint.t list option Fiber.t 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/merlin_config.mli: -------------------------------------------------------------------------------- 1 | (** Fetch merlin configuration with dune subprocesses *) 2 | 3 | open Import 4 | 5 | type t 6 | 7 | val should_read_dot_merlin : bool ref 8 | val config : t -> Mconfig.t Fiber.t 9 | val destroy : t -> unit Fiber.t 10 | 11 | module DB : sig 12 | type config := t 13 | type t 14 | 15 | val create : unit -> t 16 | val stop : t -> unit Fiber.t 17 | val run : t -> unit Fiber.t 18 | val get : t -> Uri.t -> config 19 | end 20 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/merlin_config_command.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | open Fiber.O 3 | 4 | let command_name = "ocamllsp/show-merlin-config" 5 | 6 | let command_run server store = 7 | let* json = 8 | let+ docs = 9 | Document_store.fold store ~init:[] ~f:(fun doc acc -> 10 | match Document.kind doc with 11 | | `Other -> acc 12 | | `Merlin m -> m :: acc) 13 | |> Fiber.parallel_map ~f:(fun doc -> 14 | let+ config = Document.Merlin.mconfig doc in 15 | let config : Json.t = (Mconfig.dump config :> Json.t) in 16 | let uri = Document.uri (Document.Merlin.to_doc doc) in 17 | Uri.to_string uri, config) 18 | in 19 | let json = `Assoc docs in 20 | Format.asprintf "%a@.%!" Json.pp json 21 | in 22 | let uri, chan = 23 | Filename.open_temp_file (sprintf "merlin-config.%d" (Unix.getpid ())) ".json" 24 | in 25 | output_string chan json; 26 | close_out_noerr chan; 27 | let req = 28 | let uri = Uri.of_path uri in 29 | Server_request.ShowDocumentRequest (ShowDocumentParams.create ~uri ~takeFocus:true ()) 30 | in 31 | let+ { ShowDocumentResult.success = _ } = Server.request server req in 32 | () 33 | ;; 34 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/merlin_config_command.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val command_name : string 4 | val command_run : _ Server.t -> Document_store.t -> unit Fiber.t 5 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/metrics.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | open Fiber.O 3 | 4 | let max_len = 1_000 5 | 6 | type t = { events : Chrome_trace.Event.t Queue.t } 7 | 8 | let t_var : t Fiber.Var.t = Fiber.Var.create () 9 | let get () = Fiber.Var.get_exn t_var 10 | 11 | let report (event : Chrome_trace.Event.t) : unit Fiber.t = 12 | let+ t = get () in 13 | if Queue.length t.events >= max_len 14 | then ( 15 | let (_ : Chrome_trace.Event.t) = Queue.dequeue_exn t.events in 16 | ()); 17 | Queue.enqueue t.events event 18 | ;; 19 | 20 | let dump () = 21 | let+ t = get () in 22 | let traceEvents = Queue.to_list t.events in 23 | let json = 24 | Chrome_trace.Output_object.create ~traceEvents () 25 | |> Chrome_trace.Output_object.to_json 26 | in 27 | Json.to_string (json :> Json.t) 28 | ;; 29 | 30 | let create () = { events = Queue.create () } 31 | let with_metrics t f = Fiber.Var.set t_var t f 32 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/metrics.mli: -------------------------------------------------------------------------------- 1 | type t 2 | 3 | val create : unit -> t 4 | val with_metrics : t -> (unit -> 'a Fiber.t) -> 'a Fiber.t 5 | val report : Chrome_trace.Event.t -> unit Fiber.t 6 | val dump : unit -> string Fiber.t 7 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/ocaml_lsp_server.mli: -------------------------------------------------------------------------------- 1 | val run : Lsp.Cli.Channel.t -> read_dot_merlin:bool -> unit -> unit 2 | 3 | module Diagnostics = Diagnostics 4 | module Version = Version 5 | module Position = Position 6 | module Doc_to_md = Doc_to_md 7 | module Testing = Testing 8 | module Custom_request = Custom_request 9 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/ocamlformat.mli: -------------------------------------------------------------------------------- 1 | (** Generic formatting facility for OCaml and Reason sources. 2 | 3 | Relies on [ocamlformat] for OCaml and [refmt] for reason *) 4 | 5 | open Import 6 | 7 | type error = 8 | | Unsupported_syntax of Document.Syntax.t 9 | | Missing_binary of { binary : string } 10 | | Unexpected_result of { message : string } 11 | | Unknown_extension of Uri.t 12 | 13 | val message : error -> string 14 | val run : Document.t -> Fiber.Cancel.t option -> (TextEdit.t list, error) result Fiber.t 15 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/ocamlformat_rpc.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | type t 4 | 5 | val create : unit -> t 6 | val stop : t -> unit Fiber.t 7 | 8 | val format_type 9 | : t 10 | -> typ:string 11 | -> (string, [> `Msg of string | `No_process ]) result Fiber.t 12 | 13 | val format_doc 14 | : t 15 | -> Document.t 16 | -> (TextEdit.t list, [> `Msg of string | `No_process | `No_V2 ]) result Fiber.t 17 | 18 | val run 19 | : logger:(type_:MessageType.t -> message:string -> unit Fiber.t) 20 | -> t 21 | -> (unit, [> `Disabled | `Binary_not_found ]) result Fiber.t 22 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/position.mli: -------------------------------------------------------------------------------- 1 | open! Import 2 | include module type of Lsp.Types.Position with type t = Lsp.Types.Position.t 3 | 4 | val compare_inclusion : t -> Lsp.Types.Range.t -> [ `Inside | `Outside of t ] 5 | val ( - ) : t -> t -> t 6 | val compare : t -> t -> Ordering.t 7 | val logical : t -> [> `Logical of int * int ] 8 | val of_lexical_position : Lexing.position -> t option 9 | val start : t 10 | val to_dyn : t -> Dyn.t 11 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/prefix_parser.mli: -------------------------------------------------------------------------------- 1 | (** Tries the parse the incoming string for a prefix. The string should be the 2 | source code ending at the prefix position. pos and len set the range for the 3 | regex to operate on *) 4 | val parse : pos:int -> len:int -> string -> string option 5 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/progress.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | type t 4 | 5 | val create 6 | : ClientCapabilities.t 7 | -> report_progress:(Lsp.Progress.t ProgressParams.t -> unit Fiber.t) 8 | -> create_task:(WorkDoneProgressCreateParams.t -> unit Fiber.t) 9 | -> t 10 | 11 | val end_build_if_running : t -> unit Fiber.t 12 | val build_progress : t -> Drpc.Progress.t -> unit Fiber.t 13 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/range.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | include module type of Lsp.Types.Range with type t = Lsp.Types.Range.t 3 | 4 | (** [compare r1 r2] compares first start positions, if equal compares the end 5 | positions. *) 6 | val compare : t -> t -> Ordering.t 7 | 8 | (** [contains r1 r2] returns true if [r1] contains [r2]. *) 9 | val contains : t -> t -> bool 10 | 11 | val to_dyn : t -> Dyn.t 12 | val compare_size : t -> t -> Ordering.t 13 | val first_line : t 14 | val of_loc_opt : Loc.t -> t option 15 | 16 | (** [of_loc loc] if fails to convert [loc] to [t] will return the first (or top) 17 | line in the document *) 18 | val of_loc : Loc.t -> t 19 | 20 | (** [resize_for_edit edit] returns shrunk, unchanged, or extended [edit.range] 21 | depending on the size of [edit.newText], e.g., if [edit.newText] contains 22 | less characters than [edit.range], the new range is shrunk to fit 23 | [edit.newText] only. *) 24 | val resize_for_edit : TextEdit.t -> t 25 | 26 | (** [overlaps r1 r2] is true if [r1] and [r2] overlap. *) 27 | val overlaps : t -> t -> bool 28 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/rename.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val rename : State.t -> RenameParams.t -> WorkspaceEdit.t Fiber.t 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/semantic_highlighting.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val legend : SemanticTokensLegend.t 4 | val on_request_full : State.t -> SemanticTokensParams.t -> SemanticTokens.t option Fiber.t 5 | 6 | val on_request_full_delta 7 | : State.t 8 | -> SemanticTokensDeltaParams.t 9 | -> [ `SemanticTokens of SemanticTokens.t 10 | | `SemanticTokensDelta of SemanticTokensDelta.t 11 | ] 12 | option 13 | Fiber.t 14 | 15 | module Debug : sig 16 | val meth_request_full : string 17 | val on_request_full : params:Jsonrpc.Structured.t option -> State.t -> Json.t Fiber.t 18 | end 19 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/signature_help.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val run : State.t -> SignatureHelpParams.t -> SignatureHelp.t Fiber.t 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/testing.ml: -------------------------------------------------------------------------------- 1 | (**WARNING: This is for internal use in testing only *) 2 | 3 | module Compl = Compl 4 | module Merlin_kernel = Merlin_kernel 5 | module Prefix_parser = Prefix_parser 6 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/typed_hole.ml: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | let syntax_repr = "_" 4 | let can_be_hole s = String.equal syntax_repr s 5 | 6 | (* the pattern matching below is taken and modified (minimally, to adapt the 7 | return type) from [Query_commands.dispatch]'s [Construct] branch; 8 | 9 | If we directly dispatched [Construct] command to merlin, we'd be doing 10 | useless computations: we need info whether the expression at the cursor is a 11 | hole, we don't need constructed expressions yet. 12 | 13 | Ideally, merlin should return a callback [option], which is [Some] when the 14 | context is applicable. *) 15 | let is_a_hole = function 16 | | (_, Browse_raw.Module_expr { mod_desc = Tmod_hole; _ }) :: (_, _) :: _ 17 | | (_, Browse_raw.Expression { exp_desc = Texp_hole; _ }) :: _ -> true 18 | | [] | (_, _) :: _ -> false 19 | ;; 20 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/typed_hole.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | (** This module should be used to work with typed holes. The main goal is to 4 | hide syntactic representation of a typed hole, which may change in future *) 5 | 6 | (** checks whether the current string matches the syntax representation of a 7 | typed hole *) 8 | val can_be_hole : string -> bool 9 | 10 | (** [is_a_hole nodes] checks whether the leaf node [1] is a typed hole 11 | 12 | Note: this function is extracted from merlin sources handling [Construct] 13 | command in [merlin/src/frontend/query_commands.ml] 14 | 15 | [1] leaf node is the head of the list, as 16 | [Mbrowse.t = (Env.t * Browse_raw.node) list]*) 17 | val is_a_hole : Mbrowse.t -> bool 18 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/version.ml: -------------------------------------------------------------------------------- 1 | let get () = 2 | match Build_info.V1.version () with 3 | | None -> "dev" 4 | | Some v -> Build_info.V1.Version.to_string v 5 | ;; 6 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/version.mli: -------------------------------------------------------------------------------- 1 | val get : unit -> string 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/workspace_symbol.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | val run 4 | : _ Server.t 5 | -> State.t 6 | -> WorkspaceSymbolParams.t 7 | -> SymbolInformation.t list option Fiber.t 8 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/src/workspaces.mli: -------------------------------------------------------------------------------- 1 | open Import 2 | 3 | type t 4 | 5 | val create : InitializeParams.t -> t 6 | val on_change : t -> DidChangeWorkspaceFoldersParams.t -> t 7 | val workspace_folders : t -> WorkspaceFolder.t list 8 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/dune: -------------------------------------------------------------------------------- 1 | (dirs :standard \ e2e) 2 | 3 | (library 4 | (modules ocaml_lsp_tests position_prefix_tests) 5 | (name ocaml_lsp_tests) 6 | (enabled_if 7 | (>= %{ocaml_version} 4.08)) 8 | (inline_tests) 9 | (libraries 10 | stdune 11 | ocaml_lsp_server 12 | merlin-lib.kernel 13 | lsp 14 | yojson 15 | ;; This is because of the (implicit_transitive_deps false) 16 | ;; in dune-project 17 | base 18 | ppx_expect 19 | ppx_expect.config 20 | ppx_expect.config_types 21 | ppx_inline_test.config) 22 | (preprocess 23 | (pps ppx_expect))) 24 | 25 | (executable 26 | (modules run_test_e2e) 27 | (name run_test_e2e)) 28 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e-new/code_actions.mli: -------------------------------------------------------------------------------- 1 | open Test.Import 2 | 3 | val iter_code_actions 4 | : ?prep:(unit Test.Import.Client.t -> unit Fiber.t) 5 | -> ?path:string 6 | -> ?diagnostics:Diagnostic.t list 7 | -> source:string 8 | -> Range.t 9 | -> (CodeActionResult.t -> unit) 10 | -> unit 11 | 12 | val parse_selection : string -> string * Range.t 13 | 14 | val apply_code_action 15 | : ?diagnostics:Diagnostic.t list 16 | -> string 17 | -> string 18 | -> Range.t 19 | -> string option 20 | 21 | (** [code_action_test title source] runs the code action with title [title] and 22 | prints the resulting source. *) 23 | val code_action_test : title:string -> string -> unit 24 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e-new/doc_to_md.ml: -------------------------------------------------------------------------------- 1 | open Ocaml_lsp_server.Doc_to_md 2 | 3 | let print_doc = function 4 | | Raw s -> print_endline s 5 | | Markdown s -> print_endline s 6 | ;; 7 | 8 | let%expect_test "superscript" = 9 | let doc = {| 2{^30} |} in 10 | translate doc |> print_doc; 11 | [%expect {| 2^{30} |}] 12 | ;; 13 | 14 | let%expect_test "subscript" = 15 | let doc = {| a{_b} |} in 16 | translate doc |> print_doc; 17 | [%expect {| a\_{b} |}] 18 | ;; 19 | 20 | let%expect_test "table" = 21 | let doc = 22 | {| {table {tr {td some content} {td some other content}} {tr {td in another} {td row}}} |} 23 | in 24 | translate doc |> print_doc; 25 | [%expect 26 | {| 27 | | some content | some other content | 28 | | in another | row | |}] 29 | ;; 30 | 31 | let%expect_test "table2" = 32 | let doc = 33 | {| 34 | {t | z | f | 35 | |:-----|---:| 36 | | fse | e | } 37 | |} 38 | in 39 | translate doc |> print_doc; 40 | [%expect 41 | {| 42 | | z | f | 43 | |:-|-:| 44 | | fse | e | |}] 45 | ;; 46 | 47 | let%expect_test "problematic_translation" = 48 | let doc = {| {table {tr {td {ul {li first item} {li second item}}}} } |} in 49 | translate doc |> print_doc; 50 | [%expect 51 | {| 52 | | - first item - second item | |}] 53 | ;; 54 | 55 | let%expect_test "code_with_output" = 56 | let doc = {| {@ocaml[foo][output {b foo}]} |} in 57 | translate doc |> print_doc; 58 | [%expect 59 | {| 60 | ```ocaml 61 | foo 62 | ``` 63 | output **foo** |}] 64 | ;; 65 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e-new/dune: -------------------------------------------------------------------------------- 1 | (env 2 | (_ 3 | (env-vars 4 | (OCAMLLSP_TEST true) 5 | (LEV_DEBUG 1)))) 6 | 7 | (library 8 | (name ocaml_lsp_e2e) 9 | (inline_tests 10 | (enabled_if 11 | (= %{os_type} Unix)) 12 | (deps 13 | %{bin:ocamlformat-rpc} 14 | for_ppx.ml 15 | for_pp.ml 16 | (package ocaml-lsp-server))) 17 | (libraries 18 | unix 19 | stdune 20 | fiber 21 | yojson 22 | ppx_yojson_conv_lib 23 | lev_fiber 24 | lev 25 | ocaml_lsp_server 26 | spawn 27 | jsonrpc 28 | lsp 29 | lsp_fiber 30 | ;; This is because of the (implicit_transitive_deps false) 31 | ;; in dune-project 32 | base 33 | ppx_expect 34 | ppx_expect.config 35 | ppx_expect.config_types 36 | ppx_inline_test.config) 37 | (preprocess 38 | (per_module 39 | ((action 40 | (run sed "s/world/universe/g" %{input-file})) 41 | for_pp) 42 | ((pps ppx_expect) 43 | action_extract 44 | action_inline 45 | action_mark_remove 46 | code_actions 47 | completion 48 | completions 49 | construct 50 | doc_to_md 51 | document_flow 52 | exit_notification 53 | for_ppx 54 | hover_extended 55 | inlay_hints 56 | merlin_call_compatible 57 | metrics 58 | semantic_hl_data 59 | semantic_hl_helpers 60 | semantic_hl_tests 61 | start_stop 62 | syntax_doc_tests 63 | test 64 | type_enclosing 65 | documentation 66 | merlin_jump 67 | type_search 68 | with_pp 69 | with_ppx 70 | workspace_change_config)))) 71 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e-new/for_pp.ml: -------------------------------------------------------------------------------- 1 | type world 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e-new/for_ppx.ml: -------------------------------------------------------------------------------- 1 | let%expect_test "this is a dummy source for with_ppx" = 2 | (* If you edit this file, [with_ppx] will change *) 3 | [%expect {||}] 4 | ;; 5 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e-new/helpers.ml: -------------------------------------------------------------------------------- 1 | open Test.Import 2 | 3 | let client_capabilities = ClientCapabilities.create () 4 | let uri = DocumentUri.of_path "test.ml" 5 | 6 | let test ?extra_env text req = 7 | let on_notification, diagnostics = Test.drain_diagnostics () in 8 | let handler = Client.Handler.make ~on_notification () in 9 | Test.run ~handler ?extra_env (fun client -> 10 | let run_client () = 11 | Client.start client (InitializeParams.create ~capabilities:client_capabilities ()) 12 | in 13 | let run () = 14 | let* (_ : InitializeResult.t) = Client.initialized client in 15 | let textDocument = 16 | TextDocumentItem.create ~uri ~languageId:"ocaml" ~version:0 ~text 17 | in 18 | let* () = 19 | Client.notification 20 | client 21 | (TextDocumentDidOpen (DidOpenTextDocumentParams.create ~textDocument)) 22 | in 23 | let* () = req client in 24 | let* () = Client.request client Shutdown in 25 | let* () = Fiber.Ivar.read diagnostics in 26 | Client.stop client 27 | in 28 | Fiber.fork_and_join_unit run_client run) 29 | ;; 30 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e-new/helpers.mli: -------------------------------------------------------------------------------- 1 | open Test.Import 2 | 3 | val uri : Uri.t 4 | val test : ?extra_env:string list -> string -> (unit Client.t -> unit Fiber.t) -> unit 5 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e-new/lsp_helpers.mli: -------------------------------------------------------------------------------- 1 | open Test.Import 2 | 3 | (** Send the given configuration to the language server *) 4 | val change_config : client:'a Client.t -> DidChangeConfigurationParams.t -> unit Fiber.t 5 | 6 | (** Opens a document with the language server. This must be done before trying 7 | to access it *) 8 | val open_document 9 | : client:'a Client.t 10 | -> uri:DocumentUri.t 11 | -> source:string 12 | -> unit Fiber.t 13 | 14 | (** Performs the request you return from the makeRequest function and then gives 15 | it the the handler function you provide *) 16 | val iter_lsp_response 17 | : ?prep:(unit Client.t -> unit Fiber.t) 18 | -> ?path:string 19 | -> makeRequest:(TextDocumentIdentifier.t -> 'a Client.out_request) 20 | -> source:string 21 | -> ('a -> unit) 22 | -> unit 23 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e-new/semantic_hl_data.ml: -------------------------------------------------------------------------------- 1 | let src0 = 2 | {| 3 | module Moo : sig 4 | type t 5 | 6 | type koo = 7 | | Foo of string 8 | | Bar of [ `Int of int | `String of string ] 9 | 10 | val u : unit 11 | 12 | val f : unit -> t 13 | end = struct 14 | type t = int 15 | 16 | type koo = 17 | | Foo of string 18 | | Bar of [ `Int of int | `String of string ] 19 | 20 | let u = () 21 | 22 | let f () = 0 23 | end 24 | 25 | module type Bar = sig 26 | type t = 27 | { foo : Moo.t 28 | ; bar : int 29 | } 30 | end 31 | 32 | type t = Moo.koo = 33 | | Foo of string 34 | | Bar of [ `BarInt of int | `BarString of string ] 35 | 36 | let f (foo : t) = 37 | match foo with 38 | | Moo.Foo s -> s ^ string_of_int 0 39 | | Moo.Bar (`BarInt i) -> string_of_int i 40 | | Moo.Bar (`BarString s) -> s 41 | 42 | module Foo (Arg : Bar) = struct 43 | module Inner_foo = struct 44 | type t = string 45 | end 46 | end 47 | 48 | module Foo_inst = Foo (struct 49 | type t = 50 | { foo : Moo.t 51 | ; bar : int 52 | } 53 | end) 54 | |} 55 | ;; 56 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e-new/semantic_hl_helpers.mli: -------------------------------------------------------------------------------- 1 | open Test.Import 2 | 3 | val annotate_src_with_tokens 4 | : legend:SemanticTokensLegend.t 5 | -> encoded_tokens:int array 6 | -> annot_mods:bool 7 | -> string 8 | -> string 9 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/Lifecycle.test.ts: -------------------------------------------------------------------------------- 1 | import * as Protocol from "vscode-languageserver-protocol"; 2 | import * as LanguageServer from "./../src/LanguageServer"; 3 | 4 | test("basic", async () => { 5 | const languageServer = LanguageServer.start(); 6 | await LanguageServer.exit(languageServer); 7 | }); 8 | 9 | test("initialize with empty capabilities", async () => { 10 | const languageServer = LanguageServer.start(); 11 | 12 | const capabilities: Protocol.ClientCapabilities = {}; 13 | 14 | const initializeParameters: Protocol.InitializeParams = { 15 | processId: process.pid, 16 | rootUri: LanguageServer.toURI(__dirname), 17 | capabilities: capabilities, 18 | workspaceFolders: [], 19 | }; 20 | 21 | const result = await languageServer.sendRequest( 22 | Protocol.InitializeRequest.type, 23 | initializeParameters, 24 | ); 25 | 26 | expect(result.capabilities).toBeTruthy(); 27 | await LanguageServer.exit(languageServer); 28 | }); 29 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/Request.Debug.test.ts: -------------------------------------------------------------------------------- 1 | import * as LanguageServer from "./../src/LanguageServer"; 2 | 3 | test("debug/echo", async () => { 4 | const languageServer = await LanguageServer.startAndInitialize(); 5 | 6 | const params = { 7 | message: "testing", 8 | }; 9 | 10 | const result: any = await languageServer.sendRequest("debug/echo", params); 11 | 12 | expect(result.message).toBe("testing"); 13 | await LanguageServer.exit(languageServer); 14 | }); 15 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/declaration_files/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name declaration_files)) 3 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/declaration_files/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 2.5) 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/declaration_files/lib.ml: -------------------------------------------------------------------------------- 1 | let x = 1 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/declaration_files/lib.mli: -------------------------------------------------------------------------------- 1 | val x : int 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/declaration_files/main.ml: -------------------------------------------------------------------------------- 1 | let y = Lib.x 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/ocamllsp-inferIntf.ts: -------------------------------------------------------------------------------- 1 | import outdent from "outdent"; 2 | import * as Protocol from "vscode-languageserver-protocol"; 3 | import * as Types from "vscode-languageserver-types"; 4 | import * as LanguageServer from "../src/LanguageServer"; 5 | 6 | describe("ocamllsp/inferIntf", () => { 7 | let languageServer: LanguageServer.LanguageServer; 8 | 9 | function openDocument(source: string, name: string) { 10 | languageServer.sendNotification( 11 | Protocol.DidOpenTextDocumentNotification.type, 12 | { 13 | textDocument: Types.TextDocumentItem.create( 14 | LanguageServer.toURI(name), 15 | "ocaml", 16 | 0, 17 | source, 18 | ), 19 | }, 20 | ); 21 | } 22 | 23 | beforeEach(async () => { 24 | languageServer = await LanguageServer.startAndInitialize(); 25 | }); 26 | 27 | afterEach(async () => { 28 | await LanguageServer.exit(languageServer); 29 | }); 30 | 31 | async function inferIntf(name: string) { 32 | return await languageServer.sendRequest( 33 | "ocamllsp/inferIntf", 34 | `file:///${name}`, 35 | ); 36 | } 37 | 38 | it("can infer module interfaces", async () => { 39 | openDocument( 40 | outdent` 41 | type t = Foo of int | Bar of bool 42 | 43 | let f (x : t) = x 44 | `, 45 | "test.ml", 46 | ); 47 | const actions = await inferIntf("test.ml"); 48 | expect(actions).toEqual( 49 | "type t = Foo of int | Bar of bool\nval f : t -> t\n", 50 | ); 51 | }); 52 | }); 53 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/bin/a.ml: -------------------------------------------------------------------------------- 1 | let a_x = 5 2 | 3 | module A_B = struct 4 | type a_b_t = string 5 | let a_b = "hello" 6 | end 7 | 8 | let a_d = 9 | match "" with 10 | | "" -> true 11 | | _ -> false 12 | 13 | type user = 14 | | Admin 15 | | NotAdmin 16 | 17 | let a_u = Admin 18 | 19 | let a_arr = [] 20 | 21 | let a_m, a_n = (1, 2) 22 | 23 | let a_i = 24 | let a_i_h = 6 in 25 | a_i_h 26 | 27 | module StringMap = Map.Make (String) 28 | module My_string = String 29 | 30 | module A_Mod : sig 31 | type t = int 32 | 33 | val compare : t -> t -> int 34 | end = struct 35 | type t = int 36 | 37 | let private_mod_fn = Stdlib.abs 38 | 39 | let compare = Stdlib.compare 40 | end 41 | 42 | module type X_int = sig 43 | val x : int 44 | end 45 | 46 | module Increment (M : X_int) = struct 47 | let increment_x = M.x + 1 48 | end 49 | 50 | exception Foo of string 51 | 52 | class stack_of_ints = 53 | object 54 | val mutable the_list : int list = [] 55 | 56 | method push x = the_list <- x :: the_list 57 | 58 | method pop = 59 | let result = List.hd the_list in 60 | the_list <- List.tl the_list; 61 | result 62 | 63 | method peek = List.hd the_list 64 | 65 | method size = List.length the_list 66 | end 67 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/bin/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name main) 3 | (package main) 4 | (flags :standard -w -32) 5 | (public_name main) 6 | (libraries lib)) 7 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/bin/main.ml: -------------------------------------------------------------------------------- 1 | let main_y = Lib.lib_x 2 | ;; 3 | 4 | let () = 5 | let main_z = "test" in 6 | 7 | print_endline (main_z);; 8 | 9 | print_endline (string_of_int main_y) 10 | 11 | ;; 12 | print_endline (string_of_int A.a_x) 13 | 14 | ;; 15 | print_endline (string_of_int (Lib.length [])) 16 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 2.5) 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib.opam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib.opam -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/LibTypes.mli: -------------------------------------------------------------------------------- 1 | type t = string 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (public_name lib) 3 | (modules_without_implementation libTypes) 4 | (flags :standard -w -32-38-27-34) 5 | (name lib)) 6 | 7 | 8 | (copy_files# ../vendor/*.ml{,i}) 9 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/lib.ml: -------------------------------------------------------------------------------- 1 | include List 2 | 3 | 4 | type user = { 5 | name: string 6 | } 7 | let lib_x = 1 8 | 9 | let hd = List.hd 10 | 11 | let lib_private_fn s = print_endline s 12 | 13 | let lib_type: LibTypes.t = "lib_types" 14 | 15 | let vendored_x = Vendored_lib.x 16 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/lib/lib.mli: -------------------------------------------------------------------------------- 1 | include module type of List 2 | 3 | val lib_x : int 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/main.opam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/main.opam -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_A/vendor/vendored_lib.ml: -------------------------------------------------------------------------------- 1 | let x = 5 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_B/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (flags :standard -w -32-38-27) 3 | (name lib)) 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_B/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 2.5) 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/__tests__/workspace_symbol_B/main.ml: -------------------------------------------------------------------------------- 1 | let workspace_B = "workspace_B" 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/jest.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @type {import('@jest/types').Config.ProjectConfig} 3 | */ 4 | module.exports = { 5 | roots: [""], 6 | setupFilesAfterEnv: ["./jest.setup.ts"], 7 | testEnvironment: "node", 8 | transform: { 9 | "^.+\\.tsx?$": "@swc/jest", 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/jest.setup.ts: -------------------------------------------------------------------------------- 1 | import { toEqualUri } from "./src/LanguageServer"; 2 | 3 | expect.extend({ 4 | toEqualUri, 5 | }); 6 | 7 | declare global { 8 | namespace jest { 9 | interface Matchers { 10 | toEqualUri(uri: string): R; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@ocaml/ocaml-lsp-server-e2e", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "promote": "jest --updateSnapshot", 7 | "test": "jest" 8 | }, 9 | "dependencies": { 10 | "outdent": "0.8.0", 11 | "vscode-uri": "3.0.8" 12 | }, 13 | "devDependencies": { 14 | "@swc/core": "1.10.1", 15 | "@swc/jest": "0.2.37", 16 | "@types/jest": "29.5.14", 17 | "@types/node": "22.10.2", 18 | "jest": "29.7.0", 19 | "typescript": "5.7.2", 20 | "vscode-jsonrpc": "8.0.1", 21 | "vscode-languageserver-protocol": "3.17.1", 22 | "vscode-languageserver-types": "3.17.5" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/src/Ocamlformat.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const chunks = []; 4 | process.stdin.resume(); 5 | process.stdin.on("data", (chunk) => { 6 | chunks.push(chunk); 7 | }); 8 | process.stdin.on("end", () => { 9 | const body = Buffer.concat(chunks); 10 | if (body === "special string") { 11 | process.stderr.write("special string passed\n"); 12 | process.exit(1); 13 | } else { 14 | process.stdout.write(body); 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/src/Refmt.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const chunks = []; 4 | process.stdin.resume(); 5 | process.stdin.on("data", (chunk) => { 6 | chunks.push(chunk); 7 | }); 8 | process.stdin.on("end", () => { 9 | const body = Buffer.concat(chunks); 10 | if (body === "special string") { 11 | process.stderr.write("special string passed\n"); 12 | process.exit(1); 13 | } else { 14 | process.stdout.write(body); 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/src/utils.ts: -------------------------------------------------------------------------------- 1 | export const isNotNullable = ( 2 | x: T | null | undefined, 3 | ): x is NonNullable => x !== null && x !== undefined; 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": true, 4 | "esModuleInterop": true, 5 | "lib": ["es2015"] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/ocaml_lsp_tests.ml: -------------------------------------------------------------------------------- 1 | let%expect_test "eat_message tests" = 2 | let test e1 e2 expected = 3 | let result = Ocaml_lsp_server.Diagnostics.equal_message e1 e2 in 4 | if result = expected then print_endline "[PASS]" else print_endline "[FAIL]" 5 | in 6 | test "foo bar" "foo bar" true; 7 | [%expect {| [PASS] |}]; 8 | test " foobar" "foobar" true; 9 | [%expect {| [PASS] |}]; 10 | test "foobar" "foobar " true; 11 | [%expect {| [PASS] |}]; 12 | test "foobar" "foobar\t" true; 13 | [%expect {| [PASS] |}]; 14 | test "foobar" "foobar\n" true; 15 | [%expect {| [PASS] |}]; 16 | test "foobar" "foo bar" false; 17 | [%expect {| [PASS] |}]; 18 | test "foo bar" "foo Bar" false; 19 | [%expect {| [PASS] |}] 20 | ;; 21 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/test/run_test_e2e.ml: -------------------------------------------------------------------------------- 1 | let () = 2 | let cmd = 3 | Filename.quote_command "yarn" [ "--cwd"; "ocaml-lsp-server/test/e2e"; "test" ] 4 | in 5 | Sys.command cmd |> exit 6 | ;; 7 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/vendor/cmarkit/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 The cmarkit programmers 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocaml-lsp-server/vendor/cmarkit/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name cmarkit) 3 | (wrapped false)) 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/ocamlformat.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs = (import { }); 3 | inherit (pkgs) stdenv lib; 4 | ocamlformat = 5 | let 6 | ocamlformat_version = 7 | let 8 | lists = pkgs.lib.lists; 9 | strings = pkgs.lib.strings; 10 | ocamlformat_config = strings.splitString "\n" (builtins.readFile ./.ocamlformat); 11 | prefix = "version="; 12 | ocamlformat_version_pred = line: strings.hasPrefix prefix line; 13 | version_line = lists.findFirst ocamlformat_version_pred "not_found" ocamlformat_config; 14 | version = strings.removePrefix prefix version_line; 15 | in 16 | builtins.replaceStrings ["."] ["_"] version; 17 | in builtins.getAttr ("ocamlformat_" + ocamlformat_version) pkgs; 18 | in ocamlformat 19 | -------------------------------------------------------------------------------- /thirdparty/lsp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@ocaml/ocaml-lsp", 3 | "private": true, 4 | "workspaces": [ 5 | "ocaml-lsp-server/test/e2e" 6 | ], 7 | "devDependencies": { 8 | "@biomejs/biome": "1.9.4" 9 | }, 10 | "packageManager": "yarn@1.22.22" 11 | } 12 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/.github/workflows/workflow.yml: -------------------------------------------------------------------------------- 1 | name: Main workflow 2 | 3 | on: 4 | - pull_request 5 | - push 6 | 7 | jobs: 8 | build_and_test: 9 | name: Build and test 10 | strategy: 11 | fail-fast: false 12 | matrix: 13 | os: 14 | - macos-latest 15 | - ubuntu-latest 16 | - windows-latest 17 | ocaml-compiler: 18 | - 4.14.x 19 | 20 | runs-on: ${{ matrix.os }} 21 | 22 | steps: 23 | - name: Set git to use LF 24 | run: | 25 | git config --global core.autocrlf false 26 | git config --global core.eol lf 27 | git config --global core.ignorecase false 28 | 29 | - name: Checkout code 30 | uses: actions/checkout@v2 31 | 32 | - name: Use OCaml ${{ matrix.ocaml-compiler }} 33 | uses: ocaml/setup-ocaml@v2 34 | with: 35 | ocaml-compiler: ${{ matrix.ocaml-compiler }} 36 | opam-local-packages: lev.opam lev-fiber.opam 37 | 38 | - run: opam install --deps-only --with-doc --with-test . 39 | - run: opam exec -- dune build 40 | - run: opam exec -- dune runtest 41 | 42 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | _opam 3 | _coverage 4 | *.install 5 | .vscode/ 6 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/rgrinberg/lev 8 | branch = master 9 | commit = 9258b71a2880de89762bcfac0b281979a58a2aa6 10 | parent = 3cf37f43238af9bbec82534f08a0477594603ccd 11 | method = rebase 12 | cmdver = 0.4.1 13 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/.ocamlformat: -------------------------------------------------------------------------------- 1 | version=0.21.0 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/README.cpp.md: -------------------------------------------------------------------------------- 1 | # Lev - OCaml bindings to libev 2 | 3 | [libev]: http://software.schmorp.de/pkg/libev.html 4 | [libevdoc]: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod 5 | 6 | ## Abstract 7 | 8 | [libev](libev) by Marc Lehmann is a minimal & portable event loop library. This 9 | repository contains two packages. The first is `lev` which offers low level 10 | bindings to this library. The bindings are designed to be minimal, low 11 | overhead, and easily embeddable in larger projects. The API is callback based 12 | so you need to BYOC (bring your own concurrency). 13 | 14 | The second package is `lev-fiber`. It provides a more familiar, higher level 15 | API. It is based on dune's fiber library for structured concurrency. 16 | 17 | ## Example 18 | 19 | This example of the low level API lev api: 20 | 21 | ```ocaml 22 | #include "lev/examples/readme.ml" 23 | ``` 24 | 25 | ## Documentation 26 | 27 | Lev's API is a thin wrapper around libev itself. So you should first and 28 | foremost refer to libev's extensive [documentation](libevdoc). Lev itself will 29 | document where it differs from libev's conventions. 30 | 31 | ## License 32 | 33 | `vendor/` is under Marc Lehmann's original terms (see vendor/LICENSE). 34 | 35 | Everything else is offered under ISC (see src/LICENSE.md). 36 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/dune: -------------------------------------------------------------------------------- 1 | (rule 2 | (mode promote) 3 | (deps 4 | (:dep README.cpp.md) 5 | (source_tree lev/examples/)) 6 | (target README.md) 7 | (action 8 | (run cppo -n %{dep} -o %{target}))) 9 | 10 | (env 11 | (_ 12 | (flags :standard -alert -unstable))) 13 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 3.0) 2 | 3 | (name lev) 4 | 5 | (generate_opam_files true) 6 | 7 | (license ISC) 8 | (maintainers "Rudi Grinberg ") 9 | (authors 10 | "Rudi Grinberg " 11 | "Ulugbek Abdullaev ") 12 | (source (github rgrinberg/lev)) 13 | 14 | (implicit_transitive_deps false) 15 | 16 | (package 17 | (synopsis "Bindings to libev") 18 | (description "Low level bindings to libev") 19 | (name lev) 20 | (depends 21 | (ppx_expect :with-test) 22 | base-unix)) 23 | 24 | (package 25 | (synopsis "Fiber + Lev") 26 | (description "High level API based on dune's fibers") 27 | (name lev-fiber) 28 | (depends 29 | (ppx_expect :with-test) 30 | (ocaml (>= 4.14.0)) 31 | lev 32 | dyn 33 | fiber 34 | stdune 35 | base-threads 36 | base-unix)) 37 | 38 | (package 39 | (synopsis "Fiber + Lev + Csexp") 40 | (description "Client/Servers that use csexp for transport") 41 | (name lev-fiber-csexp) 42 | (depends 43 | (ppx_expect :with-test) 44 | lev-fiber 45 | stdune 46 | dyn 47 | csexp 48 | (fiber (>= 3.1.1)) 49 | base-unix)) 50 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber-csexp.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | synopsis: "Fiber + Lev + Csexp" 4 | description: "Client/Servers that use csexp for transport" 5 | maintainer: ["Rudi Grinberg "] 6 | authors: [ 7 | "Rudi Grinberg " 8 | "Ulugbek Abdullaev " 9 | ] 10 | license: "ISC" 11 | homepage: "https://github.com/rgrinberg/lev" 12 | bug-reports: "https://github.com/rgrinberg/lev/issues" 13 | depends: [ 14 | "dune" {>= "3.0"} 15 | "ppx_expect" {with-test} 16 | "lev-fiber" 17 | "stdune" 18 | "dyn" 19 | "csexp" 20 | "fiber" {>= "3.1.1"} 21 | "base-unix" 22 | "odoc" {with-doc} 23 | ] 24 | build: [ 25 | ["dune" "subst"] {dev} 26 | [ 27 | "dune" 28 | "build" 29 | "-p" 30 | name 31 | "-j" 32 | jobs 33 | "@install" 34 | "@runtest" {with-test} 35 | "@doc" {with-doc} 36 | ] 37 | ] 38 | dev-repo: "git+https://github.com/rgrinberg/lev.git" 39 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber-csexp/src/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name lev_fiber_csexp) 3 | (public_name lev-fiber-csexp) 4 | (libraries fiber csexp stdune dyn lev_fiber)) 5 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber-csexp/src/lev_fiber_csexp.mli: -------------------------------------------------------------------------------- 1 | (** Canonical S-expression RPC. 2 | 3 | This module implements a RPC mechanism for exchanging canonical 4 | S-expressions over unix or internet sockets. It allows a server to accept 5 | connections and a client to connect to a server. 6 | 7 | However, it doesn't explain how to encode queries, responses or generally 8 | any kind of messages as Canonical S-expressions. This part should be built 9 | on top of this module. *) 10 | 11 | module Session : sig 12 | type t 13 | (** Rpc session backed by an input & output stream *) 14 | 15 | val create : 16 | socket:bool -> 17 | Lev_fiber.Io.input Lev_fiber.Io.t -> 18 | Lev_fiber.Io.output Lev_fiber.Io.t -> 19 | t 20 | 21 | val close : t -> unit 22 | 23 | (* [write t x] writes the s-expression when [x] is [Some sexp], and closes the 24 | session if [x = None ] *) 25 | val write : t -> Csexp.t list -> unit Fiber.t 26 | 27 | val read : t -> Csexp.t option Fiber.t 28 | (** If [read] returns [None], the session is closed and all subsequent reads 29 | will return [None] *) 30 | end 31 | 32 | val connect : Lev_fiber.Fd.t -> Unix.sockaddr -> Session.t Fiber.t 33 | 34 | val serve : 35 | Lev_fiber.Socket.Server.t -> f:(Session.t -> unit Fiber.t) -> unit Fiber.t 36 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber-csexp/test/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name lev_fiber_csexp_tests) 3 | (libraries 4 | fiber 5 | csexp 6 | lev 7 | lev_fiber 8 | lev_fiber_csexp 9 | stdune 10 | unix 11 | threads.posix 12 | ;; This is because of the (implicit_transitive_deps false) 13 | ;; in dune-project 14 | ppx_expect.config 15 | ppx_expect.config_types 16 | ppx_expect 17 | base 18 | ppx_inline_test.config) 19 | (inline_tests) 20 | (preprocess 21 | (pps ppx_expect))) 22 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber-csexp/test/lev_fiber_csexp_rpc_tests.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/submodules/lev/lev-fiber-csexp/test/lev_fiber_csexp_rpc_tests.mli -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | synopsis: "Fiber + Lev" 4 | description: "High level API based on dune's fibers" 5 | maintainer: ["Rudi Grinberg "] 6 | authors: [ 7 | "Rudi Grinberg " 8 | "Ulugbek Abdullaev " 9 | ] 10 | license: "ISC" 11 | homepage: "https://github.com/rgrinberg/lev" 12 | bug-reports: "https://github.com/rgrinberg/lev/issues" 13 | depends: [ 14 | "dune" {>= "3.0"} 15 | "ppx_expect" {with-test} 16 | "ocaml" {>= "4.14.0"} 17 | "lev" 18 | "dyn" 19 | "fiber" 20 | "stdune" 21 | "base-threads" 22 | "base-unix" 23 | "odoc" {with-doc} 24 | ] 25 | build: [ 26 | ["dune" "subst"] {dev} 27 | [ 28 | "dune" 29 | "build" 30 | "-p" 31 | name 32 | "-j" 33 | jobs 34 | "@install" 35 | "@runtest" {with-test} 36 | "@doc" {with-doc} 37 | ] 38 | ] 39 | dev-repo: "git+https://github.com/rgrinberg/lev.git" 40 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/bench/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name ping_pong) 3 | (libraries lev-fiber fiber lev stdune)) 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/bench/ping_pong.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/submodules/lev/lev-fiber/bench/ping_pong.mli -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/src/dune: -------------------------------------------------------------------------------- 1 | (env 2 | (_ 3 | (flags :standard -alert -unstable))) 4 | 5 | (library 6 | (name lev_fiber) 7 | (public_name lev-fiber) 8 | (instrumentation 9 | (backend bisect_ppx)) 10 | (libraries unix dyn stdune threads.posix fiber lev lev_fiber_util)) 11 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/src/util/channel.ml: -------------------------------------------------------------------------------- 1 | open Stdune 2 | 3 | type 'a t = { 4 | q : 'a Removable_queue.t; 5 | m : Mutex.t; 6 | c : Condition.t; 7 | mutable is_closed : bool; 8 | } 9 | 10 | type elt_in_channel = 11 | | Node : 12 | Mutex.t (* mutex of the channel, where this element was sent *) 13 | * 'a Removable_queue.node 14 | -> elt_in_channel 15 | 16 | let create () = 17 | { 18 | q = Removable_queue.create (); 19 | m = Mutex.create (); 20 | c = Condition.create (); 21 | is_closed = false; 22 | } 23 | 24 | let with_mutex m ~f = 25 | Mutex.lock m; 26 | Exn.protect ~f:(fun () -> f ()) ~finally:(fun () -> Mutex.unlock m) 27 | 28 | let is_empty t = with_mutex t.m ~f:(fun () -> Removable_queue.is_empty t.q) 29 | let length t = with_mutex t.m ~f:(fun () -> Removable_queue.length t.q) 30 | 31 | let send_removable t v = 32 | with_mutex t.m ~f:(fun () -> 33 | if t.is_closed then Error `Closed 34 | else 35 | let n = Removable_queue.push t.q v in 36 | Condition.signal t.c; 37 | Ok (Node (t.m, n))) 38 | 39 | let send t v = send_removable t v |> Result.map ~f:ignore 40 | 41 | let get t = 42 | with_mutex t.m ~f:(fun () -> 43 | let rec aux () = 44 | match Removable_queue.pop t.q with 45 | | Some v -> Ok v 46 | | None -> 47 | if t.is_closed then Error `Closed 48 | else ( 49 | Condition.wait t.c t.m; 50 | aux ()) 51 | in 52 | aux ()) 53 | 54 | let remove_if_not_consumed (Node (m, n)) = 55 | with_mutex m ~f:(fun () -> Removable_queue.remove n) 56 | 57 | let close t = 58 | with_mutex t.m ~f:(fun () -> 59 | if not t.is_closed then ( 60 | t.is_closed <- true; 61 | Condition.signal t.c)) 62 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/src/util/channel.mli: -------------------------------------------------------------------------------- 1 | type 'a t 2 | type elt_in_channel 3 | 4 | val create : unit -> 'a t 5 | 6 | val is_empty : 'a t -> bool 7 | (** Checks whether the channel contains elements *) 8 | 9 | val length : 'a t -> int 10 | (** Number of elements currently in the channel not consumed. Runs in O(n). *) 11 | 12 | val send_removable : 'a t -> 'a -> (elt_in_channel, [ `Closed ]) result 13 | (** [send_removable ch v] puts a value [v] in the channel [ch] in a non-blocking 14 | manner (we consider acquiring/waiting for the lock to be "non-blocking"). 15 | The returned value [elt_in_channel] can then be used to remove the put 16 | element from the channel if it hasn't been consumed by the other end of the 17 | channel yet. *) 18 | 19 | val send : 'a t -> 'a -> (unit, [ `Closed ]) result 20 | (** similar to [send_removable] but the element is non-removable from the 21 | channel once sent *) 22 | 23 | val remove_if_not_consumed : elt_in_channel -> unit 24 | (** remove element put in the channel if it hasn't been consumed yet *) 25 | 26 | val get : 'a t -> ('a, [ `Closed ]) result 27 | (** [get ch] reads a value [v] from the channel [ch]. If there is no value to 28 | read, the thread sleeps until there is some value to read. *) 29 | 30 | val close : 'a t -> unit 31 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/src/util/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name lev_fiber_util) 3 | (libraries stdune threads.posix) 4 | (instrumentation 5 | (backend bisect_ppx)) 6 | (package lev-fiber)) 7 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/src/util/removable_queue.mli: -------------------------------------------------------------------------------- 1 | type 'a t 2 | (** Like a queue, but allows O(1) removal at any position *) 3 | 4 | type 'a node 5 | 6 | val data : 'a node -> 'a 7 | val remove : _ node -> unit 8 | val is_empty : _ t -> bool 9 | val create : unit -> 'a t 10 | val push : 'a t -> 'a -> 'a node 11 | val pop : 'a t -> 'a option 12 | val peek : 'a t -> 'a node option 13 | 14 | val length : 'a t -> int 15 | (** Numbers of elements in the queue. Runs in O(n). *) 16 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/src/util/worker.ml: -------------------------------------------------------------------------------- 1 | module Id = Int 2 | 3 | type 'a t = { work_chan : 'a Channel.t; thread : Thread.t } 4 | type task = Channel.elt_in_channel 5 | 6 | let id t = Thread.id t.thread 7 | let join t = Thread.join t.thread 8 | 9 | let rec run work_chan f = 10 | match Channel.get work_chan with 11 | | Error `Closed -> () 12 | | Ok v -> 13 | f v; 14 | run work_chan f 15 | 16 | let create ~spawn_thread ~do_no_raise = 17 | let work_chan = Channel.create () in 18 | let thread = spawn_thread (fun () -> run work_chan do_no_raise) in 19 | { work_chan; thread } 20 | 21 | let add_work t v = 22 | match Channel.send_removable t.work_chan v with 23 | | Error `Closed -> Error `Stopped 24 | | Ok _ as task -> task 25 | 26 | let cancel_if_not_consumed = Channel.remove_if_not_consumed 27 | let complete_tasks_and_stop t = Channel.close t.work_chan 28 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/src/util/worker.mli: -------------------------------------------------------------------------------- 1 | type 'work t 2 | (** Simple queue that is consumed by its own thread *) 3 | 4 | val create : 5 | spawn_thread:((unit -> unit) -> Thread.t) -> do_no_raise:('a -> unit) -> 'a t 6 | (** [create ~spawn_thread ~do_no_raise] creates a worker with a task handler 7 | [do_no_raise]. The worker will not handle an exception raised by the task 8 | handler, so [do_no_raise] is expected to not raise. [spawn_thread] is used 9 | to launch the thread doing the work *) 10 | 11 | type task 12 | 13 | val cancel_if_not_consumed : task -> unit 14 | (** Cancels the task in the queue if it hasn't already been consumed by the 15 | thread. Does nothing if the task has been consumed already. *) 16 | 17 | val add_work : 'a t -> 'a -> (task, [ `Stopped ]) result 18 | 19 | module Id : sig 20 | type t 21 | 22 | val equal : t -> t -> bool 23 | end 24 | 25 | val id : _ t -> Id.t 26 | val join : _ t -> unit 27 | 28 | val complete_tasks_and_stop : _ t -> unit 29 | (** Signals the worker to complete tasks currently available in the queue and 30 | stop. *) 31 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/test/basic.ml: -------------------------------------------------------------------------------- 1 | let () = Printexc.record_backtrace false 2 | 3 | let%expect_test "toplevel exception" = 4 | (match 5 | Lev_fiber.run @@ fun () -> 6 | print_endline "raising Exit"; 7 | let _ = raise Exit in 8 | Fiber.return () 9 | with 10 | | Error Deadlock | Ok () -> assert false 11 | | Error Already_reported -> print_endline "raised Exit" 12 | | Error (Aborted _) -> assert false); 13 | [%expect 14 | {| 15 | raising Exit 16 | /----------------------------------------------------------------------- 17 | | Internal error: Uncaught exception. 18 | | Stdlib.Exit 19 | \----------------------------------------------------------------------- 20 | 21 | raised Exit |}] 22 | 23 | let%expect_test "" = 24 | (match 25 | Lev_fiber.run @@ fun () -> 26 | Fiber.fork_and_join_unit 27 | (fun () -> 28 | print_endline "t1: raising"; 29 | raise Exit) 30 | (fun () -> 31 | print_endline "t2: running"; 32 | Fiber.return ()) 33 | with 34 | | Error Deadlock | Ok () -> assert false 35 | | Error Already_reported -> print_endline "raised Exit" 36 | | Error (Aborted _) -> assert false); 37 | [%expect 38 | {| 39 | t1: raising 40 | /----------------------------------------------------------------------- 41 | | Internal error: Uncaught exception. 42 | | Stdlib.Exit 43 | \----------------------------------------------------------------------- 44 | 45 | t2: running 46 | raised Exit |}] 47 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/test/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name lev_fiber_tests) 3 | (libraries 4 | fiber 5 | lev 6 | lev_fiber 7 | stdune 8 | unix 9 | threads.posix 10 | ;; This is because of the (implicit_transitive_deps false) 11 | ;; in dune-project 12 | ppx_expect.config 13 | ppx_expect.config_types 14 | ppx_expect 15 | base 16 | ppx_inline_test.config) 17 | (inline_tests) 18 | (preprocess 19 | (pps ppx_expect))) 20 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/test/lev_fiber_threads.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/submodules/lev/lev-fiber/test/lev_fiber_threads.mli -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/test/process.ml: -------------------------------------------------------------------------------- 1 | open Stdune 2 | open Fiber.O 3 | 4 | let%expect_test "wait for simple process" = 5 | let stdin, stdin_w = Unix.pipe () in 6 | let stdout_r, stdout = Unix.pipe () in 7 | let stderr_r, stderr = Unix.pipe () in 8 | Unix.close stdin_w; 9 | Unix.close stdout_r; 10 | Unix.close stderr_r; 11 | Lev_fiber.run (fun () -> 12 | let pid = Unix.create_process "true" [| "true" |] stdin stdout stderr in 13 | let+ status = Lev_fiber.waitpid ~pid in 14 | match status with 15 | | WEXITED n -> printfn "status: %d" n 16 | | _ -> assert false) 17 | |> Lev_fiber.Error.ok_exn; 18 | [%expect {| status: 0 |}] 19 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/test/reader_writer.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/submodules/lev/lev-fiber/test/reader_writer.mli -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/test/sockets.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/submodules/lev/lev-fiber/test/sockets.mli -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/test/timers.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/submodules/lev/lev-fiber/test/timers.mli -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/test/util/bip_buffer_tests.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/submodules/lev/lev-fiber/test/util/bip_buffer_tests.mli -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/test/util/channel_tests.ml: -------------------------------------------------------------------------------- 1 | module Channel = Lev_fiber_util.Channel 2 | 3 | let%expect_test "send/recv 0, 1 in concurrent threads; then close the channel" = 4 | let ch = Channel.create () in 5 | let th0 = 6 | Thread.create 7 | (fun () -> 8 | for _ = 0 to 1 do 9 | match Channel.get ch with 10 | | Ok i -> Printf.printf "%d\n" i 11 | | Error `Closed -> assert false 12 | done; 13 | match Channel.get ch with 14 | | Ok _ -> assert false 15 | | Error `Closed -> print_endline "closed") 16 | () 17 | in 18 | let send_or_fail v = 19 | match Channel.send ch v with Ok () -> () | Error `Closed -> assert false 20 | in 21 | let th1 = 22 | Thread.create 23 | (fun () -> 24 | send_or_fail 0; 25 | send_or_fail 1; 26 | Channel.close ch) 27 | () 28 | in 29 | Thread.join th0; 30 | Thread.join th1; 31 | [%expect {| 32 | 0 33 | 1 34 | closed |}] 35 | 36 | let%expect_test "send 0, 1, 2, but remove 1" = 37 | let ch = Channel.create () in 38 | let print_int i = Printf.printf "%d\n" i in 39 | let th0 = 40 | Thread.create 41 | (fun () -> 42 | let v0 = Channel.get ch in 43 | print_int @@ Result.get_ok v0; 44 | Unix.sleepf 0.01; 45 | let v1 = Channel.get ch in 46 | print_int @@ Result.get_ok v1) 47 | () 48 | in 49 | let th1 = 50 | Thread.create 51 | (fun () -> 52 | ignore @@ Channel.send ch 0; 53 | let removable = Channel.send_removable ch 1 in 54 | Channel.remove_if_not_consumed @@ Result.get_ok removable; 55 | Channel.send ch 2) 56 | () 57 | in 58 | Thread.join th0; 59 | Thread.join th1; 60 | [%expect {| 61 | 0 62 | 2 |}] 63 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/test/util/channel_tests.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/submodules/lev/lev-fiber/test/util/channel_tests.mli -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/test/util/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name lev_fiber_util_tests) 3 | (libraries 4 | lev_fiber_util 5 | stdune 6 | unix 7 | threads.posix 8 | ;; This is because of the (implicit_transitive_deps false) 9 | ;; in dune-project 10 | ppx_expect.config 11 | ppx_expect.config_types 12 | ppx_expect 13 | base 14 | ppx_inline_test.config) 15 | (inline_tests) 16 | (preprocess 17 | (pps ppx_expect))) 18 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev-fiber/test/util/removable_queue_tests.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/submodules/lev/lev-fiber/test/util/removable_queue_tests.mli -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | synopsis: "Bindings to libev" 4 | description: "Low level bindings to libev" 5 | maintainer: ["Rudi Grinberg "] 6 | authors: [ 7 | "Rudi Grinberg " 8 | "Ulugbek Abdullaev " 9 | ] 10 | license: "ISC" 11 | homepage: "https://github.com/rgrinberg/lev" 12 | bug-reports: "https://github.com/rgrinberg/lev/issues" 13 | depends: [ 14 | "dune" {>= "3.0"} 15 | "ppx_expect" {with-test} 16 | "base-unix" 17 | "odoc" {with-doc} 18 | ] 19 | build: [ 20 | ["dune" "subst"] {dev} 21 | [ 22 | "dune" 23 | "build" 24 | "-p" 25 | name 26 | "-j" 27 | jobs 28 | "@install" 29 | "@runtest" {with-test} 30 | "@doc" {with-doc} 31 | ] 32 | ] 33 | dev-repo: "git+https://github.com/rgrinberg/lev.git" 34 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/bench/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name ping_pong) 3 | (libraries lev unix)) 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/bench/ping_pong.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/submodules/lev/lev/bench/ping_pong.mli -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/dune: -------------------------------------------------------------------------------- 1 | (vendored_dirs vendor) 2 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/examples/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names readme) 3 | (libraries lev unix)) 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/examples/readme.ml: -------------------------------------------------------------------------------- 1 | open Lev 2 | 3 | let () = 4 | let loop = Loop.default () in 5 | let stdin, stdin_w = Unix.pipe ~cloexec:true () in 6 | let stdout_r, stdout = Unix.pipe ~cloexec:true () in 7 | let stderr_r, stderr = Unix.pipe ~cloexec:true () in 8 | Unix.close stdin_w; 9 | Unix.close stdout_r; 10 | Unix.close stderr_r; 11 | let pid = 12 | Unix.create_process "sh" [| "sh"; "-c"; "exit 42" |] stdin stdout stderr 13 | in 14 | let child = 15 | match Child.create with 16 | | Error `Unimplemented -> assert false 17 | | Ok create -> 18 | create 19 | (fun t ~pid status -> 20 | Child.stop t loop; 21 | match status with 22 | | Unix.WEXITED i -> Printf.printf "%d exited with status %d\n" pid i 23 | | _ -> assert false) 24 | (Pid pid) Terminate 25 | in 26 | Child.start child loop; 27 | Loop.run_until_done loop; 28 | Child.destroy child 29 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/src/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2021 Rudi Grinberg 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 8 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 9 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 10 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 12 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 13 | PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/src/config.h: -------------------------------------------------------------------------------- 1 | // TODO port support 2 | 3 | #define EV_MULTIPLICITY 1 4 | 5 | #ifdef _MSC_VER 6 | #define HAVE_SYS_SELECT_H 1 7 | #define HAVE_SELECT 1 8 | #else /* _MSC_VER */ 9 | 10 | #if __has_include() 11 | #define HAVE_SYS_INOTIFY_H 1 12 | #endif 13 | 14 | #ifdef _WIN32 15 | #define HAVE_SYS_SELECT_H 1 16 | #define HAVE_SELECT 1 17 | #endif 18 | 19 | #if __has_include() 20 | #define HAVE_SYS_SELECT_H 1 21 | #define HAVE_SELECT 1 22 | #endif 23 | 24 | #if __has_include() 25 | #define HAVE_POLL_H 1 26 | #define HAVE_POLL 1 27 | #endif 28 | 29 | #if __has_include() 30 | #define HAVE_SYS_EPOLL_H 1 31 | #define HAVE_EPOLL 1 32 | #define HAVE_EPOLL_CTL 1 33 | #endif 34 | 35 | #if __has_include() 36 | #define HAVE_SYS_TIMERFD_H 1 37 | #endif 38 | 39 | #if __has_include() 40 | #define HAVE_SYS_SIGNALFD_H 1 41 | #define HAVE_SIGNALFD_H 1 42 | #endif 43 | 44 | #if __has_include() 45 | #define HAVE_SYS_SIGNALFD_H 1 46 | #define HAVE_SIGNALFD_H 1 47 | #endif 48 | 49 | #if __has_include() 50 | #define HAVE_INOTIFY_INIT 1 51 | #endif 52 | 53 | #if __has_include() 54 | #define HAVE_LINUX_FS_H 1 55 | #endif 56 | 57 | #if __has_include() 58 | #define HAVE_AIO_ABI_H 1 59 | #endif 60 | 61 | #if __has_include() 62 | #define HAVE_SYS_EVENT_H 1 63 | #endif 64 | 65 | #if HAVE_SYS_EVENT_H && (defined(__APPLE__) || defined(__unix__)) 66 | #define HAVE_KQUEUE 1 67 | #endif 68 | 69 | #if defined(__linux__) || defined(__unix__) || defined(__APPLE__) 70 | #define HAVE_NANOSLEEP 1 71 | #endif 72 | 73 | #endif /* _MSC_VER */ 74 | 75 | #define HAVE_FLOOR 1 76 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/src/dune: -------------------------------------------------------------------------------- 1 | (copy_files# ../vendor/*.c) 2 | 3 | (copy_files# ../vendor/{ev,ev_vars,ev_wrap}.h) 4 | 5 | (foreign_library 6 | (archive_name ev) 7 | (extra_deps 8 | ev_kqueue.c 9 | ev_epoll.c 10 | ev_iouring.c 11 | ev_poll.c 12 | ev_port.c 13 | ev_select.c 14 | ev_win32.c) 15 | (language c) 16 | (names ev)) 17 | 18 | (library 19 | (public_name lev) 20 | (synopsis "libev bindings") 21 | (libraries unix) 22 | (foreign_archives ev) 23 | (instrumentation 24 | (backend bisect_ppx)) 25 | (foreign_stubs 26 | (language c) 27 | (names lev_stubs))) 28 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/test/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name lev_tests) 3 | (modules lev_tests sockets) 4 | (libraries 5 | lev 6 | ;; This is because of the (implicit_transitive_deps false) 7 | ;; in dune-project 8 | ppx_expect.config 9 | ppx_expect.config_types 10 | ppx_expect 11 | base 12 | ppx_inline_test.config) 13 | (inline_tests) 14 | (preprocess 15 | (pps ppx_expect))) 16 | 17 | (library 18 | (name lev_tests_unix) 19 | (modules lev_tests_unix) 20 | (libraries 21 | lev 22 | ;; This is because of the (implicit_transitive_deps false) 23 | ;; in dune-project 24 | ppx_expect.config 25 | ppx_expect.config_types 26 | ppx_expect 27 | base 28 | ppx_inline_test.config) 29 | (inline_tests 30 | (enabled_if 31 | (= %{os_type} Unix))) 32 | (preprocess 33 | (pps ppx_expect))) 34 | 35 | (library 36 | (name lev_tests_signals) 37 | (modules lev_tests_signals) 38 | (libraries 39 | lev 40 | threads.posix 41 | ;; This is because of the (implicit_transitive_deps false) 42 | ;; in dune-project 43 | ppx_expect.config 44 | ppx_expect.config_types 45 | ppx_expect 46 | base 47 | ppx_inline_test.config) 48 | (inline_tests 49 | (enabled_if 50 | (= %{os_type} Unix))) 51 | (preprocess 52 | (pps ppx_expect))) 53 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/test/lev_tests_signals.ml: -------------------------------------------------------------------------------- 1 | open Lev 2 | 3 | let flags = Loop.Flag.(Set.singleton Nosigmask) 4 | 5 | let%expect_test "signal handling" = 6 | let signal = Sys.sigusr1 in 7 | let loop = Loop.create ~flags () in 8 | let signal_watcher = 9 | Signal.create ~signal (fun t -> 10 | print_endline "received signal"; 11 | ignore (Unix.sigprocmask SIG_BLOCK [ signal ]); 12 | Signal.stop t loop) 13 | in 14 | let idle = 15 | Idle.create (fun idle -> 16 | print_endline "sending signal"; 17 | Unix.kill (Unix.getpid ()) signal; 18 | Idle.stop idle loop) 19 | in 20 | Signal.start signal_watcher loop; 21 | Idle.start idle loop; 22 | Loop.run_until_done loop; 23 | [%expect {| 24 | sending signal 25 | received signal |}] 26 | 27 | let%expect_test "manual signal feeding" = 28 | let signal = Sys.sigusr2 in 29 | ignore (Unix.sigprocmask SIG_BLOCK [ signal ]); 30 | let thread = 31 | Thread.create 32 | (fun () -> 33 | print_endline "thread: awaiting signal"; 34 | ignore (Thread.wait_signal [ signal ]); 35 | Loop.feed_signal ~signal; 36 | print_endline "thread: awaited signal") 37 | () 38 | in 39 | let loop = Loop.create () in 40 | let signal_watcher = 41 | Signal.create ~signal (fun w -> 42 | print_endline "lev: received signal"; 43 | Signal.stop w loop) 44 | in 45 | Signal.start signal_watcher loop; 46 | Unix.kill (Unix.getpid ()) signal; 47 | Loop.run_until_done loop; 48 | Thread.join thread; 49 | [%expect 50 | {| 51 | thread: awaiting signal 52 | thread: awaited signal 53 | lev: received signal |}] 54 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/test/sockets.ml: -------------------------------------------------------------------------------- 1 | let%expect_test "server & client" = 2 | let server_sockaddr = Unix.ADDR_INET (Unix.inet_addr_loopback, 0) in 3 | let domain = Unix.domain_of_sockaddr server_sockaddr in 4 | let socket () = Unix.socket ~cloexec:true domain Unix.SOCK_STREAM 0 in 5 | let loop = Lev.Loop.create () in 6 | let client_sockaddr = ref None in 7 | let server_ready = 8 | let client () = 9 | let fd = socket () in 10 | print_endline "client: connecting"; 11 | Unix.connect fd 12 | (match !client_sockaddr with None -> assert false | Some s -> s); 13 | Unix.close fd 14 | in 15 | Lev.Async.create (fun async -> 16 | client (); 17 | Lev.Async.stop async loop; 18 | Lev.Async.destroy async) 19 | in 20 | Lev.Async.start server_ready loop; 21 | let () = 22 | let server_fd = socket () in 23 | Unix.set_nonblock server_fd; 24 | Unix.setsockopt server_fd Unix.SO_REUSEADDR true; 25 | Unix.bind server_fd server_sockaddr; 26 | Unix.listen server_fd 10; 27 | client_sockaddr := Some (Unix.getsockname server_fd); 28 | print_endline "server: listening"; 29 | Lev.Async.send server_ready loop; 30 | let io = 31 | Lev.Io.create 32 | (fun io _ _ -> 33 | let client_fd, _sockaddr = Unix.accept ~cloexec:true server_fd in 34 | print_endline "server: accepting client"; 35 | Unix.close client_fd; 36 | print_endline "server: terminating"; 37 | Lev.Io.stop io loop; 38 | Unix.close server_fd; 39 | Lev.Io.destroy io) 40 | server_fd 41 | (Lev.Io.Event.Set.create ~read:true ()) 42 | in 43 | Lev.Io.start io loop 44 | in 45 | Lev.Loop.run_until_done loop; 46 | [%expect 47 | {| 48 | server: listening 49 | client: connecting 50 | server: accepting client 51 | server: terminating |}] 52 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/vendor/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | VERSION_INFO = 4:0:0 4 | 5 | EXTRA_DIST = LICENSE Changes libev.m4 autogen.sh \ 6 | ev_vars.h ev_wrap.h \ 7 | ev_epoll.c ev_select.c ev_poll.c ev_kqueue.c ev_port.c ev_linuxaio.c ev_iouring.c \ 8 | ev_win32.c \ 9 | ev.3 ev.pod Symbols.ev Symbols.event 10 | 11 | man_MANS = ev.3 12 | 13 | include_HEADERS = ev.h ev++.h event.h 14 | 15 | lib_LTLIBRARIES = libev.la 16 | 17 | libev_la_SOURCES = ev.c event.c 18 | libev_la_LDFLAGS = -version-info $(VERSION_INFO) 19 | 20 | ev.3: ev.pod 21 | pod2man -n LIBEV -r "libev-$(VERSION)" -c "libev - high performance full featured event loop" -s3 <$< >$@ 22 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/vendor/README.embed: -------------------------------------------------------------------------------- 1 | This file is now included in the main libev documentation, see 2 | 3 | http://cvs.schmorp.de/libev/ev.html 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/vendor/Symbols.ev: -------------------------------------------------------------------------------- 1 | ev_async_send 2 | ev_async_start 3 | ev_async_stop 4 | ev_backend 5 | ev_break 6 | ev_check_start 7 | ev_check_stop 8 | ev_child_start 9 | ev_child_stop 10 | ev_cleanup_start 11 | ev_cleanup_stop 12 | ev_clear_pending 13 | ev_default_loop 14 | ev_default_loop_ptr 15 | ev_depth 16 | ev_embeddable_backends 17 | ev_embed_start 18 | ev_embed_stop 19 | ev_embed_sweep 20 | ev_feed_event 21 | ev_feed_fd_event 22 | ev_feed_signal 23 | ev_feed_signal_event 24 | ev_fork_start 25 | ev_fork_stop 26 | ev_idle_start 27 | ev_idle_stop 28 | ev_invoke 29 | ev_invoke_pending 30 | ev_io_start 31 | ev_io_stop 32 | ev_iteration 33 | ev_loop_destroy 34 | ev_loop_fork 35 | ev_loop_new 36 | ev_now 37 | ev_now_update 38 | ev_once 39 | ev_pending_count 40 | ev_periodic_again 41 | ev_periodic_start 42 | ev_periodic_stop 43 | ev_prepare_start 44 | ev_prepare_stop 45 | ev_recommended_backends 46 | ev_ref 47 | ev_resume 48 | ev_run 49 | ev_set_allocator 50 | ev_set_invoke_pending_cb 51 | ev_set_io_collect_interval 52 | ev_set_loop_release_cb 53 | ev_set_syserr_cb 54 | ev_set_timeout_collect_interval 55 | ev_set_userdata 56 | ev_signal_start 57 | ev_signal_stop 58 | ev_sleep 59 | ev_stat_start 60 | ev_stat_stat 61 | ev_stat_stop 62 | ev_supported_backends 63 | ev_suspend 64 | ev_time 65 | ev_timer_again 66 | ev_timer_remaining 67 | ev_timer_start 68 | ev_timer_stop 69 | ev_unref 70 | ev_userdata 71 | ev_verify 72 | ev_version_major 73 | ev_version_minor 74 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/vendor/Symbols.event: -------------------------------------------------------------------------------- 1 | event_active 2 | event_add 3 | event_base_dispatch 4 | event_base_free 5 | event_base_get_method 6 | event_base_loop 7 | event_base_loopexit 8 | event_base_new 9 | event_base_once 10 | event_base_priority_init 11 | event_base_set 12 | event_del 13 | event_dispatch 14 | event_get_callback 15 | event_get_method 16 | event_get_version 17 | event_init 18 | event_loop 19 | event_loopexit 20 | event_once 21 | event_pending 22 | event_priority_init 23 | event_priority_set 24 | event_set 25 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/vendor/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | autoreconf --install --symlink --force 4 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/vendor/configure.ac: -------------------------------------------------------------------------------- 1 | dnl also update ev.h! 2 | AC_INIT([libev], [4.33]) 3 | 4 | orig_CFLAGS="$CFLAGS" 5 | 6 | AC_CONFIG_SRCDIR([ev_epoll.c]) 7 | AM_INIT_AUTOMAKE 8 | 9 | AC_CONFIG_HEADERS([config.h]) 10 | AM_MAINTAINER_MODE 11 | 12 | AC_PROG_CC 13 | 14 | dnl Supply default CFLAGS, if not specified 15 | if test -z "$orig_CFLAGS"; then 16 | if test x$GCC = xyes; then 17 | CFLAGS="-g -O3" 18 | fi 19 | fi 20 | 21 | AC_PROG_INSTALL 22 | AC_PROG_LIBTOOL 23 | 24 | m4_include([libev.m4]) 25 | 26 | AC_CONFIG_FILES([Makefile]) 27 | AC_OUTPUT 28 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/vendor/update_ev_c: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | ( 4 | sed -ne '1,\%/\* ECB.H BEGIN \*/%p' ev.c 5 | #perl -ne 'print unless /^#if ECB_CPP/ .. /^#endif/' <~/src/libecb/ecb.h 6 | cat ~/src/libecb/ecb.h 7 | sed -ne '\%/\* ECB.H END \*/%,$p' ev.c 8 | ) >ev.c~ && mv ev.c~ ev.c 9 | 10 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/vendor/update_ev_wrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ( 4 | echo '#define VAR(name,decl) name' 5 | echo '#define EV_GENWRAP 1' 6 | cat ev_vars.h 7 | ) | cc -E -o - - | perl -ne ' 8 | while (<>) { 9 | push @syms, $1 if /(^\w+)/; 10 | } 11 | print "/* DO NOT EDIT, automatically generated by update_ev_wrap */\n", 12 | "#ifndef EV_WRAP_H\n", 13 | "#define EV_WRAP_H\n", 14 | (map "#define $_ ((loop)->$_)\n", sort @syms), 15 | "#else\n", 16 | "#undef EV_WRAP_H\n", 17 | (map "#undef $_\n", sort @syms), 18 | "#endif\n"; 19 | ' >ev_wrap.h 20 | -------------------------------------------------------------------------------- /thirdparty/lsp/submodules/lev/lev/vendor/update_symbols: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | make ev.o event.o || exit 4 | 5 | nm ev.o | perl -ne 'print "$1\n" if /\S+ [A-Z] (\S+)/' > Symbols.ev 6 | nm event.o | perl -ne 'print "$1\n" if /\S+ [A-Z] (\S+)/' > Symbols.event 7 | 8 | -------------------------------------------------------------------------------- /thirdparty/lsp/vendor/lev-fiber/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/vendor/lev-fiber/.gitkeep -------------------------------------------------------------------------------- /thirdparty/lsp/vendor/lev-fiber/util/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/vendor/lev-fiber/util/.gitkeep -------------------------------------------------------------------------------- /thirdparty/lsp/vendor/lev/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/c-cube/linol/1b4c56b134753b1dde46d63e9ed838a15d029595/thirdparty/lsp/vendor/lev/.gitkeep -------------------------------------------------------------------------------- /thirdparty/lsp/vendor/odoc-parser/src/compat.ml: -------------------------------------------------------------------------------- 1 | module Option = struct 2 | type 'a t = 'a option = None | Some of 'a 3 | 4 | let is_some = function None -> false | Some _ -> true 5 | let value ~default = function None -> default | Some x -> x 6 | 7 | let join_list l = 8 | let rec loop acc = function 9 | | [] -> Some (List.rev acc) 10 | | Some a :: q -> loop (a :: acc) q 11 | | None :: _ -> None 12 | in 13 | loop [] l 14 | end 15 | 16 | module Char = struct 17 | include Char 18 | 19 | let equal (x : char) y = x = y 20 | end 21 | 22 | module String = struct 23 | include String 24 | 25 | let for_all f str = 26 | let rec aux i = 27 | if i >= String.length str then true 28 | else if f (String.get str i) then aux (i + 1) 29 | else false 30 | in 31 | aux 0 32 | end 33 | -------------------------------------------------------------------------------- /thirdparty/lsp/vendor/odoc-parser/src/compat.mli: -------------------------------------------------------------------------------- 1 | (** @since 4.08 *) 2 | module Option : sig 3 | type 'a t = 'a option = None | Some of 'a 4 | 5 | val is_some : 'a option -> bool 6 | (** [is_some o] is [true] if and only if [o] is [Some o]. *) 7 | 8 | val value : default:'a -> 'a option -> 'a 9 | val join_list : 'a option list -> 'a list option 10 | end 11 | 12 | module Char : sig 13 | include module type of Char 14 | 15 | val equal : t -> t -> bool 16 | (** The equal function for chars. 17 | @since 4.03.0 *) 18 | end 19 | 20 | module String : sig 21 | include module type of String 22 | 23 | val for_all : (char -> bool) -> string -> bool 24 | (** [for_all p s] checks if all characters in [s] satisfy the preficate [p]. 25 | @since 4.13.0 *) 26 | end 27 | -------------------------------------------------------------------------------- /thirdparty/lsp/vendor/odoc-parser/src/dune: -------------------------------------------------------------------------------- 1 | (ocamllex lexer) 2 | 3 | (library 4 | (name odoc_parser) 5 | (libraries astring camlp-streams)) 6 | -------------------------------------------------------------------------------- /thirdparty/lsp/vendor/odoc-parser/src/lexer.mli: -------------------------------------------------------------------------------- 1 | (* Internal module, not exposed *) 2 | 3 | type input = { 4 | file : string; 5 | offset_to_location : int -> Loc.point; 6 | warnings : Warning.t list ref; 7 | lexbuf : Lexing.lexbuf; 8 | } 9 | 10 | val token : input -> Lexing.lexbuf -> Token.t Loc.with_location 11 | -------------------------------------------------------------------------------- /thirdparty/lsp/vendor/odoc-parser/src/loc.ml: -------------------------------------------------------------------------------- 1 | type point = { line : int; column : int } 2 | type span = { file : string; start : point; end_ : point } 3 | type +'a with_location = { location : span; value : 'a } 4 | 5 | let at location value = { location; value } 6 | let location { location; _ } = location 7 | let value { value; _ } = value 8 | let map f annotated = { annotated with value = f annotated.value } 9 | let same annotated value = { annotated with value } 10 | 11 | let span spans = 12 | match spans with 13 | | [] -> 14 | { 15 | file = "_none_"; 16 | start = { line = 1; column = 0 }; 17 | end_ = { line = 1; column = 0 }; 18 | } 19 | | first :: spans -> 20 | let last = List.fold_left (fun _ span -> span) first spans in 21 | { file = first.file; start = first.start; end_ = last.end_ } 22 | 23 | let nudge_start offset span = 24 | { span with start = { span.start with column = span.start.column + offset } } 25 | 26 | let spans_multiple_lines = function 27 | | { 28 | location = 29 | { start = { line = start_line; _ }; end_ = { line = end_line; _ }; _ }; 30 | _; 31 | } -> 32 | end_line > start_line 33 | -------------------------------------------------------------------------------- /thirdparty/lsp/vendor/odoc-parser/src/loc.mli: -------------------------------------------------------------------------------- 1 | (** Locations in files. *) 2 | 3 | (** This module concerns locations in source files, both points indicating a specific 4 | character and spans between two points. *) 5 | 6 | (** {2 Basic types} *) 7 | 8 | type point = { line : int; column : int } 9 | (** A specific character *) 10 | 11 | type span = { file : string; start : point; end_ : point } 12 | (** A range of characters between [start] and [end_] in a particular file *) 13 | 14 | val span : span list -> span 15 | (** [span spans] takes a list of spans and returns a single {!type-span} starting 16 | at the start of the first span and ending at the end of the final span *) 17 | 18 | val nudge_start : int -> span -> span 19 | (** This adjusts only the column number, implicitly assuming that the offset does 20 | not move the location across a newline character. *) 21 | 22 | (** {2 Located values} *) 23 | 24 | type +'a with_location = { location : span; value : 'a } 25 | (** Describes values located at a particular span *) 26 | 27 | val at : span -> 'a -> 'a with_location 28 | (** Constructor for {!with_location} *) 29 | 30 | val location : 'a with_location -> span 31 | (** Returns the location of a located value *) 32 | 33 | val value : 'a with_location -> 'a 34 | (** Returns the value of a located value *) 35 | 36 | val map : ('a -> 'b) -> 'a with_location -> 'b with_location 37 | (** Map over a located value without changing its location *) 38 | 39 | val same : _ with_location -> 'b -> 'b with_location 40 | (** [same x y] retuns the value y wrapped in a {!with_location} whose 41 | location is that of [x] *) 42 | 43 | val spans_multiple_lines : _ with_location -> bool 44 | (** [spans_multiple_lines x] checks to see whether [x] is located 45 | on a single line or whether it covers more than one. *) 46 | -------------------------------------------------------------------------------- /thirdparty/lsp/vendor/odoc-parser/src/syntax.mli: -------------------------------------------------------------------------------- 1 | (* Internal module, not exposed *) 2 | 3 | val parse : 4 | Warning.t list ref -> 5 | Token.t Loc.with_location Stream.t -> 6 | Ast.t * Warning.t list 7 | -------------------------------------------------------------------------------- /thirdparty/lsp/vendor/odoc-parser/src/warning.ml: -------------------------------------------------------------------------------- 1 | type t = { location : Loc.span; message : string } 2 | 3 | let to_string e = 4 | let { location; message } = e in 5 | let location_string = 6 | if location.start.line = location.end_.line then 7 | Printf.sprintf "line %i, characters %i-%i" location.start.line 8 | location.start.column location.end_.column 9 | else 10 | Printf.sprintf "line %i, character %i to line %i, character %i" 11 | location.start.line location.start.column location.end_.line 12 | location.end_.column 13 | in 14 | Printf.sprintf "File \"%s\", %s:\n%s" location.file location_string message 15 | 16 | let pp fmt v = Format.fprintf fmt "%s" (to_string v) 17 | 18 | let kasprintf k fmt = 19 | Format.(kfprintf (fun _ -> k (flush_str_formatter ())) str_formatter fmt) 20 | 21 | let kmake k ?suggestion = 22 | kasprintf (fun message -> 23 | match suggestion with 24 | | None -> k message 25 | | Some suggestion -> k (message ^ "\nSuggestion: " ^ suggestion)) 26 | 27 | let make ?suggestion format = 28 | let k message location = { location; message } in 29 | kmake k ?suggestion format 30 | -------------------------------------------------------------------------------- /thirdparty/lsp/vendor/update-odoc-parser.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | version=v2.3.0 4 | 5 | set -e -o pipefail 6 | 7 | TMP="$(mktemp -d)" 8 | trap "rm -rf $TMP" EXIT 9 | 10 | rm -rf odoc-parser 11 | mkdir -p odoc-parser/src 12 | 13 | ( 14 | cd $TMP 15 | git clone https://github.com/ocaml/odoc.git 16 | cd odoc 17 | git checkout $version 18 | ) 19 | 20 | SRC=$TMP/odoc 21 | 22 | cp -v $SRC/src/parser/*.{ml,mli,mll} odoc-parser/src 23 | cp -v $SRC/LICENSE odoc-parser/ 24 | 25 | git checkout odoc-parser/src/dune 26 | git add -A . 27 | -------------------------------------------------------------------------------- /vendor/jsonrpc/dune: -------------------------------------------------------------------------------- 1 | (copy_files %{project_root}/thirdparty/lsp/jsonrpc/src/*.{ml,mli}) 2 | 3 | (library 4 | (name linol_jsonrpc) 5 | (public_name linol.jsonrpc)) 6 | -------------------------------------------------------------------------------- /vendor/lsp/dune: -------------------------------------------------------------------------------- 1 | (copy_files %{project_root}/thirdparty/lsp/lsp/src/*.{ml,mli,mll}) 2 | 3 | (library 4 | (name linol_lsp) 5 | (public_name linol.lsp) 6 | (libraries linol_jsonrpc ppx_yojson_conv_lib uutf yojson) 7 | (flags :standard -open Linol_jsonrpc) 8 | (lint 9 | (pps ppx_yojson_conv))) 10 | 11 | (ocamllex uri_lexer) 12 | --------------------------------------------------------------------------------