From 8f9401594b4fc820ee60a779d8bb62737b6f586d Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sat, 8 Jun 2024 19:54:25 +0100 Subject: [PATCH] Re-add vim-projectionist Whilst I wasn't able to get it to work for all my use cases previously, it is useful for creating alternative files in Fractal, such as switching between the `*.config.yml` and `*.twig` files for a component. Other use cases, such as creating alternative files for classes and tests in PHP and Drupal projects, I can look at again now the plugin is installed. --- lib/default.nix | 1 + plugin/projectionist.lua | 57 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 plugin/projectionist.lua diff --git a/lib/default.nix b/lib/default.nix index fadb2c2..7faba67 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -70,6 +70,7 @@ rec { vimPlugins.vim-highlightedyank vimPlugins.vim-just vimPlugins.vim-nix + vimPlugins.vim-projectionist vimPlugins.nvim-spectre vimPlugins.vim-obsession vimPlugins.vim-pasta diff --git a/plugin/projectionist.lua b/plugin/projectionist.lua new file mode 100644 index 0000000..5ff7e7b --- /dev/null +++ b/plugin/projectionist.lua @@ -0,0 +1,57 @@ +vim.g.projectionist_heuristics = { + ["composer.json"] = { + ["src/*.php"] = { + type = "source", + alternate = "tests/{}Test.php", + }, + + ["src/Controller/*.php"] = { + type = "controller", + }, + + ["src/Model/*.php"] = { + type = "model", + }, + + ["src/Service/*.php"] = { + type = "service", + }, + + ["tests/*Test.php"] = { + type = "test", + alternate = "src/{}.php", + }, + }, + + ["fractal.config.js"] = { + ["*.config.yml"] = { + type = "config", + alternate = "{dirname}/{basename}.twig", + }, + + ["*.twig"] = { + type = "template", + alternate = "{dirname}/{basename}.config.yml", + }, + }, + + ["package.json"] = { + ["src/*.ts"] = { + type = "source", + alternate = "tests/{}.test.ts", + }, + + ["src/*.service.ts"] = { + type = "source", + alternate = "tests/{}.test.ts", + }, + + ["tests/*.test.ts"] = { + type = "test", + alternate = "src/{}.ts", + }, + }, +} + +-- Switch to an alternative file. +vim.keymap.set("n", "aa", "A")