diff options
| -rw-r--r-- | .php-cs-fixer.dist.php | 18 | ||||
| -rw-r--r-- | scripts/generate-readme-neovim-keymaps.php | 44 | ||||
| -rw-r--r-- | shell.nix | 13 |
3 files changed, 75 insertions, 0 deletions
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..6e89bee --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,18 @@ +<?php + +# php84Packages.php-cs-fixer is currently installed. +# The commented out options are because they don't work with 84. +# I tried to install 85 but that installs an old version of cs that is not compatible with php85 +# At some point I can install CS 85. + +$finder = PhpCsFixer\Finder::create() + ->in(__DIR__); + +return (new PhpCsFixer\Config()) + ->setRules([ + '@PSR12' => true, +# 'strict_param' => true, + 'array_syntax' => ['syntax' => 'short'], +# 'declare_strict_types' => true, + ]) + ->setFinder($finder); diff --git a/scripts/generate-readme-neovim-keymaps.php b/scripts/generate-readme-neovim-keymaps.php new file mode 100644 index 0000000..4dbe1e1 --- /dev/null +++ b/scripts/generate-readme-neovim-keymaps.php @@ -0,0 +1,44 @@ +<?php + +declare(strict_types=1); + +$source = __DIR__ . '/../nvim/.config/nvim/lua/config/keymaps.lua'; +$target = __DIR__ . '/../README.md'; + +if (!file_exists($source)) { + echo "Source keymaps.lua not found.\n"; + exit(1); +} + +if (!file_exists($target)) { + echo "Target README.md not found.\n"; + exit(1); +} + +preg_match_all( + '/set\((".*?"|{.*?}), "(.*?)".*?desc = "(.*?)"/s', + file_get_contents($source), + $matches, + PREG_SET_ORDER, +); + +$table[] = '| Key | Description | Mode |'; +$table[] = '| :--- | :--- | :--- |'; +$table = array_reduce( + $matches, + function (array $carry, array $match): array { + $key = str_replace(['<', '>'], ["\<", "\>"], $match[2]); + $description = $match[3]; + $mode = str_replace(['{ ', ' }', '"'], '', $match[1]); + + $carry[] = "| $key | $description | $mode |"; + + return $carry; + }, + $table +); + +$readme = file_get_contents($target); +$pattern = '/(<!-- BEGIN-NEOVIM-KEYMAPS -->).*(<!-- END-NEOVIM-KEYMAPS -->)/s'; +$replacement = "$1\n" . implode("\n", $table) . "\n$2"; +file_put_contents($target, preg_replace($pattern, $replacement, $readme)); diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..a57f451 --- /dev/null +++ b/shell.nix @@ -0,0 +1,13 @@ +let + nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-unstable"; + pkgs = import nixpkgs { config = {}; overlays = []; }; +in + +pkgs.mkShellNoCC { + packages = with pkgs; [ + php84 + php84Packages.composer + php84Packages.php-cs-fixer + php84Packages.php-codesniffer + ]; +} |
