withfig / fig

Public issue tracker for Fig.
https://fig.io
MIT License
2.06k stars 58 forks source link

Loading out-of-repo autocompletion specs #2828

Open pzmarzly opened 9 months ago

pzmarzly commented 9 months ago

Sanity checks

Feature Details

Currently Fig and Inshellisense both use withfig/autocomplete for completion specs. These are just TS files that compile to JS (and from what I see, could be compiled to JSON as well with no loss in functionality).

This "big repo" approach worked great for increasing adoption of TS types, in form of DefinitelyTyped repo. But at some point, it became more beneficial to let maintainers of various packages to ship their own type definitions together with their packages. So now many maintainers of JS packages ship type definitions as part of their JS package.

I'd like to see the same thing happen here. Many popular .deb / .rpm files that care a lot about UX already have structure like:

I suspect some will want to also ship their own autocomplete specs. I would imagine this could be something like /usr/share/fig-autocomplete/mycli.json. Then Fig could scan this directory at startup and load the definitions. If some spec was present both in /usr/share/fig-autocomplete and in withfig/autocomplete repo, Fig should choose /usr/share/fig-autocomplete.

What benefits would that have?

pzmarzly commented 9 months ago

I have missed the docs part that says about ~/.fig/autocomplete/build directory. So ignore most of my post. Still, could we have a machine-wide /usr/share/fig/autocomplete/build?

mschrage commented 8 months ago

I like this idea. Shouldn't be too difficult to add a machine-wide completion spec directory, in addition to ~/.fig/autocomplete/build

grant0417 commented 8 months ago

I like the idea of a "fig path" like FPATH in zsh, we could load completions from these locations in order: