|
2 | 2 | ;; |
3 | 3 | ;; Version: 1.4 |
4 | 4 | ;; Keywords: languages, extensions |
| 5 | +;; Package-Requires: ((emacs "25.2") (lsp-mode "6.0") (dash "2.14.1")) |
5 | 6 | ;; URL: https://github.com/emacs-lsp/lsp-dart.el |
6 | 7 | ;; |
7 | 8 | ;; This program is free software; you can redistribute it and/or modify |
|
28 | 29 | (require 'lsp-mode) |
29 | 30 | (require 'lsp-dart-flutter-colors) |
30 | 31 |
|
31 | | -(defconst color-name-pattern "Colors\\.\\([][:word:]\\[\\.]+\\)") |
32 | | -(defconst color-hex-pattern "Color(0x\\(\\w\\{8\\}\\))") |
33 | | -(defconst color-argb-pattern "Color.fromARGB(\\(\\w+\\), \\(\\w+\\), \\(\\w+\\), \\(\\w+\\))") |
34 | | -(defconst color-rgbo-pattern "Color.fromRGBO(\\(\\w+\\), \\(\\w+\\), \\(\\w+\\), \\([0-9.]+\\))") |
| 32 | +(defconst lsp-dart-fringe-color-name-pattern "Colors\\.\\([][:word:]\\[\\.]+\\)") |
| 33 | +(defconst lsp-dart-fringe-color-hex-pattern "Color(0x\\(\\w\\{8\\}\\))") |
| 34 | +(defconst lsp-dart-fringe-color-argb-pattern "Color.fromARGB(\\(\\w+\\), \\(\\w+\\), \\(\\w+\\), \\(\\w+\\))") |
| 35 | +(defconst lsp-dart-fringe-color-rgbo-pattern "Color.fromRGBO(\\(\\w+\\), \\(\\w+\\), \\(\\w+\\), \\([0-9.]+\\))") |
35 | 36 |
|
36 | 37 | (defcustom lsp-dart-fringe-colors t |
37 | 38 | "Enable the color overlays on fringe." |
|
73 | 74 | (remove-overlays (point-min) (point-max) 'lsp-dart-fringe-colors t) |
74 | 75 | (save-excursion |
75 | 76 | (goto-char (point-min)) |
76 | | - (while (re-search-forward color-name-pattern nil t) |
| 77 | + (while (re-search-forward lsp-dart-fringe-color-name-pattern nil t) |
77 | 78 | (let ((color (concat "#" (-> (match-string 1) |
78 | 79 | (assoc lsp-dart-flutter-colors) |
79 | 80 | cdr)))) |
80 | 81 | (lsp-dart-fringe--add-color color buffer (point-at-bol)))) |
81 | 82 | (goto-char (point-min)) |
82 | | - (while (re-search-forward color-hex-pattern nil t) |
| 83 | + (while (re-search-forward lsp-dart-fringe-color-hex-pattern nil t) |
83 | 84 | (let ((color (concat "#" (substring (match-string 1) 2)))) |
84 | 85 | (lsp-dart-fringe--add-color color buffer (point-at-bol)))) |
85 | 86 | (goto-char (point-min)) |
86 | | - (while (re-search-forward color-argb-pattern nil t) |
| 87 | + (while (re-search-forward lsp-dart-fringe-color-argb-pattern nil t) |
87 | 88 | (let ((color (lsp-dart-fringe--rgb-to-hex (match-string 2) |
88 | 89 | (match-string 3) |
89 | 90 | (match-string 4)))) |
90 | 91 | (lsp-dart-fringe--add-color color buffer (point-at-bol)))) |
91 | 92 | (goto-char (point-min)) |
92 | | - (while (re-search-forward color-rgbo-pattern nil t) |
| 93 | + (while (re-search-forward lsp-dart-fringe-color-rgbo-pattern nil t) |
93 | 94 | (let ((color (lsp-dart-fringe--rgb-to-hex (match-string 1) |
94 | 95 | (match-string 2) |
95 | 96 | (match-string 3)))) |
|
0 commit comments