Soilihi BEN SOILIHI BOINA pushed to branch minimal-server at Stefan / Typer
Commits: f995dc36 by Soilih at 2022-06-13T15:04:23-04:00 make the server available
- - - - -
4 changed files:
- README.md - btl/pervasive.typer - src/elab.ml - typer.ml
Changes:
===================================== README.md ===================================== @@ -32,3 +32,12 @@ By default, Dune creates a '_build' folder which holds all the compiled files. # Emacs files
/typer-mode.el + +# Use The LSP Server in Emacs +To use the LSP server in Emacs, you have to do 2 things: +* name the executable: **typer** + You can use the command: + *ln -s /home/path/to/your/executable/typer.exe typer* +* Install Typer-mode in Emacs and use it. For, you can open + the file *typer-mode.el* in Emacs and do: + *M-x package-install-from-buffer*
===================================== btl/pervasive.typer ===================================== @@ -567,7 +567,7 @@ define-operator "<-" 80 96; %% %% `List` is the type and `list` is the module %% -list = load "/home/soilih/Projet Maitrise/typer/btl/list.typer"; +list = load "btl/list.typer";
%% %% Macro `do` for easier series of IO operation @@ -575,13 +575,13 @@ list = load "/home/soilih/Projet Maitrise/typer/btl/list.typer"; %% e.g.: %% do { IO_return true; }; %% -do = let lib = load "/home/soilih/Projet Maitrise/typer/btl/do.typer" in lib.do; +do = let lib = load "btl/do.typer" in lib.do;
%% %% Module containing various macros for tuple %% Used by `case_` %% -tuple-lib = load "/home/soilih/Projet Maitrise/typer/btl/tuple.typer"; +tuple-lib = load "btl/tuple.typer";
%% %% Get the nth element of a tuple @@ -612,7 +612,7 @@ Tuple = tuple-lib.tuple-type; %% %% Macro `case` for a some more complex pattern matching %% -case_ = let lib = load "/home/soilih/Projet Maitrise/typer/btl/case.typer" in lib.case-macro; +case_ = let lib = load "btl/case.typer" in lib.case-macro;
%% %% plain-let @@ -629,7 +629,7 @@ define-operator "plain-let" () 3; %% define-operator "in" 3 67; %%
-plain-let_in_ = let lib = load "/home/soilih/Projet Maitrise/typer/btl/plain-let.typer" in lib.plain-let-macro; +plain-let_in_ = let lib = load "btl/plain-let.typer" in lib.plain-let-macro;
%% %% `case` at function level @@ -639,7 +639,7 @@ plain-let_in_ = let lib = load "/home/soilih/Projet Maitrise/typer/btl/plain-let %% | true => false %% | false => true; %% -_|_ = let lib = load "/home/soilih/Projet Maitrise/typer/btl/polyfun.typer" in lib._|_; +_|_ = let lib = load "btl/polyfun.typer" in lib._|_;
%% %% case_as_return_, case_return_ @@ -648,7 +648,7 @@ _|_ = let lib = load "/home/soilih/Projet Maitrise/typer/btl/polyfun.typer" in l
define-operator "as" 42 42; define-operator "return" 42 42; -depelim = load "/home/soilih/Projet Maitrise/typer/btl/depelim.typer"; +depelim = load "btl/depelim.typer"; case_as_return_ = depelim.case_as_return_; case_return_ = depelim.case_return_;
===================================== src/elab.ml ===================================== @@ -70,14 +70,15 @@ let elab_check = ref false let dloc = dummy_location
let parsing_internals = ref false + +let str_ref = ref "" let btl_folder = try Sys.getenv "TYPER_BUILTINS" - with Not_found -> let str_ref = ref "" in - let strl = String.split_on_char '/' Sys.executable_name in - for i = 1 to (List.length strl) -2 do - str_ref := !str_ref ^ "/" ^ (List.nth strl i) - done; - !str_ref ^ "/btl" + with Not_found -> let strl = String.split_on_char '/' Sys.executable_name in + for i = 1 to (List.length strl) -2 do + str_ref := !str_ref ^ "/" ^ (List.nth strl i) + done; + !str_ref ^ "/btl"
let fatal ?print_action ?loc fmt = @@ -1843,12 +1844,12 @@ let sform_load usr_elctx loc sargs _ot =
| [String (_,file_name)] -> if !in_pervasive then ( if (Filename.is_relative file_name) then - (read_file btl_folder usr_elctx) + (read_file (Filename.concat !str_ref file_name) usr_elctx) else (read_file file_name usr_elctx) ) else if (Filename.is_relative file_name) then - (read_file btl_folder !sform_default_ectx) + (read_file (Filename.concat !str_ref file_name) !sform_default_ectx) else (read_file file_name !sform_default_ectx) | _ -> (error ~loc "argument to load should be one file name (String)"; !sform_default_ectx) in
===================================== typer.ml ===================================== @@ -43,7 +43,8 @@ let arg_defs = Arg.String Log.set_typer_log_level_str, "Set the logging level");
- ("--lsp", Arg.Set lsp_server, "Enable Typer LSP server"); + ("--lsp", Arg.Unit (fun _ -> let _ = lsp_server := true + in ()), "Enable Typer LSP server");
("--check", Arg.Set Elab.elab_check, "Enable Checking");
@@ -67,6 +68,8 @@ let compile_main argv = let repl_main argv = let usage = Sys.executable_name ^ " repl [options] [<file>] …" in Arg.parse_argv argv arg_defs add_input_file usage; + if !lsp_server then Typer_lsp_server.run () + else (); print_string (Fmt.make_title " TYPER REPL "); print_endline " Typer 0.0.0 - Interpreter - (c) 2016-2021"; print_newline (); @@ -98,8 +101,6 @@ let run_main argv = Log.print_log ()
let main () = - if !lsp_server then Typer_lsp_server.run () - else (); let command, argv = if Array.length Sys.argv <= 1 then "repl", [||]
View it on GitLab: https://gitlab.com/monnier/typer/-/commit/f995dc362b84c3ea40b7f2bc5349da19cd...
Afficher les réponses par date