lsp/presets/phan: init

This commit is contained in:
Snoweuph 2026-04-11 17:48:42 +02:00
commit d9ff1b000b
No known key found for this signature in database
GPG key ID: BEFC41DA223CEC55
2 changed files with 46 additions and 0 deletions

View file

@ -4,6 +4,7 @@
./deno.nix
./harper.nix
./lemminx.nix
./phan.nix
./phpactor.nix
./pyrefly.nix
./pyright.nix

View file

@ -0,0 +1,45 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption;
inherit (lib.generators) mkLuaInline;
cfg = config.vim.lsp.presets.phan;
in {
options.vim.lsp.presets.phan = {
enable = mkEnableOption "the Phan Language Server";
};
config = mkIf cfg.enable {
vim.lsp.servers.phan = {
enable = true;
cmd = [
(getExe pkgs.php85Packages.phan)
"-m"
"json"
"--no-color"
"--no-progress-bar"
"-x"
"-u"
"-S"
"--language-server-on-stdin"
"--allow-polyfill-parser"
];
root_dir = mkLuaInline ''
function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
local cwd = assert(vim.uv.cwd())
local root = vim.fs.root(fname, { 'composer.json', '.git' })
-- prefer cwd if root is a descendant
on_dir(root and vim.fs.relpath(cwd, root) and cwd)
end
'';
};
};
}