Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ elixir.setup {
| 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 |

## Next LS

Expand Down
24 changes: 23 additions & 1 deletion lua/elixir/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ local enabled = function(value)
return value == nil or value == true
end

local get_cursor_position = function()
local rowcol = vim.api.nvim_win_get_cursor(0)
local row = rowcol[1] - 1
local col = rowcol[2]

return row, col
end

local define_user_command = function()
vim.api.nvim_create_user_command("Elixir", function(opts)
local args = vim.iter(opts.fargs)
Expand All @@ -37,6 +45,20 @@ local define_user_command = function()
if "uninstall" == subcommand then
vim.fn.delete(nextls.default_bin)
vim.notify(string.format("Uninstalled Next LS from %s", nextls.default_bin), vim.lsp.log_levels.INFO)
elseif "to-pipe" == 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",
arguments = { { position = { line = row, character = col }, uri = uri } },
}
else
not_found = true
end
Expand All @@ -52,7 +74,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" }
return { "uninstall", "to-pipe", "from-pipe" }
elseif vim.startswith(cmd, "Elixir") then
return { "nextls" }
end
Expand Down