@bus-error Finally there’s some progress. I just published 2.0.0.beta8 which contains an initial implementation of this feature.
I’d be glad if you could test this with your setup and requirements.
Details:
- setup is done via UI in the project settings, as shown in an earlier post
- the settings define a list of “shell script libraries”. Each library defines a set of library sources (i.e. the first table in the UI) and a list of directories and files, where the library is used (i.e. the second table in the UI)
- External library sources are supported, i.e. the library sources don’t have to be located inside the project or a module root
- code completion, go to definition, etc. should all be working as with regular scripts
- the order of the library sources is important. Entries at the top of the list are checked first. Re-definitions inside of library sources are not supported. That means if there are multiple definitions of the same variable or function in different library source files, then the file defined earlier in the list is the target for “go to definition”, etc.
Limitations:
- ShellCheck doesn’t know about this configuration, of course. I’ll investigate if it’s somehow possible to pass it the additional files to look at. In the long run BashSupport Pro’s own inspections for “unresolved variable” and “unused variable” are going to replace ShellChecks similar checks. The inspections are still marked as beta and not yet mature enough, though
- There may be edge-cases which I haven’t found yet, let me know if you notice anything odd or unexpected
- The UI will be improved with the next updates.
- This is supposed to also work on Windows, but I haven’t tested this yet…
Example: acme.sh
This example explains how to use this with the well-known acme.sh project
In this project all important definitions are in a single file acme.sh
. Many files rely on these definitions.
- Clone and open the repository of GitHub - acmesh-official/acme.sh: A pure Unix shell script implementing ACME client protocol
- Create a new shell script library “acme.sh” at
Settings > Languages & Frameworks > BashSupport Pro > Shell Script Libraries
:- in table “Library sources”, add a new file entry
acme.sh
- in table “Library usage”, add new entries for directories “deploy”, “dnsapi”, and “notify”
- in table “Library sources”, add a new file entry
- Apply and close the settings
- Now all scripts under “deploy”, “dnsapi”, and “notify” show completions for the definitions found in the
acme.sh
file.