You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to support type annotations for bash? e.g.,
# This should be a brief description of the package and its functionality. Try# to keep the description to one line of text and to not use the package's name.#@type string
pkgdesc='default value'# Defines on which architectures the given package is available (e.g.,# arch=(i686 x86_64)). Packages that contain no architecture specific files# should use arch=(any). Valid characters for members of this array are# alphanumerics and "_".#@type string[]
arch=()
If we write arch=x86_64 we will get error.
except we change string[] to string[] | string or string[] | 'x86_64'
And we will get document hover from the comment before variable.
And we can introduce more types. like 'true' | 'false' for bool, /\d+/ for number. @param 1: 'true' | 'false' for function input $1. Even we can define new types. like: @typedef boolean: 'true' | 'false'
What is the feature you are proposing to solve the problem?
type annotation
What alternatives have you considered?
termux-language-server use json schema to annotate type of variables. However, it is specific, not flexible.
For PKGBUILD, there is a PKGBUILD.json.
If we realize type annotation, we can use PKGBUILD.d.sh, %.ebuild.sh, build.sh.d.sh for PKGBUILD, ebuild, build.sh.
We even can introduce some magic comments. e.g., we add #@source PKGBUILD.d.sh to test.sh, it will use types of PKGBUILD.d.sh.
or #@source https://a_URL_like_DefinitelyTyped/PKGBUILD.d.sh.
*.d.sh is like *.d.ts. It is also helpful for other projects like shellcheck.
And some bash script provide some function as a wrapper of source. such as ebuild's inherit.
If we inherit toolchain-funcs, it will source $EPREFIX/var/db/repos/gentoo/eclass/toolchain-funcs.eclass and user can use the functions defined toolchain-funcs.eclass. we can use the code
in %.ebuild.d.sh:
What is the problem this feature will solve?
Many LSP support type annotations. Such as:
Is it possible to support type annotations for bash? e.g.,
If we write
arch=x86_64
we will get error.except we change
string[]
tostring[] | string
orstring[] | 'x86_64'
And we will get document hover from the comment before variable.
And we can introduce more types. like
'true' | 'false'
for bool,/\d+/
for number.@param 1: 'true' | 'false'
for function input$1
. Even we can define new types. like:@typedef boolean: 'true' | 'false'
What is the feature you are proposing to solve the problem?
type annotation
What alternatives have you considered?
termux-language-server use json schema to annotate type of variables. However, it is specific, not flexible.
For PKGBUILD, there is a PKGBUILD.json.
If we realize type annotation, we can use
PKGBUILD.d.sh
,%.ebuild.sh
,build.sh.d.sh
forPKGBUILD
,ebuild
,build.sh
.We even can introduce some magic comments. e.g., we add
#@source PKGBUILD.d.sh
totest.sh
, it will use types ofPKGBUILD.d.sh
.or
#@source https://a_URL_like_DefinitelyTyped/PKGBUILD.d.sh
.*.d.sh
is like*.d.ts
. It is also helpful for other projects like shellcheck.And some bash script provide some function as a wrapper of
source
. such as ebuild'sinherit
.If we
inherit toolchain-funcs
, it willsource $EPREFIX/var/db/repos/gentoo/eclass/toolchain-funcs.eclass
and user can use the functions definedtoolchain-funcs.eclass
. we can use the codein
%.ebuild.d.sh
:Like after
import XXX
then use functions defined inXXX.py
? Attractive and a little hard to realize?Just my 2c. Welcome to discuss!
The text was updated successfully, but these errors were encountered: