micro icon indicating copy to clipboard operation
micro copied to clipboard

Syntax highlight code for .env files

Open MavlinD opened this issue 3 years ago • 1 comments

syntax highlight code for .env type files

MavlinD avatar Jan 20 '22 10:01 MavlinD

Would it make sense to instead simply use the bash/shell highlighting? You could also add the .envrc filename as well.

pbsds avatar Jul 17 '22 20:07 pbsds

diff --git a/runtime/syntax/sh.yaml b/runtime/syntax/sh.yaml
index 329b1014..c87c243c 100644
--- a/runtime/syntax/sh.yaml
+++ b/runtime/syntax/sh.yaml
@@ -8,11 +8,12 @@ filetype: shell
 #
 # Special filenames:
 # * .bashrc, .bash_aliases, .bash_functions .bash_profile
+# * .env, .envrc (dotenv and direnv)
 # * profile, .profile (/etc/profile or ~/.profile)
 # * Pkgfile
 # * pkgmk.conf
@@ -23,7 +24,7 @@ filetype: shell
 # Fix command (fc) files:
 # * bash-fc. (followed by a random string)
 detect:
-    filename: '(\.(sh|bash|ash|ebuild)$|(\.bash(rc|_aliases|_functions|_profile)|\.?profile|Pkgfile|pkgmk\.conf|rc\.conf|PKGBUILD|APKBUILD)$|bash-fc\.)'
+    filename: '(\.(sh|bash|ash|ebuild)$|(\.bash(rc|_aliases|_functions|_profile)|\.env(rc)?|\.?profile|Pkgfile|pkgmk\.conf|rc\.conf|PKGBUILD|APKBUILD)$|bash-fc\.)'
     header: "^#!.*/(env +)?(ba)?(a)?(mk)?sh( |$)"
 
 rules:

?

pbsds avatar Oct 24 '22 19:10 pbsds

I don't see why not leave it separate. The sh file seems to have more to it.

taconi avatar Mar 17 '24 01:03 taconi

.env files are just sourced into shell

pbsds avatar Mar 17 '24 02:03 pbsds

diff --git a/runtime/syntax/sh.yaml b/runtime/syntax/sh.yaml
index 329b1014..c87c243c 100644
--- a/runtime/syntax/sh.yaml
+++ b/runtime/syntax/sh.yaml
@@ -8,11 +8,12 @@ filetype: shell
 #
 # Special filenames:
 # * .bashrc, .bash_aliases, .bash_functions .bash_profile
+# * .env, .envrc (dotenv and direnv)
 # * profile, .profile (/etc/profile or ~/.profile)
 # * Pkgfile
 # * pkgmk.conf
@@ -23,7 +24,7 @@ filetype: shell
 # Fix command (fc) files:
 # * bash-fc. (followed by a random string)
 detect:
-    filename: '(\.(sh|bash|ash|ebuild)$|(\.bash(rc|_aliases|_functions|_profile)|\.?profile|Pkgfile|pkgmk\.conf|rc\.conf|PKGBUILD|APKBUILD)$|bash-fc\.)'
+    filename: '(\.(sh|bash|ash|ebuild)$|(\.bash(rc|_aliases|_functions|_profile)|\.env(rc)?|\.?profile|Pkgfile|pkgmk\.conf|rc\.conf|PKGBUILD|APKBUILD)$|bash-fc\.)'
     header: "^#!.*/(env +)?(ba)?(a)?(mk)?sh( |$)"
 
 rules:

?

@MavlinD What do you think? To me it makes sense and would be one less file. Would you just add \.env(rc)?| in the detect.filename of the sh.yaml file.

taconi avatar Mar 17 '24 02:03 taconi