Closed akcorp2003 closed 7 years ago
Did you setup opam env correctly? What will happen if you execute merlin in the vscode's integrated terminal?
How do I check my opam env? I'm pretty sure it's set up correctly as I can run the opam
, ocaml
and even utop
in my bash terminal. I didn't, however, use brew to install it.
I can run ocamlmerlin -version
in the integrated terminal and I get the correct version output as noted in my first comment.
Are you sure only autocomplete not works? Does hover tips (show types when hover on variable) and other merlin related features works well?
All the other features don't work either.
I just tried opam remove merlin
and opam install merlin
but it didn't fix anything.
Do you know typescript? You'd better debug ocaml extension to figure out what's happan.
Unfortunately, I don't know Typescript. But how would I get started with debugging an extension? I've never tried to before.
I opened the debug window and got this:
And then I opened the debugger but got no output from the console even if I started typing inside.
'/Applications/Visual Studio Code.app/Contents/MacOS/Electron' --debugBrkPluginHost=46109 --extensionDevelopmentPath=/Users/akuang/OCamlPlugin/vscode-ocaml
The new debug window appears after you press F5 is a new vscode instance with the extension under debugging. You then open your test project folder under that window to check things. The warning is unimportant you can simply ignored.
Where are some suggested breakpoints? I tried hovering over some variables but I get no output in the debug console in the main window (not the new instance). Also, the branch mentioned in the referenced issue doesn't exist.
You can define a env variable DEBUG_VSCODE_OCAML=1 to make it log things. Or set breakpoint at src/log.ts:2
.
Sorry, I don't know much about TypeScript. How do I define this env variable? Even if I set the breakpoint at src/log.ts:2
, it will never enter it if I don't have that variable defined.
Never mind. I got it to output some variables. Will update shortly.
Here is the output after I entered a new line.
command to merlin: ["protocol","version",2]
response from merlin: ["return",{"selected":2,"latest":3,"merlin":"The Merlin toolkit version 2.5.0, for Ocaml 4.04.0"}]
command to merlin: ["checkout","auto","/Users/akuang/OCamlDev/src/filereader.ml"]
response from merlin: ["return",true]
command to merlin: ["tell","start","end","open Printf\n\nlet file = \"/Users/akuang/mf/src/\";;\n\nlet readFirstLine file_name =\n \n let line = open_in (file ^ file_name) in\n try\n let line_in_file = input_line line in\n print_endline line_in_file;\n flush stdout;\n close_in line\n with e ->\n close_in_noerr line;\n raise e\n\n;;\n\n\n\n\nlet () =\n readFirstLine \"classes/AccountHierarchyHelper.cls\";;"]
Here is the output after I typed in let
.
command to merlin: ["protocol","version",2]
response from merlin: ["return",{"selected":2,"latest":3,"merlin":"The Merlin toolkit version 2.5.0, for Ocaml 4.04.0"}]
command to merlin: ["checkout","auto","/Users/akuang/OCamlDev/src/filereader.ml"]
response from merlin: ["return",true]
command to merlin: ["tell","start","end","open Printf\n\nlet file = \"/Users/akuang/mf/src/\";;\n\nlet readFirstLine file_name =\n \n let line = open_in (file ^ file_name) in\n try\n let line_in_file = input_line line in\n print_endline line_in_file;\n flush stdout;\n close_in line\n with e ->\n close_in_noerr line;\n raise e\n\n;;\n\nl\n\nlet () =\n readFirstLine \"classes/AccountHierarchyHelper.cls\";;"]
response from merlin: ["return",true]
command to merlin: ["complete","prefix","l","at",{"line":19,"col":1},"with","doc"]
response from merlin: ["error",{"type":"type","sub":[],"valid":true,"message":"Error: /usr/local/lib/ocaml/pervasives.cmi\nis not a compiled interface for this version of OCaml.\nIt seems to be for a newer version of OCaml."}]
command to merlin: ["checkout","auto","/Users/akuang/OCamlDev/src/filereader.ml"]
response from merlin: ["return",true]
command to merlin: ["tell","start","end","open Printf\n\nlet file = \"/Users/akuang/mf/src/\";;\n\nlet readFirstLine file_name =\n \n let line = open_in (file ^ file_name) in\n try\n let line_in_file = input_line line in\n print_endline line_in_file;\n flush stdout;\n close_in line\n with e ->\n close_in_noerr line;\n raise e\n\n;;\n\nlet\n\nlet () =\n readFirstLine \"classes/AccountHierarchyHelper.cls\";;"]
response from merlin: ["return",true]
command to merlin: ["errors"]
response from merlin: ["error",{"type":"type","sub":[],"valid":true,"message":"Error: /usr/local/lib/ocaml/pervasives.cmi\nis not a compiled interface for this version of OCaml.\nIt seems to be for a newer version of OCaml."}]
It seems your compiler used by project is not identical with your compiler in env. Do you use opam switch? You can add a option ocaml.useOpamToResolve: true
to your workspace .settings.json
file then try (You must install merlin under that switch).
I don't think I'm using it as my current version of ocaml is close to the latest:
The OCaml toplevel, version 4.04.0
Even if I set ocaml.useOpamToResolve: true
, still no auto-complete.
See https://github.com/ocaml/merlin/issues/604. But your problem seems is not that case.
I can't help you any more. Open an issue at merlin project if necessary.
Alright. Thanks for giving some pointers though!
Using:
I'm having trouble with autocomplete. This is what I get:
I'm sure I have merlin installed as I get:
The Merlin toolkit version 2.5.0, for Ocaml 4.04.0
I also included the file associations in my user settings to match
*.ml
withocaml
. I've also tried reinstalling the plugin but it didn't resolve the issue.