The composer language server provides various features for composer to make development easier and faster.
For better debugging, you can use additional file logging with log4rs crate. A enviroment variable COMPOSER_LSP_LOG
needs to be set, which points to the log4rs yaml config file. For more information check the log4rs documentation.
- Shows when a package needs an update.
- Package name hover, to show details about it.
- Package go to definition.
- Package name completion.
- Actions to update the selected package.
Using cargo
cargo install composer_lsp
Plugins required:
- lspconfig (https://github.com/neovim/nvim-lspconfig)
After installing the package, add this to your lua config
local configs = require 'lspconfig.configs'
local lspconfig = require 'lspconfig'
if not configs.composer_lsp then
configs.composer_lsp = {
default_config = {
cmd = {'composer_lsp'},
filetypes = {'json'},
root_dir = function(pattern)
local cwd = vim.loop.cwd()
local root = lspconfig.util.root_pattern('composer.json', '.git')(pattern)
-- prefer cwd if root is a descendant
return lspconfig.util.path.is_descendant(cwd, root) and cwd or root
end,
settings = {},
},
}
end
lspconfig.composer_lsp.setup{}
TODO - Still need to build an extension for it.