lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

A language server that offers Lua language support - programmed in Lua

Results 496 lua-language-server issues
Sort by recently updated
recently updated
newest added

### How are you using the lua-language-server? Visual Studio Code Extension (sumneko.lua) ### Which OS are you using? Windows WSL ### What is the issue affecting? Spell Checking ### Expected...

I'm trying to add annotations to [classic](https://github.com/rxi/classic/blob/master/classic.lua), but encounter a few problems when doing so. For example, the `super` field refers to the superclass. If I were to annotate super...

Additional blank lines are added to parameter descriptions in type annotations

[{"_id":"66c84f2365e3f042b807be47","body":"This is mostly like because Lua-LS or LuaCATS can't recognize multi-line string for `@param`. When hovered on the parameter `bar`, the docstring for the parameter will be \"This is the description\" (without `foo bar`).\r\n\r\nIt'd be great if multi-line strings can be supported for `@param` desc -- because in some cases the description can be quite long. @sumneko Would this be possible?","issue_id":1708973900527,"origin_id":1897763563,"user_origin_id":1009873,"create_time":1705551251,"update_time":1705773748,"id":1724403491201,"updated_at":"2024-08-23T08:58:11.200000Z","created_at":"2024-08-23T08:58:11.200000Z"}] comment

### How are you using the lua-language-server? NeoVim ### Which OS are you using? MacOS ### What is the issue affecting? Hover ### Expected Behaviour For multiline descriptions in `@param`...

### How are you using the lua-language-server? NeoVim ### Which OS are you using? Linux ### What is the issue affecting? Other ### Expected Behaviour Global settings from the client...

How to implement automatic derivation of function parameter types

[{"_id":"66c84f4565e3f042b807be5f","body":"`script\/vm\/compiler.lua` compileLocal\r\n```lua\r\n if source.parent.type == 'funcargs' and not hasMarkDoc and not hasMarkParam then\r\n local func = source.parent.parent\r\n -- local call ---@type fun(f: fun(x: number));call(function (x) end) --> x -> number\r\n local funcNode = vm.compileNode(func)\r\n local hasDocArg\r\n for n in funcNode:eachObject() do\r\n if n.type == 'doc.type.function' then\r\n for index, arg in ipairs(n.args) do\r\n if func.args[index] == source then\r\n local argNode = vm.compileNode(arg)\r\n for an in argNode:eachObject() do\r\n if an.type ~= 'doc.generic.name' then\r\n vm.setNode(source, an)\r\n end\r\n end\r\n hasDocArg = true\r\n end\r\n end\r\n end\r\n end\r\n if not hasDocArg then\r\n local refs = vm.getRefs(source.parent.parent)\r\n local findCall\r\n if refs then\r\n for i, ref in ipairs(refs) do\r\n if ref.parent.type == 'call' then\r\n findCall = ref.parent\r\n break\r\n end\r\n end\r\n end\r\n if findCall then\r\n local index\r\n for i, arg in ipairs(source.parent) do\r\n if arg == source then\r\n index = i\r\n break\r\n end\r\n end\r\n if index then\r\n hasDocArg = true\r\n local callerArg = findCall.args[index]\r\n vm.setNode(source, vm.compileNode(callerArg))\r\n end\r\n end\r\n end\r\n if not hasDocArg then\r\n vm.setNode(source, vm.declareGlobal('type', 'any'))\r\n end\r\n end\r\n```\r\nIt's worked","issue_id":1708973900535,"origin_id":1891645534,"user_origin_id":15152525,"create_time":1705310262,"update_time":1705310262,"id":1724403525469,"updated_at":"2024-08-23T08:58:45.468000Z","created_at":"2024-08-23T08:58:45.468000Z"},{"_id":"66c84f4565e3f042b807be60","body":"`vm.getRefs` may very slow","issue_id":1708973900535,"origin_id":1892989077,"user_origin_id":5213431,"create_time":1705373018,"update_time":1705373018,"id":1724403525475,"updated_at":"2024-08-23T08:58:45.474000Z","created_at":"2024-08-23T08:58:45.474000Z"},{"_id":"66c84f4565e3f042b807be61","body":"It is indeed slow, so one should limit the search in which way.\r\nI think first just find the first valid function call.","issue_id":1708973900535,"origin_id":1892991996,"user_origin_id":15152525,"create_time":1705373309,"update_time":1705373309,"id":1724403525477,"updated_at":"2024-08-23T08:58:45.477000Z","created_at":"2024-08-23T08:58:45.477000Z"},{"_id":"66c84f4565e3f042b807be62","body":"Limiting types to local variables\uff0cmaybe better","issue_id":1708973900535,"origin_id":1893014278,"user_origin_id":15152525,"create_time":1705375431,"update_time":1705375431,"id":1724403525480,"updated_at":"2024-08-23T08:58:45.480000Z","created_at":"2024-08-23T08:58:45.480000Z"}] comment

