Looks like this. Maybe if you’d like we I could try to help you with a screenshare during the week. Could lock up to 30’ sometime today or during week
Thanks so much for the help, I really appreciate it! Maybe I’m just confused about what the feature really does. I was assuming it was similar to the VSCode functionality where it’ll actually suggest the correct typespec based on the inferred success typings. The docs for lsp-mode
’s lsp-elixir
made me think that that was the way it worked:
Suggest @spec annotations inline using Dialyzer`s inferred success typings. This requires Dialyzer.
Maybe I just misunderstood the feature. When I used VSCode I could just write a function and then above it, VSCode would suggest the correct @spec
and I could insert it. From your screenshot it looks like maybe lsp-elixir
just autocompletes the specs as you type? If that’s the case then I think everything is working fine for me; maybe the elixir-lsp
docs just need the wording tweaked.
This is lenses. Make sure they are enabled in your configuration (setq lsp-lens-enable t)
(or how you do it in doom, I am a spacemacs user)
Oh man, that did it! Thanks so much both of you
I apologize in advance for the off-topic proselytizing but I haven’t seen this mentioned on this forum and I really feel like people should be aware of it:
There is now a pretty usable emulation of Spacemacs and Magit available in VS Code via the VSpaceCode extension. It adds all the bindings and adds other extensions - the most impressive of which is edamagit that does a very respectable job of emulating magit in VS Code.
I think VS Code has had a better language experience than Emacs for at least a year or two now (for example, go to definition always works, outline, find references, faster loading of large files, better error highlighting), but I was never able to switch to it due to muscle-memory reliance on Spacemacs bindings which are too time-consuming to recreate and particularly on Magit. The only thing I’m still missing is a fuzzy find in files that competes with helm but its now good enough that the benefits outweigh the drawbacks. Also the plugin system is easy to hack on, not quite as self-integrated as Emacs but easy to learn if you know Javascript/NPM. I submitted my first patch to a plugin 4 days after adopting it with less than hour of work.
This is my first post on Elixir forum, but I think that it is necessary. I’m relatively new to Elixir world and I’ve tried few times to setup elixir-ls with lsp-mode on my vanilla emacs. Eglot worked as it is described in this heading wiki, but lsp-mode was nightmare for me. I’ve already had lsp-mode installed to try it for Java and TypeScript.
Long story short, on use-package lsp-mode
and :hook elixir-mode with lsp-mode there was constant annoying error message Symbols function definition is void: -const
. I must say that I learned a lot about elisp by trying to solve this, but nothing helped. And then, after a whole day of duckducking I found a comment on some lsp-mode error that suggested to delete complete .emacsd/elpa
folder and let emacs reload everything.
If someone in the future has lot of troubles with lsp-mode maybe this action could be last desperate resort.
FYI lsp-mode
just merged the PR to add an installer for Elixir-LS, hence from the next release it won’t be required to install it manually anymore (at least for lsp-mode
users).
Up until a few days ago I managed to disable dialyzer in Spacemacs with this snippet:
(defvar lsp-elixir--config-options (make-hash-table))
(puthash "dialyzerEnabled" :json-false lsp-elixir--config-options)
(add-hook 'lsp-after-initialize-hook
(lambda ()
(lsp--set-configuration `(:elixirLS, lsp-elixir--config-options))))
but it no longer works, any thoughts?
dev branch
backend: lsp
Finally got around to moving off of Aquamacs (stuck at emacs 24.x) and have landed on Emacs Plus (GitHub - d12frosted/homebrew-emacs-plus: Emacs Plus formulae for the Homebrew package manager) vanilla emacs distribution aimed at macOS.
As a part of that I’ve put together a configuration kit that includes all the bits that I need for Elixir in emacs at GitHub - walter/emakit: emacs editor configuration kit.
Fairly minimal, does have a few niceties for Macs, but should be mostly portable. It will install elixir-ls
, lsp-mode
, etc. (i.e. not eglot
). Basically you install your lsp server, grab emacs plus, set this up, and start emacs and things will be installed and configured.
Hope someone finds it helpful.
Hey folks, I can’t manage how to make my lsp config works with jump to definition… I don’t know if I’m doing anything wrong… I can jump to definition in the same file, but I can’t jump to other files or even jump to modules on the aliases section.
This is my configuration:
(use-package elixir-mode
:hook ((elixir-mode . flycheck-mode))
:bind (:map elixir-mode-map
("C-c i" . elixir-format))
:config (add-hook 'before-save-hook 'elixir-format))
;; (use-package alchemist
;; :hook ((elixir-mode . alchemist-mode)
;; (elixir-mode . flycheck-mode))
;; :bind (:map elixir-mode-map
;; ("C-c i" . elixir-format))
;; :init (setq alchemist-key-command-prefix (kbd "C-c ,"))
;; :config (add-hook 'before-save-hook 'elixir-format))
(use-package flycheck-credo
:after (flycheck elixir-mode)
:custom
(flycheck-elixir-credo-strict t)
:hook
(elixir-mode . flycheck-credo-setup))
(use-package exunit
:hook (elixir-mode . exunit-mode)
:bind
(:map elixir-mode-map
("C-c , a" . exunit-verify-all)
("C-c , A" . exunit-verify-all-in-umbrella)
("C-c , s" . exunit-verify-single)
("C-c , v" . exunit-verify)
("C-c , r" . exunit-rerun)
("C-c , f" . exunit-toggle-file-and-test)))
(use-package lsp-mode
:hook ((clojure-mode . lsp)
(elixir-mode . lsp)
(typescript-mode . lsp)
(rustic-mode . lsp)
(lsp-mode . lsp-enable-which-key-integration))
:bind (("M-." . lsp-find-definition))
:commands lsp
:init
(setq lsp-keymap-prefix "C-c l")
(setq gc-cons-threshold 100000000)
(setq read-process-output-max (* 1024 1024)) ;; 1mb
(setq lsp-file-watch-threshold 1500)
:config
(add-to-list 'lsp-language-id-configuration '(nix-mode . "nix"))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection '("rnix-lsp"))
:major-modes '(nix-mode)
:server-id 'nix))
:custom
(lsp-rust-analyzer-cargo-watch-command "clippy")
(lsp-rust-analyzer-server-display-inlay-hints t)
(lsp-eldoc-render-all t))
There’s a lot of configs here, because I use the lsp-mode to other languages as well
I looked at the lsp-log but didn’t find anything useful
Can you folks help me to debug this issue?
I am struggling with the completion in my setup.
I am not suggested any completions. When I ask for them explicitly by calling completion-at-point
, emacs hangs for like 10 seconds and then messages completion--some: Timeout while waiting for response. Method: textDocument/completion
.
The versions I am using
- Emacs 28.1
- ElixirLS v0.11.0
- Elixir 1.13.4 OTP 25
I set lsp-log-ip
to t
and after the timeout I see:
[Trace - 11:16:11 ] Sending request 'textDocument/completion - (47)'.
Params: {
"textDocument": {
"uri": "file:///<correct file path to the file I am editing>"
},
"position": {
"line": 28,
"character": 0
},
"context": {
"triggerKind": 1
}
}
[Trace - 11:16:21 ] Sending notification '$/cancelRequest'.
Params: {
"id": 47
}
Any ideas?
Hi all, excuse the necro-bump, but this thread has been very useful to me and I wanted to share some of my configuration which is not referenced elsewhere in this thread.
Firstly, I am making use of the ob-elixir package, which allows me to execute arbitrary elixir code in org-mode files. This is very useful for report generation!
;; Allows for Elixir usage inside an org-mode file.
;; Even cooler, you can even connect to a remote shell:
;;
;; #+BEGIN_SRC elixir :remsh name@node :sname console
;; Node.self
;; #+END_SRC
;;
;; #+RESULTS:
;; : :name@node
(straight-use-package 'ob-elixir)
(with-eval-after-load 'org
(require 'ob-elixir)
(add-to-list 'org-babel-load-languages '(elixir . t)))
(org-babel-do-load-languages 'org-babel-load-languages '())
The second thing - and I’m very surprised this hasn’t been mentioned yet - is inf-elixir! inf-elixir creates an “inferior mode” (aka an interpreter) buffer - you can then send regions and buffers to that interpreter. This is very useful for debugging and prototyping! The integration between Emacs and the interpreter makes for a very smooth experience.
(straight-use-package 'inf-elixir)
(require 'inf-elixir)
(evil-define-key '(normal emacs) elixir-mode-map (kbd "C-c i i") 'inf-elixir)
(evil-define-key '(normal emacs) elixir-mode-map (kbd "C-c i p") 'inf-elixir-project)
(evil-define-key '(normal visual-line emacs) elixir-mode-map (kbd "C-c i l") 'inf-elixir-send-line)
(evil-define-key '(normal visual visual-line emacs) elixir-mode-map (kbd "C-c i r") 'inf-elixir-send-region)
(evil-define-key '(normal emacs) elixir-mode-map (kbd "C-c i b") 'inf-elixir-send-buffer)
I hope this is helpful to someone out there!
One issue I’ve faced - and I’d love to hear if anyone else has come across this - is that completions for constants will strip the @
prefix. You can see what I mean in this video: 30 11 2022 14:07:23 - YouTube If anyone has an idea on how to fix this, I’d love to know!
Hi all,
Did you have any issue with elixir-ls-1.14-25.1?
I use Emacs 28.2, also use dialyxir as new update, with autocomplete it can suggest basic modules and functions but suddenly cannot suggest callback functions.
I’ve just went through my configuration all over again and published a post about how it all turned out to me. Here is how I am configuring it now:
https://medium.com/@victor.nascimento/elixir-emacs-development-2023-edition-1a6ccc40629
This is great thanks, I hadn’t heard of lexical before.
Playing around with it and it seems much faster than elixir-ls but is still lacking features like textDocument/hover or signatureHelp.
Even without those features I’m tempted to keep using it as the immediate feedback while typing is amazing.
I’ve got an PR updating emakit to use emacs 29 and tree-sitter (also with freshly baked credo diagnostic goodness) here:
Appreciate feedback and refinements.
Merged, emakit now updated to be based on emacs 29 and tree-sitter.
I am unable to get heex syntax support to work.
⛔ Warning (treesit): Cannot activate tree-sitter, because language grammar for heex is unavailable (not-found): (libtree-sitter-heex.so libtree-sitter-heex.so.0 libtree-sitter-heex.so.0.0 libtree-sitter-heex.dylib libtree-sitter-heex.dylib.0 libtree-sitter-heex.dylib.0.0) No such file or directory
The dylib file is present, emacs can’t find it.
I am also not able to figure out where emacs is looking for the file.
Hi Anuvrat,
I have …
.emacs.d/tree-sitter/
├── libtree-sitter-elixir.so
├── libtree-sitter-heex.so
installed using…
M-x treesit-install-language-grammer
And in emacs.d/init.el
(require 'treesit)
(require 'heex-ts-mode)
(require 'elixir-ts-mode)
Your suggestion along with the directions from Mastering emacs
book helped me get tree-sitter to work.
I am unable to get syntax-highlighting to work properly though, especially with comments strings inside sigils.
Any idea where I should look for a solution?