windows环境安装luacheck

网上看到luacheck在linux安装很简单,在win下安装,但是从未想过这个安装这么麻烦。这里把步骤记录下来,对有需要的人希望能够有所帮助。

一 首先安装lua虚拟机

1 搜索 luaforwindos ,这里放个链接,下载截图中的文件

https://github.com/rjpcomputing/luaforwindows/releases

windows环境安装luacheck

windows环境安装luacheck

2 解压

下载之后放在同一目录,解压之后把lfw_luarocks-2.2.2-win32下面的文件复制到  luarocks-2.2.2-win32目录下,安装 LuaForWindows_v5.1.5-52.

windows环境安装luacheck

3 配置lua环境变量,正确配置LUA_DEV 和 LUA_PATH(安装luaforwindows之后应该是自动配置的)

windows环境安装luacheck

正确配置之后,应该能正确输入信息

windows环境安装luacheck

二 安装 luarocks

1 用管理员权限分别安装下面三个(Git可以正常使用)

windows环境安装luacheck

2 cmd 输入luarocks,能看到luarocks的版本在 2.2以上,说明安装成功

windows环境安装luacheck

3 输入luarocks list 可以看到已经安装了的luarocks

4 输入luarocks install argparse ,会看到类似报错,

windows环境安装luacheck

这是因为缺乏VC++的编译的环境变量,检测是否安装了带有VC的Visual Studio,如果没有,修改VS程序安装VC

5 windows7 配置VS2017 环境变量

  • 属性->环境变量->高级系统设置->打开Path,添加:

D:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x86;

  • 新建Lib变量,添加一下路径:

D:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\lib\x86

    C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x86;

windows环境安装luacheck

  • 新建INCLUDE变量,添加两个路径:

D:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\include;

C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt

  • 找到VS安装目录中的 vcvarsall.bat文件,双击 

windows环境安装luacheck

  • cmd ,输入 cl ,输出如下说明配置成功

6 继续安装 luarocks ,继续安装

luarocks install lanes,报错如下,网上查了好久,一直没解决

windows环境安装luacheck

这一步卡了好久,后来在之前下载的luarocks-2.2.2-win32文件下,lfw_install_readme.text看到,打开VS的工具命令行,重新执行

windows环境安装luacheck

7 如下图,安装成功,继续安装

luarocks install luafilesystem

luarocks install luacheck

windows环境安装luacheck

安装完 luacheck ,cmd 输入 luacheck ,如下所示,就说明安装成功了

windows环境安装luacheck

到这里luacheck就安装好了

三 Sublime 配置lua环境

1 打开Sublime,点击菜单栏 Tools -> Build System -> new Build System

{

"cmd": ["lua","$file"],

"file_regex":"^(...*?):([0-9]*):?([0-9]*)",

"selector":"source.lua"

 }

2 保存到默认目录:命名为MyLua.sublime-buil 保存,关闭

windows环境安装luacheck

3 点击 菜单栏→ 工具 → MyLua(刚创建编译系统文件)  打印成功

windows环境安装luacheck

4 安装 package control,打开preferencs, 这说明安装成功

windows环境安装luacheck

在 packsge control ,选中package controll install ,回车

windows环境安装luacheck

依次安装 SublimeLinter ,SublimeLinter-luacheck

windows环境安装luacheck

安装成功之后,显示如下

windows环境安装luacheck

导入工程之后就能看到,当前代码中存在的问题,鼠标放在光标地方就出现在问题的

windows环境安装luacheck

windows环境安装luacheck

再次感谢大佬们的分析,下面分享下大佬们的链接

https://blog.****.net/hmsiwtv/article/details/8155441 https://blog.****.net/kaige_zhao/article/details/80315697      

https://blog.****.net/chinar****/article/details/78753811

https://b23.tv/av49050387