Wed, 25 Sep 2024 15:03:13 -0500
No LSP autostart when read-only
I think nvim actually threw out 'view' argc detection, I just use -R and alias
view to it.
1165 | 1 | -- elixir-tools installs elixir-ls in directories by version and otp version in |
2 | -- order to match up the right version with your app. it doesn't expose what | |
3 | -- path is in use except for how it launches elixir-ls, so we can scrape it out | |
4 | -- of there. it's not clear to me how nvim-dap would handle an adapter's | |
5 | -- definition changing, so i wouldn't expect this to work well with more than | |
6 | -- one version in the same nvim session. | |
7 | ||
8 | local function find_elixir_lsp_dap_cmd(bufnr) | |
1172
e9fe1489c0a6
fix nvim 0.10 deprecation / make required
Meredith Howard <mhoward@roomag.org>
parents:
1169
diff
changeset
|
9 | local elixir_lsp = vim.lsp.get_clients({ |
e9fe1489c0a6
fix nvim 0.10 deprecation / make required
Meredith Howard <mhoward@roomag.org>
parents:
1169
diff
changeset
|
10 | name = "ElixirLS", |
1165 | 11 | bufnr = bufnr or vim.api.nvim_get_current_buf(), |
12 | })[1] | |
13 | ||
14 | if elixir_lsp then | |
15 | local elixir_lsp_cmd = elixir_lsp.config.cmd[1] | |
16 | local dap_cmd = elixir_lsp_cmd:gsub("language_server.", "debug_adapter.") | |
17 | ||
18 | return dap_cmd | |
19 | end | |
20 | end | |
21 | ||
22 | local dap = require("dap") | |
23 | ||
24 | dap.adapters.mix_task = function(callback, _) | |
25 | local dap_cmd = find_elixir_lsp_dap_cmd() | |
26 | ||
27 | if dap_cmd then | |
28 | callback({ | |
29 | type = 'executable', | |
30 | command = find_elixir_lsp_dap_cmd(), | |
31 | args = {}, | |
32 | }) | |
33 | end | |
34 | end | |
35 | ||
36 | dap.configurations.elixir = { | |
37 | { | |
38 | type = "mix_task", | |
39 | name = "mix test", | |
40 | task = 'test', | |
41 | taskArgs = { "--trace" }, | |
42 | request = "launch", | |
43 | startApps = true, | |
44 | projectDir = "${workspaceFolder}", | |
45 | requireFiles = { | |
46 | "test/**/test_helper.exs", | |
47 | "test/**/*_test.exs" | |
48 | } | |
49 | }, | |
50 | { | |
51 | type = "mix_task", | |
52 | name = "phx.server", | |
53 | request = "launch", | |
54 | task = "phx.server", | |
55 | projectDir = "${workspaceFolder}" | |
56 | }, | |
57 | } |