Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vimUtils.vimrcFile: fixes packpath order #78385

Merged
merged 1 commit into from Feb 21, 2020
Merged

vimUtils.vimrcFile: fixes packpath order #78385

merged 1 commit into from Feb 21, 2020

Conversation

megheaiulian
Copy link
Contributor

@megheaiulian megheaiulian commented Jan 23, 2020

Motivation for this change

Fix vimUtils.vimrcFile's packDir import order:

  1. Currently the packDir's plugins are added in rtp after $VIMRUNTIME. This breaks a lot of plugins as most of them expect the pack that the plugin is in to be loaded before $VIMRUNTIME.
  2. Just adding set packpath^=... is not enough and rtp must also be prepended with the packDir's path. This's makes vim/neovim load plugins from packs in packDir in order specified by its placement in rtp (weird behavior but that's how it works).
  3. With the changes in this PR vim and neovim will load the packDir in a similar manner as when placed in .vim/ or .config/neovim and load order will be correct.

Fixes #39364

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@jonringer
Copy link
Contributor

cc @kalbasit since he was doing some vim work recently

@megheaiulian
Copy link
Contributor Author

@jonringer @kalbasit Can this PR get reviewed ?

Copy link
Contributor

@jonringer jonringer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, let me get some other's opinions

@jonringer
Copy link
Contributor

this seems to be a long standing issue, and it seems like you did your due diligence on investigating a solution. Thanks!

@rvolosatovs
Copy link
Member

coc-nvim put in configure.packages.plugins.start fails to load for me with this change applied, whereas it works fine with configure.plug.plugins.

@megheaiulian
Copy link
Contributor Author

megheaiulian commented Feb 20, 2020

Just tested this with a simple config :

neovim.override {
    configure = {
      customRC = ''
        set shiftwidth=2
        set softtabstop=2
        set expandtab
      '';
      packages.myVimPackage = with vimPlugins; {
        start = [
          coc-nvim
        ];
        opt = [ ];
      };
    };
  };

and coc-nvim is loading correctly.
@rvolosatovs Maybe you some custom config in your ~/.config/nvim that is depending on the old broken behavior ?

@jonringer
Copy link
Contributor

My main concern is that people have already developed hacks around the pre-existing design, and they might be incompatible with this fix.

@jonringer
Copy link
Contributor

that being said, I would rather have "normal path" work fine, than people having to search through issues and PRs to get their vim workflow going. The individuals who have already developed hacks likely have context to what they did and why it might be wrong.

@Mic92
Copy link
Member

Mic92 commented Feb 20, 2020

@timokau might have some insights. Otherwise it looks good.

@kalbasit
Copy link
Member

I'll give this PR a try in my vim config and report back.

@rvolosatovs
Copy link
Member

rvolosatovs commented Feb 20, 2020

@megheaiulian I can reproduce the issue with such minimal shell.nix:

with import (builtins.fetchTarball https://github.com/NixOS/nixpkgs/archive/5d2ea07f02ba60aa7af2388381f14dd62a0978dc.tar.gz) {};
stdenv.mkDerivation {
  name = "env";
  buildInputs = [
    (neovim.override {
      configure = {
        customRC = ''
          set shiftwidth=2
          set softtabstop=2
          set expandtab

          call coc#config('coc', {
          \ 'preferences': {
          \   'codeLens.enable': "true",
          \   'colorSupport': "true",
          \   'extensionUpdateCheck': "never",
          \   'formatOnSaveFiletypes': [ "go" ],
          \ },
          \ 'suggest': {
          \   'acceptSuggestionOnCommitCharacter': "true",
          \   'enablePreview': "true",
          \   'timeout': 2000,
          \   'triggerAfterInsertEnter': "true",
          \ },
          \})
        '';
        packages.myVimPackage = with vimPlugins; {
          start = [
            coc-nvim
          ];
          opt = [ ];
        };
        # Works fine with:
        #plug.plugins = with vimPlugins; [
        #  coc-nvim
        #];
      };
    })
  ];
}

I'm getting this error with package system:

Error detected while processing /nix/store/0jgkc9zhi5h40xqkkd27wa343mshzx3l-vimrc:
line   30:
E117: Unknown function: coc#config

While with plug implementation it just works.

EDIT: Replaced <nixpkgs> by link to 5d2ea07 tarball

@evanjs
Copy link
Member

evanjs commented Feb 21, 2020

It's been so long I forgot what was breaking on my end.
But I removed my workaround and various plugins seem to work still.
Success?
Happy to test specific things.

@megheaiulian
Copy link
Contributor Author

megheaiulian commented Feb 21, 2020

@rvolosatovs After further investigating this I think your expectations are wrong.
This works exactly like placing that customRC in your .config/nvim/init.vim and having coc-nvim in ./config/nvim/pack/myVimPackage/start/coc-nvim. The vimrc loads first and even if the plugin is in start you can't call functions from it there as it is not yet loaded. You can use a AutoCmd to configure the plugin or let g:coc_user_config = ....

Please note the goal of this PR is not to have packages.packageName work like plug.plugins. The goal is to have packs work like they do when loaded from defaults dotfiles paths.

@rvolosatovs
Copy link
Member

Thank you for investigating, my bad then - I assumed all plugins would be loaded already. https://github.com/neoclide/coc.nvim/wiki/Install-coc.nvim#using-vim8s-native-package-manager also does not mention anything about it 🤔

@Mic92 Mic92 merged commit 74ace1f into NixOS:master Feb 21, 2020
@Mic92
Copy link
Member

Mic92 commented Feb 21, 2020

@rvolosatovs you could ask upstream about it and maybe fix their documentation than.

@Mic92
Copy link
Member

Mic92 commented Feb 21, 2020

I think we should backport this one also to at least 20.03, but let's wait for a bit until it hits the unstable channel.

@Mic92 Mic92 added this to the 20.03 milestone Feb 21, 2020
@timokau
Copy link
Member

timokau commented Feb 21, 2020

I wish this would be fixed upstream, seems like a bug to me. But at least we finally have a fix for nix, thanks @megheaiulian!

@basilgood basilgood deleted the feature/vim-rtp-fix branch March 16, 2020 06:55
xuanduc987 added a commit to xuanduc987/vim-jetpack that referenced this pull request Mar 29, 2022
plugin syntax files did not work with neovim installed with nix package manager . 

## References
- neovim/neovim#9390
- NixOS/nixpkgs#39364 (comment)
- NixOS/nixpkgs#78385
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vim_configurable: unable to use plugin syntax files
8 participants