├── LICENSE ├── README.md └── lua ├── drupal.lua └── drupal ├── default_config.lua ├── services.lua ├── snippets ├── docs.md ├── general.lua └── hooks.lua └── utils ├── flatten.lua └── init.lua /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Jonathan Morris 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # drupal.nvim 2 | 3 | **drupal.nvim** - _a little less pain for Drupal developers daring to use neovim._ 4 | 5 | ## :lock: Requirements 6 | 7 | - [plenary.nvim](https://github.com/nvim-lua/plenary.nvim) (used for running drush) 8 | - [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) (currently autocompletion requires nvim-cmp) 9 | - [cmp_luasnip](https://github.com/saadparwaiz1/cmp_luasnip) (required for adding hook snippets) 10 | - [ripgrep](https://github.com/BurntSushi/ripgrep) (needs to be installed on your machine) 11 | - [drush](https://www.drush.org/12.x) (needs to be installed on your machine/project) 12 | 13 | ## :package: Installation 14 | 15 | Install this plugin using your favorite plugin manager, and then call 16 | `require("drupal").setup()`. 17 | 18 | ### [lazy.nvim](https://github.com/folke/lazy.nvim) 19 | 20 | Default configuration can be found in `lua/drupal/default_config.lua`. 21 | 22 | ```lua 23 | { 24 | "jdrupal-dev/drupal.nvim", 25 | dependencies = { "nvim-lua/plenary.nvim" }, 26 | config = function() 27 | require("drupal").setup({ 28 | services_cmp_trigger_character = "@", 29 | get_drush_executable = function(current_dir) 30 | -- You can use current_dir if you have different ways of 31 | -- executing drush across your Drupal projects. 32 | return "drush" 33 | end, 34 | }) 35 | end 36 | } 37 | ``` 38 | ## :sparkles: Features 39 | 40 | ### Autocomplete services 41 | 42 | You need the `devel` module installed for this feature to work.\ 43 | The `drush devel:services` command is used to get a list of all available Drupal services. 44 | 45 | To trigger the autocompletion of services you need to input the trigger character, which by default is "@". 46 | ```php 47 | \Drupal::service('@entity_') // Now you should see services beginning with entity_. 48 | ``` 49 | ### Snippets 50 | 51 | A few practical snippets are provided, you can find the complete list of snippets in `lua/drupal/snippets/docs.md`. 52 | 53 | LuaSnip snippets are automatically generated for hooks when opening nvim in a Drupal project. 54 | 55 | You can use the snippets by typing `hook_` in a `.module` or `.theme` file. 56 | When the snippet is used `hook` will automatically get replaced with the name of the current module. 57 | 58 | For example, typing `hook_theme + Enter` in `my_module.module` will generate the following code: 59 | ```php 60 |