godotengine / emacs-gdscript-mode Goto Github PK
View Code? Open in Web Editor NEWAn Emacs package to get GDScript support and syntax highlighting.
License: GNU General Public License v3.0
An Emacs package to get GDScript support and syntax highlighting.
License: GNU General Public License v3.0
Match blocks are a special case when it comes to indents, as they have nested blocks with the patterns, e.g. below, Events.UpgradeChoices.HEALTH:
:
func _on_Upgrade_Choice_made(choice: int) -> void:
match choice:
Events.UpgradeChoices.HEALTH:
stats.add_modifier(max_health, {value=15})
_health = stats.get_max_health()
health_bar.max_value = max_health
health_bar.value = _health
We indent on keywords like match, func, etc., or at the end of an if block, but we need a rule to indent after the first block and colon inside a match block.
I'm not sure how to get this one. We need to indent the block after the :$
regex, after the match keyword. There can be lots of stuff in these lines, including var assignments and more.
While now the lsp
packages supports Godot and GDScript, you still need to set it up. We should provide a guide for that so people know how to get full autocompletion.
Hi ! I'm new to Godot so any help with this problem will be appreciated. It probably isn't really a bug but some problem with my setup.
I'm submitting a...
What is the current behavior?
When trying to execute gdscript-godot-run-project
I get the following error:
Godot Engine v3.2.stable.custom_build - https://godotengine.org
ERROR: initialize: X11 Display is not available
At: platform/x11/os_x11.cpp:132.
But if I run it from Godot Engine then it runs without problems.
What is the expected behavior?
The scene or project runs without errors.
Tell us the steps to reproduce the bug, and if possible share a minimal demo of the problem.
<my godot env>
C-c C-r r
Other information
apt install godot3
gdscript-godot-executable
to godot3
wich is the executable that I'm usingWe have basic completion in place already, it'd be nice to integrate it with company, at least as a fallback completion until the language server is available in stable releases.
Between the official demos and our projects, we have to use type hints or not. The related variable should be configurable per project as a result
The gdscript-mode package available with package-install
in Emacs doesn't seem in development anymore. We could make a melpa package to make this one available instead.
Instructions to contribute a new package: https://github.com/melpa/melpa/blob/master/CONTRIBUTING.org
Some settings, like whether you want to use type hints for completion, or the godot version or executable you want to use, should be configurable per project. We have to switch these two at least at GDQuest depending on the project.
See #13 and #12. Regarding type hints, there's already a customizable variable in the project, and I'm using it with yasnippet to have conditional type hints in the snippets.
Just spent ages debugging eww to find out why it wouldn't load my local dash docsets (HTML).
Disabling gdscript package solved it.
It's down to the setting of
eww-after-render-hook is a variable defined in `eww.el'.
Its value is (gdscript-docs--eww-setup)Original value was nil
This variable can be risky when used as a file-local variable.
Note that this hook IS removed after calling up gdscript help from a GD file. The problem is that the hook is set at package load!
This clashes with other eww users, eg eww-readable.
I'm submitting a...
I have the editorconfig
package enabled and an .editorconfig file:
root = true
[*]
indent_size = 2
indent_style = tab
[*.yml]
indent_style = space
indent_size = 2
I'm using Doom Emacs :)
What is the current behavior?
When editing a gdscript file indenting from the NORMAL mode with Shift+>+>
works correctly but from the INSERT mode if I press tab the indent size used is 4.
If I change the indent size to 2 with gdscript-indent-offset
it works as expected
What is the expected behavior?
Let the editorconfig
preference overrides the indent size configured for gdscript-mode
Tell us the steps to reproduce the bug, and if possible share a minimal demo of the problem.
editoconfig
package.editorconfig
file like the one above (or with different indent size between editor config and gdscript-mode)Thanks!
Upon starting emacs, the copy of rx from Emacs 27 included in the package gives an error:
Loading /home/gdquest/Repositories/emacs-gdscript-mode/gdscript-rx.el (source)...done
Eager macro-expansion failure: (wrong-number-of-arguments (1 . 2) 3)
We have a feature to browse the online code reference, which is great. But depending on your internet connection it can take a few seconds every time you look up a symbol.
I'd like to provide an option to use an offline build of the docs as anyone can build or download the docs as static HTML files. That would allow opening the code reference for a class instantly.
We can format the entire buffer, but not the selected region. I'm currently working on a 3rd party framework where I'd like to format some lines and not mess with the entire file, that's huge, causing a hang on save.
Some features, like snippets or skeletons, could use type hints by default if the user wants to use them across projects. There should be a custom property to control this.
GDScript mode currently doesn't support folding of methods and subclasses. It'd be nice to add it, as it's available in Python. Should this be through a dedicated, e.g., evil-gdscript package?
I'd appreciate some insights on how to tackle that there.
Allow formatting the current buffer with Scony's gdformat.
We can integrate his code to this module: https://github.com/Scony/godot-gdscript-toolkit/blob/master/editor-plugins/emacs/gdformat.el
In Emacs 27.90, vanilla or with Spacemacs:
(Spacemacs) Error in dotspacemacs/user-config: Wrong type argument: stringp, ("Color8" "abs" "acos"
"asin" "assert" "atan" "atan2" "bytes2var" "ceil" "char" "clamp" "convert" "cos" "cosh" "db2linear"
"decimals" "dectime" "deg2rad" "dict2inst" "ease" "exp" "floor" "fmod" "fposmod" "funcref" "hash"
"inst2dict" "instance_from_id" "is_inf" "is_nan" "lerp" "linear2db" "load" "log" "max" "min" "name"
"nearest_po2" "pow" "preload" "print" "print_stack" "printerr" "printraw" "prints" "printt"
"rad2deg" "rand_range" "rand_seed" "randf" "randi" "randomize" "range" "round" "seed" "sign" "sin"
"sinh" "sqrt" "stepify" "str" "str2var" "tan" "tanh" "type_exists" "typeof" "var2bytes" "var2str"
"weakref" "yield")
Upon loading gdscript-mode.el
(at spacemacs startup for me), I'm getting the following errors:
Compiler-macro error for gdscript-syntax-comment-or-string-p: (wrong-type-argument listp ppss)
Compiler-macro error for gdscript-syntax-count-quotes: (wrong-type-argument number-or-marker-p (point))
They don't prevent gdscript-mode from working. It happens with both emacs 26.3 and 27 beta
I'm getting these warnings when installing this package. Maybe you want to fix it?
Thanks!
In end of data:
gdscript-hydra.el:157:1:Warning: the function `gdscript-hydra--menu/body' is
not known to be defined.
In gdscript-info-dedenter-opening-block-positions:
gdscript-indent-and-nav.el:755:24:Warning: `seq-contains' is an obsolete
function (as of 27.1); use `seq-contains-p' instead.
In gdscript-project--select-scene:
gdscript-project.el:52:111:Warning: `format' called with 1 args to fill 0
format field(s)
In end of data:
gdscript-project.el:115:1:Warning: the function `ag-project-regexp' is not
known to be defined.
Our shortcuts use 3 Ctrl chords for the most part. I'd like to make them a bit more intuitive. Some could use better mnemonic, e.g. formaT is bound to C-c C-t
.
I'd like your thoughts on the matter though:
C-c C-r p
to Run the Project instead of C-c C-r C-p
. The package markdown-mode
uses shortcuts like these.C-c C-f b
to format buffer, C-c C-f r
for the regionC-c C-i f
to insert a file's path, or we can use C-c f
There's a community developped parser and linter for gdscript called gdlint. It comes with gdformat that we already support in this package.
https://github.com/scony/godot-gdscript-toolkit/
Call gdlint file.gd
and you'll get an output like:
file.gd:line_number: Error: Error message (linter-error-id)
We could integrate this with flycheck. The linter doesn't have all the tests available in Godot itself right now, but it's easy to extend.
Add functions to:
godot --upwards ...
to let godot help us find the file from a gdscript buffer).The way I do it from the shell is:
find
to find the project.godot file, if it's down a directory, find . -iname project.godot -print -quit
.The reason for 1. is that you may have several godot projects in a given repository, i.e. projectile project. If, for instance, you have several prototypes. Of if you put your godot project in a subfolder, e.g. game/project.godot
Running gdscript-format-buffer
, once the formatting operation completed, does not revert the buffer instantly, letting you type characters that can get lost. That is unlike gdscript-format-region
, that locks Emacs until the formatter finished its work (which takes a split second now).
Emacs 27.1
gdscript-mode 1.3.0
Godot 3.2.3 (Not that it should matter)
(Note the following code blocks use spaces as they are easier to insert using github, but I have not changed any default settings in my editor, so I'm using tabs.)
When breaking a line I am unable to use tab an additional time to differentiate the broken line from the block it begins:
if(boolean_one and boolean_two and
boolean_three and boolean_four):
do_something()
Instead the tab cycles between the previous levels of indentation.
When breaking a line I should be able to tab in an additional time, as recommended by the style guide:
if(boolean_one and boolean_two and
boolean_three and boolean_four):
do_something()
The relevant style guide section is here
For what it's worth I don't have any custom indentation settings in my emacs initialization elisp. Furthermore gdscript-mode is the only installed package.
Add code snippets or skeletons for GDScript.
I use yasnippet, that's really powerful, but should snippets for this package be included here? Split to another package?
Should I use the emacs skeletons? Abbreviations? Both? As these features are included in Emacs itself.
Feedback is welcome!
While we have imenu support, it's based on the built-in Python package and not tailored to GDScript, creating tables that are useful but that also have incorrectly sorted or formatted entries at times. For instance, signals get labeled as "Structs".
Tasks:
-> type
. It'd be nice to have for variables too but with inferred types we're a bit limited.Godot's debugger uses a server-client system that allows us to support it in third-party editors.
Unfortunately, it doesn't support the debugger adapter protocol so it requires quite a bit of custom code to add debugger support in gdscript-mode.
This task is about setting the debugger support's foundations. We're aiming for a minimal implementation to start with.
The initial debugger package should allow you to:
We can build richer features after that, but that would be a good start.
I'm submitting a...
What is the current behavior?
Following the instructions to install for spacemacs don't work.
Making it work requires you to rename the directory from emacs-gdscript-mode
to gdscript-mode
.
What is the expected behavior?
Following the instructions will result in a successful installation.
Tell us the steps to reproduce the bug, and if possible share a minimal demo of the problem.
this format isn't working for this.
the solution is to add the extra step of renaming the directory to the spacemacs installation instructions.
Describe the problem you're trying to solve.
Tell us which solutions you've explored, the solution you would pick, and why you think it would be the best for everyone.
Other information
I know I mangled the format, but there wasn't exactly a clear choice of what category this fell into, and I didn't really know what to do with it.
Similar to #20, calling (require gdscript-format)
gives an error: no file found for me. This means that the files from the add-on aren't in the Emacs load path.
@ofrank123 Are you not having this issue? May this happen because I symlinked the files from my repositories directory, that's outside Emacs? For me no require
call works except if I evaluate the code from within emacs. so I'm certainly doing something wrong.
I'm submitting a...
What is the current behavior?
It is not possible to tab the "else" case inside a funkction.
What is the expected behavior?
I should be able to tab 'else:' to be on the same level then the 'if' condition.
Tell us the steps to reproduce the bug, and if possible share a minimal demo of the problem.
A project with only an Area2D (Player) an AnimatedSprite and a CollisionShape2D
With a Mark on 'e' of 'else:' and pressing tab as well as C-x h tab
the 'else:' does not change the position.
That way I get a build error in Godot.
extends Area2D
# movement speed of the player
export var speed = 400
# size of the game window
var screen_size
func _ready():
# load screen size
screen_size = get_viewport_rect().size
# delta = frame length
func _process(delta):
# player's movement vector
var velocity = Vector2()
# set movement direction depending on pressed button
if Input.is_action_pressed("ui_right"):
velocity.x -= 1
if Input.is_action_pressed("ui_left"):
velocity.x += 1
if Input.is_action_pressed("ui_up"):
velocity.y -= 1
if Input.is_action_pressed("ui_down"):
velocity.y += 1
if velocity.lenght() > 0:
velocity = velocity.normalized() * speed
$AnimatedSprite.play()
else:
$AnimatedSprite.stop()
position += velocity * delta
position.x = clamp(position.x, 0, screen_size.x)
position.x = clamp(position.y, 0, screnn_size.y)
Other information
The steps are done processed by this guide.
I use the latest official emacs on a ubuntu 20.04 Studio machine.
In godot i have set the external editor to:
That works totally fine.
I can also shift the "if ..." condition totally free so that works fine.
Following the example of other packages, we should split the code into several files to make it:
How to split the files needs some thoughts, but at least I'd:
-*- lexical-binding: t; -*-
in a comment at the top of each file, for performancesFunction calls don't get highlighted, it'd be nice to add some color for that
Generally, functions that automatically indent the code do not work at the moment.
Symbol’s function definition is void: n
In gdscript-project when we want to locate scripts the following code is used :
(defun gdscript-project--get-all-scripts ()
"Find all script files and let user choose one.
Since detection of script files require inspection of file contents,
this use ag for performance."
(if (not (featurep 'ag))
(error (format "Buffer %s is no script file. To see all available scripts in current project install package 'ag'." (buffer-name)))
(ag-project-regexp "^extends SceneTree|^extends MainLoop")
(setq gdscript-project--script-list nil)
(add-hook 'ag-search-finished-hook #'gdscript-project--ag-find-next-script)))
My Question is : is this grepping really necessary and is it still applicable? As a beginner to to GDScript, I have some scripts (.gd extension) that do not have any obvious relation to these "^extends" lines.
When I select run script from the hydra it doesn't show me any scripts. Is this broken?
I have some code to select from .gd files (and potentially .... others too, like .cs, I guess when I know more about it) in the project hierarchy (which also does a small restructure to slightly better re-use project root file recognition)) and am happy to do a pull request for that if deemed helpful.
While we can use the system godot
executable to open projects in the editor, the user should have a way to specify a path to an executable, or an alternate executable to run instead of the default, e.g. if Godot is not on the PATH.
Add an interactive function to add the path to a file in the project, using projectile, with the "res://path/to/file" format.
After setting up this mode in emacs, I added the keywords "and" and "or" as it helps me to see them highlighted. I think it would be best to include these keywords in the "keywords.txt" file by default.
I'm not sure if this is an oversight or an intentional design decision, but I had wanted to point it out.
Feel free to close this if not relevant or if it goes against the design.
rx-let
, a feature the package uses, seems to new in Emacs 27, so right now the package won't work with version 26.
A possible solution is to include a copy of the rx package here until Emacs 27 is out and spreads a bit.
I'm submitting a...
What is the current behavior?
When running gdscript-format-buffer
and an error is present, the error message is printed directly over the current file contents.
What is the expected behavior?
When running gdscript-format-buffer
and an error is present, the error message is printed in a popup frame (at bottom of Emacs window), the popup frame can be exited by pressing "q"
Tell us the steps to reproduce the bug, and if possible share a minimal demo of the problem.
Write the following function:
func erroneous():
var ()
And run gdscript-format-buffer
on the script.
The buffer will then be overwritten by the following error:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/lark/lexer.py", line 376, in lex
for x in l.lex(stream, self.root_lexer.newline_types, self.root_lexer.ignore_types):
File "/usr/local/lib/python3.7/site-packages/lark/lexer.py", line 182, in lex
raise UnexpectedCharacters(stream, line_ctr.char_pos, line_ctr.line, line_ctr.column, allowed=allowed, state=self.state, token_history=last_token and [last_token])
lark.exceptions.UnexpectedCharacters: No terminal defined for '(' at line 2 col 6
var ()
^
Expecting: {'NAME', '_NL'}
Previous tokens: Token(VAR, 'var')
During handling of the above exception, another exception occurred:
I'm submitting a...
Currently in my actual Linux distribution I can install this package because the emacs version required is greater that the installed one.
It should be possible to lower the Emacs version required without to much ado. E.g: Emacs versions of common Linux Distributions:
Thanks,
Add functions to:
godot --upwards ...
to let godot find the file)pcase
call work?In particular, the double quote in e.g. ''comment
pcase type
(''comment
`(let ((ppss (or ,syntax-ppss
(syntax-ppss))))
(and (nth 4 ppss)
(nth 8 ppss))))
I'm submitting a...
What is the current behavior?
Wrong type argument: commandp, gdscript-godot-run-project
(replace with the actual function called)
What is the expected behavior?
Tell us the steps to reproduce the bug, and if possible share a minimal demo of the problem.
gdscript-mode version: 1.1.0
Emacs version: 26.3
The attached gdscript-mode.el file fixed both issues for me.
Commit 1717837
Myself and another person couldn't get this mode to load.
(require 'gdscript-mode)
produces the errors
Eager macro-expansion failure: (file-missing "Opening input file" "No such file or directory" "/mnt/common/docs2/keywords.txt")
let: Opening input file: No such file or directory, /mnt/common/docs2/keywords.txt
(The repo is cloned at /mnt/common/docs2/elisp-local/emacs-gdscript-mode/
, and that path is in load-path
)
Looking at the code it's obvious what the problem is. The function gdscript--get-file-content-as-string
contains the line of code (setq this-directory (file-name-directory "gdscript-mode.el"))
This is wrong, this-directory
is always nil
.
To get the package in melpa, we need to address reports by this tool: https://github.com/riscy/melpazoid
If you would like to suggest and discuss features to add to the package, this is the place to do so. We now have all the essentials in place, and more features provided by the language server protocol.
The package remaps some default functions to its own, but not for vim emulation through evil-mode.
Should this be in a separate package?
I'm submitting a...
Loading of gdscript-mode ends with errors:
Compiler-macro error for gdscript-syntax-comment-or-string-p: (wrong-type-argument listp ppss)
Compiler-macro error for gdscript-syntax-count-quotes: (wrong-type-argument number-or-marker-p (point))
Compiler-macro error for gdscript-syntax-count-quotes: (wrong-type-argument number-or-marker-p str-start-pos)
Highlighting works fine, but no auto-completion and code formatting.
I'm using emacs 26.3. Bug reproduced on develop and master branch of spacemacs.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.