Code Monkey home page Code Monkey logo

emacs-gdscript-mode's People

Contributors

benjamin-asdf avatar bkaestner avatar brachystochronesd avatar calinou avatar clangdo avatar francogarcia avatar hristoast avatar jcs090218 avatar kirca avatar menacingmecha avatar nathanlovato avatar nicolaspetton avatar ofrank123 avatar rileyrg avatar ruijieyu avatar scony avatar shackra avatar tavurth avatar vlachjosef avatar xiliuya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emacs-gdscript-mode's Issues

Auto indents don't work in match blocks

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.

Running project or scene throws error

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...

  • Bug report.
  • Feature request.

Bug report

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.

  1. Load spacemacs
  2. pyenv-workon <my godot env>
  3. Open a .gd file from a project (currently following this tutorial from gdquest)
  4. C-c C-r r

Other

Other information

  • I'm using spacemacs [email protected]
  • Godot version 3.2 installed using apt install godot3
  • Installed this package following the spacemacs instructions
  • Installed gdtoolkit on virtualenv
  • I had set gdscript-godot-executable to godot3 wich is the executable that I'm using

Add support for company-mode for completion

We 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.

Make static type hints per project

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

Add support for per-project settings

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.

gdscript eww render hook causing problems

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.

The editorconfig settings are overridden

I'm submitting a...

  • Bug report.
  • Feature request.

Bug report

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.

  1. Enable the editoconfig package
  2. Create an .editorconfig file like the one above (or with different indent size between editor config and gdscript-mode)
  3. Try to indent a line

Thanks!

The package won't load in Emacs 26.3

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)

Browse docs: use local reference if available

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.

Add a command to format the region with gdformat

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.

Add an option to use type hints

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.

Code folding (with evil?)

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.

Can start lsp

when i open a project (using doom) emacs, i got:
image

How can i fix it ?

Error wrong argument stringp

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")

Compiler-macros give wrong-type-argument errors

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

Address compile warnings

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.

Improve the shortcuts

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:

  • Using a single letter for the last part of a shortcut. E.g. 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.
  • Using f for format, and b to format the buffer: C-c C-f b to format buffer, C-c C-f r for the region
  • C-c C-i to insert things in the buffer. It could be a skeleton, but also C-c C-i f to insert a file's path, or we can use C-c f

Integrate gdlint with flycheck

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.

Open and run the project in the Godot editor

Add functions to:

  • Open the project in Godot's editor (we can use godot --upwards ... to let godot help us find the file from a gdscript buffer).
  • Run the game directly from emacs?

The way I do it from the shell is:

  1. Using find to find the project.godot file, if it's down a directory, find . -iname project.godot -print -quit.
  2. The --upwards option from godot if I'm looking at a file or a directory inside the Godot project.

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

Buffer does not revert or update instantly after formatting buffer

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).

Line break indentation (double indentation) isn't possible with tab key by default

Versions

Emacs 27.1
gdscript-mode 1.3.0
Godot 3.2.3 (Not that it should matter)

Behaviors

(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.)

Observed

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.

Expected

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()

Additional Information

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

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!

Rewrite gdscript-imenu to provide GDScript-specific tables

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:

  • Correctly label functions, variables, and inner classes.
  • Add support for optional type hints, at least for functions. We need a regexp that captures -> type. It'd be nice to have for variables too but with inferred types we're a bit limited.

Initial debugger support

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:

  • Toggle breakpoints
  • Break at breakpoints when running any scene (or the project)
  • Break when an error happens
  • View the error message and stack trace
  • Jump to lines of code from the stack trace
  • Resume execution until the next breakpoint
  • Run the scene ignoring the breakpoints
  • Support all core packet types

We can build richer features after that, but that would be a good start.

Spacemacs installation instructions are incomplete

I'm submitting a...

  • Bug report.
  • Feature request.

Bug report

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.

Feature request

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

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.

