scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.07k stars 323 forks source link

Add installation instructions for Emacs #393

Closed olafurpg closed 5 years ago

olafurpg commented 5 years ago

I would love to update the website to document the installation instructions for Emacs using lsp-scala (https://github.com/rossabaker/lsp-scala/). I've been planning to do this for awhile but I have limited experience with Emacs so I got stuck on my first attempt and never got around to finish it.

cc/ @rossabaker

olafurpg commented 5 years ago

Would someone be able to help out with this? I've spent a couple hours trying to get lsp-scala working on my computer but I've never used Emacs before so it's all new to me.

The benefit of documenting the Emacs installation on the Metals website is that version numbers for generating the metals-emacs binary will stay up-to-date as new releases are published.

olafurpg commented 5 years ago

cc/ @coreyoconnor

olafurpg commented 5 years ago

Alternatively, if someone can give me a pointers on how to get started from a completely clean ~/.emacs.d then I'd love to give it another try myself. I struggled most with installing packages.

fommil commented 5 years ago

I wrote extensive Learning Emacs docs over at

that you may wish to use for your own benefit.

olafurpg commented 5 years ago

@fommil thanks, I got it working!

olafurpg commented 5 years ago

Whoops, fat thumb closed the issue while I was writing a response.

rossabaker commented 5 years ago

It's a little more burdensome than it ought to be because the package isn't in MELPA yet, like its dependency. I did some of the ceremonial linting to get it up to standard. I'll try to submit it to MELPA today.

olafurpg commented 5 years ago

I like how Emacs highlights the line that you navigate to

2018-12-10 12 27 47

I'll open a PR soon updating the docs. The integration is not perfect yet, I can't get lsp-mode to send the correct shutdown and exit hooks. It also sends textDocument/hover requests even if Metals does not declare a hover provider. Those can be improved on in the future.

olafurpg commented 5 years ago

@rossabaker would it be possible to enable the hook by default?

(add-hook 'scala-mode-hook #'lsp-scala-enable)

I'm not aware of another editor that require enabling the language server on a file-basis. It's more common to disable/enable the LSP package on per-project.

fommil commented 5 years ago

@rossabaker what do you mean "like its dependency"? https://melpa.org/#/lsp-mode

fommil commented 5 years ago

@olafurpg btw, just so you know, the red squiggly support is already provided, (non-ensime) emacs by sbt's lsp and/or flycheck. I suspect the docs may need to touch on disabling things or everybody is going to get conflicts and perf regressions. Spacemacs often enables stuff by default.

gabro commented 5 years ago

That's a very good point, We do the same for VSCode's docs, for other available Scala LSP extensions, so it makes sense for Emacs too.