feat: add LSP for Elixir
This commit is contained in:
parent
c63fff8ed4
commit
6ab566968c
2 changed files with 23 additions and 0 deletions
22
lsp/elixir.lua
Normal file
22
lsp/elixir.lua
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
---@type vim.lsp.Config
|
||||
--- 'root_dir' is chosen like this:
|
||||
--- if two or more directories containing `mix.exs` were found when searching
|
||||
--- directories upward, the second one (higher up) is chosen, with the
|
||||
--- assumption that it is the root of an umbrella app. Otherwise the directory
|
||||
--- containing the single mix.exs that was found is chosen.
|
||||
return {
|
||||
-- cmd when installing with Mason
|
||||
-- Had to install elixir and asdf (homebrew)
|
||||
-- Then ran `mix local.hex` to upgrade Hex
|
||||
cmd = { vim.env.HOME .. "/.local/share/nvim/mason/packages/elixir-ls/language_server.sh" },
|
||||
-- cmd = { "/Users/oliver.ladner/.local/share/nvim/mason/packages/elixir-ls/language_server.sh" },
|
||||
filetypes = { "elixir", "eelixir", "heex", "surface" },
|
||||
root_dir = function(bufnr, on_dir)
|
||||
local fname = vim.api.nvim_buf_get_name(bufnr)
|
||||
local matches = vim.fs.find({ "mix.exs" }, { upward = true, limit = 2, path = fname })
|
||||
local child_or_root_path, maybe_umbrella_path = unpack(matches)
|
||||
local root_dir = vim.fs.dirname(maybe_umbrella_path or child_or_root_path)
|
||||
|
||||
on_dir(root_dir)
|
||||
end,
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ vim.lsp.enable({
|
|||
"bicep",
|
||||
"proselint",
|
||||
"python",
|
||||
"elixir",
|
||||
})
|
||||
|
||||
-- Set highlight on search
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue