|
31 | 31 |
|
32 | 32 | ;;; Code: |
33 | 33 |
|
| 34 | +(require 'rx) |
| 35 | + |
34 | 36 | (defgroup gptscript-mode nil |
35 | 37 | "Major mode for editing GPTScript natural language." |
36 | 38 | :prefix "gptscript-mode-" |
37 | 39 | :group 'comm |
38 | 40 | :link '(url-link :tag "Repository" "https://github.com/emacs-openai/gptscript-mode")) |
39 | 41 |
|
| 42 | +(defvar gptscript-mode-syntax-table |
| 43 | + (let ((table (make-syntax-table))) |
| 44 | + table) |
| 45 | + "Syntax table for GPTScript file.") |
| 46 | + |
40 | 47 | (defface gptscript-mode-symbol-face |
41 | | - '((t :inherit font-lock-constant-face)) |
| 48 | + '((t :inherit font-lock-builtin-face)) |
42 | 49 | "Face for highlighting symbols in GPTScript files." |
43 | 50 | :group 'gptscript-mode) |
44 | 51 |
|
|
48 | 55 | "List of parameters name.") |
49 | 56 |
|
50 | 57 | (defconst gptscript-mode-font-lock-keywords |
51 | | - `((,(regexp-opt |
52 | | - gptscript-mode-parameters |
53 | | - 'symbols) |
| 58 | + `((,(regexp-opt gptscript-mode-parameters 'symbols) |
54 | 59 | . gptscript-mode-symbol-face)) |
55 | 60 | "Keywords in GPTScript file.") |
56 | 61 |
|
57 | 62 | ;;;###autoload |
58 | 63 | (define-derived-mode gptscript-mode text-mode "GPTScript" |
59 | 64 | "Major mode for editing GPTScript files." |
| 65 | + :syntax-table gptscript-mode-syntax-table |
60 | 66 | (font-lock-add-keywords 'gptscript-mode gptscript-mode-font-lock-keywords)) |
61 | 67 |
|
62 | 68 | ;;;###autoload |
63 | 69 | (add-to-list 'auto-mode-alist '("\\.gpt\\'" . gptscript-mode)) |
64 | 70 |
|
| 71 | +(with-eval-after-load 'company-keywords |
| 72 | + (add-to-list 'company-keywords-alist |
| 73 | + `(gptscript-mode . ,gptscript-mode-parameters))) |
| 74 | + |
65 | 75 | (provide 'gptscript-mode) |
66 | 76 | ;;; gptscript-mode.el ends here |
0 commit comments