package vcaml

  1. Overview
  2. Docs

Source file types.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
(* This files only purpose is avoid module dependency cycles via
   re-exporting types and functions. *)

open! Core
open! Async
module Subscriber_key = Unique_id.Int63 ()

module Window = struct
  type t = Nvim_internal.Types.Window.t [@@deriving sexp]

  include Comparable.Make (Nvim_internal.Types.Window)
  include Hashable.Make (Nvim_internal.Types.Window)

  let window_tyid = 1

  let of_msgpack =
    let open Msgpack in
    function
    | Extension { type_id; data } when Int.equal type_id window_tyid ->
      let open Or_error in
      t_of_string (Bytes.to_string data) >>= Nvim_internal.Types.Window.of_msgpack
    | _ -> Or_error.error_string "not a buffer message!"
  ;;

  let to_msgpack t =
    let open Msgpack in
    let data =
      Nvim_internal.Types.Window.to_msgpack t
      |> Msgpack.string_of_t_exn
      |> Bytes.of_string
    in
    Extension { type_id = window_tyid; data }
  ;;
end

module Buf = struct
  type t = Nvim_internal.Types.Buffer.t [@@deriving sexp]

  include Comparable.Make (Nvim_internal.Types.Buffer)
  include Hashable.Make (Nvim_internal.Types.Buffer)

  let buffer_tyid = 0

  let of_msgpack =
    let open Msgpack in
    function
    | Extension { type_id; data } when Int.equal type_id buffer_tyid ->
      let open Or_error.Let_syntax in
      let%bind msg = t_of_string (Bytes.to_string data) in
      Nvim_internal.Types.Buffer.of_msgpack msg
    | _ -> Or_error.error_string "not a buffer message!"
  ;;

  let to_msgpack t =
    let open Msgpack in
    let data =
      Nvim_internal.Types.Buffer.to_msgpack t
      |> Msgpack.string_of_t_exn
      |> Bytes.of_string
    in
    Extension { type_id = buffer_tyid; data }
  ;;
end

module Tabpage = struct
  type t = Nvim_internal.Types.Tabpage.t [@@deriving sexp]

  include Comparable.Make (Nvim_internal.Types.Tabpage)
  include Hashable.Make (Nvim_internal.Types.Tabpage)

  let tabpage_tyid = 2

  let of_msgpack =
    let open Msgpack in
    function
    | Extension { type_id; data } when Int.equal type_id tabpage_tyid ->
      let open Or_error in
      t_of_string (Bytes.to_string data) >>= Nvim_internal.Types.Tabpage.of_msgpack
    | _ -> Or_error.error_string "not a buffer message!"
  ;;

  let to_msgpack t =
    let open Msgpack in
    let data =
      Nvim_internal.Types.Tabpage.to_msgpack t
      |> Msgpack.string_of_t_exn
      |> Bytes.of_string
    in
    Extension { type_id = tabpage_tyid; data }
  ;;
end

type client =
  { events : (Msgpack_rpc.event -> unit) Bus.Read_only.t
  ; call_nvim_api_fn : 'a. 'a Nvim_internal.Types.api_result -> 'a Deferred.Or_error.t
  ; register_request :
      name:string -> f:(Msgpack.t list -> Msgpack.t Or_error.t) -> unit Or_error.t
  ; buffers_attached : int Buf.Table.t
  ; attach_sequencer : unit Sequencer.t
  }

module Client_info = struct
  type version =
    { major : int option
    ; minor : int option
    ; patch : int option
    ; prerelease : string option
    ; commit : string option
    }
  [@@deriving sexp_of]

  type client_type =
    [ `Remote
    | `Ui
    | `Embedder
    | `Host
    | `Plugin
    ]
  [@@deriving sexp_of]

  type client_method =
    { async : bool
    ; nargs : [ `Fixed of int | `Range of int * int ] option
    ; opts : Msgpack.t String.Map.t
    }
  [@@deriving sexp_of]

  type t =
    { version : version option
    ; methods : client_method String.Map.t
    ; attributes : string String.Map.t
    ; name : string option
    ; type_ : client_type option
    }
  [@@deriving sexp_of]
end

module Chan_info = struct
  type t =
    { id : int
    ; stream : [ `Stdio | `Stderr | `Socket | `Job ]
    ; mode : [ `Bytes | `Terminal | `Rpc ]
    ; pty : string option
    ; buffer : Buf.t option
    ; client : Client_info.t option
    }
end

module Phantom = Nvim_internal.Types.Phantom
OCaml

Innovation. Community. Security.