mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-04-27 03:47:37 +00:00
lsp/presets/phan: init
This commit is contained in:
parent
e1c3257ca3
commit
d9ff1b000b
2 changed files with 46 additions and 0 deletions
|
|
@ -4,6 +4,7 @@
|
|||
./deno.nix
|
||||
./harper.nix
|
||||
./lemminx.nix
|
||||
./phan.nix
|
||||
./phpactor.nix
|
||||
./pyrefly.nix
|
||||
./pyright.nix
|
||||
|
|
|
|||
45
modules/plugins/lsp/presets/phan.nix
Normal file
45
modules/plugins/lsp/presets/phan.nix
Normal 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
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue