diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 000000000..ba7d75152 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,12 @@ +--- +- id: lua-language-server-check + language: lua + name: lua language server check + description: > + use lua language server to check lua files + entry: lua-language-server + types: + - lua + args: + - --check + - . diff --git a/lua b/lua new file mode 120000 index 000000000..2b804bee2 --- /dev/null +++ b/lua @@ -0,0 +1 @@ +script \ No newline at end of file diff --git a/lua-language-server b/lua-language-server new file mode 100755 index 000000000..c6b41a812 --- /dev/null +++ b/lua-language-server @@ -0,0 +1,16 @@ +#!/usr/bin/env lua +local f = '%q' +local args = { + 'bee', + debug.getinfo(1).source:match("@?(.*/)[^/]+/") .. 'main.lua', +} +for _, v in ipairs(arg) do + table.insert(args, f:format(v)) +end +local isok, reason, ret = os.execute(table.concat(args, ' ')) +if type(isok) == type(0) then + ret = isok +end +if ret ~= 0 then + os.exit(1) +end diff --git a/lua-language-server-scm-1.rockspec b/lua-language-server-scm-1.rockspec new file mode 100644 index 000000000..ea24b84cd --- /dev/null +++ b/lua-language-server-scm-1.rockspec @@ -0,0 +1,39 @@ +local git_ref = '3.15.1' +local modrev = 'scm' +local specrev = '1' + +rockspec_format = '3.0' +package = 'lua-language-server' +version = modrev .. '-' .. specrev + +local repo_url = 'https://github.com/LuaLS/lua-language-server' + +description = { + summary = 'A language server that offers Lua language support - programmed in Lua', + detailed = + [[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.]], + labels = { 'lua', 'language-server', 'lpeg', 'hacktoberfest', 'lsp', 'lsp-server', 'lpeglabel' }, + homepage = repo_url, + license = 'MIT' +} + +source = { + url = repo_url .. '/archive/' .. git_ref .. '.zip', + dir = package .. '-' .. git_ref, +} + +dependencies = { 'lpeglabel', 'EmmyLuaCodeStyle', 'bee.lua' } + +build = { + type = 'builtin', + copy_directories = { 'meta', 'locale' }, + install = { + bin = { + [package] = package, + }, + conf = { + ['../main.lua'] = 'main.lua', + ['../debugger.lua'] = 'debugger.lua', + }, + } +} diff --git a/script/cli/check.lua b/script/cli/check.lua index d65c93580..e8c35f602 100644 --- a/script/cli/check.lua +++ b/script/cli/check.lua @@ -11,10 +11,10 @@ local function logFileForThread(threadId) return LOGPATH .. '/check-partial-' .. threadId .. '.json' end -local function buildArgs(exe, numThreads, threadId, format, quiet) - local args = {exe} +local function buildArgs(minIndex, numThreads, threadId, format, quiet) + local args = {} local skipNext = false - for i = 1, #arg do + for i = minIndex, #arg do local arg = arg[i] -- --check needs to be transformed into --check_worker if arg:lower():match('^%-%-check$') or arg:lower():match('^%-%-check=') then @@ -56,9 +56,10 @@ function export.runCLI() exe = arg[minIndex] minIndex = minIndex - 1 end + minIndex = minIndex + 1 -- TODO: is this necessary? got it from the shell.lua helper in bee.lua tests if platform.os == 'windows' and not exe:match('%.[eE][xX][eE]$') then - exe = exe..'.exe' + arg[minIndex] = exe..'.exe' end if not QUIET and numThreads > 1 then @@ -67,7 +68,7 @@ function export.runCLI() local procs = {} for i = 1, numThreads do - local process, err = subprocess.spawn({buildArgs(exe, numThreads, i, CHECK_FORMAT, QUIET)}) + local process, err = subprocess.spawn({buildArgs(minIndex, numThreads, i, CHECK_FORMAT, QUIET)}) if err then print(err) end