Skip to content

Support Custom Addons Path for Enhanced Editor Flexibility #3155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

IronBlood
Copy link

@IronBlood IronBlood commented Apr 16, 2025

This pull request enables users to specify a custom addons path for 3rd-party libraries, addressing the current limitation where only the VSCode-addons path is used.

Highlights:

  • Adds files.updateAddonsPath to let users update the addonsPath if it has not been configured already.
  • Validates the provided path using fs.exists after expanding it via util.expandPath.
  • Extends the language server's usability beyond VSCode to support editors like Vim/Neovim.

Currently the configuration Lua.addonRepositoryPath has a higher priority, but if it's not set, it won't affect the addon manager in vscode.

Example:

  1. Clone the addon repo, let's say the command is execute under /tmp so a folder /tmp/LLS-addons will be created with all the submodules.
    git clone --recurse-submodules https://github.com/LuaLS/LLS-Addons
  2. In the client configuration, for example neovim:
    vim.lsp.config('lua_ls', {
      on_init = function(client)
        client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
          -- don't forget the `addons` folder
          -- if it's somewhere under the `$HOME` directory, you can also use `~/path/to/LLS-Addons/addons`
          addonRepositoryPath = '/tmp/LLS-Addons/addons',
          -- other configurations
        })
      end,
      settings = { Lua = {} }
    })
  3. To add support of a library (e.g. penlight) in a project, config .luarc.json like this:
    {
        "workspace.library": [
            "${addons}/penlight/module/library",
        ]
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant