How to "refresh" NVIM venv modules without closing it ?
Currently im struggling with setting up my workspace with NVIM and TMUX. Im opening two panels, one main for nvim, and another one much smaller for console.
I source env/bin/activate
both of them and after that im openning NVIM on main panel. My issue is that, whenever i use pip install "x"
on lower panel, NVIM doesnt catch that and gives me an errors like "Import "x" could not be resolved"
. I have to close NVIM and reopen it in order to see changes. Using :e
to refresh the file doesnt work. :checkhealth
shows that venv is activated with correct PATH.
Worth to mention, im using the same configs on my MacBook and everything works as it should. Using pip
on lower panel updates main panel as well.
- OS: EndeavourOS
- Terminal: Alacritty + TMUX
- Python LSP: pyright
Here is an example photo of my problem.
Example.png
Already tried:
:e
to refresh file:setw synchronize-panes on/off
in TMUX:checkhealth
shows venv is activated and no errors- using built-in NVIM
:terminal
to activate venv and somehow refresh it (no luck)
How to "refresh" NVIM venv modules without closing it ?
Currently im struggling with setting up my workspace with NVIM and TMUX. Im opening two panels, one main for nvim, and another one much smaller for console.
I source env/bin/activate
both of them and after that im openning NVIM on main panel. My issue is that, whenever i use pip install "x"
on lower panel, NVIM doesnt catch that and gives me an errors like "Import "x" could not be resolved"
. I have to close NVIM and reopen it in order to see changes. Using :e
to refresh the file doesnt work. :checkhealth
shows that venv is activated with correct PATH.
Worth to mention, im using the same configs on my MacBook and everything works as it should. Using pip
on lower panel updates main panel as well.
- OS: EndeavourOS
- Terminal: Alacritty + TMUX
- Python LSP: pyright
Here is an example photo of my problem.
Example.png
Already tried:
:e
to refresh file:setw synchronize-panes on/off
in TMUX:checkhealth
shows venv is activated and no errors- using built-in NVIM
:terminal
to activate venv and somehow refresh it (no luck)
- Please do not upload images of code/data/errors. – dimakin Commented Feb 17 at 21:27
1 Answer
Reset to default 0Solution
The problem is LSP.
Using :LspRestart
works like a charm in my case.
Can try to setup auto :LspRestart
on file save.
Add this to your init.lua or init.vim:
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = "*.py",
callback = function()
vim.cmd("LspRestart")
end,
})
Or edit your lspconfig
pyright settings:
require'lspconfig'.pyright.setup{
settings = {
python = {
analysis = {
autoSearchPaths = true,
useLibraryCodeForTypes = true,
diagnosticMode = "workspace",
},
},
},
}
Reasons why its working on MacOS but not on EndeavourOS
According to ChatGPT:
Inotify vs. FSEvents (Linux vs. macOS)
- macOS uses FSEvents, which is a more integrated file-watching system.
- Linux (EndeavourOS) relies on inotify, and sometimes LSP clients don’t trigger reloads as reliably.
- Pyright might detect venv changes automatically on macOS but not on Linux.