liwangqian / luacoderassist Goto Github PK
View Code? Open in Web Editor NEWvscode lua assistant intelligent
vscode lua assistant intelligent
Busted autocomplete is sometimes intrusive when doing non busted related work, so maybe that could be enabled/disabled per project?
Also adding standard library autocomplete would be amazing, maybe related to #22 and if so then busted could fall into that too. Note that LuaJIT adds its own globals like bit
, jit
and ffi
which could be considered part of the standard library for LuaJIT
I don't think there is any keyword autocomplete? That would be great too. In a for
loop it should suggest in
, do
and end
, but also if
, while
, repeat
, for
and function
too (of course depending on what you type). Currently no keyword is suggested unless they are already in the file
I tried to get a dev build going but it seems that you are using an "old" way of running a test system instead of the way Microsoft has defined it by running the client from the debug menu and attaching to the language server.
I think you should update the project to the latest way since it's much easier...
See Title
语法错误检查有问题,写一个语法错误的语句,错误提示出现大约3秒钟后自动消失。
I made a quick hack to get LuaCoderAssist working in Emacs for me. By implementing a stdio version of the LSP protocol.
I haven't tested it with VSCode, but if you want to pull it in, it's there for the taking.
One example problematic file is this: https://github.com/MikuAuahDark/livesim2/blob/master/game/md5.lua
That file make sure correct MD5 is returned for certain input size due to bug in LOVE 11.2 and earlier, and use fallback in that case or if LOVE version is lower than 11.0.
Somehow, that file causes LuaCoderAssistant to hang. Once I open that file, then no type hinting, no keyword suggestion, no Luacheck, everything just stops as if I open a normal text file which affects all Lua files I open. One thing I notice is that when that happends, one of VS Code process fully uses one of my CPU core. When I terminate it, LuaCoderAssistant will complain that the server is closed, then everything backs to normal. However, once I open the problematic file again, the problem continues.
Enabling debug doesn't really help, there's no meaningful information I can get from the log (no, there's no message printed at all regarding that problem).
Version 2.2.6
EDIT: Seems not happen in version 2.2.5. Until this problem is fixed, I'll stay at 2.2.5 atm.
如题
I think it would be helpful if require('
Would open up intellisense for path completion of required file names
Also being able to complete the path from searchPaths would be great, but even just in the workspaceroot would be handy,
Insert LDoc isn't working for me. What do i wrong?
Otherwise best extension what i used. Thank you very much!
Opening a large lua file gave me this error:
[Info - 7:33:33 PM] extension initialize status: false
[Error - 7:33:33 PM] Notification handler 'workspace/didChangeConfiguration' failed with message: path must be a string or Buffer
TypeError: Cannot read property 'parse' of undefined
at SymbolManager.parseDocument (/home/boonie/.vscode-insiders/extensions/liwangqian.luacoderassist-1.2.3/server/providers/lib/symbol-manager.js:30:27)
at Coder.onDidChangeContent (/home/boonie/.vscode-insiders/extensions/liwangqian.luacoderassist-1.2.3/server/coder.js:88:37)
at documents.onDidChangeContent (/home/boonie/.vscode-insiders/extensions/liwangqian.luacoderassist-1.2.3/server/server.js:50:11)
at CallbackList.invoke (/home/boonie/.vscode-insiders/extensions/liwangqian.luacoderassist-1.2.3/node_modules/vscode-jsonrpc/lib/events.js:71:39)
at Emitter.fire (/home/boonie/.vscode-insiders/extensions/liwangqian.luacoderassist-1.2.3/node_modules/vscode-jsonrpc/lib/events.js:135:36)
at connection.onDidOpenTextDocument (/home/boonie/.vscode-insiders/extensions/liwangqian.luacoderassist-1.2.3/node_modules/vscode-languageserver/lib/main.js:174:38)
at handleNotification (/home/boonie/.vscode-insiders/extensions/liwangqian.luacoderassist-1.2.3/node_modules/vscode-jsonrpc/lib/main.js:476:43)
at processMessageQueue (/home/boonie/.vscode-insiders/extensions/liwangqian.luacoderassist-1.2.3/node_modules/vscode-jsonrpc/lib/main.js:248:17)
at Immediate.<anonymous> (/home/boonie/.vscode-insiders/extensions/liwangqian.luacoderassist-1.2.3/node_modules/vscode-jsonrpc/lib/main.js:235:13)
at runCallback (timers.js:672:20)
And when I hover over any of the variables in the file, I'm getting this error:
[Error - 7:34:14 PM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Cannot read property 'provideHover' of undefined
Code: -32603
[Error - 7:34:34 PM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Cannot read property 'provideHover' of undefined
Code: -32603
Happy to provide any other information necessary to sort out this issue.
i have a file in my project directory (./volumes/kong/lua/5.1/kong/plugins/basic-auth/handler.lua) which require another sibling file (./volumes/kong/lua/5.1/kong/plugins/basic-auth/access.lua).
the require was defined like this :
-- in handler.lua
local access = require "kong.plugins.basic-auth.access"
i would like to have code completion from the access variables.
My question are
thanks
The setting LuaCoderAssist.luacheck.enable
does not affect whether or not luacheck is enabled, and I would very much love to disable it.
Currently the only way to disable it is by renaming/removing the luacheck exe that comes with the extension.
I've had this error show up when there is no autocomplete information about a table:
[Error - 11:33:44 PM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Cannot read property 'instancing' of undefined
Code: -32603
The error is not really obtrusive, but it forcefully opens the Output panel, and displays this text
This can be easily replicated, just enable Use Love
and paste the following code on a Lua file:
local supported = love.graphics.getSupported()
print(supported.instancing)
And hover over the instancing
part. That should trigger the error
Note that the love-completion.json
just specifies that supported
is a table
and not what key-value pairs it holds.
You can check that supported
is correctly defined as a table
by hovering over it
I'm on Windows 10 x64, VSCode 1.28.0 (user setup) and using LuaCoderAssist 2.1.1
The latest change is a great improvement however it still doesn't handle my use case of relying completely on .luacheckrc in a parent directory.
Proposed solution: Wrap all automatic settings stuff in a boolean setting automaticOptions leaving just
defaultOpts and settings.options outside of the check
Doing this will allow me full control over how luacheck behaves by clearing settings.options and disabling automatic stuff. While retaining the behaviour you would like
These are the changes I have to do in order to use this plugin.
command(document) {
const settings = this.coder.settings.luacheck;
let args = [];
if settings.automaticoptions {
if (isFileSync(path_1.resolve(settings.configFilePath, ".luacheckrc"))) {
args.push('--config', path_1.resolve(settings.configFilePath, ".luacheckrc"));
}
let std = settings.std;
let luaversion = this.coder.settings.luaparse.luaversion;
if (luaversion === 5.1) {
std.push('lua51');
} else if (luaversion === 5.2) {
std.push('lua52');
} else if (luaversion === 5.3) {
std.push('lua53');
}
if (std.length > 0) {
args.push('--std', std.join('+'));
}
if (settings.ignore.length > 0) {
args.push("-i");
args.push.apply(args, settings.ignore);
}
if (this.coder.settings.format.lineWidth > 0) {
args.push('--max-line-length', this.coder.settings.format.lineWidth);
}
let mdl = engine.LoadedPackages[document.uri];
let globals = settings.globals;
if (mdl) {
mdl.type.imports.forEach(im => {
globals.push(im.name);
});
}
if (globals.length > 0) {
args.push('--read-globals');
args.push.apply(args, globals);
}
const jobs = settings.jobs;
if (jobs > 1) {
args.push('-j', jobs);
}
}
args.push.apply(args, defaultOpt);
args.push.apply(args, settings.options);
const fileName = uri_1.parse(document.uri).fsPath;
args.push("--filename", fileName, "-"); //use stdin
let cmd = settings.execPath || default_luacheck_executor;
return {
cmd: cmd,
cwd: path_1.dirname(fileName),
args: args
};
}
Hyphens in file name don't load symbols
local gui = require('mod-gui') --doesn't load symbols for mod-gui.lua
local gui = require('modgui) -- loads symbols
Related #38
Hello,
Thanks for your great work! LuaCoderAssist is the best lua extension for VS Code!
BUG in v.2.2.5 ( macOS 10.13.6 )
In outline window when activated Follow Cursor mode not occur following the cursor in the editor window.
In breadcrumbs the symbols structure is not displayed correctly and current position of the cursor is not actual.
This' a awesome extension for lua, please intergrade debugger support!
It's not uncommon for projects to extend the base libraries, like math.*
. For example, I may want to provide math.clamp
to my users:
{
"global": {
"type": "table",
"fields": {
"math": {
"type":"table",
"description":"This library is an interface to the standard C math library. It provides all its functions inside the table math.",
"link":"https://www.lua.org/manual/5.1/manual.html#5.6",
"fields": {
"clamp":{
"type":"function",
"description":"Returns a value, limited by upper and lower bounds.",
"args":[{
"name":"value"
},{
"name":"min"
},{
"name":"max"
}],
"argTypes":["number","number","number"]
}
}
}
}
}
}
However, this extension will not merge the two math tables, or even allow replacing the existing math table. Any attempts to add or remove fields are ignored.
It would be beneficial if:
engine.loadExtentLib
for stdlib to provide their own.I currently have this kind of setup
The main project ${workspaceFolder}/file.lua
A library project c:\develop\library\util.lua
A symlink to my library project on LuaPath c:\lua\modules\__library__
How would I set it up so doing
Local Var = require('__library__/util')
will correctly import the autocompletion and other features.
Hello. I just installed the extension and this error shows up whenever I open a lua file:
module.js:472
throw err;
^
Error: Cannot find module './Coder'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/boonie/.vscode-insiders/extensions/liwangqian.luacoderassist-1.2.1/server/server.js:7:15)
at Object.<anonymous> (/home/boonie/.vscode-insiders/extensions/liwangqian.luacoderassist-1.2.1/server/server.js:114:3)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
[Info - 4:18:48 AM] Connection to server got closed.
I think the import just needs to be lowercased.
The default CLI arguments should contain no extra paramaters and instead be wrapped in settings checks.
This will allow for 'out of the box' working with .luacheckrc (this file by default is looked for in the cwd up to drive root, in the users home directory, and finally in the luacheck appdata directory on windows)
const defaultOpt = ['--no-color', '--codes', '--ranges', '--formatter', 'plain'];
'-m'
and '-t''
should be removed or have their own settings.entry
if (docSym) {
globals = docSym.dependences().map((dep) => {
return dep.name;
});
}
if (globals.length > 0) {
args.push('--read-globals');
args.push.apply(args, globals);
}
Should also be wrapped in a settings check.
Also a minor thing but finally
if a .luacheckrc has an error in it, outputting the error could be helpful. Example output string follows
Critical error: Couldn't load configuration from ..\.luacheckrc: syntax error (line 163: '}' expected (to close '{' at line 156) near 'util')
Hello and thanks for this extension that is really helpful!
Im working on the AwesomeWM and we are using extensively the use of the init.lua in folder to organize our code.
for example /button/init.lua
instead of /button/button.lua
to be able to do local button = require('button')
instead of local button = require('button.button)'
To get LuaCoderAssist find my file for the moment I am forced to do require('button.init')
is there a way to configure it to do so?
Thanks in advance
I noticed LuaCoderAssist fails to parse some code.
This is the simplest code snippet I can make that produces an error.
local function foo(tbl, index)
local item = tbl[index] or {amount = 0}
item.amount = item.amount
end
[Info - 11:05:07 PM] coder inited
[Info - 11:05:07 PM] extension initialize status: true
[Error - 11:05:07 PM] TypeError: Cannot read property 'valid' of undefined
at LuaSymbol.get valid [as valid] (c:\Users\me\.vscode\extensions\liwangqian.luacoderassist-2.2.7\server\lib\engine\symbol.js:126:27)
at LuaTable.set (c:\Users\me\.vscode\extensions\liwangqian.luacoderassist-2.2.7\server\lib\engine\symbol.js:307:32)
at LuaSymbol.set (c:\Users\me\.vscode\extensions\liwangqian.luacoderassist-2.2.7\server\lib\engine\symbol.js:122:19)
at parseInitStatement (c:\Users\me\.vscode\extensions\liwangqian.luacoderassist-2.2.7\server\lib\engine\core.js:194:26)
at parseInitStatement (c:\Users\me\.vscode\extensions\liwangqian.luacoderassist-2.2.7\server\lib\engine\core.js:97:13)
at node.variables.forEach (c:\Users\me\.vscode\extensions\liwangqian.luacoderassist-2.2.7\server\lib\engine\core.js:191:13)
at Array.forEach (<anonymous>)
at parseAssignmentStatement (c:\Users\me\.vscode\extensions\liwangqian.luacoderassist-2.2.7\server\lib\engine\core.js:153:24)
at walkNode (c:\Users\me\.vscode\extensions\liwangqian.luacoderassist-2.2.7\server\lib\engine\core.js:467:17)
at Array.forEach (<anonymous>)
[Info - 11:05:08 PM] luacheck check file:///d%3A/test/test.lua in 35 ms.
I do have Lua files with longer lines but whatever I try to set lineWidth to - I always get the warning as well as the visual green line in the code. Would be great if one could disable this feature (or, of course, if the allowed lineWidth could be configured)
如果在A.lua文件中使用了B.lua文件中的方法,但是A.lua文件并没有在开头部分显式地require "B.lua"
这似乎会导致插件无法识别出A.lua中关于B.lua的引用
但实际上B.lua在运行的时候可能在之前的某阶段里已经加载进lua虚拟机中可以正常使用了
所以可不可以有一个require file entry之类的针对当前项目的设置,
这个entry中记录那些作为lua执行入口的lua文件
然后根据这些entry中的lua文件中的require信息,层层遍历,最终构建出所有lua文件的依赖关系
支持面向对象的编程风格,类似代码如下:
--- Object.lua
local Object = {}
function Object.new()
return setmetatable({}, Object)
end
function Object:tostring()
return "Object"
end
return Object
-------
------ some.lua
local Object = require('Object')
local newObj = Object.new()
print(newObj:tostring())
BUG in v.2.2.5 ( macOS 10.13.6 )
I am currently creating Corona completions to add it to LuaCoderAssist like added Love compilations and discovered strange symbols behavior when declaring and defining functions.
In the first case problem with adding new fields to returned table (CASE 1):
In the second case problem is inclusion all fields in one object, but in Lua it is not true (CASE 2):
Alternative definition of the function (CASE 3):
And once I caught this bug:
Thanks for LuaCoderAssist!
I hope my report will help make it better.
1.有QQ群之类的不
2.文件之间跳转定义需要定义或者设置哪些东西
3.vscode 自带的 ctrl+t 工作空间内的符号查找无效.
4.luacheck 格式化代码可以用tab代替空格么
It seems LCA doesn't specialize require("love")
even if "Use LOVE libraries" is checked. This is bit troublesome for me because I always use local love = require("love")
anywhere in my code. I wonder if it's possible to specialize require("love")
in this case?
It's usually happends at 10-20 minutes of coding session, then Luacheck errors/warnings stops displayed. The only way to show it back is to reload VS Code window.
Reproducing this is bit hard, but I notice it happends faster when I have to work & switch to multiple files.
I come from Atom and over there we use a package called autocomplete-lua-plus
This package can then be extended by other plugins in order to provide autocomplete for other modules, using a format called .luacompleterc
which is a JSON schema described in the README of the aforementioned plugin.
This kind of extensibility would be great for stuff like frameworks and libraries and would allow an easy way to provide advanced autocomplete for this kind of modules.
main.txt
myClass.txt
main中Test()无法跳转,New()可以
可以让luacheck也按照设置里的值工作吗?
我在windows下尝试设置成"LuaCoderAssist.luacheck.configFilePath": "D:/luacheckdefault.luacheckrc"
luacheckdefault.luacheckrc文件里这样子的:
globals = {"Util",}
然后看上去它似乎没有工作?
For versions 2.2.6, 2.2.5 I get the following error:
[Error - 4:35:40 AM] Server initialization failed.
Message: Request initialize failed with message: Cannot read property 'map' of null
Code: -32603
Always the same error.
Version 2.2.3 is fine, no error. Others on Discord do not have the same error.
Hi,
do you think that it is possible to add support to autocompletion of functions that are inherited using metatable? Example in gif below:
As you can see table B should inherit function Foo from table A (and it worked in runtime - look at the debug console, there is "foo" printed out) but vscode did not suggested this in autocompletion (it did but only because this keyword was already used in same document, it was not suggested as member function of table B). Also if table A would be in different file and got required using local A = require("a") go to definition would not work as well.
Global tables that are returned don't load symbols (however the var itself correctly shows as a table)
fileA.lua
some_var = {}
function some_var.value() return true end
return some_var
fileB.lua
local some_thing = require('fileA')
-- both some_thing and some_var show up as table types however there are no symbols for them
The plugin automatically removes all ';' at the end of a command during automatic formatting. But I need this because the LUA code is compressed and at the end everything is in one line. Is it possible to prevent the ';' from being removed?
And is it possible to make the editor check if there are ';' at the end of a command?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.