Giter Club home page Giter Club logo

luacoderassist's People

Contributors

alanfran avatar firesiku avatar liwangqian avatar pablomayobre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

luacoderassist's Issues

General autocomplete improvements

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

Build/test system

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...

Lint/diagnostics bug

语法错误检查有问题,写一个语法错误的语句,错误提示出现大约3秒钟后自动消失。

Support for LSP stdio server

I made a quick hack to get LuaCoderAssist working in Emacs for me. By implementing a stdio version of the LSP protocol.

Kaali@75effef

I haven't tested it with VSCode, but if you want to pull it in, it's there for the taking.

Hang when opening certain files

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.

Intellisense not working

See images below:

screenshot from 2018-01-28 17-37-36
screenshot from 2018-01-28 17-38-17

The first image is displaying the intellisense correctly, but the second image does not show what is inside the dict table.

Feature Request, require path intellisense

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,

How to LDoc

Insert LDoc isn't working for me. What do i wrong?

Otherwise best extension what i used. Thank you very much!

Type & Hover Error

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.

Question: How to properly set "LuaCoderAssist.search.externalPaths"

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

  1. does your plugins support this kind of code-completion scenario?
  2. if so, does LuaCoderAssist.search.externalPaths config related to this scenario?
  3. if it is, how do i properly set LuaCoderAssist.search.externalPaths?

thanks

Hover errors go to output

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

Replicate

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

Image

Screenshot of the error

System Info

I'm on Windows 10 x64, VSCode 1.28.0 (user setup) and using LuaCoderAssist 2.1.1

More automatic luacheck CLI changes requested.

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
        };
    }

使用self加字母时,无法触发VSCode的原生变量建议

1、自定义变量abc
2、使用self.a时无法显示变量建议

原生变量建议图:
image

LuaCoderAssist的变量建议图:
image

LuaCoderAssist在使用self加点后会显示本类函数名,这点是值得称赞,我原来一直使用的是VsCodeLua,这个喝好使,但也有许多不合理的地方。希望在self加点后,除了函数名,变量名也能一起显示出来。

关于全局变量的支持

image
image
image

  1. 请问目前支持全局变量的定义的跳转不.
  2. 面向对象式的定义跳转
  3. 建议增加 格式化代码的时候 是否可以设置 不去掉table的最后一个元素的逗号,不去掉的话也是符合lua语法的。这样子,在追加table成员的时候不用再手动敲 , 进去..

No auto completion for files with more than one parent folder

folder1/foo1.lua

local Foo1 = {}

function Foo1.foo()
    return true
end

return Foo1

folder1/folder2/foo2/lua

local Foo2 = {}

function Foo2.foo()
    return true
end

return Foo2

main.lua

local Foo1 = require('folder1.foo1')

local Foo2 = require('folder1.folder2.foo2')

Foo1.foo()

Foo2.foo()

image

image

无法显示VSCode的原生触发建议

在没安装(或者禁止)LuaCoderAssist插件运行时,VSCode的书写代码时会有如下提示:
image
安装(或者开启)LuaCoderAssist插件后,这些没有检查出来的函数将无法显示:
image

Outline and breadcrumbs navigation

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.

bug001

Can't extend already provided fields.

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:

  1. The workspace could prevent the first engine.loadExtentLib for stdlib to provide their own.
  2. Have entries inside of .luacompleterc or LuaCoderAssist.preloads files merge with or at least replace existing entries.

Required symbols from externalPaths does not work when in workspace Scope

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.

Error: Cannot find module './Coder'

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.

luacheck settings should default to unset.

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')

require and init.lua for AwesomeWM

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

Error with code snippet

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.

Setting the lineWidth does not work

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文件的依赖关系

考虑支持new创建的对象的智能补全和静态检查

支持面向对象的编程风格,类似代码如下:

--- 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())

Functions declaration

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):

bug002

In the second case problem is inclusion all fields in one object, but in Lua it is not true (CASE 2):

bug003

Alternative definition of the function (CASE 3):

bug004

And once I caught this bug:

bug005

Thanks for LuaCoderAssist!
I hope my report will help make it better.

使用方法和问题

1.有QQ群之类的不
2.文件之间跳转定义需要定义或者设置哪些东西
3.vscode 自带的 ctrl+t 工作空间内的符号查找无效.
4.luacheck 格式化代码可以用tab代替空格么

Lose type hinting for love when using require("love")

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?

Luacheck linter stops working after some time.

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.

Add a way to extend autocomplete

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.

请问要如何设置自定义全部变量?

我在windows下尝试设置成"LuaCoderAssist.luacheck.configFilePath": "D:/luacheckdefault.luacheckrc"
luacheckdefault.luacheckrc文件里这样子的:
globals = {"Util",}
然后看上去它似乎没有工作?

Server initialization failed Code: -32603

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.

Adding functions inherited through setmetatable to autocompletion

Hi,
do you think that it is possible to add support to autocompletion of functions that are inherited using metatable? Example in gif below:

lua

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 vars that are returned don't load symbols

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

image

Auto format removes ';'

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?

Return from return

BUG in v.2.2.5 ( macOS 10.13.6 )

When function returns values from return another functions the type of value are defining for first value only:

bug006

Thanks for LuaCoderAssist!
I hope my report will help make it better.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.