{ config, lib, pkgs, ... }: let inherit (lib) nvim mkIf getExe; cfg = config.vim.languages.elixir; in { config = mkIf (cfg.enable) { vim.startPlugins = [ "elixir-tools" ]; vim.luaConfigRC.elixir-tools = nvim.dag.entryAnywhere '' local elixir = require("elixir") local elixirls = require("elixir.elixirls") elixir.setup { elixirls = { -- alternatively, point to an existing elixir-ls installation (optional) -- not currently supported by elixirls, but can be a table if you wish to pass other args `{"path/to/elixirls", "--foo"}` cmd = "${getExe pkgs.elixir-ls}", -- default settings, use the `settings` function to override settings settings = elixirls.settings { dialyzerEnabled = true, fetchDeps = false, enableTestLenses = false, suggestSpecs = false, }, on_attach = function(client, bufnr) local map_opts = { buffer = true, noremap = true} -- run the codelens under the cursor vim.keymap.set("n", "r", vim.lsp.codelens.run, map_opts) -- remove the pipe operator vim.keymap.set("n", "fp", ":ElixirFromPipe", map_opts) -- add the pipe operator vim.keymap.set("n", "tp", ":ElixirToPipe", map_opts) vim.keymap.set("v", "em", ":ElixirExpandMacro", map_opts) -- bindings for standard LSP functions. vim.keymap.set("n", "df", "lua vim.lsp.buf.format()", map_opts) vim.keymap.set("n", "gd", "lua vim.diagnostic.open_float()", map_opts) vim.keymap.set("n", "dt", "lua vim.lsp.buf.definition()", map_opts) vim.keymap.set("n", "K", "lua vim.lsp.buf.hover()", map_opts) vim.keymap.set("n", "gD","lua vim.lsp.buf.implementation()", map_opts) vim.keymap.set("n", "1gD","lua vim.lsp.buf.type_definition()", map_opts) -- keybinds for fzf-lsp.nvim: https://github.com/gfanto/fzf-lsp.nvim -- you could also use telescope.nvim: https://github.com/nvim-telescope/telescope.nvim -- there are also core vim.lsp functions that put the same data in the loclist vim.keymap.set("n", "gr", ":References", map_opts) vim.keymap.set("n", "g0", ":DocumentSymbols", map_opts) vim.keymap.set("n", "gW", ":WorkspaceSymbols", map_opts) vim.keymap.set("n", "d", ":Diagnostics", map_opts) end } } ''; }; }