Planning report #2366
Replies: 6 comments 16 replies
-
Hey Sumneko!
I agree, the language server is already capable of solving the most common occurrences in Lua programming. However, generics and better type narrowing are two of the biggest things I frequently run in to. Right now, if I write an
I agree. Because Lua is an embedded language, it can be found pretty much anywhere in almost any configuration. This makes it incredibly hard to make a language server for it. It is not just expected in the browser or Node.js, Lua could be running in a game, in a webpage, in a mobile app, or on a homemade arcade machine. We would need at least 10 Sumneko's to personally customize the language server for all of these use cases 😄. Covering the general usage and making the language server modular/extensible is likely the only realistic way to try to support as many people as possible. I can attest that the source code for the language server is a challenge to understand. I am not very knowledgeable when it comes to running Lua as a standalone application, but taking a look through the code is daunting. The language server is very impressive, especially considering you started with little knowledge of Lua, but there are sections of its code that are noticeably in need of a refactor. This is potentially where the biggest improvement could be made. If the code and implementation is easy to understand, hopefully there will be more contributions from the community to assist you in maintaining. It will also potentially allow people to modify the entire language server to their specific use-case, if need be. Annotation SystemAllowing users to run code in their annotations would definitely help them cover many use cases. We could also provide some common functions (sort of like TypeScript utility types), like Plugin SystemSounds like a solid improvement over the current system. Developing a solid API for users to interact with is crucial to improving the customization of the language server. What will make a plugin “trusted”? Looks like there will be lots to document, count me in! 🙂 Let me know where/when I can help! I would love to help where I am capable to make this refactor worth the effort and make the language server the best it can be! This may also be a good time to rename some things 😉. |
Beta Was this translation helpful? Give feedback.
-
First of all, I think this is a syntax error for standard lua: ---[[@@@@
]] In addition, I think we should separate the core implementation from the language server, separating the code analysis core from the language server appearance. If we can use the code analysis core as a third-party library for lua, then people who need it can use it directly and build their own language server on top of it. Also, allowing trusted programs to automatically load third-party code is often seen as a vulnerability that requires careful thought. |
Beta Was this translation helpful? Give feedback.
-
I don't think it's a good idea to write code inside comments, simply make it possible for users to add metafunctions in the plugin system instead of writing metafunctions in comments. 我觉得注释里面写代码不是一个好主意,干脆在插件系统里让用户可以添加元函数,而不是在注释里写元函数。 |
Beta Was this translation helpful? Give feedback.
-
The AST-based plugin API that you added recently already solves 90% of my remaining 10% which is amazing, thank you! Custom diagnostics also sound amazing and will probably solve a lot more problems |
Beta Was this translation helpful? Give feedback.
-
Will this rewrite also address slow loading times with larger projects like the one from tencent does? https://github.com/Tencent/LuaHelper |
Beta Was this translation helpful? Give feedback.
-
I love the idea that this annotation plugin is improved with the possibility of executing code and thus being able to increase its customization... By the way, I think it would be very good if the code blocks were written like this: ---@do
--[[
-- CODE HERE
]] --
---@end This way we can start a block with the annotation ---@Do and close the block with the annotation ---@EnD we can add a special argument to the annotations to make evaluations of functions encapsulated in the environment of the annotations ---@do
--[[
function getType(luaObj)
return cats.type('enum')
end
function getSuggest(luaObj)
if type(luaObj) ~= "table" then return end
local result = cats.suggest()
for key, value in pairs(luaObj) do
results[key] = value
end
return result
end
]] --
---@end
---@eval [type: getType, suggest: getSuggest]
MagicEffectClasses = {
FIRST_MAGIC_EFFECT = 1,
SECOND_MAGIC_EFFECT = 2,
THIRD_MAGIC_EFFECT = 4,
FOURTH_MAGIC_EFFECT = 8
} This pseudo code would make the MagicEffectClasses table of type enum and would also modify the autocomplete code suggestions to our liking. With the new evaluation method to modify the suggestion: I can think of many more great ideas to customize annotations, I hope you continue with the plugin and I hope one day I can contribute more than just suggestions <3 |
Beta Was this translation helpful? Give feedback.
-
I am writing this article to share with you my recent thoughts and plans for this project, which are a Turing-complete type system and a complete plugin system .
You may have noticed that I haven't been very active lately and have left a lot of issues unresolved. This is partly due to my busy work schedule, but more importantly, I have become somewhat tired of dealing with various minor issues. I believe that this language server has already solved 90% of the problems in Lua programming, but the remaining 10% is very tedious and requires a lot of effort. I believe there are two main factors here:
Therefore, I plan to carry out a complete overhaul, carefully planning and designing each module. My goal is still to solve 90% of the problems, and let users implement the remaining 10% themselves through annotations and plugins.
The following is my vision:
Annotation system
The annotation system is the current extension, where you can write a piece of code after the type, which will be executed every time the value is evaluated.
Plugin system
The plugin system is a Lua file placed in your own project, and the server will load this file as a "Mod" if it is trusted.
I have completed the refactoring of the basic syntax parser. The entire project refactoring will take more than six months, and I will occasionally share the progress during this period.
The implementation details mentioned above will be repeatedly modified, but the overall idea will not change. Suggestions and ideas from everyone are also welcome.
Original Text (in Chinese)
我写这篇文章想给大家展示一下我最近的想法,聊一聊此项目之后的规划,那就是:图灵完备的类型系统和完备的插件体系 。
你可能注意到我最近一段时间不是很活跃,遗留了大量的issue没有处理。这自然有我忙于工作的原因,但更重要的是我有点厌倦了处理各种细枝末节的问题。我相信这个语言服务器已经解决了Lua编程中90%的问题,但是剩下的10%非常枯燥并且需要消耗大量的精力。我自认为这里有2个主要因素:
因此我打算进行一次完全的重构,仔细规划设计各个模块。我的目标依然是解决90%的问题,剩下的10%则由用户自己通过注解与插件实现。
以下是我的设想:
注解系统
注解系统是目前的扩展,你可以在类型后面写一段代码,每次求值时会运算这段代码。
插件系统
插件系统是放置在你自己工程中的Lua文件,在信任的情况下服务器会加载此文件当做“Mod”。
目前我已经完成了基础语法解析器的重构,整个项目的重构需要半年以上的时间,在此期间我会偶尔分享进度。
上述的实现细节还会反复修改,但总体思路不会变,也欢迎大家提出自己的奇思妙想。
Beta Was this translation helpful? Give feedback.
All reactions