From 1bf62491aebb2c59fa0df0a3f8242cc53ae5892c Mon Sep 17 00:00:00 2001 From: Ste Vaidis Date: Mon, 24 Jul 2023 09:20:18 +0300 Subject: [PATCH] Add 'Vim.md' --- Vim.md | 383 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 383 insertions(+) create mode 100644 Vim.md diff --git a/Vim.md b/Vim.md new file mode 100644 index 0000000..beec893 --- /dev/null +++ b/Vim.md @@ -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 + + + 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 + +``` +[""] = ":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) + + + + +# 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 +``` + +