diff --git a/README.md b/README.md index 9e298ab7..e8da172f 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,16 @@ elixir.setup { -- not currently supported by elixirls, but can be a table if you wish to pass other args `{"path/to/elixirls", "--foo"}` cmd = "/usr/local/bin/elixir-ls.sh", + -- extension point to link in to server specific commands + -- by default, the codelens action below runs a default test runner in a terminal buffer + -- replacing it as shown here will override default behavior, allow running a custom function instead + -- `args` are anything the lsp command passes back to the callback function + commands = { + ["elixir.lens.test.run"] = function(args) + -- custom functionality here as needed + end + }, + -- default settings, use the `settings` function to override settings settings = elixirls.settings { dialyzerEnabled = true, diff --git a/lua/elixir/elixirls/init.lua b/lua/elixir/elixirls/init.lua index 814320b4..8fbe7255 100644 --- a/lua/elixir/elixirls/init.lua +++ b/lua/elixir/elixirls/init.lua @@ -318,12 +318,15 @@ function M.setup(opts) if root_dir then local log_message = vim.lsp.handlers["window/logMessage"] + + local commands = vim.tbl_extend("force", { + ["elixir.lens.test.run"] = test, + }, opts.commands or {}) + vim.lsp.start(vim.tbl_extend("keep", { name = "ElixirLS", cmd = opts.cmd and wrap_in_table(opts.cmd) or { tostring(cmd) }, - commands = { - ["elixir.lens.test.run"] = test, - }, + commands = commands, settings = opts.settings or M.settings {}, capabilities = opts.capabilities or capabilities, root_dir = root_dir,