Mon, 20 May 2024 12:53:43 -0500
Bump nvim-treesitter to more recent commit
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) | |
1169
db64f7947671
Note get_active_clients deprecation
Meredith Howard <mhoward@roomag.org>
parents:
1165
diff
changeset
|
9 | -- deprecated 0.10.0: s/get_active_clients/get_clients/; s/idname/name/ |
1165 | 10 | local elixir_lsp = vim.lsp.get_active_clients({ |
11 | idname = "ElixirLS", | |
12 | bufnr = bufnr or vim.api.nvim_get_current_buf(), | |
13 | })[1] | |
14 | ||
15 | if elixir_lsp then | |
16 | local elixir_lsp_cmd = elixir_lsp.config.cmd[1] | |
17 | local dap_cmd = elixir_lsp_cmd:gsub("language_server.", "debug_adapter.") | |
18 | ||
19 | return dap_cmd | |
20 | end | |
21 | end | |
22 | ||
23 | local dap = require("dap") | |
24 | ||
25 | dap.adapters.mix_task = function(callback, _) | |
26 | local dap_cmd = find_elixir_lsp_dap_cmd() | |
27 | ||
28 | if dap_cmd then | |
29 | callback({ | |
30 | type = 'executable', | |
31 | command = find_elixir_lsp_dap_cmd(), | |
32 | args = {}, | |
33 | }) | |
34 | end | |
35 | end | |
36 | ||
37 | dap.configurations.elixir = { | |
38 | { | |
39 | type = "mix_task", | |
40 | name = "mix test", | |
41 | task = 'test', | |
42 | taskArgs = { "--trace" }, | |
43 | request = "launch", | |
44 | startApps = true, | |
45 | projectDir = "${workspaceFolder}", | |
46 | requireFiles = { | |
47 | "test/**/test_helper.exs", | |
48 | "test/**/*_test.exs" | |
49 | } | |
50 | }, | |
51 | { | |
52 | type = "mix_task", | |
53 | name = "phx.server", | |
54 | request = "launch", | |
55 | task = "phx.server", | |
56 | projectDir = "${workspaceFolder}" | |
57 | }, | |
58 | } |