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

vimPlugins: Init various coc extension plugins #64426

Merged
merged 3 commits into from Jul 10, 2019

Conversation

rvolosatovs
Copy link
Member

Motivation for this change

To allow better "Nixifying" coc setup

According to https://github.com/neoclide/coc.nvim/wiki/Using-coc-extensions#use-vims-plugin-manager-for-coc-extension coc extensions can be installed simply by adding them to RTP. (So things like this just work: https://github.com/rvolosatovs/infrastructure/blob/902a410ba2f73b32a18af3e2ccb9762c74d345aa/nixpkgs/neovim/default.nix#L10-L15)
Caveat: I managed to make it work with plug vim plugin backend, configure.packages.plugins.start does not seem to work for me again(#56338 (comment))
cc @teto

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • 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 nix-review --run "nix-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.

@teto
Copy link
Member

teto commented Jul 8, 2019

i suspect some of these plugins may need override, like coc-denite may need denite as a dependency, coc-tabnine requiring tabnine, coc-vimtex requiring vimtex etc.
For instance, I wonder if you could make coc-python work ?
Also you've mixed in vimoutliner and a.vim and some unrelated update in a single commit. It may be wiser to split this into several PRs so that one reviewer can really test the PR.

e.g.: coc-imselect should be darwin only etc

@rvolosatovs
Copy link
Member Author

Split the PR in several commits for easier review.
All I did initially was follow the default steps of adding vim plugins:

# * Add your plugin to ./vim-plugin-names
# * sort -udf ./vim-plugin-names > sorted && mv sorted vim-plugin-names
# * run ./update.py

Some of these will require extra steps indeed, however I think it's nice to at least have the extensions in nixpkgs already as a first step. (similarly how it was done for coc-nvim itself)

@malob
Copy link
Member

malob commented Jul 8, 2019

Just wanted to chime in and say that I'd love to see coc extensions added to nixpkgs, in fact it's been on my list to see if I could figure out how to do it myself.

As @teto notes, some of them will probably require unique overrides, and I think probably all of them that are actually extensions to coc (unlike coc-denite) will require an override in order to be properly installed. I expect the general overrides for each extension would be of the same form as the override for coc-nvim itself:

coc-nvim = let
version = "0.0.72";
index_js = fetchzip {
url = "https://github.com/neoclide/coc.nvim/releases/download/v${version}/coc.tar.gz";
sha256 = "128wlbnpz4gwpfnmzry5k52d58fyp9nccha314ndfnr9xgd6r52y";
};
in super.coc-nvim.overrideAttrs(old: {
# you still need to enable the node js provider in your nvim config
postInstall = ''
mkdir -p $out/share/vim-plugins/coc-nvim/build
cp ${index_js}/index.js $out/share/vim-plugins/coc-nvim/build/
'';
});

One issue that will almost certainly come up is that the overrides will be hard to keep in sync with the generated nix expressions whenever the vim plugins are updated. See PR #64411 by @teto, for an example.

Seems to me that the ideal longterm solution would be to have a separate script that generated the necessary nix expressions for coc extensions, but that seems like a lot of work.

@rvolosatovs
Copy link
Member Author

@malob It's not necessarily a lot of effort. E.g. for coc-go something as simple as 1eb975c should be sufficient.

coc-nvim is quite an exception really since there we actually want to version it.

@malob
Copy link
Member

malob commented Jul 9, 2019

@rvolosatovs, hmmm you are probably totally right. I accidentally assumed that the process for installing extensions would be similar to the process of installing coc.nvim itself.

@rvolosatovs
Copy link
Member Author

Does anyone want to contribute to this?
I won't be able to go through the plugins and add overrides any time soon.

@malob
Copy link
Member

malob commented Jul 9, 2019

I'd be happy contribute, but I'll need some tips about how to get started.

@teto
Copy link
Member

teto commented Jul 10, 2019

ok let's merge this because I know it can be a pain to rebase the vim generated plugins.
I hope there will be some follow up PRs to make the different plugins work out of the box as much as possible.

@malob you can just look at pkgs/misc/vim-plugins/overrides.nix and try to adapt these to the different plugins.

@ersinakinci
Copy link
Contributor

I have no idea whether this comment will be noticed, but I want to gently and respectfully ask whether merging this PR in an incomplete state was the best course of action.

I don't know how many other people may have run into this problem, but I've spent about two days trying to figure out why there are coc extensions in the Nix repo that have no documentation on how to use them, no explanation of how they are loaded by coc, and ultimately (as I found out the hard way) don't work. This time is on top of the day or two that I spent figuring out why the coc plugin itself is available in Nixpkgs even though coc's documentation says that I should use Plug. Nix's relatively unhelpful wiki page on setting up vim doesn't give a clear explanation of how the vim packages work, either.

I'm a newcomer to Nix and I've quickly become aware that I'm not the only one having a hard time with the documentation. I've been trying to update the docs myself as well trying to contribute to vim plugins. I don't mean to sound ungrateful. I'm aware that most of us are doing this for free and that keeping docs up-to-date is a task that most people don't relish, especially when the code is in flux.

But why make things harder on new users by intentionally, knowingly merging broken code? Had I not stumbled on this PR by accident, I would still be scratching my head, wondering why the mainline Nixpkgs repo has these tantalizingly-named coc- packages that are essentially unusable. (Or some of them, anyway. FWIW, in the extensions that I tested, the problem is that we need overrides to add some kind of build step, as @teto observed above.)

Thank you all for your hard work. I greatly appreciate it, and I hope that we can all make the UX more hospitable, especially for new users.

@rvolosatovs
Copy link
Member Author

I think we should just mark the broken coc plugins as such to avoid confusion for now.
After switching to coc and opening this PR I found myself not using any plugins besides vanilla coc, so adding necessary overrides fell down on my priority list.
@malob did you make any progress on this by any chance?

@earksiinni I actually stopped searching for answers in the docs and most of the time just read the source. For NixOS option I man configuration.nix first, search for the option I'm interested in(or find such) and then use the filepaths specified to read the source. For packages I just grep/(or rg in my case) the codebase. That way I can also use git blame to find relevant commits/PRs, which may have additional context.

@ersinakinci
Copy link
Contributor

@rvolosatovs, I've also stopped going to the docs, in part due to my struggles with coc extensions. I'm currently writing a deep dive about what exactly happens when one installs a Nix package. It has been highly informative. I follow a workflow similar to yours. (Didn't know that configuration.nix had a man page, though, thanks for the tip!)

However, I don't think that "the documentation is bad, so check the source code" is a good state of affairs for the community. Merging broken code merely compounds the problem.

I'd like to take a crack at fixing the broken extensions this week.

@malob
Copy link
Member

malob commented Nov 1, 2019

@rvolosatovs, no progress unfortunately, I tried a couple of times but didn't get to far before hitting issues.

@ersinakinci
Copy link
Contributor

@malob @rvolosatovs, I've made some progress and have fixed vimPlugins.coc-prettier on my local machine. Will post in #64560 to keep the discussion in one place.

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.

None yet

4 participants