mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
Merge pull request #150 from Vagahbond/features/php
languages/php: init
This commit is contained in:
commit
b273d50f1b
4 changed files with 107 additions and 0 deletions
|
@ -16,6 +16,7 @@ Language specific support means there is a combination of language specific plug
|
||||||
* Dart: <<opt-vim.languages.dart.enable>>
|
* Dart: <<opt-vim.languages.dart.enable>>
|
||||||
* Go: <<opt-vim.languages.go.enable>>
|
* Go: <<opt-vim.languages.go.enable>>
|
||||||
* Lua: <<opt-vim.languages.lua.enable>>
|
* Lua: <<opt-vim.languages.lua.enable>>
|
||||||
|
* PHP: <<opt-vim.languages.php.enable>>
|
||||||
|
|
||||||
Adding support for more languages, and improving support for existing ones are great places
|
Adding support for more languages, and improving support for existing ones are great places
|
||||||
where you can contribute with a PR.
|
where you can contribute with a PR.
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
[[sec-release-0.5-changelog]]
|
[[sec-release-0.5-changelog]]
|
||||||
=== Changelog
|
=== Changelog
|
||||||
|
|
||||||
|
https://github.com/vagahbond[vagahbond]:
|
||||||
|
* Added phan language server for PHP.
|
||||||
|
|
||||||
|
* Added phpactor language server for PHP.
|
||||||
|
|
||||||
https://github.com/horriblename[horriblename]:
|
https://github.com/horriblename[horriblename]:
|
||||||
|
|
||||||
* Added transparency support for tokyonight theme.
|
* Added transparency support for tokyonight theme.
|
||||||
|
|
|
@ -25,6 +25,7 @@ in {
|
||||||
./svelte.nix
|
./svelte.nix
|
||||||
./java.nix
|
./java.nix
|
||||||
./lua.nix
|
./lua.nix
|
||||||
|
./php.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
options.vim.languages = {
|
options.vim.languages = {
|
||||||
|
|
100
modules/languages/php.nix
Normal file
100
modules/languages/php.nix
Normal file
|
@ -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;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
}
|
Loading…
Reference in a new issue