gdscript-format doesn't load automatically

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.

No 'tab' possible on 'else:' condition

I'm submitting a...

  • Bug report.
  • Feature request.

Bug report

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

Other information
The steps are done processed by this guide.
Screenshot_2020-04-28_23-49-43

I use the latest official emacs on a ubuntu 20.04 Studio machine.
In godot i have set the external editor to:

  • Exec Path: emacsclient
  • Exec Flags: -c -a '' {file}

That works totally fine.
I can also shift the "if ..." condition totally free so that works fine.

Split the code into multiple files

Following the example of other packages, we should split the code into several files to make it:

  • Easier to maintain and extend, having a clear purpose for each file
  • Faster to open and parse each file, I noticed that it can take some time for Emacs to open and process a big elisp file. This is especially true when using a lisp formatter like with the semantic package.

How to split the files needs some thoughts, but at least I'd:

  • Move the list of class names and keywords to text files, and parse and create a list of strings from lisp, to make them easier to update.
  • Have a file for
    1. imenu.
    2. evil-specific code.
    3. loading snippets.
    4. syntax highlighting and font-faces.
    5. And generally, each section in the current file, separated by a long horizontal line. Utils, navigation, indentation... when and if possible.

Checklist

  • Have lexical binding, i.e. -*- lexical-binding: t; -*- in a comment at the top of each file, for performances

<info required> identifying scripts to run

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.

Add a setting to specify the godot executable

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.

Insert path to file

Add an interactive function to add the path to a file in the project, using projectile, with the "res://path/to/file" format.

Add Keywords "and" and "or" to keywords.txt

Feature request

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.

Make the package compatible with Emacs 26

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.

GDFormat overwrites file contents with error (if any)

I'm submitting a...

  • Bug report.
  • Feature request.

Bug report

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.

Screenshot 2020-04-28 at 11 38 53

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"

Screenshot 2020-04-28 at 11 38 37

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:

Put a lower Emacs version requisite

I'm submitting a...

  • Bug report.
  • Feature request.

Feature request

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:

  • Ubuntu 18.04 LTS == 25.2
  • Linux Mint 19.3 == 25.2
  • Debian Stable == 26.1
  • Centos 8 == 26.1

Thanks,

Open project in Godot

Add functions to:

  • Open the project in Godot's editor (use godot --upwards ... to let godot find the file)
  • Run the game

Review gdscript-syntax--context-compiler-macro function

  • What does eval-and-compile do in this case?
  • How does the 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))))

gdscript-godot not autoloading and keymap is obsolete

I'm submitting a...

  • Bug report.
  • Feature request.

Bug report

What is the current behavior?

  1. When gdscript-mode is called, gdscript-godot is not loaded, thus there is no access to functions like gdscript-godot-run-project and similar. When calling one of these functions the following error is shown in the minibuffer:

Wrong type argument: commandp, gdscript-godot-run-project

(replace with the actual function called)

  1. Also, in gdscript-mode.el, variable gdscript-mode-map has key definitions that point to apparently older names for the functions mentioned in the previous paragraph.

What is the expected behavior?

  1. gdscript-godot should be loaded when gdscript-mode is called.
  2. in gdscript-mode.el, the key definitions in the keymap should correspond to the correct function names.

Tell us the steps to reproduce the bug, and if possible share a minimal demo of the problem.

  1. Open a .gd file.
  2. Do M-x gdscript-godot-run-project.
  3. Do C-c C-p.

Other

gdscript-mode version: 1.1.0
Emacs version: 26.3

The attached gdscript-mode.el file fixed both issues for me.

gdscript-mode.txt

Doesn't run, can't find keywords.txt

Commit 1717837

  • Bug report.
  • Feature request.

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.

Which features would you like to see?

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.

Compiler-macro error on loading in Spacemacs

I'm submitting a...

  • Bug report.
  • Feature request.

Bug report

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.