rescript-mode icon indicating copy to clipboard operation
rescript-mode copied to clipboard

`(require 'compile)` fixes issue loading the mode

Open switch-to-gitlab opened this issue 1 year ago • 0 comments

Hello,

I'm not the worlds most proficient emacs user, so you can take this all with that grain of salt, but I struggled with an issue and found a solution so I thought I'd share just in case it helps anyone else.

I tried following the steps in the README but whenever I opened a ReScript file, the package wouldn't load with the following error in the minibuffer: "Symbol's value as variable is void: compilation-error-regexp-alist-alist".

For a minimum reproduction, I stripped my init.el down to just this:

;; melpa
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)

;; rescript
(customize-set-variable
  'lsp-rescript-server-command
    '("rescript-language-server" "--stdio"))
(with-eval-after-load 'rescript-mode
  ;; Tell `lsp-mode` about the language server
  (require 'lsp-rescript)
  ;; Enable `lsp-mode` in rescript-mode buffers
  (add-hook 'rescript-mode-hook 'lsp-deferred)
  ;; Enable display of type information in rescript-mode buffers
  (require 'lsp-ui)
  (add-hook 'rescript-mode-hook 'lsp-ui-doc-mode))

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages
   '(lsp-rescript company lsp-ui lsp-mode)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

This reproduced the issue for me with the same void variable error as above.

I searched the error and found this issue on a different project which suggested adding (require 'compile) might help, and so without hardly the vaguest sense of what that line does, I stuck it in the line below my ;; rescript comment, and suddenly the mode started working as expected for me.

Since I don't know what I'm doing I can hardly recommend any specific course of action for this project but at a minimum this troubleshooting measure might merit a note in the README file? Just a suggestion.

Thank you for working on this project. It is appreciated.

switch-to-gitlab avatar Nov 15 '24 00:11 switch-to-gitlab