EvWilson / slimux.nvim

Send content from the current Neovim buffer to a configurable tmux pane.
13 stars 3 forks source link

Error sending visual selection to tmux (vim.send_highlighted_text) #9

Closed twidxuga closed 6 hours ago

twidxuga commented 1 month ago

Thanks for a great and useful plugin.

I'm getting the following error when attempting to send a visual selection to a tmux pane:

E5108: Error executing lua: ...a/.local/share/nvim/lazy/slimux.nvim/lua/slimux/init.lua:98: b
ad argument #1 to 'gsub' (string expected, got nil)                                          
stack traceback:                                                                             
        [C]: in function 'gsub'                                                              
        ...a/.local/share/nvim/lazy/slimux.nvim/lua/slimux/init.lua:98: in function 'escape' 
        ...a/.local/share/nvim/lazy/slimux.nvim/lua/slimux/init.lua:139: in function 'send'  
        ...a/.local/share/nvim/lazy/slimux.nvim/lua/slimux/init.lua:153: in function <...a/.l
ocal/share/nvim/lazy/slimux.nvim/lua/slimux/init.lua:151>                                    
"Whiteboard.txt" 280L, 10089B 

I'm use LazyVim and my slimux.nvim config is:

  {
    "EvWilson/slimux.nvim",
    config = function()
      local slimux = require("slimux")
      slimux.setup({
        target_socket = slimux.get_tmux_socket(),
        target_pane = string.format("%s.2", slimux.get_tmux_window()),
      })
      vim.keymap.set(
        "v",
        "<leader>r",
        slimux.send_highlighted_text,
        { desc = "Send currently highlighted text to configured tmux pane" }
      )
      vim.keymap.set(
        "n",
        "<leader>r",
        slimux.send_paragraph_text,
        { desc = "Send paragraph under cursor to configured tmux pane" }
      )
    end,
  },

I don't get any errors when sending paragraphs, only visual selections.

My version of Neovim is NVIM v0.11.0-dev-482+g7381f0a1d5

Hope this is useful!

twidxuga commented 1 month ago

Troubleshooting further, it looks to be related with wrong columns being reported by vim.api.nvim_buf_get_mark(current_buffer, ">") or vim.api.nvim_buf_get_mark(current_buffer, "<").

Conincidentally, there is also a recent bug report https://github.com/neovim/neovim/issues/29807, that could be related.

twidxuga commented 1 month ago

Nvim devs feedback on this particular issue here and suggested using vim.region()/getregionpos() instead. I tried their other suggestion involving modifying the keymap, but it didn't work.

haolian9 commented 1 month ago

hi, i'm just here to say i am no 'Nvim devs', just an avarage user. what i had said just a suggestion based on my past experiences on using nvim_buf_get_mark('>'), which you can see here. but if it does not work, i'm sorry for pointing a wrong direction.

twidxuga commented 1 month ago

@haolian9 I stand corrected, but appreciate your contribution nonetheless,

EvWilson commented 1 month ago

Hey folks! First off, thanks so much for the kind word about the plugin. Second, I'll be trying to take a look at this over the weekend, but probably won't get to it for another couple days. I'm unfortunately running a bit ragged after recovering from the recent CrowdStrike incident, but will be trying to look into this soon. Thanks also for the links to other potential upstream issues!

EvWilson commented 6 hours ago

Hello again! Sorry to be delayed in getting back to this. I haven't been able to reproduce this on mainline Neovim (I'm on 10.1, current stable). I'm afraid that due to the possibility of upstream being in a broken state, I won't be attempting to track down the issue in the provided version number. If this is a hard blocker of a critical workflow and you need the bleeding edge, I'd be happy to connect and work through a solution. Otherwise, I may recommend downgrading to stable, and I'll update the project README with compatibility guidelines to be more explicit.

Thanks so much for your interest in the project!