# Drupal PHP IDE on Rocky Linux
- Syntax hilighting
- PHP debugger
- PHP Linter
- PHP Language server
- Multiple cursors editing
- Fuzzy searching files / words
- Git integration
## System Depentencies
(https://rockylinux.org)
```sh
dnf -y install ninja-build
dnf -y install gcc gcc-c++ make cmake unzip gettext curl python3-pip
```
## NeoVIM installation
(https://neovim.io)
```sh
cd ~
git clone https://github.com/neovim/neovim
cd neovim
git checkout stable
make CMAKE_BUILD_TYPE=RelWithDebInfo
make install
# /usr/local/share/man/man1/nvim.1
# /usr/local/bin/nvim
# /usr/local/lib64/nvim/
# /usr/local/share/nvim/
# /usr/local/share/applications/nvim.desktop
# /usr/local/share/locale/*/LC_MESSAGES/*
```
## AstroNVim distribution installation
(https://astronvim.com)
```sh
mv ~/.config/nvim ~/.config/nvim.bak
mv ~/.local/share/nvim ~/.local/share/nvim.bak
mv ~/.local/state/nvim ~/.local/state/nvim.bak
mv ~/.cache/nvim ~/.cache/nvim.bak
cd ~
git clone --depth 1 https://github.com/AstroNvim/AstroNvim ~/.config/nvim
nvim
```
```sh
mkdir ~/.config/nvim/lua/user && cd $_
wget https://git.vaidis.eu/stevaidis/dev/raw/branch/main/vim/init.lua
wget https://git.vaidis.eu/stevaidis/dev/raw/branch/main/vim/polish.lua
nvim
```
## Debuging
(https://xdebug.org)
`/etc/php.ini`
```ini
[XDebug]
zend_extension=/opt/remi/php74/root/usr/lib64/php/modules/xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.mode=debug,develop
xdebug.client_host=localhost
xdebug.client_port=9000
xdebug.idekey="xdebug"
xdebug.log=/tmp/xdebug.log
xdebug.start_with_request=trigger
```
Debug adapter installation
```sh
cd ~
git clone https://github.com/xdebug/vscode-php-debug.git
cd vscode-php-debug
npm install && npm run build
```
Debug adapter nvim plugin
`:MasonInstall php-debug-adapter`
Debug chrome plugin
(https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc)
to trigger debugger send the cookie `XDEBUG_SESSION=XDEBUG_ECLIPSE; Path=/; Expires=Sat, 27 Jul 2024 08:17:10 GMT;`
## LSP server
(https://intelephense.com)
`:MasonInstall intelephense`
## Linter
(https://www.drupal.org/project/coder)
Install coder for phpcs
```sh
composer global require drupal/coder
composer global show -P # check coder path
phpcs --standard=Drupal -e # check sniffs exists
phpcs --config-set installed_paths ~/.config/composer/vendor/drupal/coder/coder_sniffer
phpcs -i # Verify drupal coding standar
```
Setup coder
`/var/www/sites/mydrupalproject/phpcs.xml.dist`
```xml
PHP CodeSniffer configuration for myproject development.
.
```
Disable too many userless warnings
`phpcs.xml`
```xml
My custom coding standard.
```
Don't push it to production
```sh
echo 'phpcs.xml.dist' >> /var/www/sites/mydrupalproject/.gitignore
```
Install plugin for diagnostics
- `:MasonInstall phpcs`
## Formatter
- `:MasonInstall phpcbf`
## Extra
`~/.config/nvim/lua/user/init.lua`
```lua
return {
plugins = {
-- plugins objects goes here
-- themes objects goes here
},
mappings = {
n = {
-- normal mode keymaps
},
t = {
-- edit mode keymaps
}
},
polish = function()
-- autostart vmirc commands
end,
lsp = {
-- LSP settings goes here
},
diagnostics = {
virtual_text = false,
underline = false,
},
}
```
### Plugin: Multiple cursors
(https://github.com/mg979/vim-visual-multi)
### Plugin: Highligh same word
(https://github.com/dominikduda/vim_current_word)
### Plugin: LSP messages
(https://git.sr.ht/~whynothugo/lsp_lines.nvim)
### Plugin: Transparent background
(https://github.com/xiyaowong/transparent.nvim)
# GIT integration
(https://github.com/jesseduffield/lazygit)
```sh
dnf copr enable atim/lazygit -y
dnf install lazygit
```
### keymaps
Normal mode
# Theme Switcher
``
```lua
{
'zaldih/themery.nvim',
lazy = false,
config = function()
require("themery").setup({
themes = {
'astrodark',
'astromars',
'astrotheme',
'catppuccin',
'catppuccin-frappe',
'catppuccin-macchiato',
'catppuccin-mocha',
'tokyonight-night',
'tokyonight-storm',
'tokyonight-moon',
'vim-monokai-tasty',
'nightfox',
'nightfly',
'moonfly',
'terafox',
'carbonfox',
'PaperColor',
'onedark',
'onedarker',
'vscode',
'material',
'kanagawa-wave',
'kanagawa-dragon',
'tender',
'terafox',
},
themeConfigFile = "~/.config/nvim/lua/user/polish.lua",
livePreview = true,
})
end,
},
```
`.local/share/nvim/lazy/themery.vim.lua/themery/persistence.lua`
```lua
local configToWrite = "-- This block will be replaced by Themery.\n"
configToWrite = configToWrite..beforeCode
configToWrite = configToWrite.."vim.cmd [[:colorscheme "
configToWrite = configToWrite..theme.colorscheme.."]]\n"
configToWrite = configToWrite..afterCode
```
`.config/nvim/lua/user/polish.lua`
```lua
return function(local_vim)
-- Themery block
-- This block will be replaced by Themery.
vim.cmd [[:colorscheme onedarker]]
-- end themery block
return local_vim
end
```
```
[""] = ":bnext",
[""] = ":bprev"
```
## keymaps
### Navigate files
- `e` toggle file manager
- `ff` fuzzy search file
- `fw` fuzzy search string
- `` switch tab forwards
- `` switch tab backwords
### Naviggate code
- `]` go to definition
- `/` toggle comment line(s)
### Multiple cursors
- `` add cursor above
- `` add cursor bellow
- `` add cursor next same word
### LSP
- `lf` format code
### Debug
- `F9` Toggle Breakpoint
- `F5` Start
- `F6` Pause
- `d` other debug keymaps
### Terminal
- `F7` toggle Terminal
- `th` horizontal
- `tv` vertical
# TODO
Support for:
- JSON
- YML
- XML
- HTML
- CSS
- JS/TS
`users/init.lua`
```lua
colorscheme = "astrodark",
-- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on
diagnostics = {
virtual_text = true,
underline = true,
},
```
JSON format #1
(https://github.com/gennaro-tedesco/nvim-jqx)
```lua
{
"gennaro-tedesco/nvim-jqx",
ft = { "json", "yaml" },
},
```
# JSON format #2
```sh
npm install -g fixjson
```
(https://github.com/vim-autoformat/vim-autoformat)
(https://github.com/sbdchd/neoformat)
create custom theme
(https://github.com/rktjmp/lush.nvim)
### twig formatter
`:TSInstall html`
`:TSInstall twig`
### Exclude directories from FZF
`.ignore`
```
sites
vendor
libraries
profile
```
# JS / TS
`MasonInstall typescript-language-server`
`MasonInstall js-debug-adapter`
`MasonInstall html-lsp`
`MasonInstall css-lsp`
`MasonInstall json-lsp`
`MasonInstall YAMLLINT`
# Override code plugin settingss
Add `require("nvim-treesitter.install").prefer_git = true` to `init.lua`
`TSInstall http json`
# RestAPI Client
(https://hurl.dev/)
```sh
yum install -y pkg-config gcc openssl-devel libxml2-devel git
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
git clone --depth 1 https://github.com/Orange-OpenSource/hurl.git --branch 4.0.0
cd hurl
cargo install hurl
hurl -V
```