LuaLS / LuaLS/lua-language-server

Add documentation for the plugin environment

未关闭
#2,092 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

documentation feat/plugin
主要语言
Lua
星标
4.4k
派生
442
PR 合并指标
30 天内没有已合并 PR

描述

Plugins have a surprisingly large amount of flexibility when the surrounding environment is considered. Unfortunately, most of the environment is undocumented, which means there's a good chance plugin developers don't know how much their plugin can really do.

Currently, printing out package.path and package.cpath gives these directories

package.path

# directories provided by the extension
$LSP/script/?.lua
$LSP/script/?/init.lua

# access to the plugin's directory
$PLUGIN/?.lua

package.cpath

$LSP/bin/?.dll

where:

  • $LSP is the path to this project's folder, and
  • $PLUGIN is a path to the plugin's current directory. ~/project/config/plugin.lua would make $PLUGIN point to ~/project/config

Along with giving plugins the ability to have sub-modules, the LSP has some very useful utilities in its script folder like:

  • vm for inspecting types (or so it seems)
  • parser.compile for getting an AST
  • inspect which looks like kikito/inspect.lua
  • config for reading LSP settings like Lua.runtime.version

I don't work with Visual Studio enough to understand the DLLs in $LSP/bin, or at least not enough to work with them in Lua.

... has some useful information too.

local inspect = require("inspect")

print(inspect({ ... }))
--[[--> 
{ 
  <function 1>,                   -- this plugin loaded as a chunk using `load()`
  "file:///$WORKSPACE_FOLDER",    -- a URI pointing to the workspace folder
  {}                              -- arguments provided by the setting `Lua.runtime.pluginArgs`
}
]]

I think this information is useful enough to be documented in the wiki. I can contribute to it if need be.

It would be even more useful and accessible if there was a meta-addon that adds the $LSP/script directory to Lua.workspace.library or a boolean option that adds the directory internally. I can try to contribute to that as well.

I understand that $LSP/script may be updated often for bugfixes and other things. If this is the case, I think it would at least be useful to provide a directory for plugin utilities.

I'm not sure about what to do when the VS Code extension gets updated since it changes directory. Maybe, more generally, the LSP can warn you about missing libraries.

Also, if $LSP/script updates too frequently to be mentioned in the wiki, I think the meta-addon route would be more fruitful.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先查看 issue 中关于 plugin 环境的详细信息,包括 package.path、package.cpath、$LSP/script 工具,以及通过 .... 传递的 plugin 参数。确认哪些行为已经稳定到足以记录在 wiki 中,然后让 plugin 作者清楚了解环境和可用工具,而不要依赖推测性的 DLL 或 meta-addon 更改。

由索引模型根据 Issue 内容生成。

评估

技术栈
lua
领域
documentation
Issue 类型
文档
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。