From 5a8e7b666340d2d676aaf3588c515c7b8ab7c105 Mon Sep 17 00:00:00 2001 From: Nikola Jichev Date: Sat, 9 Mar 2024 12:10:42 +0200 Subject: [PATCH 1/5] Add alias-refactor to the workspace commands --- lua/elixir/init.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lua/elixir/init.lua b/lua/elixir/init.lua index fcdf2e9c..be8a126a 100644 --- a/lua/elixir/init.lua +++ b/lua/elixir/init.lua @@ -39,6 +39,11 @@ local define_user_command = function() local args = vim.iter(opts.fargs) local command = args:next() local not_found = false + local workspace_commands = { + ["to-pipe"] = true, + ["from-pipe"] = true, + ["alias-refactor"] = true, + } if "nextls" == command then local subcommand = args:next() @@ -48,18 +53,11 @@ local define_user_command = function() string.format("[elixir-tools] Uninstalled Next LS from %s", nextls.default_bin), vim.lsp.log_levels.INFO ) - elseif "to-pipe" == subcommand then + elseif workspace_commands[subcommand] then local row, col = get_cursor_position() local uri = vim.uri_from_bufnr(0) vim.lsp.buf.execute_command { - command = "to-pipe", - arguments = { { position = { line = row, character = col }, uri = uri } }, - } - elseif "from-pipe" == subcommand then - local row, col = get_cursor_position() - local uri = vim.uri_from_bufnr(0) - vim.lsp.buf.execute_command { - command = "from-pipe", + command = subcommand, arguments = { { position = { line = row, character = col }, uri = uri } }, } else @@ -77,7 +75,7 @@ local define_user_command = function() complete = function(_, cmd_line) local cmd = vim.trim(cmd_line) if vim.startswith(cmd, "Elixir nextls") then - return { "uninstall", "to-pipe", "from-pipe" } + return { "uninstall", "to-pipe", "from-pipe", "alias-refactor" } elseif vim.startswith(cmd, "Elixir") then return { "nextls" } end From 5c568a447749f56d3d80ef59662d2a1acbe9bfc0 Mon Sep 17 00:00:00 2001 From: Nikola Jichev Date: Sat, 9 Mar 2024 14:44:11 +0200 Subject: [PATCH 2/5] Update the readme --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8da60905..8b4102d9 100644 --- a/README.md +++ b/README.md @@ -166,11 +166,12 @@ elixir.setup { ``` ### Full List -| Command | Subcommand | Description | -|---------|------------|------------------------------------------------------------------------------------------------------| -| nextls | uninstall | Removes the `nextls` executable from the default location: `~/.cache/elixir-tools/nextls/bin/nextls` | -| nextls | to-pipe | Extracts the first argument to a pipe call | -| nextls | from-pipe | Inlines the pipe call to a function call the first argument to a pipe | +| Command | Subcommand | Description | +|---------|----------------|------------------------------------------------------------------------------------------------------| +| nextls | uninstall | Removes the `nextls` executable from the default location: `~/.cache/elixir-tools/nextls/bin/nextls` | +| nextls | to-pipe | Extracts the first argument to a pipe call | +| nextls | from-pipe | Inlines the pipe call to a function call inlining the first argument | +| nextls | alias-refactor | Aliases the module under the cursor refactoring similar calls as well | ## Next LS From ff856a1c87b52b42602fc8487a285df80d56ec6f Mon Sep 17 00:00:00 2001 From: Nikola Jichev Date: Wed, 27 Mar 2024 16:57:07 +0200 Subject: [PATCH 3/5] Put uninstall last --- lua/elixir/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/elixir/init.lua b/lua/elixir/init.lua index be8a126a..5ee4e0f3 100644 --- a/lua/elixir/init.lua +++ b/lua/elixir/init.lua @@ -75,7 +75,7 @@ local define_user_command = function() complete = function(_, cmd_line) local cmd = vim.trim(cmd_line) if vim.startswith(cmd, "Elixir nextls") then - return { "uninstall", "to-pipe", "from-pipe", "alias-refactor" } + return { "alias-refactor", "to-pipe", "from-pipe", "uninstall" } elseif vim.startswith(cmd, "Elixir") then return { "nextls" } end From f2a314ac1b2e925d20c3b7efbb9aa6a406dff6c7 Mon Sep 17 00:00:00 2001 From: Nikola Jichev Date: Wed, 27 Mar 2024 16:59:19 +0200 Subject: [PATCH 4/5] Match the command order in the readme as well --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8b4102d9..3e4b263a 100644 --- a/README.md +++ b/README.md @@ -168,10 +168,10 @@ elixir.setup { | Command | Subcommand | Description | |---------|----------------|------------------------------------------------------------------------------------------------------| -| nextls | uninstall | Removes the `nextls` executable from the default location: `~/.cache/elixir-tools/nextls/bin/nextls` | +| nextls | alias-refactor | Aliases the module under the cursor refactoring similar calls as well | | nextls | to-pipe | Extracts the first argument to a pipe call | | nextls | from-pipe | Inlines the pipe call to a function call inlining the first argument | -| nextls | alias-refactor | Aliases the module under the cursor refactoring similar calls as well | +| nextls | uninstall | Removes the `nextls` executable from the default location: `~/.cache/elixir-tools/nextls/bin/nextls` | ## Next LS From b2a698785fc2ee037c1866ef43aa5b1249bfd2ed Mon Sep 17 00:00:00 2001 From: Mitchell Hanberg Date: Sat, 20 Apr 2024 08:51:55 -0400 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e4b263a..cb8486d1 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,7 @@ elixir.setup { | Command | Subcommand | Description | |---------|----------------|------------------------------------------------------------------------------------------------------| -| nextls | alias-refactor | Aliases the module under the cursor refactoring similar calls as well | +| nextls | alias-refactor | Aliases the module under the cursor, refactoring similar calls as well | | nextls | to-pipe | Extracts the first argument to a pipe call | | nextls | from-pipe | Inlines the pipe call to a function call inlining the first argument | | nextls | uninstall | Removes the `nextls` executable from the default location: `~/.cache/elixir-tools/nextls/bin/nextls` |