```lua local function t(a) a? --unkown end t({A=1}) ``` This feature is not available in the current language server. I would like to add it as a feature and have...

Unable to turn off continuous align

[{"_id":"66c84f56d340b986da0e9c1f","body":"please see https:\/\/github.com\/CppCXY\/EmmyLuaCodeStyle\/blob\/master\/lua.template.editorconfig\r\nthe names of many options have changed, and many new options have been added.\r\nyour question is set `align_array_table=false`","issue_id":1708973900540,"origin_id":1469190241,"user_origin_id":40318218,"create_time":1678846313,"update_time":1678846313,"id":1724403542395,"updated_at":"2024-08-23T08:59:02.395000Z","created_at":"2024-08-23T08:59:02.395000Z"},{"_id":"66c84f56d340b986da0e9c20","body":"@CppCXY I just tried the suggest option but behavior wise nothing changed. Still behaves as @KayleMaster described above.","issue_id":1708973900540,"origin_id":1891065881,"user_origin_id":42165023,"create_time":1705264634,"update_time":1705264634,"id":1724403542400,"updated_at":"2024-08-23T08:59:02.400000Z","created_at":"2024-08-23T08:59:02.400000Z"},{"_id":"66c84f56d340b986da0e9c21","body":"Aight. So the situation is that I'm providing the arguments directly through `nvim-lspconfig` rather that `.editorconfig`. It can't handle the value passed als lua bool. You will have to provide `\"false\"` like so (if that correlates to your issue):\r\n\r\n```lua\r\nLua = {\r\n . . .\r\n format = {\r\n enable = true,\r\n defaultConfig = {\r\n indent_style = \"space\",\r\n indent_size = \"4\",\r\n quote_style = \"double\",\r\n align_array_table = \"false\",\r\n },\r\n },\r\n},\r\n```","issue_id":1708973900540,"origin_id":1891068594,"user_origin_id":42165023,"create_time":1705265403,"update_time":1705265439,"id":1724403542404,"updated_at":"2024-08-23T08:59:02.404000Z","created_at":"2024-08-23T08:59:02.404000Z"},{"_id":"66c84f56d340b986da0e9c22","body":"> Aight. So the situation is that I'm providing the arguments directly through `nvim-lspconfig` rather that `.editorconfig`. It can't handle the value passed als lua bool. You will have to provide `\"false\"` like so (if that correlates to your issue):\r\n> \r\n> ```lua\r\n> Lua = {\r\n> . . .\r\n> format = {\r\n> enable = true,\r\n> defaultConfig = {\r\n> indent_style = \"space\",\r\n> indent_size = \"4\",\r\n> quote_style = \"double\",\r\n> align_array_table = \"false\",\r\n> },\r\n> },\r\n> },\r\n> ```\r\n\r\n![image](https:\/\/github.com\/LuaLS\/lua-language-server\/assets\/40318218\/9631506c-3f1b-4c5f-b65a-432e8c415836)\r\n\r\nI don't have neovim., so I tested it on vscode and it's basically right. maybe you already have a .editorconfig file in your workspace, so it won't use the default configuration.","issue_id":1708973900540,"origin_id":1891237500,"user_origin_id":40318218,"create_time":1705288383,"update_time":1705288383,"id":1724403542407,"updated_at":"2024-08-23T08:59:02.407000Z","created_at":"2024-08-23T08:59:02.407000Z"}] comment

### How are you using the lua-language-server? Visual Studio Code Extension (sumneko.lua) ### Which OS are you using? Windows ### What is the issue affecting? Formatting ### Expected Behaviour ```lua...

feat/formatter

Type warning when calling os.time with a table

[{"_id":"66c84f56a5570c2d1504c7e5","body":"Interesting, I can't reproduce this issue.","issue_id":1708973900544,"origin_id":1885116192,"user_origin_id":41503714,"create_time":1704901757,"update_time":1704901757,"id":1724403542481,"updated_at":"2024-08-23T08:59:02.481000Z","created_at":"2024-08-23T08:59:02.481000Z"},{"_id":"66c84f56a5570c2d1504c7e6","body":"I can reproduce it. It's because of the fix for this issue: https:\/\/github.com\/LuaLS\/lua-language-server\/issues\/2235\r\n\r\n`os.time` should probably be updated to accept `osdate` as well.","issue_id":1708973900544,"origin_id":1889672965,"user_origin_id":756608,"create_time":1705079707,"update_time":1705079707,"id":1724403542484,"updated_at":"2024-08-23T08:59:02.483000Z","created_at":"2024-08-23T08:59:02.483000Z"},{"_id":"66c84f56a5570c2d1504c7e7","body":"I also narrowed it down to that commit. Maybe @carsakiller can tell us why the `osdate` param type didn't work and needed to be duplicated as `osdateparam`?","issue_id":1708973900544,"origin_id":1890382625,"user_origin_id":41503714,"create_time":1705135242,"update_time":1705135242,"id":1724403542487,"updated_at":"2024-08-23T08:59:02.486000Z","created_at":"2024-08-23T08:59:02.486000Z"},{"_id":"66c84f56a5570c2d1504c7e8","body":"It didn't work because of the introduction of the missing field diagnostic. `osdate` fields returned by `os.date` won't have `nil` values, but you can pass a partial `osdate` to `os.time`. Simply updating `osdate` to make the fields optional would've made it difficult to work with the value returned from `os.date` (you'd have to check for `nil`), so I can understand why a separate type was needed.","issue_id":1708973900544,"origin_id":1890455097,"user_origin_id":756608,"create_time":1705151662,"update_time":1705151662,"id":1724403542489,"updated_at":"2024-08-23T08:59:02.489000Z","created_at":"2024-08-23T08:59:02.489000Z"},{"_id":"66c84f56a5570c2d1504c7e9","body":"@firas-assaad is correct. It was necessary to prevent excessive nil checking. This seems to be a similar problem, unfortunately. `os.date` can return a `string` or `table` (depending on the argument) but the server is unable to narrow the resulting type, leading to this warning that it *could* be a string.\r\n\r\nI'm not sure if there is anything we can do with just the definitions to fix the string issue, as the return types of `os.date` are correct and the argument type of `os.time` is correct. We can't add a `string` as an option for `os.time` and we can't remove it as a return type of `os.date` either.\r\n\r\nIf we add `osdate` like @firas-assaad said, we can do the following:\r\n```lua\r\nlocal tDate = os.date(\"*t\", os.time())\r\n---@cast tDate -string\r\nlocal newTime = os.time(tDate)\r\n```","issue_id":1708973900544,"origin_id":1890593025,"user_origin_id":61925890,"create_time":1705165205,"update_time":1705165205,"id":1724403542492,"updated_at":"2024-08-23T08:59:02.491000Z","created_at":"2024-08-23T08:59:02.491000Z"},{"_id":"66c84f56a5570c2d1504c7ea","body":"I'm fine with having to cast to remove the string type. The current logic makes sense: a function may return a string, so if you pass the value to another function that only accepts tables, you'll have to add annotations to express your intent.\r\n\r\nNow it'd be nice if we could override function definitions to say that the more specific `'*t'` argument returns a table whereas any other string argument returns a string, but that's probably a different story.","issue_id":1708973900544,"origin_id":1890598503,"user_origin_id":756608,"create_time":1705166287,"update_time":1705166428,"id":1724403542494,"updated_at":"2024-08-23T08:59:02.494000Z","created_at":"2024-08-23T08:59:02.494000Z"},{"_id":"66c84f56a5570c2d1504c7eb","body":"That is the problem talked about pretty extensively in https:\/\/github.com\/LuaLS\/lua-language-server\/issues\/1456.","issue_id":1708973900544,"origin_id":1890599880,"user_origin_id":61925890,"create_time":1705166617,"update_time":1705166617,"id":1724403542496,"updated_at":"2024-08-23T08:59:02.496000Z","created_at":"2024-08-23T08:59:02.496000Z"}] comment

### How are you using the lua-language-server? Visual Studio Code Extension (sumneko.lua) ### Which OS are you using? Windows ### What is the issue affecting? Type Checking ### Expected Behaviour...

feat/type check

[Feature request] User defined type guards like TypeScript's one

[{"_id":"66c84f1fd340b986da0e9c07","body":"I'd like this feature as well. It's been proposed a couple of times in the past, but it's apparently hard to implement: https:\/\/github.com\/LuaLS\/lua-language-server\/issues\/1030#issuecomment-1156378355","issue_id":1708973900548,"origin_id":1889678339,"user_origin_id":756608,"create_time":1705079950,"update_time":1705079950,"id":1724403487898,"updated_at":"2024-08-23T08:58:07.897000Z","created_at":"2024-08-23T08:58:07.897000Z"}] comment

As a simple example, I would like to annotate the following `@guard x string`. This is in effect returning a boolean, which narrows down the type of the argument x....

enhancement
feat/LuaCats Annotations
feat/type check

No warning when assign constant `nil` to required table field

[{"_id":"66c84f34d340b986da0e9c0b","body":"why? https:\/\/github.com\/LuaLS\/lua-language-server\/commit\/e5f07d0c9830afdfa1ce3b354a123212e5837526","issue_id":1708973900551,"origin_id":1883053171,"user_origin_id":43112758,"create_time":1704806837,"update_time":1704806837,"id":1724403508624,"updated_at":"2024-08-23T08:58:28.624000Z","created_at":"2024-08-23T08:58:28.624000Z"}] comment

### How are you using the lua-language-server? Visual Studio Code Extension (sumneko.lua) ### Which OS are you using? Linux ### What is the issue affecting? Type Checking ### Expected Behaviour...

#1861 This feature request requests variadic generics functionality, as well as mapping those generics. My proposed implementation of this feature request would allow the following example syntax: ```lua ---@generic R,...