LuaLS / LLS-Addons

Addons for use with Sumneko's Lua Language Server
https://github.com/LuaLS/lua-language-server
MIT License
63 stars 46 forks source link

Add devilspie2 addon #182

Closed sparr closed 1 month ago

sparr commented 1 month ago

This addon is for writing scripts and config for https://github.com/dsalt/devilspie2

sparr commented 1 month ago

Thanks for the merge!

I can see this in the Addon Manager now, and can install/enable it, which puts "Lua.workspace.library": ["${addons}/devilspie2/module/library"] in my workspace settings... but the library doesn't seem to actually get used with my code. I previously had that same setting set to "/home/sparr/src/LuaLS-Addon-devilspie2/library" and then ""/home/sparr/src/LLS-Addons/addons/devilspie2/module/library" as I was preparing for this PR, and those works, but maybe I've mis-formed the addon module definition here somehow?

Having installed the addon, the folder button in the addon manager takes me to /home/sparr/.config/VSCodium/User/globalStorage/sumneko.lua/addonManager/addons/devilspie2/ which does have a module/library folder matching what was merged in this PR.

carsakiller commented 4 weeks ago

@sparr, are you on v3.11.0? I have tested it, and it seems to work fine. If you are, can you provide your OS?

sparr commented 4 weeks ago

I am on EndeavourOS (~Arch Linux), running VSCodium 1.93.1 and sumneko.lua-3.11.0-linux-x64.

I have no user or workspace settings for the lua extension. Here are the settings from defaultSettings.json:

defaultSettings.json ```json { "Lua.addonManager.enable": true, "Lua.codeLens.enable": false, "Lua.completion.autoRequire": true, "Lua.completion.callSnippet": "Disable", "Lua.completion.displayContext": 0, "Lua.completion.enable": true, "Lua.completion.keywordSnippet": "Replace", "Lua.completion.postfix": "@", "Lua.completion.requireSeparator": ".", "Lua.completion.showParams": true, "Lua.completion.showWord": "Fallback", "Lua.completion.workspaceWord": true, "Lua.diagnostics.disable": [], "Lua.diagnostics.disableScheme": [ "Lua.diagnostics.enable": true, "Lua.diagnostics.globals": [], "Lua.diagnostics.globalsRegex": [], "Lua.diagnostics.groupFileStatus": {}, "Lua.diagnostics.groupSeverity": {}, "Lua.diagnostics.ignoredFiles": "Opened", "Lua.diagnostics.libraryFiles": "Opened", "Lua.diagnostics.neededFileStatus": {}, "Lua.diagnostics.severity": {}, "Lua.diagnostics.unusedLocalExclude": [], "Lua.diagnostics.workspaceDelay": 3000, "Lua.diagnostics.workspaceEvent": "OnSave", "Lua.diagnostics.workspaceRate": 100, "Lua.doc.packageName": [], "Lua.doc.privateName": [], "Lua.doc.protectedName": [], "Lua.doc.regengine": "glob", "Lua.docScriptPath": "", "Lua.format.defaultConfig": {}, "Lua.format.enable": true, "Lua.hint.arrayIndex": "Auto", "Lua.hint.await": true, "Lua.hint.enable": false, "Lua.hint.paramName": "All", "Lua.hint.paramType": true, "Lua.hint.semicolon": "SameLine", "Lua.hint.setType": false, "Lua.hover.enable": true, "Lua.hover.enumsLimit": 5, "Lua.hover.expandAlias": true, "Lua.hover.previewFields": 50, "Lua.hover.viewNumber": true, "Lua.hover.viewString": true, "Lua.hover.viewStringMax": 1000, "Lua.language.completeAnnotation": true, "Lua.language.fixIndent": true, "Lua.misc.executablePath": "", "Lua.misc.parameters": [], "Lua.nameStyle.config": {}, "Lua.runtime.builtin": {}, "Lua.runtime.fileEncoding": "utf8", "Lua.runtime.meta": "${version} ${language} ${encoding}", "Lua.runtime.nonstandardSymbol": [], "Lua.runtime.path": [ "Lua.runtime.pathStrict": false, "Lua.runtime.plugin": "", "Lua.runtime.pluginArgs": [], // "Lua.runtime.special" : { "Lua.runtime.special": {}, "Lua.runtime.unicodeName": false, "Lua.runtime.version": "Lua 5.4", "Lua.semantic.annotation": true, "Lua.semantic.enable": true, "Lua.semantic.keyword": false, "Lua.semantic.variable": true, "Lua.signatureHelp.enable": true, "Lua.spell.dict": [], "Lua.type.castNumberToInteger": true, "Lua.type.checkTableShape": false, "Lua.type.inferParamType": false, "Lua.type.weakNilCheck": false, "Lua.type.weakUnionCheck": false, "Lua.typeFormat.config": {}, "Lua.window.progressBar": true, "Lua.window.statusBar": true, "Lua.workspace.checkThirdParty": "", "Lua.workspace.ignoreDir": [ "Lua.workspace.ignoreSubmodules": true, "Lua.workspace.library": [], "Lua.workspace.maxPreload": 5000, "Lua.workspace.preloadFileSize": 500, "Lua.workspace.useGitIgnore": true, "Lua.workspace.userThirdParty": [], ```

