Add custom/user-defined function highlighting to the default PHP.plist for e text editor


/ Published in: XML
Save to your folder(s)

This will highlight all functions not previously defined in PHP for the e text editor. They are assigned to the "entities" in the theme editor. By default, they are highlighted only when originally defined, but not when they are in use in your code; this fixes that. This also fixes the current setup to highlight numeric constants as such when used inside a custom function call or definition.


Copy this code and paste it in your HTML
  1. <!-- added after the definition for "language_constant" near the bottom -->
  2. <key>numeric_constant</key>
  3. <dict>
  4. <key>match</key>
  5. <string>([0-9]+)</string>
  6. <key>name</key>
  7. <string>constant.language.php</string>
  8. </dict>
  9.  
  10.  
  11. <!-- added as the last definition in the main "patterns" array -->
  12. <dict>
  13. <key>begin</key>
  14. <string>\b([0-9a-zA-Z_-]+)\s*\(</string>
  15. <key>beginCaptures</key>
  16. <dict>
  17. <key>1</key>
  18. <dict>
  19. <key>name</key>
  20. <string>entity.name.function.php</string>
  21. </dict>
  22. <key>2</key>
  23. <dict>
  24. <key>name</key>
  25. <string>punctuation.definition.parameters.begin.php</string>
  26. </dict>
  27. </dict>
  28. <key>end</key>
  29. <string>\)</string>
  30. <key>endCaptures</key>
  31. <dict>
  32. <key>1</key>
  33. <dict>
  34. <key>name</key>
  35. <string>punctuation.definition.parameters.end.php</string>
  36. </dict>
  37. </dict>
  38. <key>name</key>
  39. <string>meta.function.php</string>
  40. <key>patterns</key>
  41. <array>
  42. <dict>
  43. <key>include</key>
  44. <string>#string-double-quoted</string>
  45. </dict>
  46. <dict>
  47. <key>include</key>
  48. <string>#numeric_constant</string>
  49. </dict>
  50. <dict>
  51. <key>include</key>
  52. <string>#string-single-quoted</string>
  53. </dict>
  54. <dict>
  55. <key>include</key>
  56. <string>#string-backtick</string>
  57. </dict>
  58. <dict>
  59. <key>include</key>
  60. <string>#var_global</string>
  61. </dict>
  62. <dict>
  63. <key>include</key>
  64. <string>#var_global_safer</string>
  65. </dict>
  66. <dict>
  67. <key>include</key>
  68. <string>#var_basic</string>
  69. </dict>
  70. <dict>
  71. <key>include</key>
  72. <string>#language_constant</string>
  73. </dict>
  74. </array>
  75. </dict>
  76.  
  77.  
  78. <!-- added in the "patterns" array for the original function definition (near line 450 in the default PHP.plist -->
  79. <dict>
  80. <key>include</key>
  81. <string>#numeric_constant</string>
  82. </dict>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.