From f7e9007aa42a4f8ed88e51270b33dd2077365318 Mon Sep 17 00:00:00 2001 From: William Boman Date: Sun, 17 Oct 2021 23:00:00 +0200 Subject: add setting for configuring server install dir (#166) --- lua/nvim-lsp-installer/fs.lua | 10 ++++++++-- lua/nvim-lsp-installer/path.lua | 2 -- lua/nvim-lsp-installer/servers/init.lua | 4 ++-- lua/nvim-lsp-installer/settings.lua | 5 +++++ 4 files changed, 15 insertions(+), 6 deletions(-) (limited to 'lua') 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. -- cgit v1.2.3-70-g09d2