435 lines
8.6 KiB
Markdown
435 lines
8.6 KiB
Markdown
# 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 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
|
|
```
|
|
|
|
## 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
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<ruleset name="myproject">
|
|
<description>PHP CodeSniffer configuration for myproject development.</description>
|
|
<file>.</file>
|
|
<arg name="extensions" value="php,module,inc,install,test,profile,theme,css,info,txt,md,yml"/>
|
|
<config name="drupal_core_version" value="9"/>
|
|
<rule ref="/root/.config/composer/vendor/drupal/coder/coder_sniffer/Drupal">
|
|
<!-- Example how you would disable a rule you are not compliant with yet:
|
|
<exclude name="Drupal.Commenting.Deprecated"/>
|
|
-->
|
|
</rule>
|
|
<rule ref="/root/.config/composer/vendor/drupal/coder/coder_sniffer/DrupalPractice"/>
|
|
<!-- Example how you would disable an external rule you do not like:
|
|
<rule ref="PEAR.Functions.ValidDefaultValue.NotAtEnd">
|
|
<severity>0</severity>
|
|
</rule>
|
|
-->
|
|
</ruleset>
|
|
```
|
|
|
|
Disable too many userless warnings
|
|
|
|
`phpcs.xml`
|
|
|
|
```xml
|
|
<ruleset name="MyStandard">
|
|
<description>My custom coding standard.</description>
|
|
<rule ref="PEAR">
|
|
<exclude name="Generic.Commenting.DocComment.ContentBeforeClose"/>
|
|
<exclude name="Generic.Commenting.DocComment.ContentAfterOpen"/>
|
|
<exclude name="Generic.Commenting.DocComment.MissingShort"/>
|
|
<exclude name="PEAR.NamingConventions.ValidFunctionName"/>
|
|
<exclude name="PEAR.NamingConventions.ValidVariableName"/>
|
|
<exclude name="PEAR.NamingConventions.ValidFunctionName.PrivateNoUnderscore"/>
|
|
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine"/>
|
|
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket"/>
|
|
<exclude name="PEAR.Commenting.InlineComment"/>
|
|
<exclude name="PEAR.Commenting.ClassComment"/>
|
|
<exclude name="PEAR.Commenting.ClassComment.Missing"/>
|
|
<exclude name="PEAR.Commenting.FunctionComment.Missing"/>
|
|
<exclude name="PEAR.Commenting.FunctionComment.MissingReturn"/>
|
|
<exclude name="PEAR.Commenting.FileComment.Missing"/>
|
|
<exclude name="PEAR.Commenting.FileComment.MissingCategoryTag"/>
|
|
<exclude name="PEAR.Commenting.FileComment.MissingPackageTag"/>
|
|
<exclude name="PEAR.Commenting.FileComment.MissingLinkTag"/>
|
|
<exclude name="PEAR.Commenting.FileComment.MissingVersion"/>
|
|
</rule>
|
|
</ruleset>
|
|
```
|
|
|
|
|
|
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
|
|
```
|
|
|
|
```
|
|
["<Tab>"] = ":bnext<cr>",
|
|
["<S-Tab>"] = ":bprev<cr>"
|
|
```
|
|
## keymaps
|
|
|
|
### Navigate files
|
|
|
|
- `<SPC>e` toggle file manager
|
|
- `<SPC>ff` fuzzy search file
|
|
- `<SPC>fw` fuzzy search string
|
|
- `<TAB>` switch tab forwards
|
|
- `<S-TAB>` switch tab backwords
|
|
|
|
### Naviggate code
|
|
|
|
- `<CTRL>]` go to definition
|
|
- `<SPC>/` toggle comment line(s)
|
|
|
|
### Multiple cursors
|
|
|
|
- `<C-S-Up>` add cursor above
|
|
- `<C-S-Down>` add cursor bellow
|
|
- `<C-n>` add cursor next same word
|
|
|
|
### LSP
|
|
|
|
- `<SPC>lf` format code
|
|
|
|
### Debug
|
|
|
|
- `F9` Toggle Breakpoint
|
|
- `F5` Start
|
|
- `F6` Pause
|
|
- `<SPC>d` other debug keymaps
|
|
|
|
### Terminal
|
|
|
|
- `F7` toggle Terminal
|
|
- `<SPC>th` horizontal
|
|
- `<SPC>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
|
|
```
|
|
|
|
|