如何在Neovim配置中启用Intelephense?PHP LSP无法工作
PHP Intelephense LSP在Neovim中无法正常工作
我使用Neovim配置进行C/C++、Python、汇编、Rust及PHP开发,除汇编与PHP外,其余语言的LSP均正常运行(支持语法高亮、自动补全等功能)。目前暂不处理汇编相关问题,但PHP对应的Intelephense LSP无法正常工作。我已通过Mason.nvim和npm两种方式安装Intelephense,但均未生效。
以下是我的配置文件:
lsp.lua
local lsp_zero = require('lsp-zero') lsp_zero.on_attach(function(client, bufnr) -- see :help lsp-zero-keybindings -- to learn the available actions lsp_zero.default_keymaps({buffer = bufnr}) end) -- here you can setup the language servers require("mason").setup() require('lspconfig').clangd.setup({}) -- C/C++ LSP require('lspconfig').lua_ls.setup({}) -- Lua LSP require('lspconfig').pylsp.setup({}) -- Python LSP require('lspconfig').tsserver.setup({}) -- Javascript/Typescript LSP require('lspconfig').html.setup({}) -- HTML LSP require('lspconfig').cssls.setup({}) -- CSS LSP require('lspconfig').intelephense.setup({}) -- PHP Intelephense please work -- Autocompletion local cmp = require('cmp') local cmp_action = require('lsp-zero').cmp_action() cmp.setup({ mapping = cmp.mapping.preset.insert({ -- `Tab` key to confirm completion ['<Tab>'] = cmp.mapping.confirm({select = false}), -- Ctrl+Space to trigger completion menu ['<C-Space>'] = cmp.mapping.complete(), -- Navigate between snippet placeholder ['<C-f>'] = cmp_action.luasnip_jump_forward(), ['<C-b>'] = cmp_action.luasnip_jump_backward(), -- Scroll up and down in the completion documentation ['<C-u>'] = cmp.mapping.scroll_docs(-4), ['<C-d>'] = cmp.mapping.scroll_docs(4), }) })
packer.lua
vim.cmd [[packadd packer.nvim]] return require("packer").startup(function(use) use "wbthomason/packer.nvim" -- packer self-import use { 'nvim-telescope/telescope.nvim', tag = '0.1.5', -- or , branch = '0.1.x', requires = { {'nvim-lua/plenary.nvim'} } } -- fuzzy finder use { 'nvim-lualine/lualine.nvim', requires = { 'nvim-tree/nvim-web-devicons', opt = true } } -- lualine use({ "folke/tokyonight.nvim", config = function() vim.cmd("colorscheme tokyonight") end }) -- tokyonight use { 'nvim-treesitter/nvim-treesitter', run = function() local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) ts_update() end } -- treesitter use("mbbill/undotree") -- undotree use("theprimeagen/harpoon") -- harpoon use("CRAG666/code_runner.nvim") -- coderunner use { 'VonHeikemen/lsp-zero.nvim', branch = 'v3.x', requires = { --- Uncomment the two plugins below if you want to manage the language servers from neovim {'williamboman/mason.nvim'}, {'williamboman/mason-lspconfig.nvim'}, -- LSP Support {'neovim/nvim-lspconfig'}, -- Autocompletion {'hrsh7th/nvim-cmp'}, {'hrsh7th/cmp-nvim-lsp'}, {'L3MON4D3/LuaSnip'}, } } -- LSP end)
当前LSP未正常工作的状态:
内容的提问来源于stack exchange,提问作者n0rmi
相关产品推荐
相关产品推荐

