Add 'Vim.md'
This commit is contained in:
parent
583f9601a3
commit
1bf62491ae
383
Vim.md
Normal file
383
Vim.md
Normal file
@ -0,0 +1,383 @@
|
||||
# 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 cmake gcc make 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
|
||||
```
|
||||
|
||||
## 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)
|
||||
|
||||
|
||||
|
||||
|
||||
## 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
|
||||
|
||||
```
|
||||
["<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)
|
||||
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
```
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user