When I open the Lua Addon Manager, depending on where I am in troubleshooting (with reinstalling various things, resetting settings, etc) I see one of the following four states:

  1. no addons listed and a git rebase error in the log (which I failed to copy before losing that log to a recent delete and reinstall)
  2. all addons listed in the default state with an Enable button
  3. Devilspie2 at the top of the list with Enable and Uninstall buttons
  4. Devilspie2 at the top of the list with Disable and Uninstall buttons

From state 2 or state 3 if I click Enable then my workspace settings are populated with this:

{
    "Lua.workspace.library": [
        "${addons}/devilspie2/module/library"
    ],
    "Lua.workspace.checkThirdParty": false
}

Clicking Disable has no effect on the workspace settings or the state of the addon manager interface (the addon stays apparently enabled) aside from momentarily greying out the Disable and Uninstall buttons.

Clicking Uninstall greys out the buttons for a moment then removes the Uninstall button, leaving just a Disable button, and producing a popup saying there was an error in the addon manager and offering to file a bug report which copies the following log:

Retrieved Log ``` #### STARTUP #### [2024-10-08 06:27:10] | DEBUG | WebVue | Workspace Open: true [2024-10-08 06:27:10] | DEBUG | Filesystem | Created directory at "/home/sparr/.config/VSCodium/User/globalStorage/sumneko.lua/addonManager" [2024-10-08 06:27:10] | VERBOSE | Command | Executing "getAddons" ({"command":"getAddons","data":{"page":1}}) [2024-10-08 06:27:11] | ERROR | Addon Manager | Failed to fetch addons! Please check your connection to GitHub. [2024-10-08 06:27:11] | ERROR | Addon Manager | Cannot rebase onto multiple branches. [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found REFramework-LLS [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found RavenscriptIDEA [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found RavenscriptIDEA_withRavenM [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found StormworksAddonLua [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found TTSLua [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found ao [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found argparse [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found bee [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found busted [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found cc-tweaked [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found cocos4.0 [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found devilspie2 [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found dkjson [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found fenster [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found fivem [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found garrysmod [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found halion [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found lapis [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found lldebugger [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found lmathx [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found love-nuklear [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found love2d [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found lovr [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found lpeg [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found lua-cjson [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found luaecs [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found luafilesystem [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found luaharfbuzz [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found lualogging [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found luasocket [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found luassert [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found luaunit [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found luazip [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found luvit [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found lzlib [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found md5 [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found minetest [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found mirai [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found moneymoney [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found moonloader [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found nodemcu-esp32 [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found nodemcu-esp8266 [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found openresty [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found penlight [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found powder-toy [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found skynet [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found slnunicode [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found smbx2-lunalua [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found starfallex [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found tex-lualatex [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found tex-lualibs [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found tex-luametatex [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found tex-luatex [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found toml-edit [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found transformice [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found trilogyloader [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found umbrella [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found unbound-api [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found xmake [2024-10-08 06:27:11] | VERBOSE | Addon Manager | Found yue [2024-10-08 06:27:15] | VERBOSE | Command | Executing "getAddons" ({"command":"getAddons","data":{"page":1}}) [2024-10-08 06:27:20] | VERBOSE | Command | Executing "open" ({"command":"open","data":{"name":"devilspie2"}}) [2024-10-08 06:27:20] | INFO | Open Addon | Opening "devilspie2" addon in file explorer [2024-10-08 06:27:53] | VERBOSE | Command | Executing "getAddons" ({"command":"getAddons","data":{"page":1}}) [2024-10-08 06:27:58] | VERBOSE | Command | Executing "getAddons" ({"command":"getAddons","data":{"page":1}}) [2024-10-08 06:28:45] | VERBOSE | Command | Executing "getAddons" ({"command":"getAddons","data":{"page":1}}) [2024-10-08 06:30:09] | VERBOSE | Command | Executing "enable" ({"command":"enable","data":{"name":"devilspie2"}}) [2024-10-08 06:30:09] | DEBUG | Addon | Initialized submodule [2024-10-08 06:30:09] | DEBUG | Addon | Submodule up to date [2024-10-08 06:30:09] | INFO | Addon | Applied addon settings for devilspie2 [2024-10-08 06:30:09] | INFO | Addon | Enabled "devilspie2" [2024-10-08 06:30:38] | VERBOSE | Command | Executing "getAddons" ({"command":"getAddons","data":{"page":1}}) [2024-10-08 06:30:41] | VERBOSE | Command | Executing "disable" ({"command":"disable","data":{"name":"devilspie2"}}) [2024-10-08 06:30:41] | WARN | Addon | "devilspie2" is already disabled [2024-10-08 06:30:47] | VERBOSE | Command | Executing "getAddons" ({"command":"getAddons","data":{"page":1}}) [2024-10-08 06:31:23] | VERBOSE | Command | Executing "disable" ({"command":"disable","data":{"name":"devilspie2"}}) [2024-10-08 06:31:23] | WARN | Addon | "devilspie2" is already disabled [2024-10-08 06:31:37] | VERBOSE | Command | Executing "uninstall" ({"command":"uninstall","data":{"name":"devilspie2"}}) [2024-10-08 06:31:38] | DEBUG | Filesystem | Deleted /home/sparr/.config/VSCodium/User/globalStorage/sumneko.lua/addonManager/addons/devilspie2/module [2024-10-08 06:31:38] | INFO | Addon | Uninstalled devilspie2 [2024-10-08 06:31:38] | ERROR | Filesystem | Unable to resolve nonexistent file 'vscode-userdata:/home/sparr/.config/VSCodium/User/globalStorage/sumneko.lua/addonManager/addons/devilspie2/module' [2024-10-08 06:31:38] | ERROR | Filesystem | Unable to resolve nonexistent file 'vscode-userdata:/home/sparr/.config/VSCodium/User/globalStorage/sumneko.lua/addonManager/addons/devilspie2/module' ```

