mirror of
https://github.com/godotengine/emacs-gdscript-mode.git
synced 2026-01-04 18:09:55 +03:00
Added a command to insert a file path at point using Projectile.
Closes #36.
This commit is contained in:
@@ -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.3"))
|
||||
;; Package-Requires: ((emacs "26.3") (projectile "2.1.0"))
|
||||
;; Maintainer: nathan@gdquest.com
|
||||
;; Created: Feb 2020
|
||||
;; Keywords: languages
|
||||
@@ -33,6 +33,8 @@
|
||||
;;; Code:
|
||||
|
||||
(require 'gdscript-syntax)
|
||||
(require 'gdscript-utils)
|
||||
(require 'projectile)
|
||||
|
||||
(defvar-local gdscript-completion--all-keywords
|
||||
(eval-when-compile (append gdscript-keywords gdscript-built-in-classes
|
||||
@@ -48,6 +50,23 @@
|
||||
(list start end gdscript-completion--all-keywords
|
||||
. nil)))
|
||||
|
||||
(defun gdscript-completion-insert-file-path-at-point (&optional arg)
|
||||
"Insert a file path at point using Godot's relative path (\"res:\").
|
||||
|
||||
With a prefix ARG invalidates the cache first. If invoked outside
|
||||
of a project, displays a list of known projects to jump."
|
||||
(interactive "P")
|
||||
(projectile-maybe-invalidate-cache arg)
|
||||
(let* ((project-root (projectile-ensure-project (projectile-project-root)))
|
||||
(file (projectile-completing-read
|
||||
"Find file: "
|
||||
(projectile-project-files project-root))))
|
||||
(when file
|
||||
(insert
|
||||
(concat "\"res://"
|
||||
(gdscript-util--get-godot-project-file-path-relative file)
|
||||
"." (file-name-extension file) "\"")))))
|
||||
|
||||
(provide 'gdscript-completion)
|
||||
|
||||
;;; gdscript-completion.el ends here
|
||||
|
||||
Reference in New Issue
Block a user