-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Closed
Labels
closed:questionissues that are closed as usage questionsissues that are closed as usage questions
Description
Neovim version (nvim -v)
NVIM v0.7.0-dev+719-gbdfea9d9a
Language server name/version
pyright
Operating system/version
macOS Monterey 12.1
Steps to reproduce using "nvim -u minimal_init.lua"
I installed nvim-lspconfig
, nvim-lsp-installer
and cmp-nvim-lsp
plugins, also I installed pyright via :LspInstall pyright
,
config file for nvim-lspconfig
local nvim_lsp = require('lspconfig')
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings
local opts = { noremap=true, silent=true }
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
-- Set some keybinds conditional on server capabilities
if client.resolved_capabilities.document_formatting then
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
end
if client.resolved_capabilities.document_range_formatting then
buf_set_keymap("v", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts)
end
-- Set autocommands conditional on server_capabilities
if client.resolved_capabilities.document_highlight then
vim.api.nvim_exec([[
hi LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow
hi LspReferenceText cterm=bold ctermbg=red guibg=LightYellow
hi LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END
]], false)
end
end
-- Use a loop to conveniently both setup defined servers
-- and map buffer local keybindings when the language server attaches
local servers = { "pyright", "rust_analyzer", "tsserver", "clangd" }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup { on_attach = on_attach }
end
nvim-lsp-installer
local lsp_installer = require("nvim-lsp-installer")
local lsp_installer_servers = require('nvim-lsp-installer.servers')
local servers = {
"rust_analyzer",
"clangd",
"pyright",
"tsserver",
"sumneko_lua",
}
for _, server_name in pairs(servers) do
local server_available, server = lsp_installer_servers.get_server(server_name)
if server_available then
server:on_ready(function ()
-- When this particular server is ready (i.e. when installation is finished or the server is already installed),
-- this function will be invoked. Make sure not to also use the "catch-all" lsp_installer.on_server_ready()
-- function to set up your servers, because by doing so you'd be setting up the same server twice.
local opts = {}
server:setup(opts)
end)
if not server:is_installed() then
-- Queue the server to be installed.
server:install()
end
end
end
the only difference that made the mentioned error is that I added below config for nvim-cmp
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
local lspconfig = require('lspconfig')
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver' }
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
-- on_attach = my_custom_on_attach,
capabilities = capabilities,
}
end
To reproduce with minimal setup.
nvim -u minimal_init.lua
Expected behavior
No error should display.
Actuall, If I delete the casuing-error config, pyright can be detected correct and function correctly.
Actual behavior
When I open a python file like this: nvim test.py
, I get this error:
Spawning language server with cmd: `pyright-langserver` failed. The language server is either not installed, missing from PATH, or not executable.
Log file
No response
urmzd, flexmachina, kkopiec and drskoolie
Metadata
Metadata
Assignees
Labels
closed:questionissues that are closed as usage questionsissues that are closed as usage questions