commit dd3b444bd2897750b804795cf6aea2cfb0587a94 Author: nal-chris Date: Wed Sep 16 22:59:48 2020 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a0e76af --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.netrwhist diff --git a/init.vim b/init.vim new file mode 100644 index 0000000..4e51002 --- /dev/null +++ b/init.vim @@ -0,0 +1,180 @@ +" Plugins --- {{{ +call plug#begin(stdpath('data') . '/plugged') +Plug 'rafi/awesome-vim-colorschemes' +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf.vim' +Plug 'phpactor/phpactor', { 'do': 'composer install', 'for': 'php' } +Plug 'ncm2/ncm2' +Plug 'roxma/nvim-yarp' + +autocmd BufEnter * call ncm2#enable_for_buffer() +set completeopt=noinsert,menuone,noselect + +Plug 'phpactor/ncm2-phpactor' +call plug#end() +" }}} + +" Basic settings ---- {{{ +set nocompatible "Use the latest vim settings/options +syntax enable "Enable syntax highlighting +let mapleader = ',' "The default leader is \, but a comma is much better +let localleader = '\\' "The leader to be used for filetype specific mappings +set number relativenumber "Show relative line numbers +set noerrorbells visualbell t_vb= "Remove the bells +set tabstop=4 "Set how many columns a tab counts for +set shiftwidth=4 "How many columns text is indented when using reindent +set softtabstop=4 "Set columns for tabs in insert mode +set expandtab "Use spaces instead of tabs +set smartindent "Automatically indent code +set ignorecase "Ignores case when searching +set smartcase "Doesn't ignore case when the search includes upper case characters +set backupdir=/tmp// "Store backup files in the /tmp directory +set directory=/tmp// "Store swap files in the /tmp directory +set undodir=/tmp// "Store undo history in the /tmp directory +set undofile "Store the undo history +set spell "Enable spell checking +set autowriteall "Save the file when switching buffers +"}}} + +" Visuals ---- {{{ +colorscheme nord +set t_Co=256 "User 256 colors. This is useful for terminal vim +set guifont=Fira_Code:h17 +set guioptions-=e "We don't want GUI tabs + +set guioptions-=l +set guioptions-=L +set guioptions-=r +set guioptions-=R +set nowrap "Don't wrap lines around +"Set line number Colour to be same as background +hi LineNr guibg=bg +"Get rid of ugly split borders +hi vertsplit guifg=bg guibg=bg +" }}} + +" Split Management --- {{{ +set splitbelow +set splitright + +"We'll set simpler mappings to switch between splits +nnoremap +nnoremap +nnoremap +nnoremap +" }}} + +" Search --- {{{ +set hlsearch +set incsearch + +set path+=** +" }}} + +" Mappings --- {{{ +" Editing files - {{{ +"Make it easy to edit the vimrc file +nnoremap ev :tabedit $MYVIMRC +"Source the vimrc file +nnoremap es :source $MYVIMRC +" }}} + +"Add simple highlight removal +nnoremap :nohlsearch + +"Convert tabs to spaces +nnoremap :retab + +"Map movement keys to Escape +inoremap jj +inoremap jk +inoremap kk +inoremap hh + +"Delete a line in insert mode +inoremap ddi + +"Use semicolon instead of colon for commands +nnoremap ; : + +"Append the line with a semicolon +inoremap ; mzA;`za +nnoremap ; mzA;`za + +"Easily navigate items in the quickfix menu +nnoremap ] :cnext +nnoremap [ :cprevious + +"Indent arrays +nnoremap { mzF[`a``%i`z +nnoremap } mzF[`a``%i`zvi[:s/,\s*/,\r/gvi[=`z:nohlsearch + +"A command to properly indent json code +com! FormatJSON %!python -m json.tool +" }}} + +" Moving around --- {{{ +"Use capital H and L to move to the start and end of lines +nnoremap H ^ +nnoremap L $ + +"Move a line up or down +nnoremap ddp +nnoremap ddkP +" }}} + +" Operator mappings --- {{{ +onoremap in( :normal! f(vi( +onoremap il( :normal! F)vi( +onoremap an( :normal! f(va( +onoremap al( :normal! F)va( +onoremap an{ :normal! f{vi( +onoremap al{ :normal! F}vi( +" }}} + +" Abbreviations --- {{{ +iabbrev adn and +iabbrev waht what +iabbrev tehn then +iabbrev tihs this +iabbrev teh the +iabbrev Teh The +" }}} + +" Auto-Commands --- {{{ + +"Automatically source the config files on save. +augroup autosourcing + autocmd! + autocmd BufWritePost $MYVIMRC source % "Source the vimrc file +augroup END + +"Fold vimrc and zshrc files on open +augroup autofolding + autocmd! + autocmd BufReadPost $MYVIMRC :setlocal foldlevelstart=0 + autocmd FileType vim setlocal foldmethod=marker + autocmd BufReadPost zsh :setlocal foldlevelstart=0 + autocmd FileType zsh setlocal foldmethod=marker +augroup END + +"Automatically save files +augroup autosaving + autocmd! + autocmd FocusLost * silent! wa "Save all files when moving away from the window +augroup END + +augroup modes + autocmd! + autocmd FocusLost * call feedkeys("\") "Go to normal mode when moving away + autocmd BufNewFile * call feedkeys("i") "Go to insert mode when starting a new file +augroup END + +" }}} + +" Notes and tips +" - press 'zz' to instantly center the line where the cursor is located. +" - You can increment numbers with . +" - To operate on multiple lines use to select the lines, to go to +" insert mode, perform edit, press . +" - Use the command :r to paste the output of a command to the buffer.