Skip to content

Commit 70aaa4d

Browse files
committed
Fix #2343, support pre-commit
1 parent 24b9faa commit 70aaa4d

File tree

5 files changed

+73
-4
lines changed

5 files changed

+73
-4
lines changed

.pre-commit-hooks.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- id: lua-language-server-check
3+
language: lua
4+
name: lua language server check
5+
description: >
6+
use lua language server to check lua files
7+
entry: lua-language-server
8+
types:
9+
- lua
10+
args:
11+
- --check
12+
- .

lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
script

lua-language-server

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env lua
2+
local f = '%q'
3+
local args = {
4+
'bee',
5+
debug.getinfo(1).source:match("@?(.*/)[^/]+/") .. 'main.lua',
6+
}
7+
for _, v in ipairs(arg) do
8+
table.insert(args, f:format(v))
9+
end
10+
local isok, reason, ret = os.execute(table.concat(args, ' '))
11+
if type(isok) == type(0) then
12+
ret = isok
13+
end
14+
if ret ~= 0 then
15+
os.exit(1)
16+
end

lua-language-server-scm-1.rockspec

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
local git_ref = '3.15.1'
2+
local modrev = 'scm'
3+
local specrev = '1'
4+
5+
rockspec_format = '3.0'
6+
package = 'lua-language-server'
7+
version = modrev .. '-' .. specrev
8+
9+
local repo_url = 'https://github.com/LuaLS/lua-language-server'
10+
11+
description = {
12+
summary = 'A language server that offers Lua language support - programmed in Lua',
13+
detailed =
14+
[[The Lua language server provides various language features for Lua to make development easier and faster. With nearly a million installs in Visual Studio Code, it is the most popular extension for Lua language support.]],
15+
labels = { 'lua', 'language-server', 'lpeg', 'hacktoberfest', 'lsp', 'lsp-server', 'lpeglabel' },
16+
homepage = repo_url,
17+
license = 'MIT'
18+
}
19+
20+
source = {
21+
url = repo_url .. '/archive/' .. git_ref .. '.zip',
22+
dir = package .. '-' .. git_ref,
23+
}
24+
25+
dependencies = { 'lpeglabel', 'EmmyLuaCodeStyle', 'bee.lua' }
26+
27+
build = {
28+
type = 'builtin',
29+
copy_directories = { 'meta', 'locale' },
30+
install = {
31+
bin = {
32+
[package] = package,
33+
},
34+
conf = {
35+
['../main.lua'] = 'main.lua',
36+
['../debugger.lua'] = 'debugger.lua',
37+
},
38+
}
39+
}

script/cli/check.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ local function logFileForThread(threadId)
1111
return LOGPATH .. '/check-partial-' .. threadId .. '.json'
1212
end
1313

14-
local function buildArgs(exe, numThreads, threadId, format, quiet)
15-
local args = {exe}
14+
local function buildArgs(minIndex, numThreads, threadId, format, quiet)
15+
local args = {}
1616
local skipNext = false
17-
for i = 1, #arg do
17+
for i = minIndex, #arg do
1818
local arg = arg[i]
1919
-- --check needs to be transformed into --check_worker
2020
if arg:lower():match('^%-%-check$') or arg:lower():match('^%-%-check=') then
@@ -56,6 +56,7 @@ function export.runCLI()
5656
exe = arg[minIndex]
5757
minIndex = minIndex - 1
5858
end
59+
minIndex = minIndex + 1
5960
-- TODO: is this necessary? got it from the shell.lua helper in bee.lua tests
6061
if platform.os == 'windows' and not exe:match('%.[eE][xX][eE]$') then
6162
exe = exe..'.exe'
@@ -67,7 +68,7 @@ function export.runCLI()
6768

6869
local procs = {}
6970
for i = 1, numThreads do
70-
local process, err = subprocess.spawn({buildArgs(exe, numThreads, i, CHECK_FORMAT, QUIET)})
71+
local process, err = subprocess.spawn({buildArgs(minIndex, numThreads, i, CHECK_FORMAT, QUIET)})
7172
if err then
7273
print(err)
7374
end

0 commit comments

Comments
 (0)