Skip to content

Commit 4f4370c

Browse files
committed
Replace Mason elixirls with elixir-tools
These two don't play well together :( If they play well in the future, I'll migrate back to Mason. elixir-tools installs its LSP binaries in $HOME/.cache, so at least it's smart enough not to install the same exact LSP over and over again. It'll only install a different version if it sees that my current project is using a different version of OTP, which is fair. If I think of a good reason to enable nextls or projectionist, the config will make it easy to do so, but I can't think of a good reason at this time.
1 parent e58647d commit 4f4370c

1 file changed

Lines changed: 25 additions & 15 deletions

File tree

lua/plugins/lsp.lua

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,14 @@ return { -- LSP Plugins
166166
})
167167
end
168168

169-
-- Elixir-specific keymaps, but they only work with elixir-tools installed
170-
-- TODO: Figure out how to run these commands in the LSP itself, without needing the elixir-tools
171-
-- TODO: Make sure the client name works, might need to be ElixirLS if you're using the install from elixir-tools
169+
-- Elixir-specific keymaps, but they only work with elixir-tools installed. Better to let elixir-tools
170+
-- handle the installation than Mason, since they don't play well together today.
171+
-- Possibly in the future, elixir-ls will work better with Mason out of the box.
172172
local elixirDesc = 'LSP Elixir: '
173-
if client and client.name == 'elixirls' then
174-
vim.keymap.set('n', '<space>fp', ':ElixirFromPipe<cr>', { desc = elixirDesc .. '[f]rom [p]ipe', buffer = true, noremap = true })
175-
vim.keymap.set('n', '<space>tp', ':ElixirToPipe<cr>', { desc = elixirDesc .. '[t]o [p]ipe', buffer = true, noremap = true })
176-
vim.keymap.set('v', '<space>em', ':ElixirExpandMacro<cr>', { desc = elixirDesc .. '[e]xpand [m]acro', buffer = true, noremap = true })
173+
if client and client.name == 'ElixirLS' then
174+
vim.keymap.set('n', '<leader>|f', ':ElixirFromPipe<cr>', { desc = elixirDesc .. '[|] [f]rom', buffer = true, noremap = true })
175+
vim.keymap.set('n', '<leader>|', ':ElixirToPipe<cr>', { desc = elixirDesc .. 'to [|]', buffer = true, noremap = true })
176+
vim.keymap.set('v', '<leader>em', ':ElixirExpandMacro<cr>', { desc = elixirDesc .. '[e]xpand [m]acro', buffer = true, noremap = true })
177177
end
178178

179179
-- The following code creates a keymap to toggle inlay hints in your
@@ -233,7 +233,6 @@ return { -- LSP Plugins
233233
-- - settings (table): Override the default settings passed when initializing the server.
234234
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
235235
local servers = {
236-
elixirls = {},
237236
emmet_language_server = {},
238237
ruby_lsp = {},
239238
-- clangd = {},
@@ -297,12 +296,6 @@ return { -- LSP Plugins
297296
-- by the server configuration above. Useful when disabling
298297
-- certain features of an LSP (for example, turning off formatting for ts_ls)
299298
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
300-
301-
-- At this point, server is an empty table for elixirls, and server_name becomes a dot method
302-
-- So for elixir, this is equivalent to
303-
--
304-
-- ```require('lspconfig').elixirls.setup({})```
305-
--
306299
require('lspconfig')[server_name].setup(server)
307300
end,
308301
},
@@ -322,7 +315,24 @@ return { -- LSP Plugins
322315
},
323316
event = { 'BufReadPre', 'BufNewFile' },
324317
config = function()
325-
require('elixir').setup()
318+
local elixir = require 'elixir'
319+
320+
elixir.setup {
321+
elixirls = {
322+
enable = true,
323+
settings = {
324+
dialyzerEnabled = false,
325+
enableTestLenses = false,
326+
fetchDeps = false,
327+
},
328+
},
329+
nextls = {
330+
enable = false,
331+
},
332+
projectionist = {
333+
enable = false,
334+
},
335+
}
326336
end,
327337
},
328338
}

0 commit comments

Comments
 (0)