language_python.lua 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. local syntax = require "core.syntax"
  2. syntax.add {
  3. files = "%.py$",
  4. comment = "#",
  5. patterns = {
  6. { pattern = { "#", "\n" }, type = "comment" },
  7. { pattern = { '[ruU]?"', '"', '\\' }, type = "string" },
  8. { pattern = { "[ruU]?'", "'", '\\' }, type = "string" },
  9. { pattern = { '"""', '"""' }, type = "string" },
  10. { pattern = "0x[%da-fA-F]+", type = "number" },
  11. { pattern = "-?%d+[%d%.eE]*", type = "number" },
  12. { pattern = "-?%.?%d+", type = "number" },
  13. { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
  14. { pattern = "[%a_][%w_]*%f[(]", type = "function" },
  15. { pattern = "[%a_][%w_]*", type = "symbol" },
  16. },
  17. symbols = {
  18. ["class"] = "keyword",
  19. ["finally"] = "keyword",
  20. ["is"] = "keyword",
  21. ["return"] = "keyword",
  22. ["continue"] = "keyword",
  23. ["for"] = "keyword",
  24. ["lambda"] = "keyword",
  25. ["try"] = "keyword",
  26. ["def"] = "keyword",
  27. ["from"] = "keyword",
  28. ["nonlocal"] = "keyword",
  29. ["while"] = "keyword",
  30. ["and"] = "keyword",
  31. ["global"] = "keyword",
  32. ["not"] = "keyword",
  33. ["with"] = "keyword",
  34. ["as"] = "keyword",
  35. ["elif"] = "keyword",
  36. ["if"] = "keyword",
  37. ["or"] = "keyword",
  38. ["else"] = "keyword",
  39. ["import"] = "keyword",
  40. ["pass"] = "keyword",
  41. ["break"] = "keyword",
  42. ["except"] = "keyword",
  43. ["in"] = "keyword",
  44. ["del"] = "keyword",
  45. ["raise"] = "keyword",
  46. ["yield"] = "keyword",
  47. ["assert"] = "keyword",
  48. ["self"] = "keyword2",
  49. ["None"] = "literal",
  50. ["True"] = "literal",
  51. ["False"] = "literal",
  52. }
  53. }