aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-05-21 17:41:42 +0200
committerGitHub <noreply@github.com>2022-05-21 17:41:42 +0200
commit63f950401c666e18a82d93a7e6e1b0d7044f0432 (patch)
tree8087f03d550d765a1a01618d899d7ffbd0a9cf0b
parentrun autogen_metadata.lua (diff)
downloadmason-63f950401c666e18a82d93a7e6e1b0d7044f0432.tar
mason-63f950401c666e18a82d93a7e6e1b0d7044f0432.tar.gz
mason-63f950401c666e18a82d93a7e6e1b0d7044f0432.tar.bz2
mason-63f950401c666e18a82d93a7e6e1b0d7044f0432.tar.lz
mason-63f950401c666e18a82d93a7e6e1b0d7044f0432.tar.xz
mason-63f950401c666e18a82d93a7e6e1b0d7044f0432.tar.zst
mason-63f950401c666e18a82d93a7e6e1b0d7044f0432.zip
feat(github): add setting to customize asset download url (#711)
Closes #678.
-rw-r--r--README.md9
-rw-r--r--doc/nvim-lsp-installer.txt80
-rw-r--r--lua/nvim-lsp-installer/core/managers/github/init.lua3
-rw-r--r--lua/nvim-lsp-installer/settings.lua9
4 files changed, 73 insertions, 28 deletions
diff --git a/README.md b/README.md
index 385376c9..5f82fb3e 100644
--- a/README.md
+++ b/README.md
@@ -378,5 +378,14 @@ local DEFAULT_SETTINGS = {
-- Limit for the maximum amount of servers to be installed at the same time. Once this limit is reached, any further
-- servers that are requested to be installed will be put in a queue.
max_concurrent_installers = 4,
+
+ github = {
+ -- The template URL to use when downloading assets from GitHub.
+ -- The placeholders are the following (in order):
+ -- 1. The repository (e.g. "rust-lang/rust-analyzer")
+ -- 2. The release version (e.g. "v0.3.0")
+ -- 3. The asset name (e.g. "rust-analyzer-v0.3.0-x86_64-unknown-linux-gnu.tar.gz")
+ download_url_template = "https://github.com/%s/releases/download/%s/%s",
+ },
}
```
diff --git a/doc/nvim-lsp-installer.txt b/doc/nvim-lsp-installer.txt
index 9625803d..1f1fa530 100644
--- a/doc/nvim-lsp-installer.txt
+++ b/doc/nvim-lsp-installer.txt
@@ -50,13 +50,13 @@ https://github.com/williamboman/nvim-lsp-installer/blob/main/CUSTOM_SERVERS.md.
QUICK START *nvim-lsp-installer-quickstart*
The only thing needed to get started with nvim-lsp-installer is to make sure
-to call the `setup()` function _before_ you set up any servers: >
+to call the `setup()` function _before_ you set up any servers:
require("nvim-lsp-installer").setup {}
-<
+
Next, in your initialization files |init.lua|, setup the servers you want to use.
-Refer to |lspconfig| for more information! For example: >
+Refer to |lspconfig| for more information! For example:
require("nvim-lsp-installer").setup {}
local lspconfig = require("lspconfig")
@@ -67,34 +67,34 @@ Refer to |lspconfig| for more information! For example: >
lspconfig.sumneko_lua.setup { on_attach = on_attach }
lspconfig.tsserver.setup { on_attach = on_attach }
-<
-To view the UI for nvim-lsp-installer, run: >
+
+To view the UI for nvim-lsp-installer, run:
:LspInstallInfo
-<
-Install a language server via `:LspInstall`, for example: >
+
+Install a language server via `:LspInstall`, for example:
:LspInstall tsserver
-<
-You may also install multiple languages at a time: >
+
+You may also install multiple languages at a time:
:LspInstall tsserver graphql rust_analyzer
-<
+
To install a specific version of a language server, you may provide it as part
-of the server name, like so: >
+of the server name, like so:
:LspInstall tsserver@0.6.3 graphql@latest rust_analyzer@nightly
-<
+
To install a server associated with the filetype of the currently opened
-buffer, simply just run: >
+buffer, simply just run:
:LspInstall
-<
+
Please refer to each server's own release page to find which versions are available.
@@ -111,10 +111,10 @@ Opens the UI for nvim-lsp-installer.
Installs language servers. If the `--sync` argument is passed, the command will
be blocking until all installations complete. This is useful for headless
-installations, for example: >
+installations, for example:
$ nvim --headless -c "LspInstall --sync rust_analyzer clangd clojure_lsp" -c q
-<
+
If no server names are provided (`:LspInstall`), you will be prompted to
select which server associated with the currently opened buffer's filetype you
@@ -126,10 +126,10 @@ instead.
Uninstalls language servers. If the `--sync` argument is passed, the command will
be blocking until all installations complete. This is useful for headless
-installations, for example: >
+installations, for example:
$ nvim --headless -c "LspUninstall --sync rust_analyzer clangd clojure_lsp" -c q
-<
+
*:LspUninstallAll*
:LspUninstallAll [--no-confirm]
@@ -156,10 +156,9 @@ You can configure certain behavior of nvim-lsp-installer when calling the
Refer to the |nvim-lsp-installer-default-settings| for all available settings.
-Example: >
+Example:
require("nvim-lsp-installer").setup({
- ensure_installed = { "rust_analyzer", "sumneko_lua" }, -- ensure these servers are always installed
automatic_installation = true, -- automatically detect which servers to install (based on which servers are set up via lspconfig)
ui = {
icons = {
@@ -169,10 +168,10 @@ Example: >
}
}
})
-<
+
*nvim-lsp-installer-default-settings*
-The following settings are applied by default. >
+The following settings are applied by default.
local DEFAULT_SETTINGS = {
-- A list of servers to automatically install if they're not already installed. Example: { "rust_analyzer", "sumneko_lua" }
@@ -234,19 +233,48 @@ The following settings are applied by default. >
-- Limit for the maximum amount of servers to be installed at the same time. Once this limit is reached, any further
-- servers that are requested to be installed will be put in a queue.
max_concurrent_installers = 4,
+
+ github = {
+ -- The template URL to use when downloading assets from GitHub.
+ -- The placeholders are the following (in order):
+ -- 1. The repository (e.g. "rust-lang/rust-analyzer")
+ -- 2. The release version (e.g. "v0.3.0")
+ -- 3. The asset name (e.g. "rust-analyzer-v0.3.0-x86_64-unknown-linux-gnu.tar.gz")
+ download_url_template = "https://github.com/%s/releases/download/%s/%s",
+ },
+ }
+
+
+==============================================================================
+DOWNLOAD MIRRORS *nvim-lsp-installer-download-mirrors*
+
+------------------------------------------------------------------------------
+GITHUB MIRROR *nvim-lsp-installer-download-mirror-github*
+
+ It's possible to customize the download URL used when downloading assets
+ from GitHub releases by setting the `github.download_url_template`
+ settings during setup, like so:
+
+ require("nvim-lsp-installer").setup {
+ github = {
+ -- The template URL to use when downloading assets from GitHub.
+ -- The placeholders are the following (in order):
+ -- 1. The repository (e.g. "rust-lang/rust-analyzer")
+ -- 2. The release version (e.g. "v0.3.0")
+ -- 3. The asset name (e.g. "rust-analyzer-v0.3.0-x86_64-unknown-linux-gnu.tar.gz")
+ download_url_template = "https://my.mirror.com/%s/releases/download/%s/%s",
+ },
}
-<
==============================================================================
DEBUGGING *nvim-lsp-installer-debugging*
To help with debugging issues with installing/uninstall servers, please make
-sure to set nvim-lsp-installer's log level to DEBUG or TRACE, like so: >
+sure to set nvim-lsp-installer's log level to DEBUG or TRACE, like so:
require("nvim-lsp-installer").setup {
log_level = vim.log.levels.DEBUG
}
-<
You may find the logs by entering the command `:LspInstallLog`. Providing the
contents of this file when reporting an issue will help tremendously.
@@ -341,13 +369,11 @@ get_server({server_name})
ok: boolean, server: |lsp_installer.Server|
Example: ~
->
local lsp_installer = require'nvim-lsp-installer'
local ok, rust_server = lsp_installer.get_server("rust_analyzer")
if ok then
rust_server:install()
end
-<
==============================================================================
diff --git a/lua/nvim-lsp-installer/core/managers/github/init.lua b/lua/nvim-lsp-installer/core/managers/github/init.lua
index b3721705..10c7c049 100644
--- a/lua/nvim-lsp-installer/core/managers/github/init.lua
+++ b/lua/nvim-lsp-installer/core/managers/github/init.lua
@@ -4,6 +4,7 @@ local client = require "nvim-lsp-installer.core.managers.github.client"
local platform = require "nvim-lsp-installer.core.platform"
local Result = require "nvim-lsp-installer.core.result"
local _ = require "nvim-lsp-installer.core.functional"
+local settings = require "nvim-lsp-installer.settings"
local M = {}
@@ -59,7 +60,7 @@ function M.release_file(opts)
0
)
end
- local download_url = ("https://github.com/%s/releases/download/%s/%s"):format(opts.repo, release, asset_file)
+ local download_url = settings.current.github.download_url_template:format(opts.repo, release, asset_file)
return {
release = release,
download_url = download_url,
diff --git a/lua/nvim-lsp-installer/settings.lua b/lua/nvim-lsp-installer/settings.lua
index e346763f..dd4a3d18 100644
--- a/lua/nvim-lsp-installer/settings.lua
+++ b/lua/nvim-lsp-installer/settings.lua
@@ -63,6 +63,15 @@ local DEFAULT_SETTINGS = {
-- Limit for the maximum amount of servers to be installed at the same time. Once this limit is reached, any further
-- servers that are requested to be installed will be put in a queue.
max_concurrent_installers = 4,
+
+ github = {
+ -- The template URL to use when downloading assets from GitHub.
+ -- The placeholders are the following (in order):
+ -- 1. The repository (e.g. "rust-lang/rust-analyzer")
+ -- 2. The release version (e.g. "v0.3.0")
+ -- 3. The asset name (e.g. "rust-analyzer-v0.3.0-x86_64-unknown-linux-gnu.tar.gz")
+ download_url_template = "https://github.com/%s/releases/download/%s/%s",
+ },
}
M._DEFAULT_SETTINGS = DEFAULT_SETTINGS