Soilihi BEN SOILIHI BOINA pushed to branch soilih at Stefan / Typer
Commits: 7e546235 by Soilih BEN SOILIH at 2021-09-12T23:52:44-06:00 fixing some order issues in completions
- - - - -
1 changed file:
- src/typer_lsp_server.ml
Changes:
===================================== src/typer_lsp_server.ml ===================================== @@ -802,27 +802,10 @@ let lsp_compl_from_var (ret : Debruijn.lexp_context * (((Source.Location.t * str let kind_of_a_lexp (e: Lexp.lexp) : Lsp.Types.CompletionItemKind.t = let open Elexp in match Lexp.lexp_lexp' e with - | Imm (Float (_, _)) - | Imm (Integer (_, _)) - | Imm (String (_, _)) - | Imm (Block (_, _) | Symbol _ | Node (_, _)) - | SortLevel SLz -> Lsp.Types.CompletionItemKind.Variable - | SortLevel (SLsucc e) -> Lsp.Types.CompletionItemKind.Variable - | SortLevel (SLlub (e1, e2)) -> Lsp.Types.CompletionItemKind.Variable - | Sort (l, Stype e) -> Lsp.Types.CompletionItemKind.Variable - | Sort (_, StypeLevel) - | Sort (_, StypeOmega) -> Lsp.Types.CompletionItemKind.Variable - | Builtin (_, t) -> Lsp.Types.CompletionItemKind.Variable - | Var ((l, name), idx) -> Lsp.Types.CompletionItemKind.Variable - | Susp (e, s) -> Lsp.Types.CompletionItemKind.Variable - | Let (l, defs, e) -> Lsp.Types.CompletionItemKind.Variable - | Arrow (ak, v, t1, l, t2) -> Lsp.Types.CompletionItemKind.Variable - | Inductive (l, _label, args, cases) -> Lsp.Types.CompletionItemKind.Variable - | Case (l, e, ret, branches, default) -> Lsp.Types.CompletionItemKind.Variable - | Metavar (idx, s, _) -> Lsp.Types.CompletionItemKind.Variable - | Lambda (ak, (l,_), t, e) -> Lsp.Types.CompletionItemKind.Function - | Call (f, args) -> Lsp.Types.CompletionItemKind.Function + | Lambda (ak, (l,_), t, e) -> Lsp.Types.CompletionItemKind.Function | Cons (t, (_l, name)) -> Lsp.Types.CompletionItemKind.Constructor + | _ -> Lsp.Types.CompletionItemKind.Variable +
let kind_of_a_varbind (element : Debruijn.env_elem ) : Lsp.Types.CompletionItemKind.t = let (_,vrb,_) = element in @@ -845,14 +828,14 @@ let lsp_compl_from_var (ret : Debruijn.lexp_context * (((Source.Location.t * str (* Transform a context to a list of completion item *) let ctx_to_ci_list (lctx : Debruijn.env_elem list) (range:Lsp.Types.Range.t) = List.map ( fun (x: Debruijn.env_elem) -> - let ((_,s),_,_) = x in + let ((_,s),_,t) = x in let str = Option.get s in let label = str in let textEdit = Lsp.Types.TextEdit.create ~range:range ~newText:(str) in let kind = kind_of_a_varbind x in let ci = Lsp.Types.CompletionItem.create ~label:label ~kind:kind - ~textEdit:textEdit ~detail:str () + ~textEdit:textEdit ~detail:(Lexp.lexp_string t) () in ci
@@ -883,17 +866,19 @@ let lsp_compl_from_var (ret : Debruijn.lexp_context * (((Source.Location.t * str | [] -> "" | _ -> List.fold_left (fun x y -> x ^ (String.make 1 y)) "" char_list
- + let char_index (str:string) (chr:char) : int = + try String.index str chr + with e -> String.index str (Char.uppercase_ascii chr) let rec str_order (substr:string) (str:string) : bool = match str_to_char_list substr with | [] -> false | [hd] -> string_contain (String.make 1 hd) str - | [hd;tl] -> let ihd = String.index str hd in - let itl = String.index str tl in + | [hd;tl] -> let ihd = char_index str hd in + let itl = char_index str tl in if (ihd < itl) then true else false - | hd::ml::tl -> let ihd = String.index str hd in - let iml = String.index str ml in + | hd::ml::tl -> let ihd = char_index str hd in + let iml = char_index str ml in if ( ihd < iml ) then str_order (char_list_to_str (ml::tl)) str else false @@ -1079,8 +1064,9 @@ class lsp_server =
let filtred_list = filter_lctx l_ctx [] in let comp_list = ctx_to_ci_list filtred_list range in + let comp_list_ret = complete_oth word comp_list in
- let e = Some (`List comp_list) in + let e = Some (`List comp_list_ret) in let f = Linol_lwt.return e in f
end
View it on GitLab: https://gitlab.com/monnier/typer/-/commit/7e546235f17173e3f0964492867f243a3a...