Merge branch 'nvim-lsp-installer'

neovim_0.6
ray-x 3 years ago
commit c890f3818d

@ -223,7 +223,7 @@ require'navigator'.setup({
diagnostic_head_severity_1 = "🈲",
-- refer to lua/navigator.lua for more icons setups
},
lspinstall = false, -- set to true if you would like use the lsp installed by lspinstall
lsp_installer = false, -- set to true if you would like use the lsp installed by williamboman/nvim-lsp-installer
lsp = {
code_action = {enable = true, sign = true, sign_priority = 40, virtual_text = true},
code_lens_action = {enable = true, sign = true, sign_priority = 40, virtual_text = true},
@ -402,29 +402,40 @@ The plugin can be loaded lazily (packer `opt = true` ), And it will check if opt
The terminal will need to be able to output nerdfont and emoji correctly. I am using Kitty with nerdfont (Victor Mono).
## Integration with lspinstall
## Integration with lsp_installer (williamboman/nvim-lsp-installer)
If you'd like to only use the lsp servers installed by lspinstall. Please set
If you'd like to only use the lsp servers installed by lsp_installer. Please set
```lua
lspinstall = false
lsp_installer = true
```
In the config.
If you need to use the setup from navigator instead of default setup in lspinstall. Please setup
Navigator will startup the server installed by lsp-installer. Please do not call `server:setup{opts}` from lsp installer
as it will override the navigator setup
Also, could use following setups
```lua
lspinstall = false
require'navigator'.setup({
-- lsp_installer = false -- default value is false
lsp = {
tsserver = { cmd = {'your tsserver installed by lspinstall'} }
tsserver = { cmd = {'your tsserver installed by lsp_installer'} }
}
})
```
example cmd setup (mac) for pyright :
```
cmd = { "/Users/username/.local/share/nvim/lsp_servers/python/node_modules/.bin/pyright-langserver", "--stdio" }
```
## Usage
Please refer to lua/navigator/lspclient/mapping.lua on key mappings. Should be able to work out-of-box.

@ -60,7 +60,7 @@ _NgConfigValues = {
-- cmd = {'lua-language-server'}
}
},
lspinstall = false, -- set to true if you would like use the lsp installed by lspinstall
lsp_installer = false, -- set to true if you would like use the lsp installed by williamboman/nvim-lsp-installer
icons = {
icons = true, -- set to false to use system default ( if you using a terminal does not have nerd/icon)
-- Code action
@ -114,6 +114,10 @@ M.deprecated = function(cfg)
if cfg.lsp ~= nil and cfg.lsp.disable_format_ft ~= nil and cfg.lsp.disable_format_ft ~= {} then
warn('disable_format_ft renamed to disable_format_cap')
end
if cfg.lspinstall ~= nil then
warn('lspinstall deprecated, please use lsp-installer instead')
end
end
local extend_config = function(opts)

@ -10,8 +10,8 @@ return {
["guihua.lua"] = "ray-x/guihua.lua"
}
if _NgConfigValues.lspinstall == true then
lazy_plugins["nvim-lspinstall"] = "kabouzeid/nvim-lspinstall"
if _NgConfigValues.lsp_installer == true then
lazy_plugins["nvim-lsp-installer"] = "williamboman/nvim-lsp-installer"
end
-- packer installed
@ -25,13 +25,13 @@ return {
end
if _NgConfigValues.lspinstall == true then
local has_lspinst, lspinst = pcall(require, "lspinstall")
log('lspinstall', has_lspinst)
if _NgConfigValues.lsp_installer == true then
local has_lspinst, lspinst = pcall(require, "lsp_installer")
log('lsp_installer installed', has_lspinst)
if has_lspinst then
lspinst.setup()
local configs = require "lspconfig/configs"
local servers = require'lspinstall'.installed_servers()
local servers = require'nvim-lsp-installer'.get_installed_servers()
for _, server in pairs(servers) do
local cfg = require'navigator.lspclient.clients'.get_cfg(server)
local lsp_inst_cfg = configs[server]

@ -2,6 +2,8 @@
local log = require"navigator.util".log
local trace = require"navigator.util".trace
local uv = vim.loop
local warn = require'navigator.util'.warn
_NG_Loaded = {}
_LoadedFiletypes = {}
@ -156,8 +158,7 @@ local setups = {
},
rust_analyzer = {
root_dir = function(fname)
return util.root_pattern("Cargo.toml", "rust-project.json", ".git")(fname)
or util.path.dirname(fname)
return util.root_pattern("Cargo.toml", "rust-project.json", ".git")(fname) or util.path.dirname(fname)
end,
filetypes = {"rust"},
message_level = vim.lsp.protocol.MessageType.error,
@ -268,17 +269,19 @@ local servers = {
"r_language_server", "rust_analyzer", "terraformls", "svelte"
}
if config.lspinstall == true then
local has_lspinst, lspinst = pcall(require, "lspinstall")
local has_lspinst = false
if config.lsp_installer == true then
has_lspinst, _ = pcall(require, "nvim-lsp-installer")
if has_lspinst then
local srvs = lspinst.installed_servers()
log('lspinstalled servers', srvs)
local srvs = require'nvim-lsp-installer.servers'.get_installed_servers()
log('lsp_installered servers', srvs)
if #srvs > 0 then
servers = srvs
end
end
log(servers)
end
if config.lsp.disable_lsp == 'all' then
config.lsp.disable_lsp = servers
end
@ -288,6 +291,8 @@ local ng_default_cfg = {
flags = {allow_incremental_sync = true, debounce_text_changes = 1000}
}
local configs = {}
-- check and load based on file type
local function load_cfg(ft, client, cfg, loaded)
-- if _NG_LSPCfgSetup ~= true then
@ -295,6 +300,7 @@ local function load_cfg(ft, client, cfg, loaded)
-- lspconfig_setup(cfg)
-- _NG_LSPCfgSetup = true
-- end
log(ft, client, loaded)
if lspconfig[client] == nil then
log("not supported by nvim", client)
@ -373,6 +379,15 @@ local function lsp_startup(ft, retry, user_lsp_opts)
end
for _, lspclient in ipairs(servers) do
-- check should load lsp
if type(lspclient) == 'table' then
if lspclient.name then
lspclient = lspclient.name
else
warn("incorrect set for lspclient", vim.inspect(lspclient))
goto continue
end
end
if user_lsp_opts[lspclient] ~= nil and user_lsp_opts[lspclient].filetypes ~= nil then
if not vim.tbl_contains(user_lsp_opts[lspclient].filetypes, ft) then
trace("ft", ft, "disabled for", lspclient)
@ -390,6 +405,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
end
local default_config = {}
log(lspclient)
if lspconfig[lspclient] == nil then
print("lspclient", lspclient, "no longer support by lspconfig, please submit an issue")
goto continue
@ -464,8 +480,18 @@ local function lsp_startup(ft, retry, user_lsp_opts)
end
end
log('loading', lspclient, 'name', lspconfig[lspclient].name)
log('loading', lspclient, 'name', lspconfig[lspclient].name, 'has lspinst', has_lspinst)
-- start up lsp
if has_lspinst and _NgConfigValues.lsp_installer then
local installed, installer_cfg = require("nvim-lsp-installer.servers").get_server(lspconfig[lspclient].name)
log('lsp server', installer_cfg, lspconfig[lspclient].name)
if installed and installer_cfg then
cfg.cmd = installer_cfg:get_default_options().cmd
log(cfg)
end
end
load_cfg(ft, lspclient, cfg, loaded)
_NG_Loaded[lspclient] = true
@ -489,8 +515,10 @@ local function lsp_startup(ft, retry, user_lsp_opts)
lspconfig.efm.setup(cfg)
log('efm loading')
_NG_Loaded['efm'] = true
configs['efm'] = cfg
end
end
if not retry or ft == nil then
return
end

Loading…
Cancel
Save