Skip to content

[BUG] Lua Linter setup #5

Closed

Description

@rpatters1

Describe the bug
This is not exactly a bug, but I don't see a better choice for where to put this.

The instructions for installing luac on Mac should be: brew install lua

Also, I have installed Visual Studio Code, lua (including luac), and lualinter. It says it is running in Visual Studio Code, with the default options. And my Code explorer shows the Lua Scripts folder that contains luaconfig.config. But I'm getting no de-linting joy. Any ideas?

Activity

  1. changed the title [-][BUG][/-] [+][BUG] Lua Linter setup[/+] on Jun 9, 2020
  2. Nick-Mazuk commented on Jun 9, 2020

    @Nick-Mazuk
    Member

    Ok, I'll update the markdown file.

    If you go to preferences (⌘ comma), is "Format on Save" turned on? If not, that's likely the issue. I'm also adding that to the markdown file.

  3. rpatters1 commented on Jun 9, 2020

    @rpatters1
    CollaboratorAuthor
  4. rpatters1 commented on Jun 10, 2020

    @rpatters1
    CollaboratorAuthor
  5. Nick-Mazuk commented on Jun 10, 2020

    @Nick-Mazuk
    Member

    Hmm…

    I'm not sure why it's not working.

    The only thing I can think of is that perhaps you are already writing formatted code?

    If you want to test this, try using this line of code:

    if variable<2 then print('hello') end

    It should turn into

    if variable < 2 then
        print("hello")
    end

    @CJGarciaMusic Have you used the linter? If so, anything else you had to do to set it up?

  6. rpatters1 commented on Jun 12, 2020

    @rpatters1
    CollaboratorAuthor
  7. Nick-Mazuk commented on Jun 15, 2020

    @Nick-Mazuk
    Member

    Interesting. Honestly, I don't know what's causing that. I had no trouble with the setup myself. I've tried to replicate the issue on my end, but I haven't been able to.

  8. Nick-Mazuk commented on Jul 31, 2021

    @Nick-Mazuk
    Member

    I may have written about the wrong plugin…

    In short, I was wondering why my code formatting wasn't working anymore for Lua files and had to debug it. The lua-linter extension did not seem to be formatting the code. Instead, I had another extension called vscode-lua-format which formats the code.

    This extension was already installed for me, but I had to add this to VS Code's settings.json

    "[lua]": {
        "editor.defaultFormatter": "Koihik.vscode-lua-format"
    },

    So my guess is that to get the code formatting, you need to:

    1. Install vscode-lua-format
    2. Add the above snippet to your settings.json

    If this works for you, I'll update the docs.

  9. rpatters1 commented on Jul 31, 2021

    @rpatters1
    CollaboratorAuthor
  10. Nick-Mazuk commented on Aug 7, 2021

    @Nick-Mazuk
    Member

    If everything is working, this…

    if variable<2 then print('hello') end

    …should be reformatted to this when you save:

    if variable < 2 then
        print("hello")
    end

    If it is not formatted, you can try to manually trigger the format. The easiest way is to use the command palette (⌘⇧P) and type/select Format Document.


    For the settings.json, I'm not 100% sure where it is on the disk. I always open it through the command palette (⌘⇧P) and select Preferences: Open Settings (JSON) to edit it straight in VS Code.

  11. rpatters1 commented on Aug 7, 2021

    @rpatters1
    CollaboratorAuthor
  12. Nick-Mazuk commented on Mar 27, 2022

    @Nick-Mazuk
    Member

    Hate to beat a dead horse, but I was playing around with a new folder structure for Lua scripts this weekend and found out that this setting must be set for code formatting to work.

    The formatter seems to not automatically pick up the config file.

    Screen Shot 2022-03-27 at 11 35 33 AM

  13. Nick-Mazuk commented on Mar 27, 2022

    @Nick-Mazuk
    Member

    Just created PR #156 which includes all my relevant settings and extensions for this repo.

    (or at least I think it has all my relevant settings and extensions).

  14. rpatters1 commented on Apr 28, 2022

    @rpatters1
    CollaboratorAuthor

    I applied the settings from the files in PR #156 and I now have Lua linter function in VS Code. It is complaining that it can't find the file ./luaconfig.config. Is that something that should be added to the Pull Request?

  15. rpatters1 commented on Apr 28, 2022

    @rpatters1
    CollaboratorAuthor

    A new issue I'm having is that it is adding in spurious line breaks when I save. Is there a setting to prevent this?

  16. rpatters1 commented on Apr 28, 2022

    @rpatters1
    CollaboratorAuthor

    Never mind. I found ./luaconfig.config (lol) and it also addressed the spurious line breaks.

  17. Nick-Mazuk commented on Apr 29, 2022

    @Nick-Mazuk
    Member

    Great! Glad you finally got it working and figured out those issues. Is it time to close this issue?

  18. rpatters1 commented on Apr 29, 2022

    @rpatters1
    CollaboratorAuthor

    Yes, I think so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions