diff options
| author | William Boman <william@redwill.se> | 2021-10-17 23:00:00 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-17 23:00:00 +0200 |
| commit | f7e9007aa42a4f8ed88e51270b33dd2077365318 (patch) | |
| tree | d8629ca880d29d313440a984255974a55869ff37 | |
| parent | add vala_ls (#167) (diff) | |
| download | mason-f7e9007aa42a4f8ed88e51270b33dd2077365318.tar mason-f7e9007aa42a4f8ed88e51270b33dd2077365318.tar.gz mason-f7e9007aa42a4f8ed88e51270b33dd2077365318.tar.bz2 mason-f7e9007aa42a4f8ed88e51270b33dd2077365318.tar.lz mason-f7e9007aa42a4f8ed88e51270b33dd2077365318.tar.xz mason-f7e9007aa42a4f8ed88e51270b33dd2077365318.tar.zst mason-f7e9007aa42a4f8ed88e51270b33dd2077365318.zip | |
add setting for configuring server install dir (#166)
| -rw-r--r-- | README.md | 13 | ||||
| -rw-r--r-- | doc/nvim-lsp-installer.txt | 14 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/fs.lua | 10 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/path.lua | 2 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/servers/init.lua | 4 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/settings.lua | 5 |
6 files changed, 39 insertions, 9 deletions
@@ -100,12 +100,18 @@ end ### Configuration You can configure certain behavior of nvim-lsp-installer by calling the `.settings()` function. + +Make sure to provide your settings before any other interactions with nvim-lsp-installer! + Refer to the [default configuration](#default-configuration) for all available settings. Example: ```lua -require("nvim-lsp-installer").settings { +local lsp_installer = require("nvim-lsp-installer") + +-- Provide settings first! +lsp_installer.settings { ui = { icons = { server_installed = "✓", @@ -114,6 +120,8 @@ require("nvim-lsp-installer").settings { } } } + +lsp_installer.on_server_ready(function (server) server:setup {} end) ``` ## Available LSPs @@ -228,6 +236,9 @@ local DEFAULT_SETTINGS = { }, }, + -- The directory in which to install all servers. + install_root_dir = path.concat { vim.fn.stdpath "data", "lsp_servers" }, + pip = { -- These args will be added to `pip install` calls. Note that setting extra args might impact intended behavior -- and is not recommended. diff --git a/doc/nvim-lsp-installer.txt b/doc/nvim-lsp-installer.txt index 3900f122..f333e456 100644 --- a/doc/nvim-lsp-installer.txt +++ b/doc/nvim-lsp-installer.txt @@ -129,11 +129,17 @@ SETTINGS *nvim-lsp-installer-settings* You can configure certain behavior of nvim-lsp-installer by calling the `.settings()` function. +Make sure to provide your settings before any other interactions with +nvim-lsp-installer! + Refer to the |nvim-lsp-installer-default-settings| for all available settings. Example: > - require("nvim-lsp-installer").settings { + local lsp_installer = require("nvim-lsp-installer") + + -- Provide settings first! + lsp_installer.settings { ui = { icons = { server_installed = "✓", @@ -142,8 +148,9 @@ Example: > } } } -< + lsp_installer.on_server_ready(function (server) server:setup {} end) +< *nvim-lsp-installer-default-settings* The following settings are applied by default. > @@ -170,6 +177,9 @@ The following settings are applied by default. > }, }, + -- The directory in which to install all servers. + install_root_dir = path.concat { vim.fn.stdpath "data", "lsp_servers" }, + pip = { -- These args will be added to `pip install` calls. Note that setting extra args might impact intended behavior -- and is not recommended. diff --git a/lua/nvim-lsp-installer/fs.lua b/lua/nvim-lsp-installer/fs.lua index 775809fd..ed018da2 100644 --- a/lua/nvim-lsp-installer/fs.lua +++ b/lua/nvim-lsp-installer/fs.lua @@ -1,12 +1,18 @@ local pathm = require "nvim-lsp-installer.path" local log = require "nvim-lsp-installer.log" +local settings = require "nvim-lsp-installer.settings" local uv = vim.loop local M = {} local function assert_ownership(path) - if not pathm.is_subdirectory(pathm.SERVERS_ROOT_DIR, path) then - error(("Refusing to operate on path outside of the servers root dir (%s)."):format(pathm.SERVERS_ROOT_DIR)) + if not pathm.is_subdirectory(settings.current.install_root_dir, path) then + error( + ("Refusing to operate on path (%s) outside of the servers root dir (%s)."):format( + path, + settings.current.install_root_dir + ) + ) end end diff --git a/lua/nvim-lsp-installer/path.lua b/lua/nvim-lsp-installer/path.lua index 4ed3d563..41961ffd 100644 --- a/lua/nvim-lsp-installer/path.lua +++ b/lua/nvim-lsp-installer/path.lua @@ -40,6 +40,4 @@ function M.is_subdirectory(root_path, path) return path:sub(1, #root_path) == root_path end -M.SERVERS_ROOT_DIR = M.concat { vim.fn.stdpath "data", "lsp_servers" } - return M diff --git a/lua/nvim-lsp-installer/servers/init.lua b/lua/nvim-lsp-installer/servers/init.lua index 6124ba5a..64359520 100644 --- a/lua/nvim-lsp-installer/servers/init.lua +++ b/lua/nvim-lsp-installer/servers/init.lua @@ -116,7 +116,7 @@ local function scan_server_roots() return cached_server_roots end local result = {} - local ok, entries = pcall(fs.readdir, path.SERVERS_ROOT_DIR) + local ok, entries = pcall(fs.readdir, settings.current.install_root_dir) if not ok then -- presume servers root dir has not been created yet (i.e., no servers installed) return {} @@ -139,7 +139,7 @@ local function get_server_install_dir(server_name) end function M.get_server_install_path(dirname) - return path.concat { path.SERVERS_ROOT_DIR, dirname } + return path.concat { settings.current.install_root_dir, dirname } end function M.is_server_installed(server_name) diff --git a/lua/nvim-lsp-installer/settings.lua b/lua/nvim-lsp-installer/settings.lua index 0eff752a..1d999573 100644 --- a/lua/nvim-lsp-installer/settings.lua +++ b/lua/nvim-lsp-installer/settings.lua @@ -1,3 +1,5 @@ +local path = require "nvim-lsp-installer.path" + local DEFAULT_SETTINGS = { ui = { icons = { @@ -20,6 +22,9 @@ local DEFAULT_SETTINGS = { }, }, + -- The directory in which to install all servers. + install_root_dir = path.concat { vim.fn.stdpath "data", "lsp_servers" }, + pip = { -- These args will be added to `pip install` calls. Note that setting extra args might impact intended behavior -- and is not recommended. |
