Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 20ae0d1

Browse files
committed
Merge pull request #6 from xpol/master
Support `luajit -bl` and add settings to set luac or luajit path.
2 parents f6fb9ae + 764304d commit 20ae0d1

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,26 @@ linter-lua
33

44
> luac — The luac program parses lua files. It can be used for detecting errors in lua code. See [http://www.lua.org/manual/4.0/luac.html](http://www.lua.org/manual/4.0/luac.html) for more informations about luac.
55
6-
This package will lint your `.lua` opened files in Atom through luac. **It will lint on edit and/or save**, so you'll see instantly if your code has errors.
6+
This package will lint your `.lua` opened files in Atom through luac or [luajit](http://luajit.org/running.html). **It will lint on edit and/or save**, so you'll see instantly if your code has errors.
77

88
Due to the way that luac works it will only notify you of the first error found in the file.
99

1010
## Linter Installation
11-
Before using this package, you must ensure that `luac` is installed on your system.
11+
Before using this package, you must ensure that `luac` or `luajit` is installed on your system.
1212

1313
## Installation
1414

1515
* `$ apm install linter` (if you don't have [AtomLinter/Linter](https://github.com/AtomLinter/Linter) installed).
1616
* `$ apm install linter-lua`
1717

18+
## Configuration
19+
20+
Atom -> Preferences... -> Packages -> Linter lua -> Settings:
21+
22+
* **Executable** Path to your `luac` or `luajit` executable.
1823

1924
## Other available linters
25+
- [linter-luacheck](https://atom.io/packages/linter-luacheck), for lua using `luacheck`
2026
- [linter-php](https://atom.io/packages/linter-php), for PHP using `php -l`
2127
- [linter-phpcs](https://atom.io/packages/linter-phpcs) - Linter plugin for PHP, using phpcs.
2228
- [linter-phpmd](https://atom.io/packages/linter-phpmd) - Linter plugin for PHP, using phpmd.

lib/init.coffee

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module.exports =
2-
configDefaults:
3-
luacExecutablePath: null
2+
config:
3+
executable:
4+
type: 'string'
5+
default: 'luac'
6+
description: 'The executable path to luac or luajit.'
47

58
activate: ->
69
console.log 'activate linter-lua'

lib/linter-lua.coffee

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ class LinterLua extends Linter
66
# list/tuple of strings. Names should be all lowercase.
77
@syntax: 'source.lua'
88

9-
# A string, list, tuple or callable that returns a string, list or tuple,
10-
# containing the command line (with arguments) used to lint.
11-
cmd: 'luac -p'
12-
139
linterName: 'luac'
1410

1511
# A regex pattern used to extract information from the executable's output.
@@ -24,10 +20,17 @@ class LinterLua extends Linter
2420
constructor: (editor) ->
2521
super(editor)
2622

27-
atom.config.observe 'linter-lua.luacExecutablePath', =>
28-
@executablePath = atom.config.get 'linter-lua.luacExecutablePath'
23+
# Set to observe config options
24+
atom.config.observe 'linter-lua.executable', => @updateCommand()
25+
26+
updateCommand: ->
27+
executable = atom.config.get 'linter-lua.executable'
28+
if /luajit[^\\/]*$/.test(executable)
29+
@cmd = [executable, '-bl']
30+
else
31+
@cmd = [executable, '-p']
2932

3033
destroy: ->
31-
atom.config.unobserve 'linter-lua.luacExecutablePath'
34+
atom.config.unobserve 'linter-lua.executable'
3235

3336
module.exports = LinterLua

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"linter-package": true,
44
"activationEvents": [],
55
"main": "./lib/init",
6-
"version": "0.1.3",
7-
"description": "Lint Lua on the fly, using luac -p",
6+
"version": "0.1.4",
7+
"description": "Lint Lua on the fly, using luac -p or luajit -bl",
88
"repository": {
99
"type": "git",
1010
"url": "https://github.com/AtomLinter/linter-lua"

0 commit comments

Comments
 (0)