Closed bus710 closed 11 months ago
Does elixir ls show up when you do :LspInfo
as attached to the buffer?
Is there any logs when you do :ElixirOutputPanel
Hi @mhanberg Thanks for quick response.
For the q1:
Language client log: /home/bus710/.local/state/nvim/lsp.log
Detected filetype: elixir
1 client(s) attached to this buffer:
Client: ElixirLS (id: 1, bufnr: [1])
filetypes:
autostart: false
root directory: /home/bus710/Downloads/demo
cmd: /home/bus710/.cache/nvim/elixir-tools.nvim/installs/elixir-lsp/elixir-ls/tags_v0.15.1/1.15.5-25/language_server.sh
Other clients that match the filetype: elixir
(below, tailwindcss shows up, but I guess that is not related to this issue)
For the q2:
[Info] Started ElixirLS v0.15.1
[Info] Running in /home/bus710/Downloads/demo
[Info] ElixirLS built with elixir "1.15.5" on OTP "25"
[Info] Running on elixir "1.15.5 (compiled with Erlang/OTP 25)" on OTP "25"
[Info] Protocols are not consolidated
[Info] Elixir sources not found (checking in /home/runner/work/elixir/elixir). Code navigation to Elixir modules disabled.
[Info] Loaded DETS databases in 96ms
[Info] Starting build with MIX_ENV: test MIX_TARGET: host
[Info] Compile took 345 milliseconds
[Info] [ElixirLS WorkspaceSymbols] Indexing...
[Info] [ElixirLS WorkspaceSymbols] Module discovery complete
[Info] [ElixirLS WorkspaceSymbols] 22 callbacks added to index
[Info] [ElixirLS WorkspaceSymbols] 191 modules added to index
[Info] [ElixirLS WorkspaceSymbols] 398 types added to index
[Info] [ElixirLS WorkspaceSymbols] 4376 functions added to index
[Info] Experimental server is disabled.
Hope these outputs help somehow.
Hmm, everything should be good.
I'll now ask, have you actually set any keymaps? the plugin doesn't do it for you
meaning, can you try by running :lua vim.lsp.buf.definition()
while your cursor is an appropriate place
First of all, the definition() function doesn't do anything when I ran it during the cursor was on the PageController in the router.ex file of a minimal Phoenix app.
Second, I thought AstroNvim has some basic keymaps for me, so I didn't set anything for elixir-tools other than the introduced ones in the README (AstroNvim community plugins for Go and Rust do it out of box, so my assumption might be wrong).
I guess I should do some configurations like your README, but for the shortcuts I actually want... like:
vim.keymap.set("n", "gd", vim.lsp.buf.definition())
If this is the case, I am so sorry for your time :sweat_smile:
Please feel free to close this issue.
Thanks you,
Another minor question - is this the same for elixir-tools.vscode as well? Should I still set keymaps for Vscode?
I think.... AstroNvim has its own keymaps setting as default. https://astronvim.com/recipes/mappings#disable-telescope-lsp-mappings
So maybe my assumption is not totally wrong.
First of all, the definition() function doesn't do anything when I ran it during the cursor was on the PageController in the router.ex file of a minimal Phoenix app.
Unfortunately you picked a bad case to try haha. ElixirLS got definitino doesn't work on controller references in the router, because the router does some funky compile time macro stuff. You should try it on almost any other module.
Second, I thought AstroNvim has some basic keymaps for me, so I didn't set anything for elixir-tools other than the introduced ones in the README (AstroNvim community plugins for Go and Rust do it out of box, so my assumption might be wrong).
Well, if those plugins for Go and Rust are included with Astro, then it makes sense that they have some default configuration. elixir-tools.nvim is not included in Astro.
Another minor question - is this the same for elixir-tools.vscode as well? Should I still set keymaps for Vscode?
I'm not really understanding the question, to be honest. But elixir-tools.vscode doesn't have any keymaps that come with it, but VSCode should already have some default ones that apply to all LSPs
I think.... AstroNvim has its own keymaps setting as default. https://astronvim.com/recipes/mappings#disable-telescope-lsp-mappings
So maybe my assumption is not totally wrong.
If Astro specifies the keymaps in an LspAttach autocmd, then they should work automatically with elixir-tools.nvim. If they are specified by using the on_attach callback when starting the LSP ,then you'll need to manually pass that into the elixir-tools setup function
Yeah, it defines it in the on_attach callback.
You should be able to set it with something like this
{
"elixir-tools/elixir-tools.nvim",
version = "*",
event = { "BufReadPre", "BufNewFile" },
config = function()
local elixir = require("elixir")
local elixirls = require("elixir.elixirls")
elixir.setup {
nextls = {enable = false},
credo = {},
elixirls = {
enable = true,
settings = elixirls.settings {
dialyzerEnabled = false,
enableTestLenses = false,
},
on_attach = function(client, bufnr)
-- 👇
require("astronvim.lsp.util").on_attach(client, bufnr) -- 👈 this is what you should add
-- ☝️
vim.keymap.set("n", "<space>fp", ":ElixirFromPipe<cr>", { buffer = true, noremap = true })
vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", { buffer = true, noremap = true })
vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", { buffer = true, noremap = true })
end,
}
}
end,
dependencies = {
"nvim-lua/plenary.nvim",
},
}
So, I was able to make the gd keymap work.
on_attach = function(client, bufnr)
-- require("astronvim.lsp.util").on_attach(client, bufnr)
vim.keymap.set("n", "gd", vim.lsp.buf.definition)
vim.keymap.set("n", "<space>fp", ":ElixirFromPipe<cr>", { buffer = true, noremap = true })
vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", { buffer = true, noremap = true })
vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", { buffer = true, noremap = true })
end,
I guess the global keymap doesn't work for elixir file for some reason. Also, your suggestion is commented out because the gd key doesn't work when the require().on_attach() is active.
Also, what I could confirm is that, the PageController is indeed a bad case to try the gd key. Instead, other tokens like these are better:
If my module is there with the project name, it is working as well. Let's say the project name is "demo", and my live view module named "HelloLive" has the prefix with that like "DemoWeb.HelloLive", the gd keymap works!
Thanks a lot! Now I feel little more confidence with my setup.
Hi, thanks for this great plugin! I think this will help many people and myself to get close to Elixir programming.
So, my problem is, I was able to install this plugin via Nvim/AstroNvim/Lazy.vim. The plugin installs ElixirLS and NextLS, but doesn't properly work. Especially the shortcut key for "Go to definition (gd)" doesn't work. I tried enabling/disabling the options (ElixirLS, NextLS, Credo), but no luck yet.
My current setup is:
The detail of the plugin is:
How it was configured (in ~/.config/nvim/lua/user/plugins/user.lua):
```lua return { -- along with other plugins... { "vim-erlang/vim-erlang-runtime" }, { "vim-erlang/vim-erlang-compiler" }, { "vim-erlang/vim-erlang-omnicomplete" }, { "vim-erlang/vim-erlang-tags" }, { "elixir-editors/vim-elixir" }, { "elixir-tools/elixir-tools.nvim", version = "*", event = { "BufReadPre", "BufNewFile" }, config = function() local elixir = require "elixir" local elixirls = require "elixir.elixirls" elixir.setup { nextls = { enable = false }, credo = { enable = true }, elixirls = { enable = true, -- https://github.com/elixir-tools/elixir-tools.nvim/issues/143 -- ls ~/.cache/nvim/elixir-tools.nvim/installs/elixir-lsp/elixir-ls/ tag = "v0.15.1", settings = elixirls.settings { dialyzerEnabled = false, enableTestLenses = false, }, on_attach = function(client, bufnr) vim.keymap.set("n", "How the log looks like:
``` [START][2023-08-31 12:25:03] LSP logging initiated [ERROR][2023-08-31 12:25:03] .../vim/lsp/rpc.lua:734 "rpc" "/home/bus710/.cache/nvim/elixir-tools.nvim/installs/elixir-lsp/elixir-ls/tags_v0.15.1/1.15.5-25/language_server.sh" "stderr" "running /home/bus710/.cache/nvim/elixir-tools.nvim/installs/elixir-lsp/elixir-ls/tags_v0.15.1/1.15.5-25/launch.sh\nLooking for ASDF install in /home/bus710/.asdf/asdf.sh\nASDF found, relaunching in bash shell\nLooking for ASDF install in /home/bus710/.asdf/asdf.sh\nSourcing ASDF\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Codegen (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Codegen.beam)\n lib/codegen.ex:1: Jason.Codegen (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Sigil (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Sigil.beam)\n lib/sigil.ex:1: Jason.Sigil (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Helpers (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Helpers.beam)\n lib/helpers.ex:1: Jason.Helpers (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Formatter (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Formatter.beam)\n lib/formatter.ex:1: Jason.Formatter (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.beam)\n lib/jason.ex:1: Jason (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Fragment (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Fragment.beam)\n lib/fragment.ex:1: Jason.Fragment (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.DecodeError (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.DecodeError.beam)\n lib/decoder.ex:1: Jason.DecodeError (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.EncodeError (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.EncodeError.beam)\n lib/encode.ex:1: Jason.EncodeError (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.OrderedObject (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.OrderedObject.beam)\n lib/ordered_object.ex:1: Jason.OrderedObject (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encoder (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encoder.beam)\n lib/encoder.ex:1: Jason.Encoder (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Decoder (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Decoder.beam)\n lib/decoder.ex:25: Jason.Decoder (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encode (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encode.beam)\n lib/encode.ex:14: Jason.Encode (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Enumerable.Jason.OrderedObject (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Enumerable.Jason.OrderedObject.beam)\n lib/ordered_object.ex:77: Enumerable.Jason.OrderedObject (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encoder.Any (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encoder.Any.beam)\n lib/encoder.ex:77: Jason.Encoder.Any (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encoder.Jason.OrderedObject (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encoder.Jason.OrderedObject.beam)\n lib/ordered_object.ex:90: Jason.Encoder.Jason.OrderedObject (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encoder.Atom (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encoder.Atom.beam)\n lib/encoder.ex:175: Jason.Encoder.Atom (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Decoder.Unescape (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Decoder.Unescape.beam)\n lib/decoder.ex:461: Jason.Decoder.Unescape (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encoder.Integer (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encoder.Integer.beam)\n lib/encoder.ex:181: Jason.Encoder.Integer (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encoder.Float (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encoder.Float.beam)\n lib/encoder.ex:187: Jason.Encoder.Float (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encoder.List (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encoder.List.beam)\n lib/encoder.ex:193: Jason.Encoder.List (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encoder.Map (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encoder.Map.beam)\n lib/encoder.ex:199: Jason.Encoder.Map (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encoder.BitString (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encoder.BitString.beam)\n lib/encoder.ex:205: Jason.Encoder.BitString (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encoder.Date (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encoder.Date.beam)\n lib/encoder.ex:218: Jason.Encoder.Date (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encoder.Time (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encoder.Time.beam)\n lib/encoder.ex:218: Jason.Encoder.Time (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encoder.NaiveDateTime (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encoder.NaiveDateTime.beam)\n lib/encoder.ex:218: Jason.Encoder.NaiveDateTime (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encoder.DateTime (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encoder.DateTime.beam)\n lib/encoder.ex:218: Jason.Encoder.DateTime (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encoder.Decimal (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encoder.Decimal.beam)\n lib/encoder.ex:224: Jason.Encoder.Decimal (module)\n" [WARN][2023-08-31 12:25:09] ...lsp/handlers.lua:537 "warning: redefining module Jason.Encoder.Jason.Fragment (current version loaded from /home/bus710/.asdf/installs/elixir/1.15.5-otp-25/.mix/archives/jason-1.4.1/jason-1.4.1/ebin/Elixir.Jason.Encoder.Jason.Fragment.beam)\n lib/encoder.ex:232: Jason.Encoder.Jason.Fragment (module)\n" [WARN][2023-08-31 12:25:16] ...lsp/handlers.lua:537 "warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead\n lib/esbuild.ex:69: Esbuild.start/2\n" [WARN][2023-08-31 12:25:16] ...lsp/handlers.lua:537 "warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead\n lib/esbuild.ex:83: Esbuild.start/2\n" [WARN][2023-08-31 12:25:16] ...lsp/handlers.lua:537 "warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead\n lib/tailwind.ex:72: Tailwind.start/2\n" [WARN][2023-08-31 12:25:16] ...lsp/handlers.lua:537 "warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead\n lib/tailwind.ex:86: Tailwind.start/2\n" [WARN][2023-08-31 12:25:18] ...lsp/handlers.lua:537 "warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead\n lib/finch/http2/pool.ex:362: Finch.HTTP2.Pool.connected/3\n" [WARN][2023-08-31 12:25:18] ...lsp/handlers.lua:537 "warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead\n lib/finch/http2/pool.ex:460: Finch.HTTP2.Pool.connected_read_only/3\n" [WARN][2023-08-31 12:25:28] ...lsp/handlers.lua:537 "warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead\n lib/plug/cowboy.ex:352: Plug.Cowboy.to_args/5\n" ```Cache structure (tree in $HOME/.cache/nvim/elixir-tools.nvim)
``` . ├── elixir-tools-credo-language-server.txt └── installs └── elixir-lsp └── elixir-ls └── tags_v0.15.1 └── 1.15.5-25 ├── debugger.bat ├── debugger.sh ├── deep_merge-1.0.0.ez ├── elixir_ls_debugger-0.15.1.ez ├── elixir_ls_utils-0.15.1.ez ├── elixir_sense-2.0.0.ez ├── erl2ex-0.0.10.ez ├── erlex-0.2.6.ez ├── jason_v-1.4.0.ez ├── language_server-0.15.1.ez ├── language_server.bat ├── language_server.sh ├── launch.sh ├── path_glob_vendored-0.1.1.ez └── statistex-1.0.0.ez 6 directories, 16 files ```So the log says it tried to call asdf.sh, but I don't know where to see the detailed log.
If anybody needs additional info from my side, please let me know.
Thanks,