Skip to content

Commit

Permalink
Fix normal mode eval. for -> vim.iter
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLeoP committed Mar 1, 2024
1 parent c9cd6df commit 22d6aa6
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lua/powershell/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,10 @@ M.eval = function()
local term_channel = assert(util.term_channels[client_id])

local mode = api.nvim_get_mode().mode
---@type string
local text
---@type string[]?
local lines
if mode == "n" then
text = api.nvim_get_current_line()
api.nvim_chan_send(term_channel, text)
lines = { api.nvim_get_current_line() }
elseif mode == "v" or mode == "V" or mode == "\22" then
vim.cmd.normal { args = { "\27" }, bang = true }

Expand All @@ -373,12 +372,12 @@ M.eval = function()
local end_row = vim.fn.line "'>" - 1
local end_col = vim.fn.col "'>" --[[@as integer]]

local lines = api.nvim_buf_get_text(0, start_row, start_col, end_row, end_col, {})

for _, line in ipairs(lines) do
api.nvim_chan_send(term_channel, line .. "\r")
end
lines = api.nvim_buf_get_text(0, start_row, start_col, end_row, end_col, {})
end
vim
.iter(lines)
:map(function(line) return line .. "\r" end)
:each(function(line) api.nvim_chan_send(term_channel, line) end)

-- HACK: for some reason, the neovim terminal does not update when using this
-- local client = assert(vim.lsp.get_client_by_id(client_id))
Expand Down

0 comments on commit 22d6aa6

Please sign in to comment.