| README.md | ||
ever since moving from spacemacs to neovim i have been unable to recreate my main window management workflow
i use a tiling window manager (previously i3, more recently sway), so already have keybindings for switching/resizing windows
with emacs daemon + clients, i could open each new "emacs window" as a new terminal window the shared daemon meant that each window shared the same background state (buffers, "registers", project, linting stuffs, etc) and since each window was a new terminal window, i could switch/resize windows using my already known tiling window manager keybindings
there were some drawback to this of course. the main one was that spacemacs had to be running on the local machine because it had to talk to the local window manager this could be worked around using X11 forwarding over ssh, but was only viable on the local network. doing so over the internet was laggy as hell since every keypress had to traverse the net this restriction meant connecting to a remote dev vm required using emacs tramp, which causes big problems for lsp/linting since most lsp servers/linters expect to be running near the codebase being worked on.
the other drawback was that smaller windows (just large enough to show a small function) didn't have much space to show filepicker/search ui popups since it could only draw across the single small window
there has been some work to add daemonization/frames to neovim, but work has slowed https://github.com/neovim/neovim/issues/2161
there are a couple directions to go when working around this
- Session Syncing: instead of having a central server, synchronize each copy of neovim by writing/reading session files
- Command Capture: instead of having multiple terminal windows, each controlled by sway, use neovim windows but capture tiling window manager commands while inside neovim
Some edge cases to keep in mind:
- how does this work when we run neovim on a remote host over ssh?
- how does this work when working on just a laptop?
- how does this work when working on multiple screens?
Details of each approach
Session Syncing
- This method is talked about a bit on the neovim daemonization github issue https://github.com/neovim/neovim/issues/2161
- The idea is to abuse session state files to keep buffer state files synced between all of the different neovim instances.
- The session files need to be written out when certain actions occur in the currently active neovim instance
- The session files then need to be read and loaded when a neovim instance becomes active
This has the obvious drawback of being rather resource wasteful This also has the potential to deadloack How do you keep edited/opened buffers in sync between the instances? How does this work over ssh??
- we could have a remote neovim instance open new terminal windows on the local machine, but kinda messy to implement
need something for autosaving: https://github.com/okuuva/auto-save.nvim
and probably something for autoloading unmodified buffers:
stevearc/dotfiles@6bc8a8c96a/.config/nvim/init.lua (L286-L297)
Command Capture
-The idea here is that the window manager keybindings should move us between neovim windows, until the edge of the neovim pane is reached. Then the keybindings move us between tiled windows
-
https://jasoncarloscox.com/creations/vim-sway-nav is a basic solution to this.
- it adds a shell script that the sway keybindings calls, which checks if the active window is neovim. if it is, then the command is sent to neovim
- otherwise it is sent to sway as usual
- no resizing support?
-
an i3 + vim solution https://github.com/jwilm/i3-vim-focus
How does this work over ssh??
- sway would need some way of:
- knowing what ssh session is in the terminal, and that it is vim
- the above impl searches through proc for the vim session in the current selected terminal, doing that over ssh is going to be inefficient
- knowing what ssh session is in the terminal, and that it is vim
POTENTIAL SOLUTION:
- get current vim session from current window selected by sway
- get vim server name from that
- send command to vim server according to name
- when starting vim server over ssh, export the name so the first line can find it?