-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change phan executable specialize PHP LSP Command fix spelling mistakes specify binaries for php lsps Clean UP PHP part Remove test file Un-hardcode php LSPs I also separated phan and PHPactor because apparently they do kind of the same thing. Add capabilities and on_attach thingamabob Couldnt they be added automatically if they're needed everywhere? typo: remove capital C Add php to documentation Add php lsp's phan and phpactor doc: release-note Add php lsp's phan and phpactor
- Loading branch information
Showing
4 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ in { | |
./svelte.nix | ||
./java.nix | ||
./lua.nix | ||
./php.nix | ||
]; | ||
|
||
options.vim.languages = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
{ | ||
pkgs, | ||
config, | ||
lib, | ||
... | ||
}: | ||
with lib; | ||
with builtins; let | ||
cfg = config.vim.languages.php; | ||
|
||
defaultServer = "phpactor"; | ||
servers = { | ||
phpactor = { | ||
package = pkgs.phpactor; | ||
lspConfig = '' | ||
lspconfig.phpactor.setup{ | ||
capabilities = capabilities, | ||
on_attach = default_on_attach, | ||
cmd = ${ | ||
if isList cfg.lsp.package | ||
then nvim.lua.expToLua cfg.lsp.package | ||
else '' | ||
{ | ||
"${getExe cfg.lsp.package}", | ||
"language-server" | ||
}, | ||
'' | ||
} | ||
} | ||
''; | ||
}; | ||
|
||
phan = { | ||
package = pkgs.php81Packages.phan; | ||
lspConfig = '' | ||
lspconfig.phan.setup{ | ||
capabilities = capabilities, | ||
on_attach = default_on_attach, | ||
cmd = ${ | ||
if isList cfg.lsp.package | ||
then nvim.lua.expToLua cfg.lsp.package | ||
else '' | ||
{ | ||
"${getExe cfg.lsp.package} | ||
"-m", | ||
"json", | ||
"--no-color", | ||
"--no-progress-bar", | ||
"-x", | ||
"-u", | ||
"-S", | ||
"--language-server-on-stdin", | ||
"--allow-polyfill-parser" | ||
}, | ||
'' | ||
} | ||
} | ||
''; | ||
}; | ||
}; | ||
in { | ||
options.vim.languages.php = { | ||
enable = mkEnableOption "PHP language support"; | ||
|
||
treesitter = { | ||
enable = mkEnableOption "Enable PHP treesitter" // {default = config.vim.languages.enableTreesitter;}; | ||
package = nvim.types.mkGrammarOption pkgs "php"; | ||
}; | ||
|
||
lsp = { | ||
enable = mkEnableOption "PHP LSP support" // {default = config.vim.languages.enableLSP;}; | ||
|
||
server = mkOption { | ||
description = "PHP LSP server to use"; | ||
type = with types; enum (attrNames servers); | ||
default = defaultServer; | ||
}; | ||
|
||
package = mkOption { | ||
description = "PHP LSP server package, or the command to run as a list of strings"; | ||
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]''; | ||
type = with types; either package (listOf str); | ||
default = servers.${cfg.lsp.server}.package; | ||
}; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable (mkMerge [ | ||
(mkIf cfg.treesitter.enable { | ||
vim.treesitter.enable = true; | ||
vim.treesitter.grammars = [cfg.treesitter.package]; | ||
}) | ||
(mkIf cfg.lsp.enable { | ||
vim.lsp.lspconfig = { | ||
enable = true; | ||
sources.php-lsp = servers.${cfg.lsp.server}.lspConfig; | ||
}; | ||
}) | ||
]); | ||
} |