How to get sudo <coreutils-command> syntax-highlighted the way I want in my language-unix-shell package?


#1

Hi,

I have these coreutils lines in my unix-shell.cson grammar file:

      {
        'match': '(?<![\\-/\\./\'/\"/=/:/[a-zA-Z0-9_]/])((?<![a-zA-Z0-9_]\\s))\\b(?:base32|base64|basename|cat|chcon|chgrp|chmod|chown|chroot|cksum|comm|cp|csplit|cut|date|dd|df|dir|dircolors|dirname|du|echo|env|expand|expr|factor|false|fmt|fold|head|hostid|id|install|join|link|ln|logname|ls|md5sum|mkdir|mkfifo|mknod|mktemp|mv|nice|nl|nohup|nproc|numfmt|od|paste|pathchk|pinky|pr|printenv|printf|ptx|pwd|readlink|realpath|rm|rmdir|runcon|seq|sha1sum|sha224sum|sha256sum|sha384sum|sha512sum|shred|shuf|sleep|sort|split|stat|stdbuf|stty|sum|sync|tac|tail|tee|test|timeout|touch|tr|true|truncate|tsort|tty|uname|unexpand|uniq|unlink|users|vdir|wc|who|whoami|yes)\\b(?![\\-\'/\"/=/`/_/])'
        'name': 'support.function.coreutils.shell'
      }
      {
        'begin': '(?<![\\-/\\./\'/\"/=/:/[a-zA-Z0-9_]/])(sudo)\\s(base32|base64|basename|cat|chcon|chgrp|chmod|chown|chroot|cksum|comm|cp|csplit|cut|date|dd|df|dir|dircolors|dirname|du|echo|env|expand|expr|factor|false|fmt|fold|head|hostid|id|install|join|link|ln|logname|ls|md5sum|mkdir|mkfifo|mknod|mktemp|mv|nice|nl|nohup|nproc|numfmt|od|paste|pathchk|pinky|pr|printenv|printf|ptx|pwd|readlink|realpath|rm|rmdir|runcon|seq|sha1sum|sha224sum|sha256sum|sha384sum|sha512sum|shred|shuf|sleep|sort|split|stat|stdbuf|stty|sum|sync|tac|tail|tee|test|timeout|touch|tr|true|truncate|tsort|tty|uname|unexpand|uniq|unlink|users|vdir|wc|who|whoami|yes)(?![\\|/;/&/$/[a-zA-Z0-9_-]//\"/\'/./])'
        'beginCaptures':
          '1':
            'name': 'support.function.extras.shell'
          '2':
            'name': 'support.function.coreutils.shell'
        'end': '(\\||;|&|$|[a-zA-Z0-9_-]|\"|\'|\\.)'
        'endCaptures':
          '0':
            'name': 'punctuation.definition.function.shell'
      }

For some reason the shell code sudo cp /tmp/apt-fast/apt-fast /usr/bin only has sudo syntax-highlighted, although it is given the right syntax-highlighting, namely it is given the support.function.extras.shell style. So cp is not given the support.function.coreutils.shell syntax-highlighting like it should be… Any ideas how to fix this so each component of this code is syntax-highlighted the way it should be? By-the-way sudo apt-fast install -y git has sudo applied the support.function.extras.shell style and apt-fast applied the support.function.packages.shell style, like it should (so it is working the way it should be) and this is achieved via these lines in my unix-shell.cson file (I am mentioning this as it might help you help me with this issue):

      {
        'begin': '(?<![\\-/\\./\'/\"/=/:/[a-zA-Z0-9_]/])(sudo)\\s(antigen|apacman|apm|apm-bleeding|apm-beta|apm-git|apt|apt-cache|apt-fast|apt-get|apt-key|add-apt-repository|apt-add-repository|apt-config|apt-mark|aptitude|bacman|bauerbill|Bauerbill.py|bundle|checkupdates|cleanupdelta|composer|conary|cower|dpkg|dpkg-architecture|dpkg-buildflags|dpkg-buildpackage|dpkg-checkbuilddeps|dpkg-deb|dpkg-distaddfile|dpkg-divert|dpkg-genchanges|dpkg-gencontrol|dpkg-gensymbols|dpkg-log-summary|dpkg-maintscript-helper|dpkg-mergechangelogs|dpkg-name|dpkg-parsechangelog|dpkg-query|dpkg-scanpackages|dpkg-scansources|dpkg-shlibdeps|dpkg-source|dpkg-split|dpkg-statoverride|dpkg-trigger|dpkg-vendor|dnf|ebuild|emerge|eopkg|equery|equo|etc-update|explodepkg|gem|installpkg|lein|makechrootpkg|makepkg|makepkg-template|mkarchiso|mkarchroot|npm|osc|paccache|pacdiff|paclist|paclog-pkglist|pacaur|packer|pacman|pacman-db-upgrade|pacman-key|pacman-optimize|pacscripts|pacsearch|pacsort|pactree|pbget|pet2tgz|pkg|pkg\_add|pkg\_check|pkg\_create|pkg\_delete|pkg\_info|pkg\_mklocatedb|pkg\_sign|pkgdelta|pip|pip3|pkgtool|powerpill|Powerpill.py|rankmirrors|removepkg|repo-add|repo-elephant|repo-remove|repoquery|testpkg|revdep-rebuild|rpm|rpm2archive|rpm2cpio|rpmargs|rpmbuild|mock|rpmdb|rpmdev-bumpspec|rpmdev-checksig|rpmdev-cksum|rpmdev-diff|rpmdev-extract|rpmdev-md5|rpmdev-newinit|rpmdev-newspec|rpmdev-packager|rpmdev-rmdevelrpms|rpmdev-setuptree|rpmdev-sha1|rpmdev-sha224|rpmdev-sha256|rpmdev-sha384|rpmdev-sha512|rpmdev-sort|rpmdev-sum|rpmdev-vercmp|rpmdev-wipetree|rpmdiff|rpmdrake|rpmelfsym|rpmfile|rpm-find-leaves|rpmgraph|rpminfo|rpmkeys|rpmlint|rpmls|rpmpeek|rpmquery|rpmsodiff|rpmsoname|rpmspec|rpmverify|slackpkg|slapt-get|snap|snapcraft|snapcraft-parser|trizen|updpkgsums|namcap|mksrcinfo|upgradepkg|urpmi|urpme|urpmq|urpmf|urpmi.update|vercmp|yaourt|yum|yum-builddep|zypper)(?![\\|/;/&/$/[a-zA-Z0-9_-]//\"/\'/./])'
        'beginCaptures':
          '1':
            'name': 'support.function.extras.shell'
          '2':
            'name': 'support.function.packages.shell'
        'end': '(\\||;|&|$|[a-zA-Z0-9_-]|\"|\'|\\.)'
        'endCaptures':
          '0':
            'name': 'punctuation.definition.function.shell'
      }

Thanks for your time,
Brenton