···8686 Some (path :: paths_in_bindings bindings, loc)
8787 | Patch {self; _}
8888 | Object {self; _;} ->
8989- (* Option.to_list self; *)
9089 Option.map (fun path -> [path], loc) self
9190 | Fun (bindings, _) -> Some (paths_in_bindings bindings, loc)
9291 | Subtree _
···174173let analyse_syntax nodes =
175174 let@ () = S.run in
176175 List.iter analyse nodes
176176+177177+exception Found of string
178178+179179+let word_at ~position (doc : Lsp.Text_document.t) =
180180+ let L.Position.{line; character;} = position in
181181+ let line = List.nth_opt (String.split_on_char '\n' (Lsp.Text_document.text doc)) line in
182182+ match line with
183183+ | None -> None
184184+ | Some line ->
185185+ let words = String.split_on_char ' ' line in
186186+ Logs.debug (fun m -> m "line has %d words" (List.length words));
187187+ try
188188+ let acc = ref 0 in
189189+ List.iter
190190+ (fun word ->
191191+ Logs.debug (fun m -> m "%s" word);
192192+ let length = String.length word in
193193+ if !acc + length + 1 > character then raise (Found word)
194194+ else acc := !acc + length + 1
195195+ )
196196+ words;
197197+ None
198198+ with
199199+ | Found str -> Some str