What do you think of 'Brackets' as an editor + How to use luacheck code linter

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
drunken_munki
Party member
Posts: 125
Joined: Tue Mar 29, 2011 11:05 pm

What do you think of 'Brackets' as an editor + How to use luacheck code linter

Post by drunken_munki » Fri May 18, 2018 12:00 pm

Been trying a few editors out, I usually use notepad++.

What caught my eye was the 'luacheck' linting tool: https://github.com/mpeterv/luacheck

Here I already tried out the tool manually which can create a report of your code issues... but then the section on integration with editors caught my other eye. So I tried sublime... hated it, and couldn't get the linter to work either.

Then I tried Brackets which is available on all systems it seems: http://brackets.io/

From here I installed it, ran it and went to File -> 'Extension Manager'. Then I searched for 'luacheck' and installed the interface for it.
Image1.png
Image1.png (98.72 KiB) Viewed 160 times

I also had to download luacheck from the github page, actually I got the one-off windows x86_64 binary and put it somewhere on my system. This needs to be reachable in the PATH, so I linked it in the system settings:
https://github.com/mpeterv/luacheck/rel ... acheck.exe


Now when I opened my working directory in Brackets I can see the source tree on the left, I open a file and it auto-lints the file. Neat.
Image2.png
Image2.png (148.77 KiB) Viewed 160 times

To configure luacheck properly, I create '.luacheckrc' which is written in basic Lua syntax and normally placed into the root directory of your code. However, to get this to work properly with Brackets I created a symbolic link (or just copy it) to:
"%LOCALAPPDATA%\Luacheck\.luacheckrc"

On other systems I beleive this file should be copied to:
"~/Library/Application Support/Luacheck/.luacheckrc" on OS X/macOS, and "$XDG_CONFIG_HOME/luacheck/.luacheckrc" or "~/.config/luacheck/.luacheckrc" on a linux type OS.


My '.luacheckrc' consists of the following settings, to give you an idea of how to set it up:

Code: Select all

-- Create symbolic link of this file into this directory: %LOCALAPPDATA%\Luacheck\.luacheckrc

-- Include 'love' into the global pool (read/write)
std = {
  globals = {"love"}
}

-- Include all source sub-dirs or file paths relative to the root dir:
include_files = {
                  "./game/",
                  "./monkey_box/",
                  "main.lua"
                } 

-- Message codes to filter out:
-- https://luacheck.readthedocs.io/en/stable/warnings.html
-- 611 A line consists of nothing but white space
-- 612 A line contains trailing white space
-- 614 Trailing white space in a comment
-- 631 line is too long
-- 311 value assigned to variable x is unused
-- 113 accessing undefined variable x 
-- 111 setting non-standard global variable x
-- 411 variable x was previously defined on line
-- 542 empty if branch
-- 422 shadowing definition of argument
-- 421 shadowing definition of variable
ignore = {"611", "612", "614", "631", "311", "113", "111", "411", "542", "422", "421"}
Image3.png
Image3.png (155.36 KiB) Viewed 160 times

So I spent about a day of coding time to tidy up my code and really really enjoyed using this linter, I think I cleaned up over 2000 warnings and found three bugs in the process, heh.

I realised that some features are lacking in Brackets such as a more sensible search/replace tool, but I think there are a lot of plugins being made or available.

So have you tried this, what do you think?
Last edited by drunken_munki on Sun May 20, 2018 11:40 am, edited 5 times in total.

User avatar
D0NM
Party member
Posts: 180
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: What do you think of 'Brackets' as an editor?

Post by D0NM » Sat May 19, 2018 7:16 pm

hi!
1) Brackets is a nice editor.
2) I think your howto will be handy. Because some time ago I browsed all "lua-ish" brackets plugins, got no instant results and dropped them all.
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Follow @Zabuyaki.
Twitter @FaMeSoft / GP32 Free Platformer: SUPER PLUSHA
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:

User avatar
MissDanish
Prole
Posts: 11
Joined: Wed Mar 07, 2018 11:21 pm
Location: Denmark

Re: What do you think of 'Brackets' as an editor?

Post by MissDanish » Sat May 19, 2018 7:23 pm

damn, it looks way better than the skins for atom (what I use). But I am guessing it's probably not possible to have a button that can execute your game easily in Brackets?
Smol programmer :neko:

User avatar
drunken_munki
Party member
Posts: 125
Joined: Tue Mar 29, 2011 11:05 pm

Re: What do you think of 'Brackets' as an editor?

Post by drunken_munki » Sun May 20, 2018 9:27 am

I'm going to check how to create a run command today, and also possibly how to use the git integration; will report back soon.


OK running a love project is easy:

File -> Extension Manager -> Search for "Run LÖVE" and install it.

Restart the editor and you can use ctrl-shift-l or click the edit menu -> "Run with LÖVE". I have my love folder reachable in the system PATH.


Styler themes are pretty easy to find something you like: File -> Extension Manager -> Themes tab and install.

Then go to View -> Themes and pick from drop-down list.

Post Reply

Who is online

Users browsing this forum: drunken_munki and 5 guests