remove lsp installer 🎄🎆

pull/268/head
ray-x 1 year ago
parent bdc962a080
commit 5a289ac77d

@ -274,7 +274,6 @@ require'navigator'.setup({
diagnostic_head_severity_1 = "🈲",
-- refer to lua/navigator.lua for more icons setups
},
lsp_installer = false, -- set to true if you would like use the lsp installed by williamboman/nvim-lsp-installer
mason = false, -- set to true if you would like use the lsp installed by williamboman/mason
lsp = {
enable = true, -- skip lsp setup, and only use treesitter in navigator.
@ -521,36 +520,16 @@ 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).
## Integrate with mason (williamboman/mason.nvim) or lsp_installer (williamboman/nvim-lsp-installer, `deprecated`)
## Integrate with mason (williamboman/mason.nvim)
If you are using mason or lsp_installer and would like to use the lsp servers installed by lsp_installer. Please set
If you are using mason and would like to use the lsp servers installed by mason. Please set
```lua
lsp_installer = true --lsp_installer users, deprecated
mason = true -- mason user
```
In the config. Also please setup the lsp server from installer setup with `server:setup{opts}`
lsp-installer example:
```lua
use({
'williamboman/nvim-lsp-installer',
config = function()
local lsp_installer = require('nvim-lsp-installer')
lsp_installer.setup{}
end,
})
use({
'ray-x/navigator.lua',
config = function()
require('navigator').setup({
lsp_installer = true,
})
end,
})
```
for mason
@ -618,19 +597,17 @@ Another way to setup mason is disable navigator lsp setup and using mason setup
})
```
Please refer to [lsp_installer_config](https://github.com/ray-x/navigator.lua/blob/master/playground/init_lsp_installer.lua)
for more info
Alternatively, Navigator can be used to startup the server installed by lsp-installer.
Alternatively, Navigator can be used to startup the server installed by mason.
as it will override the navigator setup
To start LSP installed by lsp_installer, please use following setups
To start LSP installed by mason, please use following setups
```lua
require'navigator'.setup({
-- lsp_installer = false -- default value is false
-- mason = false -- default value is false
lsp = {
tsserver = { cmd = {'your tsserver installed by lsp_installer or mason'} }
tsserver = { cmd = {'your tsserver installed by mason'} }
-- e.g. tsserver = { cmd = {'/home/username/.local/share/nvim/mason/packages/typescript-language-server/node_modules/typescript/bin/tsserver'} }
}
@ -641,7 +618,7 @@ example cmd setup (mac) for pyright :
```lua
require'navigator'.setup({
-- lsp_installer = false -- default value is false
-- mason = false -- default value is false
lsp = {
tsserver = {
@ -653,38 +630,6 @@ require'navigator'.setup({
```
The lsp servers installed by nvim-lsp-installer is in following dir
```lua
local path = require 'nvim-lsp-installer.path'
local install_root_dir = path.concat {vim.fn.stdpath 'data', 'lsp_servers'}
```
And you can setup binary full path to this: (e.g. with gopls)
`install_root_dir .. '/go/gopls'` So the config is
```lua
local path = require 'nvim-lsp-installer.path'
local install_root_dir = path.concat {vim.fn.stdpath 'data', 'lsp_servers'}
require'navigator'.setup({
-- lsp_installer = false -- default value is false
lsp = {
gopls = {
cmd = { install_root_dir .. '/go/gopls' }
}
}
}
```
Use lsp_installer configs
You can delegate the lsp server setup to lsp_installer with `server:setup{opts}`
Here is an example [init_lsp_installer.lua](https://github.com/ray-x/navigator.lua/blob/master/playground/init_lsp_installer.lua)
### Integration with other lsp plugins (e.g. rust-tools, go.nvim, clangd extension)
There are lots of plugins provides lsp support

@ -105,7 +105,6 @@ _NgConfigValues = {
},
servers = {}, -- you can add additional lsp server so navigator will load the default for you
},
lsp_installer = false, -- set to true if you would like use the lsp installed by williamboman/nvim-lsp-installer
mason = false, -- set to true if you would like use the lsp installed by williamboman/mason
mason_disabled_for = {}, -- disable mason for specified lspclients
icons = {

@ -9,10 +9,6 @@ return {
['guihua.lua'] = 'ray-x/guihua.lua',
}
if _NgConfigValues.lsp_installer == true then
lazy_plugins['nvim-lsp-installer'] = 'williamboman/nvim-lsp-installer'
end
-- packer installed
loader = require('packer').loader
for plugin, url in pairs(lazy_plugins) do
@ -28,25 +24,6 @@ return {
end
end
if _NgConfigValues.lsp_installer == true then
vim.cmd('packadd nvim-lsp-installer')
local has_lspinst, lspinst = pcall(require, 'nvim-lsp-installer')
log('lsp_installer installed', has_lspinst)
if has_lspinst then
lspinst.setup()
local configs = require('lspconfig/configs')
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]
if lsp_inst_cfg and lsp_inst_cfg.document_config.default_config then
lsp_inst_cfg = lsp_inst_cfg.document_config.default_config
lsp_inst_cfg = vim.tbl_deep_extend('keep', lsp_inst_cfg, cfg)
require('lspconfig')[server].setup(lsp_inst_cfg)
end
end
end
end
end,
load = function(plugin_name, path)
local loader = nil

@ -65,26 +65,10 @@ end
local setups = require('navigator.lspclient.clients_default').defaults()
local servers = require('navigator.lspclient.servers')
local lsp_installer_servers = {}
local lsp_mason_servers = {}
local has_lspinst = false
local has_mason = false
has_lspinst, _ = pcall(require, 'nvim-lsp-installer')
if has_lspinst then
local srvs = require('nvim-lsp-installer.servers').get_installed_servers()
if #srvs > 0 then
lsp_installer_servers = srvs
end
end
has_mason, _ = pcall(require, 'mason-lspconfig')
if has_mason then
local srvs=require'mason-lspconfig'.get_installed_servers()
if #srvs > 0 then
lsp_installer_servers = srvs
end
end
log("lsp_installer:", lsp_installer_servers)
if config.lsp.disable_lsp == 'all' then
config.lsp.disable_lsp = servers
@ -384,38 +368,6 @@ local function lsp_startup(ft, retry, user_lsp_opts)
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 installer server config ' .. lspconfig[lspclient].name, installer_cfg)
if installed and installer_cfg then
local paths = installer_cfg:get_default_options().cmd_env and installer_cfg:get_default_options().cmd_env.PATH
if not paths then
-- for some reason lspinstaller does not install the binary, check default PATH
log('lsp installer does not install the lsp in its path, fallback')
return load_cfg(ft, lspclient, cfg, loaded)
end
paths = vim.split(paths, ':')
if vfn.empty(cfg.cmd) == 1 then
cfg.cmd = { installer_cfg.name }
end
if vfn.executable(cfg.cmd[1]) == 0 then
for _, path in ipairs(paths) do
log(path)
if vfn.isdirectory(path) == 1 and string.find(path, installer_cfg.root_dir) then
cfg.cmd[1] = path .. path_sep .. cfg.cmd[1]
log(cfg.cmd)
break
end
end
log('update cmd', cfg.cmd)
else
log('cmd installed', cfg.cmd)
end
end
end
local function mason_disabled_for(client)
local mdisabled = _NgConfigValues.mason_disabled_for
if #mdisabled > 0 then
@ -426,6 +378,14 @@ local function lsp_startup(ft, retry, user_lsp_opts)
return false
end
has_mason, _ = pcall(require, 'mason-lspconfig')
if has_mason then
local srvs=require'mason-lspconfig'.get_installed_servers()
if #srvs > 0 then
lsp_mason_servers = srvs
end
end
log("lsp mason:", lsp_mason_servers)
if has_mason and _NgConfigValues.mason and not mason_disabled_for(lspconfig[lspclient].name) then
local servers = require'mason-lspconfig'.get_installed_servers()
if not vim.tbl_contains(servers, lspconfig[lspclient].name) then
@ -440,12 +400,12 @@ local function lsp_startup(ft, retry, user_lsp_opts)
log('failed to get name', lspconfig[lspclient].name, pkg_name)
end
log('lsp installer server config ' .. lspconfig[lspclient].name, pkg)
log('lsp mason server config ' .. lspconfig[lspclient].name, pkg)
if pkg then
local path = pkg:get_install_path()
if not path then
-- for some reason lspinstaller does not install the binary, check default PATH
log('lsp installer does not install the lsp in its path, fallback')
log('lsp mason does not install the lsp in its path, fallback')
return load_cfg(ft, lspclient, cfg, loaded)
end

Loading…
Cancel
Save