Skip to content

Commit 6b42953

Browse files
committed
refactor!: scope lsp options under elixirls key
When setting up elixir-ls, one should now scope all of the opts under an `elixirls` key in the opts table. Old: ```lua local elixir = require("elixir") elixir.setup { settings = { -- some settings } } ``` New: ```lua local elixir = require("elixir") elixir.setup { elixirls = { settings = { -- some settings } } } ``` In addition, the function to merge settings into the default settings now lives in the elixirls module Old: ```elixir local elixir = require("elixir") elixir.settings { -- some settings } ``` New: ```elixir local elixirls = require("elixir.elixirls") elixirls.settings { -- some settings } ```
1 parent 5aa3b16 commit 6b42953

File tree

9 files changed

+82
-82
lines changed

9 files changed

+82
-82
lines changed

README.md

Lines changed: 65 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
## Install
1616

17-
Requires 0.8.
17+
Requires 0.8
1818

1919
### lazy.nvim
2020

@@ -24,20 +24,23 @@ Requires 0.8.
2424
ft = { "elixir", "eex", "heex", "surface" },
2525
config = function()
2626
local elixir = require("elixir")
27+
local elixirls = require("elixir.elixirls")
2728

2829
elixir.setup {
29-
settings = elixir.settings {
30-
dialyzerEnabled = false,
31-
enableTestLenses = false,
32-
},
33-
log_level = vim.lsp.protocol.MessageType.Log,
34-
message_level = vim.lsp.protocol.MessageType.Log,
35-
on_attach = function(client, bufnr)
36-
-- whatever keybinds you want, see below for more suggestions
37-
vim.keymap.set("n", "<space>fp", ":ElixirFromPipe<cr>", { buffer = true, noremap = true })
38-
vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", { buffer = true, noremap = true })
39-
vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", { buffer = true, noremap = true })
40-
end,
30+
elixirls = {
31+
settings = elixirls.settings {
32+
dialyzerEnabled = false,
33+
enableTestLenses = false,
34+
},
35+
log_level = vim.lsp.protocol.MessageType.Log,
36+
message_level = vim.lsp.protocol.MessageType.Log,
37+
on_attach = function(client, bufnr)
38+
-- whatever keybinds you want, see below for more suggestions
39+
vim.keymap.set("n", "<space>fp", ":ElixirFromPipe<cr>", { buffer = true, noremap = true })
40+
vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", { buffer = true, noremap = true })
41+
vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", { buffer = true, noremap = true })
42+
end,
43+
}
4144
}
4245
end,
4346
dependencies = {
@@ -68,60 +71,55 @@ Note: Not specifying the `repo`, `branch`, or `tag` options will default to the
6871

6972
```lua
7073
local elixir = require("elixir")
71-
72-
elixir.setup({
73-
-- specify a repository and branch
74-
repo = "mhanberg/elixir-ls", -- defaults to elixir-lsp/elixir-ls
75-
branch = "mh/all-workspace-symbols", -- defaults to nil, just checkouts out the default branch, mutually exclusive with the `tag` option
76-
tag = "v0.13.0", -- defaults to nil, mutually exclusive with the `branch` option
77-
78-
-- alternatively, point to an existing elixir-ls installation (optional)
79-
-- not currently supported by elixirls, but can be a table if you wish to pass other args `{"path/to/elixirls", "--foo"}`
80-
cmd = "/usr/local/bin/elixir-ls.sh",
81-
82-
-- default settings, use the `settings` function to override settings
83-
settings = elixir.settings({
84-
dialyzerEnabled = true,
85-
fetchDeps = false,
86-
enableTestLenses = false,
87-
suggestSpecs = false,
88-
}),
89-
90-
on_attach = function(client, bufnr)
91-
local map_opts = { buffer = true, noremap = true}
92-
93-
-- run the codelens under the cursor
94-
vim.keymap.set("n", "<space>r", vim.lsp.codelens.run, map_opts)
95-
-- remove the pipe operator
96-
vim.keymap.set("n", "<space>fp", ":ElixirFromPipe<cr>", map_opts)
97-
-- add the pipe operator
98-
vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", map_opts)
99-
vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", map_opts)
100-
101-
-- bindings for standard LSP functions.
102-
vim.keymap.set("n", "<space>df", "<cmd>lua vim.lsp.buf.format()<cr>", map_opts)
103-
vim.keymap.set("n", "<space>gd", "<cmd>lua vim.diagnostic.open_float()<cr>", map_opts)
104-
vim.keymap.set("n", "<space>dt", "<cmd>lua vim.lsp.buf.definition()<cr>", map_opts)
105-
vim.keymap.set("n", "<space>K", "<cmd>lua vim.lsp.buf.hover()<cr>", map_opts)
106-
vim.keymap.set("n", "<space>gD","<cmd>lua vim.lsp.buf.implementation()<cr>", map_opts)
107-
vim.keymap.set("n", "<space>1gD","<cmd>lua vim.lsp.buf.type_definition()<cr>", map_opts)
108-
-- keybinds for fzf-lsp.nvim: https://github.com/gfanto/fzf-lsp.nvim
109-
-- you could also use telescope.nvim: https://github.com/nvim-telescope/telescope.nvim
110-
-- there are also core vim.lsp functions that put the same data in the loclist
111-
vim.keymap.set("n", "<space>gr", ":References<cr>", map_opts)
112-
vim.keymap.set("n", "<space>g0", ":DocumentSymbols<cr>", map_opts)
113-
vim.keymap.set("n", "<space>gW", ":WorkspaceSymbols<cr>", map_opts)
114-
vim.keymap.set("n", "<leader>d", ":Diagnostics<cr>", map_opts)
115-
116-
117-
-- keybinds for vim-vsnip: https://github.com/hrsh7th/vim-vsnip
118-
vim.cmd([[imap <expr> <C-l> vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : '<C-l>']])
119-
vim.cmd([[smap <expr> <C-l> vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : '<C-l>']])
120-
121-
-- update capabilities for nvim-cmp: https://github.com/hrsh7th/nvim-cmp
122-
require("cmp_nvim_lsp").update_capabilities(capabilities)
123-
end
124-
})
74+
local elixirls = require("elixir.elixirls")
75+
76+
elixir.setup {
77+
elixirls = {
78+
-- specify a repository and branch
79+
repo = "mhanberg/elixir-ls", -- defaults to elixir-lsp/elixir-ls
80+
branch = "mh/all-workspace-symbols", -- defaults to nil, just checkouts out the default branch, mutually exclusive with the `tag` option
81+
tag = "v0.13.0", -- defaults to nil, mutually exclusive with the `branch` option
82+
83+
-- alternatively, point to an existing elixir-ls installation (optional)
84+
-- not currently supported by elixirls, but can be a table if you wish to pass other args `{"path/to/elixirls", "--foo"}`
85+
cmd = "/usr/local/bin/elixir-ls.sh",
86+
87+
-- default settings, use the `settings` function to override settings
88+
settings = elixirls.settings {
89+
dialyzerEnabled = true,
90+
fetchDeps = false,
91+
enableTestLenses = false,
92+
suggestSpecs = false,
93+
},
94+
95+
on_attach = function(client, bufnr)
96+
local map_opts = { buffer = true, noremap = true}
97+
98+
-- run the codelens under the cursor
99+
vim.keymap.set("n", "<space>r", vim.lsp.codelens.run, map_opts)
100+
-- remove the pipe operator
101+
vim.keymap.set("n", "<space>fp", ":ElixirFromPipe<cr>", map_opts)
102+
-- add the pipe operator
103+
vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", map_opts)
104+
vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", map_opts)
105+
106+
-- bindings for standard LSP functions.
107+
vim.keymap.set("n", "<space>df", "<cmd>lua vim.lsp.buf.format()<cr>", map_opts)
108+
vim.keymap.set("n", "<space>gd", "<cmd>lua vim.diagnostic.open_float()<cr>", map_opts)
109+
vim.keymap.set("n", "<space>dt", "<cmd>lua vim.lsp.buf.definition()<cr>", map_opts)
110+
vim.keymap.set("n", "<space>K", "<cmd>lua vim.lsp.buf.hover()<cr>", map_opts)
111+
vim.keymap.set("n", "<space>gD","<cmd>lua vim.lsp.buf.implementation()<cr>", map_opts)
112+
vim.keymap.set("n", "<space>1gD","<cmd>lua vim.lsp.buf.type_definition()<cr>", map_opts)
113+
-- keybinds for fzf-lsp.nvim: https://github.com/gfanto/fzf-lsp.nvim
114+
-- you could also use telescope.nvim: https://github.com/nvim-telescope/telescope.nvim
115+
-- there are also core vim.lsp functions that put the same data in the loclist
116+
vim.keymap.set("n", "<space>gr", ":References<cr>", map_opts)
117+
vim.keymap.set("n", "<space>g0", ":DocumentSymbols<cr>", map_opts)
118+
vim.keymap.set("n", "<space>gW", ":WorkspaceSymbols<cr>", map_opts)
119+
vim.keymap.set("n", "<leader>d", ":Diagnostics<cr>", map_opts)
120+
end
121+
}
122+
}
125123
```
126124

127125
## Features

lua/elixir/language_server/init.lua renamed to lua/elixir/elixirls/init.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
local Path = require("plenary.path")
22
local popup = require("plenary.popup")
33

4-
local Version = require("elixir.language_server.version")
5-
local Download = require("elixir.language_server.download")
6-
local Compile = require("elixir.language_server.compile")
4+
local Version = require("elixir.elixirls.version")
5+
local Download = require("elixir.elixirls.download")
6+
local Compile = require("elixir.elixirls.compile")
77
local Utils = require("elixir.utils")
88

99
local capabilities = vim.lsp.protocol.make_client_capabilities()

lua/elixir/init.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
local language_server = require("elixir.language_server")
1+
local elixirls = require("elixir.elixirls")
2+
local credo = require("elixir.credo")
23
local mix = require("elixir.mix")
34
local projectionist = require("elixir.projectionist")
45

56
local M = {}
67

7-
M.settings = language_server.settings
8-
M.open_output_panel = language_server.open_output_panel
8+
M.elixirls = {}
9+
10+
M.elixirls.settings = elixirls.settings
11+
M.elixirls.open_output_panel = elixirls.open_output_panel
912

1013
function M.setup(opts)
1114
mix.setup()
1215
projectionist.setup()
13-
language_server.setup(opts)
16+
elixirls.setup(opts["elixirls"] or {})
17+
credo.setup(opts["credo"] or {})
1418
end
1519

1620
return M

tests/compile_spec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
local eq = assert.are.same
22
local Path = require("plenary.path")
3-
local Compile = require("elixir.language_server.compile")
3+
local Compile = require("elixir.elixirls.compile")
44

5-
local versions = require("elixir.language_server.version").get()
5+
local versions = require("elixir.elixirls.version").get()
66

77
describe("compile", function()
88
before_each(function()

tests/download_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local Path = require("plenary.path")
22
local eq = assert.are.same
3-
local Download = require("elixir.language_server.download")
3+
local Download = require("elixir.elixirls.download")
44
vim.notify = function(thing)
55
io.stdout:write(thing .. "\n")
66
end

tests/elixir_spec.lua renamed to tests/elixirls_spec.lua

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
local eq = assert.are.same
21
local shell = vim.fn.system
3-
local curl = require("plenary.curl")
4-
local elixir = require("elixir.language_server")
2+
local elixirls = require("elixir.elixirls")
53

64
describe("elixir", function()
75
describe("command", function()
@@ -11,7 +9,7 @@ describe("elixir", function()
119

1210
it("returns false when it's not installed", function()
1311
local install_path = "tmp/fake_install"
14-
local result = elixir.command({
12+
local result = elixirls.command({
1513
path = install_path,
1614
repo = "foo/biz",
1715
ref = "bar/baz",
@@ -27,7 +25,7 @@ describe("elixir", function()
2725
shell("mkdir -p tmp/fake_install/foo/biz/bar_baz/foobarbaz")
2826
shell("touch tmp/fake_install/foo/biz/bar_baz/foobarbaz/language_server.sh")
2927

30-
local result = elixir.command({
28+
local result = elixirls.command({
3129
path = install_path,
3230
repo = "foo/biz",
3331
ref = "bar/baz",

0 commit comments

Comments
 (0)