Klafyvel / nvim-smuggler

Send code to your Julia REPL, get diagnostics in return.
MIT License
19 stars 2 forks source link

Add an option to set a fixed socket path. #8

Open Klafyvel opened 8 months ago

Klafyvel commented 8 months ago

Following https://github.com/Klafyvel/REPLSmuggler.jl/issues/10, it would be interesting to have a configuration option that fixes the name of the julia socket used rather than asking it to the user.

The most flexible way would be to allow the user to specify a lua function in the configuration, whose task would be to return a path to the socket. For example:

{
  "klafyvel/nvim-smuggler",
  opts = {
    socket_choice_function = function()
      local last_pane_id = trim(vim.fn.system('tmux display -pt "{last}" "#{pane_id}"'))
      return "~/juliasockets/" .. last_pane_id
    end
  },
  dependencies = { "nvim-neotest/nvim-nio" },
}

And then, with https://github.com/Klafyvel/REPLSmuggler.jl/pull/12, you could have in your startup.jl file something like (not tested):

atreplinit() do repl
  using REPLSmuggler
  io = IOBuffer()
  run(pipeline(`tmux display -p "#{pane_id}"`, io))
  name = filter(!isspace, String(take!(io)))
  smuggle(name, basepath="~/juliasockets")
end

What do you think @fredrikekre?

fredrikekre commented 8 months ago

Thanks for looking into this.

For me the extra configurability with a basepath isn't necessarily necessary, but specifying the socket name in REPLSmuggle.smuggle() would be great and then the same discovery mechanism that you have already now can be used on the neovim side.