neoclide / coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Other
24.15k stars 953 forks source link

feat(extensions): allow github extensions to be installed through development mode #5002

Closed asmodeus812 closed 2 months ago

asmodeus812 commented 2 months ago

Problem description https://github.com/neoclide/coc.nvim/discussions/5001

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 78.57143% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 98.55%. Comparing base (48bae5f) to head (7ae5ff3).

Files Patch % Lines
src/extension/installer.ts 78.57% 3 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #5002 +/- ## ========================================== - Coverage 98.56% 98.55% -0.02% ========================================== Files 273 273 Lines 26072 26074 +2 Branches 5390 5390 ========================================== - Hits 25698 25697 -1 - Misses 218 222 +4 + Partials 156 155 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

fannheyward commented 2 months ago

Similar discussion https://github.com/neoclide/coc.nvim/discussions/4960

I'd like to recommend to use plugin manager to install extensions that not published to npm yet. Something like Plug 'neoclide/coc-tsserver', {'do': 'yarn install --frozen-lockfile'} https://github.com/neoclide/coc.nvim/wiki/Using-coc-extensions#use-vims-plugin-manager-for-coc-extension

This fix treats the URL github.com as whitelist to allow running in development mode, what if an extension hosted with gitlab.com or sr.ht or custom git repo? My thought: limit CocInstall to run in production only, and use plugin manger to run in development mode, with more flexibility.

The primary use of CocInstall from a URL is to install code snippets like https://github.com/rafamadriz/friendly-snippets.

asmodeus812 commented 2 months ago

Hi Thanks for taking a look,

The main reason i would like to have coc manage this instead of a plugin manager, is first most package managers do not provide an api to do this programatically, they are declarative, so you have do it in your plugin config, where as i want the clone and build of the extension to happen programatically when i choose that. I can easily do that with CocInstall for regular npm hosted packages. I do not like the idea of having two completely separate paths working differently but essentially doing the same thing.

Secondly there is no way to ever build an extension from a clone of a github repo with the current implementation. Most of coc extensions have a lot of devDependencies, and the current implementation fails to build everthing that it downloads from github, due to the devDeps not being downloaded in production mode. Meaning that feature (to pull an extension from github) is effectively dead as it is. It is not working anyway. (It can only work if the owner includes the lib build artifacts, which noone does, it is not a good idea too since those could be quite big)

As for the source being github, can be easily extended to work with other hosts, but most package managers only support github (maybe gitlab too, at the very best) to begin with any way.

If it is a custom git repo, it should be probably managed by the user, i think coc providing a way to clone from github is at the very least an MVP, allowing users to pull from packages which are possibly not published or the repo is not synced with npm that often (which was one of my other use cases too, i had an extension not be up to date in npm compared to the repo), anything more should be managed by the user.

I just wanted to make the existing feature work correctly.

fannheyward commented 2 months ago

cc @Freed-Wu