# VIM This repo contains my vim configuration, hope it will be useful for you. ## Installation You will need `vim` and `git` to be able to use this configuration. **Since VIM 9.1.0327, vim can now read config from $XDG_CONFIG_HOME/vim** ```sh git clone https://git.arka.rocks/vimrc.git ~/config/vim ``` **If you use older vim version which do not support $XDG_CONFIG_HOME/vim, use the install.sh script and clone the config inside ~/.vim** ```sh git clone https://git.arka.rocks/vimrc.git ~/.vim ``` *If you want to run the install script which will sed ~/.config/vim to ~/.vim withtout copying the data into ~/.vim, you can run it with any argument you want.* ```sh ./install.sh any_argument_you_want ``` ## Plugins This config has just the necessary plugins installed: ### Themes - [OneDark](https://github.com/joshdick/onedark.vim) onedark theme. ### Graphics utilities - [Vim which key](https://github.com/liuchengxu/vim-which-key) show leader keybinds in a GUI. - [Vim gitgutter](https://github.com/airblade/vim-gitgutter) to see diff between files with git. - [Css color](https://github.com/ap/vim-css-color) preview css colors. (searching better plugins for all viewing all colors codes) ### LSP - [ALE](https://github.com/dense-analysis) linters, fixers, completion & LSP ## Command & keybinds ### General - `hl` remove highlighting #### Window - `Ctrl+h` move to the left window, - `Ctrl+j` move to the bottom window, - `Ctrl+k` move to the upper window, - `Ctrl+l` move to the right window, #### Buffer - `bd` close the current buffer, - `ba` close all the buffers, - `bn` go to the next buffer, - `bp` go to the precedent buffer, #### Tabs - `tn` open a new tab, - `to` close all other tabs, - `tc` close current tab page, - `tm` move the tab after another, - `t` go to the next tab, - `tl` toggle between this tab and the last accessed tab, - `te` open a new tab with the current buffer, #### Spell check - `ss` toggle / untoggle spellchecking, - `sn` go to the next word to spellcheck, - `sp` go to the previous word to spellcheck, - `sa` add a word into the dictionary, - `s?` show the list of alternatives for the word, More help at `:help spell` ### Treeview For help, use `:help netrw`. Key binds: - `Ctrl+f` open the treeview buffer at the left, - `gh` show/hide hidden files, - `gp` change permission of local file - `I` show netrw banner, - `j/k` movement, - `-` go up one dir, - `` go down one dir, - `d` create a directory, - `%` create a file, - `R` rename/move a file, - `D` delete a file ### Vim Gutter For help, use `:help gitgutter`. Keybinds: - `hp` go to the previous hunk, - `hn` go to the next hunk, - `hP` to preview hunk, - `hs` to stage hunk, - `hu` to undo hunk, - `ht` to toggle GitGutter. Hunks are the difference between your file and the git file. ### ALE (Linter, fixers, completion, LSP) For help, use `:help ALE`. Key binds: - `gd` go to the definition, - `gn` go to the next diagnostic, - `gp` go to the previous diagnostic, - `gr` go to the reference, - `gR` rename element, - `gy` type definition, - `gi` go to implementation, - `gh` documentation, - `gf` format document. ## Snippets TODO in ALE ## Linters / fixers & LSP Linters and fixers needed to be installed for each language used. ### Python For python, you need to have [python-lsp-server](https://github.com/python-lsp/python-lsp-server). It can be system wide, or just in a virtualenv. ```bash python3 -m venv .venv source .venv/bin/activate pip install pyton-lsp-server[all] ``` ### PHP For PHP, a combinaison of linters and fixers is used. - [Intelephense](https://github.com/bmewburn/intelephense-docs) LSP - [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) linter - [PHP MessDetector](https://phpmd.org/) linter - [PHP code fixer](https://cs.symfony.com/) fixer ## Formatter By default my config add autoformatting on save on each filetype, you just need a LSP server for the filetype. But if it's not working you could use vim formatting `ggvG=`, `=` is vim command for formatting text. ## VM To code on a virtual machine, I use sshfs, it just mount the system of the vm on my machine and tada! ```bash sudo mkdir /mnt/vm sudo sshfs -o allow_other -p 22 user@localhost:/home/user/ /mnt/vm/ ```