Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 436
Plugins
carsakiller edited this page Aug 10, 2023
·
4 revisions
⚠️ WarningThis wiki has been replaced by the wiki on our website. This wiki will be removed in the future.
Plugins can be used to modify how the language server works.
This does not provide hinting or reporting of custom syntax errors, however, it will let you create a custom syntax that will then be output to a separate file.

- Add
--develop=truetoLua.misc.parameters- This allows the plugin to write to
LOGPATH/diffed.lua
- This allows the plugin to write to
- Create
.vscode/lua/plugin.luain your workspace (or some other absolute location) - Specify the path of the plugin via the
Lua.runtime.pluginsetting
This function provides the uri and text of the file that has been edited and expects a list of differences to be returned. The result will be written to diffed.lua in your log location.
---@classdiff---@fieldstartinteger # The number of bytes at the beginning of the replacement---@fieldfinishinteger # The number of bytes at the end of the replacement---@fieldtextstring # What to replace---@paramuristring # The uri of file---@paramtextstring # The content of file---@returnnil|diff[]functionOnSetText(uri, text) end
functionOnSetText(uri, text)
iftext:sub(1, 4) ~='--##' thenreturnnilendlocaldiffs= {}
diffs[#diffs+1] = {
start=1,
finish=4,
text='',
}
forlocalPos, colonPos, typeName, finishintext:gmatch'()local%s+[%w_]+()%s*%:%s*([%w_]+)()' dodiffs[#diffs+1] = {
start=localPos,
finish=localPos-1,
text= ('---@type %s\n'):format(typeName),
}
diffs[#diffs+1] = {
start=colonPos,
finish=finish-1,
text='',
}
endreturndiffsend