pythonpython-3.xneovimtmux

NVIM not refreshing venv after using pip from another shell


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.



Here is an example photo of my problem.
Example.png


Already tried:


Solution

  • Solution

    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)