29 Commits

Author SHA1 Message Date
Jen-Chieh Shen
79739fc80f Merge pull request #175 from godotengine/dependabot/github_actions/actions/checkout-6 2025-11-22 01:07:30 +08:00
dependabot[bot]
9822c8a921 Bump actions/checkout from 5 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-21 14:17:02 +00:00
Jen-Chieh Shen
e94dfd9dc7 Merge pull request #173 from Passky/master 2025-11-04 22:37:10 +08:00
passky
e3b47496a3 fix: add default value for eglot lsp port extraction as fallback
See #169:
"network/language_server/remote_port" only presents in settings file when it has been modified from the default value from later version of godot.
So it always fail to extraction and return nothing,we can fix that by add a default value.
Also: bump gdscript-eglot-version to 4.5
2025-10-05 00:37:41 +08:00
Jen-Chieh Shen
bd0a741066 ci: Bump Emacs 30 minor version to 2 (#172) 2025-09-18 12:58:05 +02:00
Jen-Chieh Shen
a0d25b46d8 Merge pull request #171 from godotengine/dependabot/github_actions/actions/checkout-5 2025-08-12 20:16:39 -07:00
dependabot[bot]
2afbcecdd2 Bump actions/checkout from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-12 21:05:22 +00:00
Jen-Chieh Shen
5136be407a fix: Warning missing lexical-binding cookie (#167) 2025-04-23 11:21:59 +02:00
Alexandr Semenov
1938aa7e2d Improve gdscript-ts-mode highlighting with (#165)
* Added class_name highlighting
* Simplified keyword highlighting
* Added missing for/in keywords
* Added builtin types support
* Fixed class_definition face; treat preload() as builtin
* Fixed int/bool/float/void not being treated as builtin types
* Fixed escape sequences highlighting
2025-04-20 16:18:34 +02:00
Jen-Chieh Shen
3f3739dd88 Merge pull request #164 from nyxkn/patch-1 2025-03-31 23:33:38 -07:00
nyxkn
17c270190b Update README.md
Fix extra c in `scanner.c`
It also seems I need to add `-I./` to avoid:
```
scanner.c:5:10: fatal error: tree_sitter/parser.h: No such file or directory
    5 | #include <tree_sitter/parser.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
```
2025-04-01 07:16:48 +01:00
Jen-Chieh Shen
e18cf2cea3 Merge pull request #163 from godotengine/dependabot/github_actions/actions/checkout-4 2025-02-25 13:20:38 -08:00
dependabot[bot]
f195ca86f8 Bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-25 20:42:03 +00:00
Nathan Lovato
703c776260 Merge pull request #160 from jcs-PR/ci/depbot
ci: Add dependabot.yml
2025-02-25 21:41:26 +01:00
Nathan Lovato
d83b971e20 Merge pull request #162 from godotengine/ci/30.1
ci: Test Emacs 30.1
2025-02-25 21:33:33 +01:00
Jen-Chieh Shen
208e231138 ci: Test Emacs 30.1 2025-02-24 15:05:33 -08:00
Jen-Chieh Shen
707e77ded3 ci: Add dependabot.yml 2025-01-09 12:43:32 -08:00
xiliuya
c3d9988984 Merge pull request #158 from katomuso/refactor-gdscript-eglot-contact
Refactor gdscript-eglot-contact
2024-12-07 14:10:35 +08:00
Kato Muso
f320e02427 Add docstring for gdscript-eglot--extract-port function 2024-12-06 23:40:53 +00:00
Kato Muso
88f6bca508 Add docstring for gdscript-eglot--get-config-dir function 2024-12-06 23:40:11 +00:00
Kato Muso
686feebf2d Add gdscript-eglot--extract-port function 2024-11-05 07:15:28 +00:00
Kato Muso
f8fce3ad1a Add gdscript-eglot--get-config-dir function 2024-11-05 07:15:21 +00:00
Kato Muso
3052839d71 Refactor gdscript-eglot-contact 2024-11-04 09:28:33 +00:00
Nathan Lovato
bee7f99c6f Merge pull request #156 from katomuso/fix-config-dir
Fix config directory in gdscript-eglot-contact
2024-11-04 09:21:14 +01:00
Kato Muso
d1076e1b59 Fix config directory in gdscript-eglot-contact 2024-11-03 21:44:41 +00:00
Nathan Lovato
52b3637df8 Merge pull request #155 from katomuso/tweak-gdscript-eglot-version
Change gdscript-eglot-version type to be string instead of integer
2024-11-02 11:10:57 +01:00
Kato Muso
21be7cd6d3 Bump gdscript-eglot-version to 4.3 2024-11-02 06:59:41 +00:00
Kato Muso
b03647b62e Change gdscript-eglot-version type to be string instead of integer 2024-11-02 06:57:58 +00:00
Nathan Lovato
e0c8700d25 Merge pull request #153 from godotengine/jcs090218-patch-1
ci: Test Emacs 29.4
2024-09-17 08:58:08 +02:00
6 changed files with 132 additions and 55 deletions

6
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily

View File

@@ -23,6 +23,7 @@ jobs:
- 27.2
- 28.2
- 29.4
- 30.2
experimental: [false]
include:
- os: ubuntu-latest
@@ -41,7 +42,7 @@ jobs:
emacs-version: 27.2
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- uses: jcs090218/setup-emacs@master
with:

2
Eask
View File

@@ -1,3 +1,5 @@
;; -*- mode: eask; lexical-binding: t -*-
(package "gdscript-mode"
"0.1.0"
"Major mode for Godot's GDScript language")

View File

@@ -231,7 +231,7 @@ To support Gdscript, we must install [gdscript-grammar](https://github.com/Prest
git clone https://github.com/PrestonKnopp/tree-sitter-gdscript.git
cd tree-sitter-gdscript/src
cc -std=c99 -c parser.c
cc -c scanner.cc
cc -c scanner.c -I./
cc -shared parser.o scanner.o -o libtree-sitter-gdscript.so
```

View File

@@ -38,9 +38,41 @@
:group 'gdscript)
;;;###autoload
(defcustom gdscript-eglot-version 4
(defcustom gdscript-eglot-version "4.5"
"The version of godot in use."
:type 'integer)
:type 'string)
;;;###autoload
(defcustom gdscript-eglot-default-lsp-port 6005
"The default port for eglot to connect when extraction fails."
:type 'integer
:group 'gdscript-eglot)
(defun gdscript-eglot--get-config-dir ()
"Get system-specific directory with Godot configuration files."
(pcase system-type
('darwin (expand-file-name "~/Library/Application Support/Godot/"))
('windows-nt (file-name-concat (getenv "APPDATA") "Godot"))
('gnu/linux (file-name-concat
(or (getenv "XDG_CONFIG_HOME") (expand-file-name "~/.config"))
"godot"))))
(defun gdscript-eglot--extract-port (editor-settings-file)
"Extract LSP port from Godot EDITOR-SETTINGS-FILE.
If extraction fails, return `gdscript-eglot-default-port'.
NOTE: remote_port value only presents if it has been modified from the default value,
So this extract shall fail by default."
(or
(when (file-exists-p editor-settings-file)
(with-temp-buffer
(insert-file-contents editor-settings-file)
(when (re-search-forward
(rx "network/language_server/remote_port"
(* space) ?= (* space)
(group (+ digit)))
nil t)
(string-to-number (match-string 1)))))
gdscript-eglot-default-lsp-port))
;;;###autoload
(defun gdscript-eglot-contact (_interactive)
@@ -52,30 +84,12 @@ definitions of HOST, PORT, and INTERACTIVE.
For more context, see
https://lists.gnu.org/archive/html/bug-gnu-emacs/2023-04/msg01070.html."
(save-excursion
(let* ((cfg-dir (or (getenv "XDG_CONFIG_HOME")
(pcase system-type
('darwin "~/Library/Application Support/Godot/")
('windows-nt "%APPDATA%\\Godot\\")
('gnu/linux "~/.config/"))))
(cfg-buffer
(find-file-noselect
(expand-file-name
(format "godot/editor_settings-%d.tres"
gdscript-eglot-version)
cfg-dir)))
(port
(with-current-buffer cfg-buffer
(goto-char 0)
(and
(re-search-forward
(rx "network/language_server/remote_port"
(* space) ?= (* space)
(group (+ digit)))
nil t)
(string-to-number (match-string 1))))))
(kill-buffer cfg-buffer)
;; then return the host-port list when found
(and port (list "localhost" port)))))
(let* ((config-dir (gdscript-eglot--get-config-dir))
(settings-file (file-name-concat
config-dir
(format "editor_settings-%s.tres" gdscript-eglot-version))))
(when-let* ((port (gdscript-eglot--extract-port settings-file)))
(list "localhost" port)))))
(provide 'gdscript-eglot)
;;; gdscript-eglot.el ends here.

View File

@@ -68,64 +68,121 @@ It must be a function with two arguments: TYPE and NAME.")
(if (string= type "class")
"*class definition*"
"*function definition*"))
;;; Keywords
(defvar gdscript-ts--treesit-keywords '("and" "as" "break" "class" "class_name"
"const" "continue" "elif" "else" "enum" "export" "extends" "for" "func" "if" "in" "is"
"master" "match" "not" "onready" "or" "pass" "puppet" "remote" "remotesync" "return" "setget" "signal"
"var" "while"))
(defvar gdscript-ts--keyword-regex
(rx bot (| "func" "var" "const" "set" "get" "setget" "signal" "extends"
"match" "if" "elif" "else" "for" "in" "while" "break" "continue"
"pass" "return" "when" "yield" "await"
"class" "class_name" "abstract" "is" "onready" "tool" "static"
"export" "as" "void" "enum" "assert" "breakpoint"
"sync" "remote" "master" "puppet"
"remotesync" "mastersync" "puppetsync"
"trait" "namespace" "super"
"and" "or" "not"
"await" "yield" "self") eot))
;;; Types
(defvar gdscript-ts--builtin-type-regex
"\\`\\(int\\|bool\\|float\\|void\\|Vector2\\|Vector2i\\|Vector3\\|Vector3i\\|Vector4\\|Vector4i\\|Color\\|Rect2\\|Rect2i\\|Array\\|Basis\\|Dictionary\\|Plane\\|Quat\\|RID\\|Rect3\\|Transform\\|Transform2D\\|Transform3D\\|AABB\\|String\\|Color\\|NodePath\\|PoolByteArray\\|PoolIntArray\\|PoolRealArray\\|PoolStringArray\\|PoolVector2Array\\|PoolVector3Array\\|PoolColorArray\\|bool\\|int\\|float\\|Signal\\|Callable\\|StringName\\|Quaternion\\|Projection\\|PackedByteArray\\|PackedInt32Array\\|PackedInt64Array\\|PackedFloat32Array\\|PackedFloat64Array\\|PackedStringArray\\|PackedVector2Array\\|PackedVector2iArray\\|PackedVector3Array\\|PackedVector3iArray\\|PackedVector4Array\\|PackedColorArray\\|JSON\\|UPNP\\|OS\\|IP\\|JSONRPC\\|XRVRS\\)\\'")
(defvar gdscript-ts--type-regex
"\\`[A-Z][a-zA-Z0-9_]*[a-z][a-zA-Z0-9_]*\\'")
;;; Constants
(defvar gdscript-ts--constant-regex "\\`[A-Z_][A-Z0-9_]+\\'")
;;; Setting
(defvar gdscript-ts--feature-list
'(( comment definition)
( keyword string type annotation)
( number constant escape-sequence)
( bracket delimiter function operator property)))
(defvar gdscript-ts--treesit-settings
(treesit-font-lock-rules
:language 'gdscript
:feature 'comment
'((comment) @font-lock-comment-face)
:language 'gdscript
:feature 'constant
`(([(null) (false) (true)] @font-lock-constant-face)
(const_statement name: (name) @font-lock-constant-face)
(enumerator left: (identifier) @font-lock-constant-face)
((identifier) @font-lock-constant-face
(:match ,gdscript-ts--constant-regex @font-lock-constant-face))
(variable_statement
name: (name) @font-lock-constant-face
(:match ,gdscript-ts--constant-regex @font-lock-constant-face)))
:language 'gdscript
:feature 'bracket
`(["[" "]" "(" ")" "{" "}"] @font-lock-bracket-face)
:language 'gdscript
:feature 'delimiter
`(["," ":" "."] @font-lock-delimiter-face)
:language 'gdscript
:feature 'type
`(((identifier) @font-lock-builtin-face
(:match ,gdscript-ts--builtin-type-regex @font-lock-builtin-face))
(get_node) @font-lock-builtin-face
((identifier) @font-lock-type-face
(:match ,gdscript-ts--type-regex @font-lock-type-face))
(enum_definition name: (_) @font-lock-type-face)
(class_name_statement (name) @font-lock-type-face)
(class_definition (name) @font-lock-type-face))
:language 'gdscript
:feature 'definition
'((function_definition (name) @font-lock-function-name-face)
(class_definition
(name) @font-lock-function-name-face)
(parameters (identifier) @font-lock-variable-name-face))
'((function_definition (name) @font-lock-function-name-face))
:language 'gdscript
:feature 'annotation
'((annotation "@" @font-lock-preprocessor-face
(identifier) @font-lock-preprocessor-face))
:language 'gdscript
:feature 'keyword
`(([,@gdscript-ts--treesit-keywords] @font-lock-keyword-face)
([(false) (true)] @font-lock-keyword-face))
`((ERROR _ @font-lock-keyword-face (:match ,gdscript-ts--keyword-regex @font-lock-keyword-face))
(_ _ @font-lock-keyword-face (:match ,gdscript-ts--keyword-regex @font-lock-keyword-face)))
:language 'gdscript
:feature 'string
'((string) @font-lock-string-face)
:language 'gdscript
:feature 'type
'(((type) @font-lock-type-face)
(get_node) @font-lock-type-face)
:feature 'function
:language 'gdscript
'((call (identifier) @font-lock-function-call-face)
'((call (identifier) @font-lock-builtin-face (:match "preload" @font-lock-builtin-face))
(call (identifier) @font-lock-function-call-face)
(attribute_call (identifier) @font-lock-function-call-face))
:language 'gdscript
:feature 'variable
'((_ (name) @font-lock-variable-name-face))
:feature 'number
:language 'gdscript
'(([(integer) (float)] @font-lock-number-face))
:feature 'property
:language 'gdscript
:feature 'property
'((attribute (identifier) (identifier) @font-lock-property-use-face))
:feature 'operator
:language 'gdscript
`(["+" "-" "*" "/" "^" ">" "<" "="] @font-lock-operator-face)))
`(["+" "+=" "-" "-=" "*" "*=" "/" "/=" "^" "^=" ">" ">="
"<" "<=" "|" "|=" "%" "%=" "&" "&=" ">>" ">>=" "<<" "<<="
"||" "&&" "==" "!=" "->" "~" "=" ":="]
@font-lock-operator-face)
:language 'gdscript
:override t
:feature 'escape-sequence
'((escape_sequence) @font-lock-escape-face)))
;;; Funtion
@@ -220,10 +277,7 @@ Similar to `gdscript-imenu-create-index' but use tree-sitter."
:syntax-table gdscript-mode-syntax-table
(when (treesit-ready-p 'gdscript)
(treesit-parser-create 'gdscript)
(setq-local treesit-font-lock-feature-list
'(( comment definition)
( keyword string type)
( function variable number property operator)))
(setq-local treesit-font-lock-feature-list gdscript-ts--feature-list)
(setq-local treesit-font-lock-settings gdscript-ts--treesit-settings)
;;; TODO: create-imenu
(setq-local imenu-create-index-function