Scony / godot-gdscript-toolkit

Independent set of GDScript tools - parser, linter, formatter, and more
MIT License
944 stars 65 forks source link

gdlint on godot editor? #271

Closed quimnuss closed 5 months ago

quimnuss commented 7 months ago

Not an issue but I couldn't find the information anywhere. Is it possible to display the linting hints in the Godot editor?

It's difficult to correct the linting warnings that gdformat doesn't fix.

Here's my pre-commit

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.4.0 # Use the ref you want to point at
    hooks:
      - id: trailing-whitespace
      - id: check-added-large-files
        args: [--maxkb=500]
      - id: check-case-conflict
      - id: check-json
      - id: check-merge-conflict
      - id: check-yaml
        args: ["--unsafe"] # Instead of loading the files, simply parse them for syntax
      - id: mixed-line-ending
  - repo: https://github.com/Scony/godot-gdscript-toolkit
    rev: 4.2.2
    hooks:
      - id: gdlint
        name: gdlint
        description: "gdlint - linter for GDScript"
        entry: gdlint
        language: python
        language_version: python3
        require_serial: true
        types: [gdscript]
        exclude: ^addons/
      - id: gdformat
        name: gdformat
        description: "gdformat - formatter for GDScript"
        entry: gdformat
        language: python
        language_version: python3
        require_serial: true
        args: ["-l 150"]
        types: [gdscript]
        exclude: ^addons/
Scony commented 7 months ago

Sorry, I have no idea. Maybe someone else will be able to answer that...

quimnuss commented 7 months ago

If the creator of this awesome tool doesn't know, I don't think anybody will know how to hack the godot editor to use external linting. It does work on vscode, althought some linting issues would be nice to have proposed fixes (e.g. sort definitions)

Should I close this?

chrisl8 commented 7 months ago

If you want some additional hints/info in VSCode when using this as a linter, that seems doable via a combination of changes to this code and enhancements to https://github.com/EddieDover/vscode-formatter-godot (or whatever VSCode extension you use for running this).

Right now that extension just prints the output from gdlint verbatim. I could see either adding an option to gdlint to give some more helpful output, including links to the docs, and/or something in the/an extension to translate the gdlint output into more helpful output.

As to "quick fixes", that would require digging into how to ask the IDE to perform some of its tricks like reformatting variable names and such. I have no idea how that works now in IDEs, but in theory it is possible? Again, in VSCode, not Godot's built in editor.

el-falso commented 7 months ago

It's absolutely possible, I created an asset for this a week ago in combination with gdlint: https://godotengine.org/asset-library/asset/2520