package lsp

  1. Overview
  2. Docs
LSP protocol implementation in OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

jsonrpc-1.6.0.tbz
sha256=35e8c7341f8eb1fa39fb0f0e0701a7ed90b9a0bb89ccf84b7ed997cd258cbec3
sha512=c96a7a3ca845ec193e9edc4a74804a22d6e37efc852b54575011879bd2105e0df021408632219f542ca3ad85b36b5c8b72f2b417204d154d5f0dd0839535afa5

doc/lsp.stdune/Stdune/Pp/index.html

Module Stdune.PpSource

Pretty-printing.

Sourcetype +'tag t

A document that is not yet rendered. The argument is the type of tags in the document. For instance tags might be used for styles.

Basic combinators

Sourceval nop : _ t

A pretty printer that prints nothing

Sourceval seq : 'a t -> 'a t -> 'a t

seq x y prints x and then y

Sourceval concat : ?sep:'a t -> 'a t list -> 'a t

concat ?sep l prints elements in l separated by sep. sep defaults to nop.

Sourceval concat_map : ?sep:'a t -> 'b list -> f:('b -> 'a t) -> 'a t

Convenience function for List.map followed by concat

Sourceval concat_mapi : ?sep:'a t -> 'b list -> f:(int -> 'b -> 'a t) -> 'a t
Sourceval verbatim : string -> _ t

An indivisible block of text

Sourceval char : char -> _ t

A single character

Sourceval text : string -> _ t

Print a bunch of text. The line may be broken at any spaces in the text.

Sourceval textf : ('a, unit, string, _ t) format4 -> 'a

Same as text but take a format string as argument.

Break hints

Sourceval space : _ t

space instructs the pretty-printing algorithm that the line may be broken at this point. If the algorithm decides not to break the line, a single space will be printed instead.

So for instance verbatim "x" ++ space ++ verbatim "y" might produce "x y" or "x\n<indentation>y".

Sourceval cut : _ t

cut instructs the pretty-printing algorithm that the line may be broken at this point. If the algorithm decides not to break the line, nothing is printed instead.

So for instance verbatim "x" ++ space ++ verbatim "y" might produce "xy" or "x\n<indentation>y".

Sourceval break : nspaces:int -> shift:int -> _ t

break is a generalisation of space and cut. It also instructs the pretty-printing algorithm that the line may be broken at this point. If it ends up being broken, shift will be added to the indentation level, otherwise nspaces spaces will be printed. shift can be negative, in which case the indentation will be reduced.

Sourceval custom_break : fits:(string * int * string) -> breaks:(string * int * string) -> _ t

custom_break ~fits:(a, b, c) ~breaks:(x, y, z) is a generalisation of break. It also instructs the pretty-printing algorithm that the line may be broken at this point. If it ends up being broken, x is printed, the line breaks, y will be added to the indentation level and z is printed, otherwise a will be printed, b spaces are printed and then c is printed. The indentation y can be negative, in which case the indentation will be reduced.

Sourceval newline : _ t

Force a newline to be printed

Boxes

Boxes are the basic components to control the layout of the text. Break hints such as space and cut may cause the line to be broken, depending on the splitting rules. Whenever a line is split, the rest of the material printed in the box is indented with indent.

You can think of a box with indentation as something with this shape:

   ######################### <- first line
   <indent>#################
   <indent>#################
   <indent>#################
   <indent>#################

And the top left corner of this shape is anchored where the box was declared. So for instance, the following document:

 Pp.verbatim "....." ++ Pp.box ~indent:2 (Pp.text "some long ... text") 

would produce:

   .....some long ...
          text
Sourceval box : ?indent:int -> 'a t -> 'a t

Try to put as much as possible on each line. Additionally, a break hint always break the line if the breaking would reduce the indentation level inside the box (break with negative shift value).

Sourceval vbox : ?indent:int -> 'a t -> 'a t

Always break the line when encountering a break hint.

Sourceval hbox : 'a t -> 'a t

Print everything on one line, no matter what

Sourceval hvbox : ?indent:int -> 'a t -> 'a t

If possible, print everything on one line. Otherwise, behave as a vbox

Sourceval hovbox : ?indent:int -> 'a t -> 'a t

Try to put as much as possible on each line. Basically the same as box but without the rule about breaks with negative shift value.

Tags

Tags are arbitrary pieces of information attached to a document. They can be used to add styles to pretty-printed text, for instance to print to the terminal with colors.

Sourceval tag : 'a -> 'a t -> 'a t

tag x t Tag the material printed by t with x

Sourceval map_tags : 'a t -> f:('a -> 'b) -> 'b t

Convert tags in a documents

Sourceval filter_map_tags : 'a t -> f:('a -> 'b option) -> 'b t

Convenience functions

Sourceval enumerate : 'a list -> f:('a -> 'b t) -> 'b t

enumerate l ~f produces an enumeration of the form:

  - item1
  - item2
  - item3
  ...
Sourceval chain : 'a list -> f:('a -> 'b t) -> 'b t

chain l ~f is used to print a succession of items that follow each other. It produces an output of this form:

     item1
  -> item2
  -> item3
  ...

Operators

Sourcemodule O : sig ... end

Rendering

Sourceval to_fmt : Format.formatter -> _ t -> unit

Render a document to a classic formatter

Sourceval to_fmt_with_tags : Format.formatter -> 'a t -> tag_handler:(Format.formatter -> 'a -> 'a t -> unit) -> unit
OCaml

Innovation. Community. Security.