diff options
| author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2023-02-17 18:05:08 +0200 | 
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-17 18:05:08 +0200 | 
| commit | f43cc8e20b8443f052c8bd1dd74066eec514587b (patch) | |
| tree | 1d2a69140fcedc2030b36725fc922117dab39ac0 /lua/lvim/lsp/providers/lua_ls.lua | |
| parent | ddc86f3a8aaa1afd36cf8f1a46a29a57922efc8a (diff) | |
refactor(lsp)!: lua lsp renamed (#3836)
Need to run `:LvimCacheReset` after this for lua ftplugin regenration
* chore: bump plugins version
* refactor(loader): update lazy's cache setup
* chore: bump plugins version
* chore(lsp): skip antlerls for html
* fix(lsp): lua lsp renamed (#3841)
* fix(loader): lazy's cache is now a directory
* fix: LvimUpdate should bump core plugins (#3846)
* chore: bump plugins version
* fix(cmp): handle deprecated tree-sitter api (#3853)
* fix(loader): wrap cache invocation with pcall
avoid problems when lazy hasn't been updated yet
* chore(lsp): skip docker-compose ls
* chore: bump plugins
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: kylo252 <[email protected]>
Co-authored-by: Jieru Mei <[email protected]>
Co-authored-by: LostNeophyte <[email protected]>
Diffstat (limited to 'lua/lvim/lsp/providers/lua_ls.lua')
| -rw-r--r-- | lua/lvim/lsp/providers/lua_ls.lua | 63 | 
1 files changed, 63 insertions, 0 deletions
| diff --git a/lua/lvim/lsp/providers/lua_ls.lua b/lua/lvim/lsp/providers/lua_ls.lua new file mode 100644 index 00000000..2d3f4932 --- /dev/null +++ b/lua/lvim/lsp/providers/lua_ls.lua @@ -0,0 +1,63 @@ +local default_workspace = { +  library = { +    vim.fn.expand "$VIMRUNTIME", +    get_lvim_base_dir(), +    require("neodev.config").types(), +    "${3rd}/busted/library", +    "${3rd}/luassert/library", +  }, + +  maxPreload = 5000, +  preloadFileSize = 10000, +} + +local add_packages_to_workspace = function(packages, config) +  -- config.settings.Lua = config.settings.Lua or { workspace = default_workspace } +  local runtimedirs = vim.api.nvim__get_runtime({ "lua" }, true, { is_lua = true }) +  local workspace = config.settings.Lua.workspace +  for _, v in pairs(runtimedirs) do +    for _, pack in ipairs(packages) do +      if v:match(pack) and not vim.tbl_contains(workspace.library, v) then +        table.insert(workspace.library, v) +      end +    end +  end +end + +local lspconfig = require "lspconfig" + +local make_on_new_config = function(on_new_config, _) +  return lspconfig.util.add_hook_before(on_new_config, function(new_config, _) +    local server_name = new_config.name + +    if server_name ~= "lua_ls" then +      return +    end +    local plugins = { "plenary.nvim", "telescope.nvim", "nvim-treesitter", "LuaSnip" } +    add_packages_to_workspace(plugins, new_config) +  end) +end + +lspconfig.util.default_config = vim.tbl_extend("force", lspconfig.util.default_config, { +  on_new_config = make_on_new_config(lspconfig.util.default_config.on_new_config), +}) + +local opts = { +  settings = { +    Lua = { +      telemetry = { enable = false }, +      runtime = { +        version = "LuaJIT", +        special = { +          reload = "require", +        }, +      }, +      diagnostics = { +        globals = { "vim", "lvim", "reload" }, +      }, +      workspace = default_workspace, +    }, +  }, +} + +return opts | 
