" Modeline and Notes { " vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker={,} foldlevel=0 foldmethod=marker spell: " " __ __ __ ___ " | \/ |_ _ \ \ / (_)_ __ ___ _ __ ___ " | |\/| | | | | \ \ / /| | '_ ` _ \| '__/ __| " | | | | |_| | \ V / | | | | | | | | | (__ " |_| |_|\__, | \_/ |_|_| |_| |_|_| \___| " |___/ " } " Installed Plugins { call plug#begin() " General { " Navigation { Plug 'unblevable/quick-scope' " } Plug 'bling/vim-bufferline' Plug 'farmergreg/vim-lastplace' Plug 'junegunn/fzf' Plug 'justinmk/vim-sneak' Plug 'ctrlpvim/ctrlp.vim' Plug 'mbbill/undotree' Plug 'mhinz/vim-signify' Plug 'myusuf3/numbers.vim' Plug 'preservim/nerdtree' Plug 'rhysd/conflict-marker.vim' Plug 'terryma/vim-multiple-cursors' Plug 'tpope/vim-abolish' Plug 'tpope/vim-surround' Plug 'vim-airline/vim-airline' " } " Programming { Plug 'airblade/vim-gitgutter' Plug 'dense-analysis/ale' Plug 'godlygeek/tabular' Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'preservim/nerdcommenter' Plug 'rrethy/vim-hexokinase', { 'do': 'make hexokinase' } Plug 'sheerun/vim-polyglot' Plug 'tpope/vim-fugitive' Plug 'Xuyuanp/nerdtree-git-plugin' Plug 'Yggdroot/indentLine' " } " UI { Plug 'gruvbox-community/gruvbox' " This has to be loaded last to work Plug 'ryanoasis/vim-devicons' " } call plug#end() " } " General { colorscheme gruvbox " Set colour scheme set clipboard=unnamed,unnamedplus " Use + register for copy-paste set mouse=a " Automatically enable mouse usage set mousehide " Hide the mouse cursor while typing autocmd BufEnter * if bufname("") !~ "^\[A-Za-z0-9\]*://" | lcd %:p:h | endif " Always switch to the current file directory set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter') set virtualedit=onemore " Allow for cursor beyond last character set hidden " Allow buffer switching without saving set iskeyword-=. " '.' is an end of word designator set iskeyword-=# " '#' is an end of word designator set iskeyword-=- " '-' is an end of word designator " } " Vim UI { set cursorline " show cursor line highlight clear SignColumn " SignColumn should match background highlight clear LineNr " Current line number row will have same background color in relative mode set ignorecase " Ignore case on search set smartcase " Don't ignore upper case characters on search set scrolljump=5 " Lines to scroll when cursor leaves screen set scrolloff=3 " Minimum lines to keep above and below cursor set foldenable " Auto fold code set list " Display whitespace " } " Formatting { set shiftwidth=4 " Use indents of 4 spaces set expandtab " Tabs are spaces, not tabs set tabstop=4 " An indentation every four columns set softtabstop=4 " Let backspace delete indent set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J) set splitright " Puts new vsplit windows to the right of the current set splitbelow " Puts new split windows to the bottom of the current set pastetoggle= " pastetoggle (sane indentation on pastes) " } " Key Mappings { " Switch between different windows by their direction no j| "switching to below window no k| "switching to above window no l| "switching to right window no h| "switching to left window " More convenient leaders let mapleader = "," let maplocalleader = '_' " Visual shifting (does not exit Visual mode) vnoremap < >gv " LanguageClient-neovim nnoremap :call LanguageClient_contextMenu() map lk :call LanguageClient#textDocument_hover() map lg :call LanguageClient#textDocument_definition() map lr :call LanguageClient#textDocument_rename() map lf :call LanguageClient#textDocument_formatting() map lb :call LanguageClient#textDocument_references() map la :call LanguageClient#textDocument_codeAction() map ls :call LanguageClient#textDocument_documentSymbol() " For when you forget to sudo.. Really Write the file. cmap w!! w !sudo tee % >/dev/null " } " Plugin Configuration { " NerdTree { " Start nerdtree automatically when no files are specified autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif " Don't open nerdtree when opening session file autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 0 && !exists("s:std_in") && v:this_session == "" | NERDTree | endif " Start nerdtree automatically when opening up a directory autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif " Close vim if only windo left is nerdtree autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif " Toggle nerdtree map :NERDTreeToggle " } " NerdCommenter { " Add spaces after comment delimiters by default let g:NERDSpaceDelims = 1 " } " Airline { " Enable powerline fonts let g:airline_powerline_fonts=1 " } " hexokinase { set termguicolors " } " coc { vmap f (coc-format-selected) nmap f (coc-format-selected) " Run jest for current project command! -nargs=0 Jest :call CocAction('runCommand', 'jest.projectTest') " Run jest for current file command! -nargs=0 JestCurrent :call CocAction('runCommand', 'jest.fileTest', ['%']) " Run jest for current test nnoremap te :call CocAction('runCommand', 'jest.singleTest') " Init jest in current cwd, require global jest command exists command! JestInit :call CocAction('runCommand', 'jest.init') " use and to navigate completion list inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" " } " ale { " Shortcuts jump between linting errors map [c (ale_previous_wrap) nmap ]c (ale_next_wrap) let g:ale_sign_error = '❌' let g:ale_sign_warning = '⚠️' " Fix files let g:ale_fixers = {'javascript': ['prettier', 'eslint'], 'sh': ['shfmt'], 'json': ['prettier']} " Fix files automatically on save let g:ale_fix_on_save = 1 " } " }