willothy / flatten.nvim

Open files and command output from wezterm, kitty, and neovim terminals in your current neovim instance
https://luarocks.org/modules/willothy/flatten.nvim
MIT License
473 stars 13 forks source link

[Bug] File opened in another nvim instance #57

Closed Bekaboo closed 1 year ago

Bekaboo commented 1 year ago

Describe the bug File is opened in another nvim instance when I tried to open a file in a normal terminal (not nvim builtin-terminal) using nvim <filename>.

Mininal config

https://github.com/willothy/flatten.nvim/assets/76579810/b60394e5-3288-4b1e-a711-88831654490d

local tmp = vim.env.TMPDIR
  or vim.env.TEMPDIR
  or vim.env.TMP
  or vim.env.TEMP
  or '/tmp'
local data = tmp .. '/' .. (vim.env.NVIM_APPNAME or 'nvim')
local packages_root = data .. '/site'
local cloned_root = packages_root .. '/pack/packages/start'
local cloned_path = cloned_root .. '/dropbar.nvim'
local url = 'https://github.com/willothy/flatten.nvim'

vim.fn.mkdir(cloned_root, 'p')
vim.opt.pp:prepend(packages_root)
vim.opt.rtp:prepend(packages_root)

if not vim.loop.fs_stat(cloned_path) then
  vim.fn.system({ 'git', 'clone', url, cloned_path })
end

require('flatten').setup()

To Reproduce Steps to reproduce the behavior:

  1. Save the minimal config above as minimal.lua
  2. nvim --clean -u minimal.lua in one terminal
  3. In another terminal, run nvim --clean -u minimal.lua <filename>
  4. The file is opened in the first nvim instance instead of the second one.

Expected behavior File is opened in the second nvim instance

Screenshots

Desktop (please complete the following information):

Additional context Can confirm that the bug is introduced after commit d92c93959e9ac52a00002d6fd64c2d2ca5dd7192.

willothy commented 1 year ago

Thanks! I'll look into this ASAP. Pretty interesting to me that it opened in a version that didn't even have the plugin active lol.

willothy commented 1 year ago

Not sure why I thought one didn't have the plugin active. But anyways, what terminal emulator are you using? If vim.env.NVIM isn't available, flatten now creates servers for kitty/wezterm splits - have you tried disabling this in your config to see if the issue persists? I'll also try this out with the minimal init right now.

Bekaboo commented 1 year ago

@willothy I'm using wezterm

willothy commented 1 year ago

Hmm, I am as well but can't seem to repro yet, I'll keep trying though.

Bekaboo commented 1 year ago

@willothy I'm using wezterm with tmux and fish shell, if that's related.

willothy commented 1 year ago

Oh! I see, that's intended functionality, added by PR #53. Was able to repro after restarting wezterm. You can disable wezterm/kitty nesting in your config by disabling these options:

one_per = {
    kitty = true,
    wezterm = true, 
},

This was a breaking change and has been a surprise for some people, sorry about that!

Bekaboo commented 1 year ago

Thanks, that fixed it.