Недавно я перешел с менеджера плагинов Packer на Lazy.
Использование LSP, LspConfig , Mason , MasonLspConfig с несколькими языковыми серверами для программирования.
Проблема в том, что у Neovim есть проблемы с доступом к этим серверам. Он работал с менеджером пакетов Packer. Может быть я что-то неправильно настроил, но я понятия не имею, в чем может быть проблема.
Языковые серверы установлены и добавлены в PATH.
Spawning language server with cmd: `lua-language-server` failed with error message: EACCES: permission denied
Команда "lua-language-server" как таковая вызывается.
Я использую Fish shell в качестве оболочки по умолчанию.
Вот мой файл конфигурации плагина:
return {
{ "lvimuser/lsp-inlayhints.nvim" },
{
"neovim/nvim-lspconfig",
dependencies = { "lvimuser/lsp-inlayhints.nvim" },
config = function()
local lspconfig = require("lspconfig")
lspconfig.gopls.setup({
on_attach = function(client, bufnr)
require("settings/shared").on_attach(client, bufnr)
require("lsp-inlayhints").setup({
inlay_hints = {
type_hints = {
prefix = "=> "
},
},
})
require("lsp-inlayhints").on_attach(client, bufnr)
require("illuminate").on_attach(client)
end,
settings = {
gopls = {
analyses = {
nilness = true,
unusedparams = true,
unusedwrite = true,
useany = true,
},
experimentalPostfixCompletions = true,
gofumpt = true,
staticcheck = true,
usePlaceholders = true,
hints = {
assignVariableTypes = true,
compositeLiteralFields = true,
compositeLiteralTypes = true,
constantValues = true,
functionTypeParameters = true,
parameterNames = true,
rangeVariableTypes = true,
}
},
},
})
end
},
{ "williamboman/mason.nvim" },
{ "Afourcat/treesitter-terraform-doc.nvim" },
{ "williamboman/mason-lspconfig.nvim",
dependencies = { "williamboman/mason.nvim" },
config = function()
local mason_lspconfig = require("mason-lspconfig")
mason_lspconfig.setup({
PATH = "prepend",
ensure_installed = {
"eslint",
"gopls", -- WARNING: This could be an issue with goenv switching.
"marksman",
"rust_analyzer",
"sumneko_lua",
"terraformls",
"tflint",
"tsserver",
"yamlls",
}
})
mason_lspconfig.setup_handlers({
function(server_name)
require("lspconfig")[server_name].setup({
on_attach = function(client, bufnr)
require("settings/shared").on_attach(client, bufnr)
require("illuminate").on_attach(client)
if server_name == "terraformls" then
require("treesitter-terraform-doc").setup()
end
end
})
end
})
end
},
{ "simrat39/symbols-outline.nvim",
config = function()
require("symbols-outline").setup({
-- autofold_depth = 1, -- h: close, l: open, W: close all, E: open all
auto_close = false,
highlight_hovered_item = true,
position = "left",
width = 15,
symbols = {
File = { icon = "", hl = "GruvboxAqua" }, -- TSURI
Module = { icon = "", hl = "GruvboxBlue" }, -- TSNamespace
Namespace = { icon = "", hl = "GruvboxBlue" }, -- TSNamespace
Package = { icon = "", hl = "GruvboxBlue" }, -- TSNamespace
Class = { icon = "𝓒", hl = "GruvboxGreen" }, -- TSType
Method = { icon = "ƒ", hl = "GruvboxOrange" }, -- TSMethod
Property = { icon = "", hl = "GruvboxOrange" }, -- TSMethod
Field = { icon = "", hl = "GruvboxRed" }, -- TSField
Constructor = { icon = "", hl = "TSConstructor" },
Enum = { icon = "ℰ", hl = "GruvboxGreen" }, -- TSType
Interface = { icon = "ﰮ", hl = "GruvboxGreen" }, -- TSType
Function = { icon = "", hl = "GruvboxYellow" }, -- TSFunction
Variable = { icon = "", hl = "GruvboxPurple" }, -- TSConstant
Constant = { icon = "", hl = "GruvboxPurple" }, -- TSConstant
String = { icon = "𝓐", hl = "GruvboxGray" }, -- TSString
Number = { icon = "#", hl = "TSNumber" },
Boolean = { icon = "⊨", hl = "TSBoolean" },
Array = { icon = "", hl = "GruvboxPurple" }, -- TSConstant
Object = { icon = "⦿", hl = "GruvboxGreen" }, -- TSType
Key = { icon = "🔐", hl = "GruvboxGreen" }, -- TSType
Null = { icon = "NULL", hl = "GruvboxGreen" }, -- TSType
EnumMember = { icon = "", hl = "GruvboxRed" }, -- TSField
Struct = { icon = "𝓢", hl = "GruvboxGreen" }, -- TSType
Event = { icon = "🗲", hl = "GruvboxGreen" }, -- TSType
Operator = { icon = "+", hl = "TSOperator" },
TypeParameter = { icon = "𝙏", hl = "GruvboxRed" } --TTSParameter
},
})
end
},
{ "mfussenegger/nvim-lint",
config = function()
local lint = require("lint")
lint.linters_by_ft = {
go = { "golangcilint" }, -- ~/.golangci.yml
}
-- see ./lsp.lua for calls to this plugin's try_lint() function.
end
},
}
Вот что :LspInfo
говорит:
Detected filetype: lua
{ 0 client(s) attached to this buffer:
{
{ Other clients that match the filetype: lua
Config: sumneko_lua
filetypes: lua
root directory: /home/user/.config/nvim
cmd: lua-language-server
cmd is executable: Unable to find executable. Please check your path and ensure the server is
installed
autostart: true
custom handlers:
Configured servers list: gopls, terraformls, yamlls, tflint, eslint, tsserver, marksman, rust_analyzer, sumneko_lua
После перезагрузки системы lsp-config обнаружил файл lua-language-server
.
Я предполагаю, что PATH не был правильно получен.
Для тех, у кого есть подобные проблемы - убедитесь, что у вас установлены языковые серверы, правильно добавлены в PATH, и не забудьте указать источник файла конфигурации с переменными.
Вот мои переменные для сервера lua-language-server
и gopls
в формате fish shell:
# Lua
set -gx PATH ~/.config/lsp/lua-language-server/bin $PATH
# Go
set -gx GOPATH ~/go
set -gx PATH /usr/local/go/bin $PATH
set -gx PATH $GOPATH/bin $PATH
А вот они в формате bash:
# Lua
export PATH=$PATH:$HOME/.config/lsp/lua-language-server/bin
# Go
export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin
export PATH=$PATH:$GOPATH/bin