erlang / sourcer

An Erlang language server, providing IDE services.
Apache License 2.0
121 stars 19 forks source link

Fixes for stdio mode (tested with lsp-mode for emacs) #22

Closed klajo closed 5 years ago

klajo commented 5 years ago

Make DEBUG/TRACE optional at compilation time (off by default). If lsp-mode for emacs is run with sourcer in stdio mode (not tcp) then lsp-mode will fail like on text that is not part of the proper LSP jsonrpc texts:

error in process filter: progn: Error parsing language server output: (error No Content-Length header)

Instead of having these (same for TRACE macros) in the source code:

-define(DEBUG, true).
-define(DEBUG, 1).

... use rebar3 profiles to enable DEBUG/TRACE builds. From README.md:

Run this to build everything:

    rebar3 compile

Run this to build everything with `DEBUG` printouts enabled:

    rebar3 as debug compile

Run this to build everything with `TRACE` printouts enabled:

    rebar3 as trace compile

Run this to build everything with both `DEBUG` and `TRACE` printouts enabled:

    rebar3 as debug,trace compile

Please note that these will result in different builds below the
`_build` directory.
coveralls commented 5 years ago

Coverage Status

Coverage decreased (-0.08%) to 60.328% when pulling 3d00fb806a6077d2c5156f898bd0f6961eb9a8cc on klajo:emacs-lsp-mode-stdio-fixes into 74e29c5823dd86e810990b7d6eb6393c62ef5710 on erlang:master.

klajo commented 5 years ago

Made a new stdio reader.

vladdu commented 5 years ago

Thank you @klajo! It looks good, will try to merge it as soon as I get some time for it.

Regarding the debug printouts, I'm considering making them go to stderr instead. Only being able to enable them for all modules or for none is a little too coarse.

klajo commented 5 years ago

I force-pushed an update to the branch, where I changed the debug/trace to only comment out the defines. I.e. this PR now contains commented-out defines and the stdio reader fix. The original "rebar3 as debug compile" change is here.

klajo commented 5 years ago

Thanks for merging!

vladdu commented 5 years ago

Sure, I have to thank you more for the fix! Sorry that it took a while, I was on vacation.

klajo commented 5 years ago

No worries.