At that point the devilspie2/module directory has been deleted but devilspie2/info.json still exists. This leaves the addons/ git repository in the following state:

On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    devilspie2/module

no changes added to commit (use "git add" and/or "git commit -a")

I can't reproduce it right now, but I suspect the git error mentioned earlier is somewhere downstream of this situation.

At no point during any of the process described above, including when the module was apparently successfully enabled in my workspace settings, did the language server stop showing an Undefined global in my test lua file containing local window_name = get_window_name().

sparr commented 4 weeks ago

I just discovered/noticed that the addons/*/module directories are empty. The git submodules for the addons repo were never updated / checked out. If I do a git submodule update to check them all out, and use the workspace settings shown above, it still doesn't work. However, I can change those settings as follows:

{
    "Lua.workspace.library": [
        "/home/sparr/.config/VSCodium/User/globalStorage/sumneko.lua/addonManager/addons/devilspie2/module/library"
    ],
    "Lua.workspace.checkThirdParty": false
}

and it works, so at least I know that library/devispie2.lua is good.

sparr commented 4 weeks ago

aaaaaand I found the (a?) problem!

            elseif platform.os == "linux" then
                local serverPath = util.expandPath(fs.path("~/.vscode-server/data"):string())
                if fs.exists(serverPath) then
                    -- addons are installed via SSH remote
                    return serverPath .."/" .. dataPath
                else
                    return "~/.config/Code/" .. dataPath
                end

The path is hardcoded for Code which means it will fail for VSCodium and Code-OSS and any other renamed versions of the app. I'll try to figure out how to fix this and open a PR.