Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommend to use reason-language-server for emacs #617

Open
wants to merge 1 commit into
base: source
Choose a base branch
from

Conversation

jjlee
Copy link

@jjlee jjlee commented Mar 12, 2020

Edit: Actually having clicked create on this PR after forgetting to yesterday, I remember that I have run into some trouble with the language server: it hangs on pasting text sometimes, I had to hack the lsp-mode.el source code to silence that for now. I'm trying to figure out why that happens, maybe I'll make some progress with that in the next few days...

I don't know exactly what was meant by upgrading reason-mode to use reason-language-server so I removed that text.
I'm pretty sure this wording is better than the status quo: even after hacking elisp and experimenting with merlin on the command line, I wasn't able to get it to recognize that my file was Reason code rather than OCaml. With LSP it seems to be working fine for me so far, using the spacemacs layer (aside from merlin still running and generating errors sometimes -- I'll try and find time to investigate how to kill that off and update the spacemacs layer later on).

I don't know exactly what was meant by upgrading reason-mode to use reason-language-server so I removed that text.
I'm pretty sure this wording is better than the status quo: even after hacking elisp and experimenting with merlin on the command line, I wasn't able to get it to recognize that my file was Reason code rather than OCaml.  With LSP it seems to be working fine for me so far, using the spacemacs layer (aside from merlin still running and generating errors sometimes -- I'll try and find time to investigate how to kill that off and update the spacemacs layer later on).
@jjlee
Copy link
Author

jjlee commented Mar 12, 2020

Created this about the hang: jaredly/reason-language-server#423

@jjlee
Copy link
Author

jjlee commented Mar 12, 2020

By the way, for other struggling emacsers, I hacked lsp-mode.el as follows:

 (defun lsp--find-workspaces-for (msg-or-method)
   "Find all workspaces in the current that can handle MSG."
   (let ((method (if (stringp msg-or-method)
                     msg-or-method
                   (plist-get msg-or-method :method))))
-    (-if-let (reqs (cdr (assoc method lsp-method-requirements)))
-        (-let (((&plist :capability :check-command) reqs))
-          (--filter
-          (with-lsp-workspace it
-            (or
-              (when check-command (funcall check-command it))
-              (when capability (lsp--capability capability))
-              (lsp--registered-capability method)
-              (and (not capability) (not check-command))))
-          (lsp-workspaces)))
-      (lsp-workspaces))))
+    ;; (message method)
+    (if (equal method "textDocument/rangeFormatting")
+        nil
+      (-if-let (reqs (cdr (assoc method lsp-method-requirements)))
+          (-let (((&plist :capability :check-command) reqs))
+            (--filter
+             (with-lsp-workspace it
+               (or
+                (when check-command (funcall check-command it))
+                (when capability (lsp--capability capability))
+                (lsp--registered-capability method)
+                (and (not capability) (not check-command))))
+             (lsp-workspaces)))
+        (lsp-workspaces)))))

And I think because I also seem to have a too-old flycheck for the lsp-mode I've got, I also had to comment out the :end-column and :end-line in function lsp--flycheck-start in the same file.

In spacemacs (I'm on develop branch as of a few months ago, I think) I also had to run this, or else the errors from lsp shown in the buffer wouldn't update when I edited stuff:

(spacemacs|define-jump-handlers reason-mode)

With that, using reason-mode and turning off merlin-mode and enabling lsp with the config suggested by reason-language-server's docs, things seem to be working so far...

@davesnx
Copy link
Member

davesnx commented Aug 29, 2023

I'm not an emacs user but this might be outdated. Is this still relevant?

A resource from OCaml https://batsov.com/articles/2022/08/23/setting-up-emacs-for-ocaml-development/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants