nix-community / nixvim

Configure Neovim with Nix! [maintainers=@GaetanLepage, @traxys, @mattsturgeon, @khaneliman]
https://nix-community.github.io/nixvim
MIT License
1.71k stars 263 forks source link

coq_nvim - cannot import name 'batched' from 'std2.itertools' #694

Closed jacekpoz closed 11 months ago

jacekpoz commented 11 months ago

Plugin affected: coq_nvim Nixpkgs channel: unstable Home-manager version: unstable

Description

this seems very similar to https://github.com/nix-community/nixvim/issues/400, upon launching nvim I get this

cannot import name 'batched' from 'std2.itertools' (/nix/store/440s2ivl3rk6kxxac5sdkgsww6px2cg1-python3-
3.11.5-env/lib/python3.11/site-packages/std2/itertools.py)

Please update dependencies using :COQdeps
-
-
Dependencies will be installed privately inside `/home/jacek/.cache/coq_nvim/vars`
`rm -rf gb8cpdfpg9y1z5bmcai09f25jm9wllxp-vimplugin-coq_nvim-2023-10-07` will cleanly remove everything
Press ENTER or type command to continue

and running :COQdeps gives me this

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/nix/store/gb8cpdfpg9y1z5bmcai09f25jm9wllxp-vimplugin-coq_nvim-2023-10-07/coq/__main__.py", line
 85, in <module>
    assert not _IN_VENV
AssertionError

[Process exited 1]

I did exactly what you told pupbrained to do in that issue, just updated my flake, ran that python binary and tried importing batched there with this result:

~/niksos on  master [!+?] took 34s ❯ /nix/store/n8rjv7v0bw3yxbdpvmjnwwwh8h2swzd6-neovim-4d757bb/bin/nvim-python3
Python 3.11.5 (main, Aug 24 2023, 12:23:19) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import std2
>>> import std2.itertools
>>> import std2.itertools.batched
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'std2.itertools.batched'; 'std2.itertools' is not a package
>>> import std2.itertools.batche
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'std2.itertools.batche'; 'std2.itertools' is not a package
>>> import std2.itertools.batch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'std2.itertools.batch'; 'std2.itertools' is not a package
>>> from std2.itertools import batched
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'batched' from 'std2.itertools' (/nix/store/440s2ivl3rk6kxxac5sdkgsww6px2cg1-python3-3.11.5-env/lib/python3.11/site-packages/std2/itertools.py)
>>> 

I also checked and ~/.local/share/nvim doesn't have any coq related directories and I already tried removing the entire directory

Config

            programs.nixvim = {
                enable = true;
                package = pkgs.neovim-nightly;
                enableMan = true;
                #colorscheme = "catppuccin";
                #colorschemes.catppuccin = {
                #    flavour = "mocha";
                #    transparentBackground = true;
                #};

                options = {
                    number = true;
                    relativenumber = true;
                    autoread = true;
                    so = 7;
                    cmdheight = 1;
                    ignorecase = true;
                    smartcase = true;
                    showmatch = true;
                    timeoutlen = 500;
                    encoding = "utf8";
                    smarttab = true;
                    shiftwidth = 4;
                    tabstop = 4;
                    expandtab = true;
                    linebreak = true;
                    smartindent = true;
                    updatetime = 300;
                    hidden = true;
                    background = "dark";
                    mousemoveevent = true;
                };

                globals = {
                    mapLeader = " ";
                    mapLocalLeader = " ";
                };

                plugins = {
                    airline = {
                        enable = true;
                        powerline = true;
                        #theme = "catppuccin";
                    };
                    fugitive.enable = true;
                    treesitter = {
                        enable = true;
                        ensureInstalled = [
                            "lua"
                            "rust"
                            "markdown"
                            "markdown-inline"
                            "python"
                            "cmake"
                            "cpp"
                            "c"
                        ];
                        folding = false;
                        indent = true;
                        nixvimInjections = true;
                        incrementalSelection.enable = true;
                    };
                    coq-nvim = {
                        enable = true;
                        autoStart = "shut-up";
                        installArtifacts = true;
                        recommendedKeymaps = true;
                    };
                    chadtree = {
                        enable = true;
                        keymap.openFileFolder.tertiary = [ "<leader>t" "<middlemouse>" ];
                    };
                    toggleterm = {
                        enable = true;
                        direction = "float";
                        openMapping = "<C-\\>";
                        shadeTerminals = true;
                        shadingFactor = 2;
                        size = 10;
                    };
                    # TODO laytan/cloak.nvim
                    gitsigns = {
                        enable = true;
                        currentLineBlame = true;
                        numhl = true;
                        signcolumn = true;
                        wordDiff = true;
                    };
                    lsp = {
                        enable = true;
                        servers = {
                            rust-analyzer.enable = true;
                            lua-ls.enable = true;
                            clangd.enable = true;
                            nil_ls.enable = true;
                            bashls.enable = true;
                        };
                        #onAttach = ''
                        #    vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')

                        #    local bufopts = { noremap = true, silent = true, buffer = bufnr }
                        #    vim.keymap.set('n', '<space>wl', function()
                        #        print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
                        #    end, bufopts)
                        #    vim.keymap.set('n', '<C-f>', function() vim.lsp.buf.format { async = true } end, bufopts)
                        #'';
                        keymaps = {
                            lspBuf = {
                                gD = "declaration";
                                gd = "definition";
                                K = "hover";
                                gi = "implementation";
                                "<C-k>" = "signature_help";
                                "<leader>wa" = "add_workspace_folder";
                                "<leader>wr" = "remove_workspace_folder";
                                "<leader>wl" = "list_workspace_folders";
                                "<leader>D" = "type_definition";
                                "<leader>r" = "rename";
                                "<leader>a" = "code_action";
                                gr = "references";
                                "<C-f>" = "format";
                            };
                            diagnostic = {
                                "<leader>e" = "open_float";
                                "<leader>j" = "goto_prev";
                                "<leader>k" = "goto_next";
                                "<leader>q" = "setloclist";
                            };
                            # TODO maybe change
                            silent = false;
                        };
                    };
                    rust-tools = {
                        enable = true;
                        crateGraph = {
                            enabledGraphvizBackends = [ "png" "svg" ];
                            backend = "x11";
                        };
                        inlayHints = {
                            auto = true;
                            onlyCurrentLine = true;
                            showParameterHints = true;
                        };
                    };
                    leap.enable = true;
                    fidget.enable = true;
                    telescope = {
                        enable = true;
                        keymaps = {
                            "<leader>ff" = "find_files";
                            "<leader>fg" = "live_grep";
                            "<leader>fb" = "buffers";
                            "<leader>fh" = "help_tags";
                        };
                        # TODO maybe change
                        keymapsSilent = false;
                    };
                    comment-nvim.enable = true;
                    crates-nvim.enable = true;
                    harpoon = {
                        enable = true;
                        enableTelescope = true;
                        keymapsSilent = false;
                    };
                };
            };
GaetanLepage commented 11 months ago

Yes, this is "my fault". I did not adapt the patch we apply to the coq_nvim source recently. As the code has changed and the plugin was updated, the patch no longer has effect.

I have just opened a PR to fix that: https://github.com/NixOS/nixpkgs/pull/266859

GaetanLepage commented 11 months ago

And the python dependencies had not been updated for a while. This is, I think, the cause of your bug.

jacekpoz commented 11 months ago

that was really quick, thank you! hope it gets merged soon :-)

GaetanLepage commented 11 months ago

Actually, I need to adapt the patch a bit more because the plugin author has changed the logic a bit...

GaetanLepage commented 11 months ago

The PR has been merged. We now have to wait for it to land on nixos-unstable.

jacekpoz commented 11 months ago

I could never find this, how quick do commits from master land in unstable?

siph commented 11 months ago

It's usually a few days: https://status.nixos.org/

GaetanLepage commented 11 months ago

@jacekpoz can you update and retry ? It should be fixed...

jacekpoz commented 11 months ago

sorry for the long wait, I needed to fix my flake…

everything works fine here!

GaetanLepage commented 11 months ago

Great ! Closing then.