7 Commits

Author SHA1 Message Date
Nathan Lovato
361439f28b Update CHANGELOG with 1.0.2 release notes 2020-02-17 10:42:56 -06:00
Nathan Lovato
3c5e31bfe3 Address package-lint warnings and errors
See #4
2020-02-17 10:34:32 -06:00
Nathan Lovato
dfe2cd922e Update documentation using checkdoc
Preparing for the MELPA release.

See #4
2020-02-17 09:43:49 -06:00
Nathan Lovato
f17c6a7418 Format code in gdscript-completion 2020-02-17 07:37:26 -06:00
Nathan Lovato
68be13a965 Refactor gdscript-syntax to use a let construct 2020-02-17 07:36:55 -06:00
Nathan Lovato
c633a6f4d1 Refactor rx code to fix import error with gdscript-rx macro 2020-02-17 07:36:34 -06:00
Nathan Lovato
92a1087a30 Compile keywords in the language 2020-02-16 07:32:50 -06:00
12 changed files with 1580 additions and 1523 deletions

View File

@@ -2,6 +2,29 @@
This document lists new features, improvements, changes, and bug fixes in each release of the package.
## GDScript mode 1.0.2 ##
### Changes ###
- Addressed linting and checkdoc errors for a release on the [MELPA](https://melpa.org/) package archive.
- Split some more of the code to make the code easier to read and to maintain.
### Bug fixes ###
- Fixed `function-definition-void` errors in some cases due to a missing file import.
## GDScript mode 1.0.1 ##
This minor release fixes a bug with the GDScript keywords.
### Improvements ###
- Compile keywords for faster auto-completion and syntax highlighting.
### Bug fixes ###
- Fixed missing language keywords and constants lists.
## GDScript mode 1.0.0 ##
This is the initial release of gdscript-mode, which adds support for the [Godot engine](https://godotengine.org/)'s GDScript programming language in Emacs.

1424
emacs-rx.el Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,7 @@
;; Author: Nathan Lovato <nathan@gdquest.com>, Fabián E. Gallina <fgallina@gnu.org>
;; URL: https://github.com/GDQuest/emacs-gdscript-mode/
;; Version: 0.1.0
;; Package-Requires: ((emacs "26.0"))
;; Package-Requires: ((emacs "26.3"))
;; Maintainer: nathan@gdquest.com
;; Created: Feb 2020
;; Keywords: languages
@@ -34,7 +34,10 @@
(require 'gdscript-syntax)
(defvar-local gdscript-completion--all-keywords (append gdscript-keywords gdscript-built-in-classes gdscript-built-in-constants gdscript-built-in-functions gdscript-built-in-types))
(defvar-local gdscript-completion--all-keywords
(eval-when-compile (append gdscript-keywords gdscript-built-in-classes
gdscript-built-in-constants gdscript-built-in-functions
gdscript-built-in-types)))
(defun gdscript-completion-at-point ()
"This is the function to be used for the hook `completion-at-point-functions'."

View File

@@ -5,7 +5,7 @@
;; Author: Nathan Lovato <nathan@gdquest.com>
;; URL: https://github.com/GDQuest/emacs-gdscript-mode/
;; Version: 0.1.0
;; Package-Requires: ((emacs "26.0"))
;; Package-Requires: ((emacs "26.3"))
;; Maintainer: nathan@gdquest.com
;; Created: Jan 2020
;; Keywords: languages

View File

@@ -5,7 +5,7 @@
;; Author: Nathan Lovato <nathan@gdquest.com>
;; URL: https://github.com/GDQuest/emacs-gdscript-mode/
;; Version: 0.1.0
;; Package-Requires: ((emacs "26.0"))
;; Package-Requires: ((emacs "26.3"))
;; Maintainer: nathan@gdquest.com
;; Created: Jan 2020
;; Keywords: languages
@@ -35,6 +35,7 @@
(require 'gdscript-customization)
(require 'gdscript-indent-and-nav)
(require 'gdscript-rx)
;; NOTE: this and the fill docstring function can be simplified. They're
;; originally from the Python package, which supports multiple docstrings fill

View File

@@ -5,7 +5,7 @@
;; Author: Pawel Lampe <pawel.lampe@gmail.com>, Nathan Lovato <nathan@gdquest.com>
;; URL: https://github.com/GDQuest/emacs-gdscript-mode/
;; Version: 1.0.0
;; Package-Requires: ((emacs "26.0"))
;; Package-Requires: ((emacs "26.3"))
;; Maintainer: nathan@gdquest.com
;; Created: Feb 2020
;; Keywords: languages
@@ -32,7 +32,10 @@
;;; Code:
(defun gdscript-format--run-gdformat (buffer-input buffer-output buffer-error)
"Call gdformat process."
"Call gdformat process.
Argument BUFFER-INPUT reference to the input buffer to format.
Argument BUFFER-OUTPUT the buffer to write the output of the gdformat call.
Argument BUFFER-ERROR the buffer to write errors to."
(with-current-buffer buffer-input
(let ((process (make-process :name "gdformat"
:command (list "gdformat" "-"):buffer

View File

@@ -5,7 +5,7 @@
;; Author: Nathan Lovato <nathan@gdquest.com>, Fabián E. Gallina <fgallina@gnu.org>
;; URL: https://github.com/GDQuest/emacs-gdscript-mode/
;; Version: 1.0.0
;; Package-Requires: ((emacs "26.0"))
;; Package-Requires: ((emacs "26.3"))
;; Maintainer: nathan@gdquest.com
;; Created: Feb 2020
;; Keywords: languages

View File

@@ -1,11 +1,11 @@
;;; gdscript-syntax.el --- Syntax highlighting for GDScript -*- lexical-binding: t; -*-
;;; gdscript-indent-and-nav.el --- Syntax highlighting for GDScript -*- lexical-binding: t; -*-
;; Copyright (C) 2020 GDQuest, Free Software Foundation, Inc.
;; Author: Nathan Lovato <nathan@gdquest.com>, Fabián E. Gallina <fgallina@gnu.org>
;; URL: https://github.com/GDQuest/emacs-gdscript-mode/
;; Version: 1.0.0
;; Package-Requires: ((emacs "26.0"))
;; Package-Requires: ((emacs "26.3"))
;; Maintainer: nathan@gdquest.com
;; Created: Feb 2020
;; Keywords: languages
@@ -26,11 +26,17 @@
;;; Commentary:
;; Sets up the syntax table and font-faces for GDScript.
;; Functions copies from Emacs 27's built-in python.el to handle indents,
;; querying info about the language's symbols or the context at point, and for
;; navigation.
;; There are dependencies between the *indent*, *info*, and *nav* functions that prevent us from splitting them into separate .el files at the moment.
;;; Code:
(require 'gdscript-utils)
(require 'gdscript-rx)
(require 'gdscript-syntax)
(require 'cl-lib)
;;; Indentation
@@ -774,7 +780,7 @@ With optional argument LINE-NUMBER, check that line instead."
(point-marker))))
(defun gdscript-info-beginning-of-backslash (&optional line-number)
"Return the point where the backslashed line starts.
"Return the point where the backslashed line start.
Optional argument LINE-NUMBER forces the line number to check against."
(save-excursion
(when line-number
@@ -1447,29 +1453,6 @@ This command assumes point is not in a string or comment."
(or arg (setq arg 1))
(gdscript-nav-up-list (- arg)))
(defun gdscript-nav-if-name-main ()
"Move point at the beginning the __main__ block.
When \"if __name__ == \\='__main__\\=':\" is found returns its
position, else returns nil."
(interactive)
(let ((point (point))
(found (catch 'found
(goto-char (point-min))
(while (re-search-forward
(gdscript-rx line-start
"if" (+ space)
"__name__" (+ space)
"==" (+ space)
(group-n 1 (or ?\" ?\'))
"__main__" (backref 1) (* space) ":")
nil t)
(when (not (gdscript-syntax-context-type))
(beginning-of-line)
(throw 'found t))))))
(if found
(point)
(ignore (goto-char point)))))
(provide 'gdscript-indent-and-nav)
;;; gdscript-indent-and-nav.el ends here

View File

@@ -5,7 +5,7 @@
;; Author: Nathan Lovato <nathan@gdquest.com>, Fabián E. Gallina <fgallina@gnu.org>
;; URL: https://github.com/GDQuest/emacs-gdscript-mode/
;; Version: 0.1.0
;; Package-Requires: ((emacs "26.0"))
;; Package-Requires: ((emacs "26.3"))
;; Maintainer: nathan@gdquest.com
;; Created: Jan 2020
;; Keywords: languages
@@ -36,11 +36,8 @@
(require 'gdscript-imenu)
(require 'gdscript-fill-paragraph)
(require 'gdscript-completion)
;; gdscript-rx is a copy of Emacs 27's rx module, to ensure compatibility with
;; Emacs 26
(if (version< emacs-version "27")
(require 'gdscript-rx))
(require 'gdscript-format)
(require 'gdscript-rx)
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.gd\\'" . gdscript-mode))
@@ -59,53 +56,12 @@
;; Indent specific
(define-key map "\177" 'gdscript-indent-dedent-line-backspace)
(define-key map (kbd "<backtab>") 'gdscript-indent-dedent-line)
(define-key map (kbd "\t") 'company-complete)
map)
"Keymap for `gdscript-mode'.")
;;; GDScript regex
(defmacro gdscript-rx (&rest regexps)
"Gdscript mode specialized rx macro.
This variant of `rx' supports common Gdscript named REGEXPS."
`(rx-let ((block-start (seq symbol-start
(or "func" "static" "class" "if" "elif" "else"
"for" "while" "match")
symbol-end))
(dedenter (seq symbol-start
(or "elif" "else")
symbol-end))
(block-ender (seq symbol-start
(or "break" "continue" "pass" "return")
symbol-end))
(defun (seq symbol-start
(or "func" "class" "static func")
symbol-end))
(symbol-name (seq (any letter ?_) (* (any word ?_))))
(open-paren (or "{" "[" "("))
(close-paren (or "}" "]" ")"))
(simple-operator (any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%))
(not-simple-operator (not simple-operator))
;; TODO: clean up operators that don't exist in GDScript
(operator (or "==" ">=" "is" "not"
"**" "//" "<<" ">>" "<=" "!="
"+" "-" "/" "&" "^" "~" "|" "*" "<" ">"
"=" "%"))
(assignment-operator (or "+=" "-=" "*=" "/=" "//=" "%=" "**="
">>=" "<<=" "&=" "^=" "|="
"="))
(string-delimiter (seq
;; Match even number of backslashes.
(or (not (any ?\\ ?\' ?\")) point
;; Quotes might be preceded by an
;; escaped quote.
(and (or (not (any ?\\)) point) ?\\
(* ?\\ ?\\) (any ?\' ?\")))
(* ?\\ ?\\)
;; Match single or triple quotes of any kind.
(group (or "\"\"\"" "\"" "'''" "'")))))
(rx ,@regexps)))
(defun gdscript-hideshow-forward-sexp-function (_arg)
"Gdscript specific `forward-sexp' function for `hs-minor-mode'.
"Gdscript specific `forward-sexp' function for function `hs-minor-mode'.
Argument ARG is ignored."
(gdscript-nav-end-of-defun)
(unless (gdscript-info-current-line-empty-p)

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,7 @@
;; Author: Nathan Lovato <nathan@gdquest.com>, Fabián E. Gallina <fgallina@gnu.org>
;; URL: https://github.com/GDQuest/emacs-gdscript-mode/
;; Version: 1.0.0
;; Package-Requires: ((emacs "26.0"))
;; Package-Requires: ((emacs "26.3"))
;; Maintainer: nathan@gdquest.com
;; Created: Feb 2020
;; Keywords: languages
@@ -30,7 +30,7 @@
;;; Code:
(defun gdscript--get-package-file-content-as-string (file-path-relative)
(defun gdscript--get-file-content-as-string (file-path-relative)
"Returns the content of a file in this package as a list of
strings. Used to retrieve lists of keywords for syntax
highlighting.
@@ -40,22 +40,27 @@ file without the directory path. This is for compatibility with
the Doom Emacs distribution, which flattens the package's
structure."
(with-temp-buffer
(setq this-directory (file-name-directory (or load-file-name buffer-file-name)))
(setq requested-path (concat this-directory file-path-relative))
(setq file-path (if (file-readable-p requested-path)
requested-path
(concat this-directory
(file-name-nondirectory file-path-relative))))
(insert-file-contents file-path)
(split-string (buffer-string)
"\n"
t)))
(let (this-directory requested-path file-path)
(setq this-directory (file-name-directory "gdscript-mode.el"))
(setq requested-path (concat this-directory file-path-relative))
(setq file-path (if (file-readable-p requested-path)
requested-path
(concat this-directory
(file-name-nondirectory file-path-relative))))
(insert-file-contents file-path)
(split-string (buffer-string)
"\n"
t))))
(defconst gdscript-keywords (eval-when-compile (gdscript--get-file-content-as-string "data/keywords.txt")))
(defconst gdscript-built-in-constants (eval-when-compile (gdscript--get-file-content-as-string "data/built-in-constants.txt")))
;; Only contains types that are not classes and that the Godot editor highlights
;; like built-in keywords
(defconst gdscript-built-in-types (gdscript--get-package-file-content-as-string "data/built-in-types.txt"))
(defconst gdscript-built-in-functions (gdscript--get-package-file-content-as-string "data/built-in-functions.txt"))
(defconst gdscript-built-in-types (eval-when-compile (gdscript--get-file-content-as-string "data/built-in-types.txt")))
(defconst gdscript-built-in-functions (eval-when-compile (gdscript--get-file-content-as-string "data/built-in-functions.txt")))
;; Contains all engine classes and node types, including vectors, transforms, etc.
(defconst gdscript-built-in-classes (gdscript--get-package-file-content-as-string "data/built-in-classes.txt"))
(defconst gdscript-built-in-classes (eval-when-compile (gdscript--get-file-content-as-string "data/built-in-classes.txt")))
(defun regex-maker (words)
(regexp-opt words 'symbols))

View File

@@ -5,7 +5,7 @@
;; Author: Nathan Lovato <nathan@gdquest.com>, Fabián E. Gallina <fgallina@gnu.org>
;; URL: https://github.com/GDQuest/emacs-gdscript-mode/
;; Version: 0.1.0
;; Package-Requires: ((emacs "26.0"))
;; Package-Requires: ((emacs "26.3"))
;; Maintainer: nathan@gdquest.com
;; Created: Jan 2020
;; Keywords: languages