" Set encoding set encoding=UTF-8 " Set keymodel set keymodel=startsel,stopsel set backspace=indent,eol,start set grepprg=rg\ --vimgrep\ --smart-case\ --follow set clipboard+=unnamedplus " Indents word-wrapped lines as much as the 'parent' line set wrap set breakindent " Ensures word-wrap does not split words set formatoptions=l set lbr " Set colorscheme colorscheme codedark " Disable compatibility with vi which can cause unexpected issues. set nocompatible " Enable type file detection. Vim will be able to try to detect the type of file in use. filetype on " Enable plugins and load plugin for the detected file type. filetype plugin on " Load an indent file for the detected file type. filetype indent on " Turn syntax highlighting on syntax on " Add numbers to each line on the left-hand side set number set relativenumber " Hihglight cursor line set cursorline " Set mouse scroll set mouse=a " Set shift width to 4 spaces set shiftwidth=4 " Set tab width to 4 columns set tabstop=4 " Use space instead of tab set expandtab " Do not wrap lines. set nowrap " Do not let cursor scroll below or above N number of lines when scrolling set scrolloff=10 " While searching through a file incrementally highlight matching characters set incsearch " Show partial command you type in the last line of screen set showcmd " Show the mode you are in last line set showmode " Show matching words during search set showmatch " Use highlighting when doing a search set hlsearch " Set the commands to save in history, default is 20 set history=1000 " Enable auto completion menu after pressing TAB set wildmenu " Make wildmenu behave like Bash completion set wildmode=list:longest " Wildmenu will ignore files with these extensions, bc we don't want to edit " them with vim set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx " PLUGINS ----------------------------------------------------------------- {{{ " Plugin code goes here let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' if empty(glob(data_dir . '/autoload/plug.vim')) silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif call plug#begin('~/.vim/plugged') Plug 'tomasiser/vim-code-dark' Plug 'preservim/nerdtree' Plug 'mbbill/undotree' Plug 'ryanoasis/vim-devicons' Plug 'junegunn/goyo.vim' Plug 'tpope/vim-fugitive' Plug 'airblade/vim-gitgutter' Plug 'ap/vim-css-color' Plug 'tpope/vim-commentary' Plug 'tpope/vim-unimpaired' Plug 'tpope/vim-surround' Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' Plug 'mattn/emmet-vim' Plug 'manzeloth/live-server' Plug 'pangloss/vim-javascript' Plug 'vim-python/python-syntax' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' if has('nvim') Plug 'nvim-lua/plenary.nvim' Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'nvim-treesitter/nvim-treesitter-context' Plug 'neovim/nvim-lspconfig' Plug 'nvim-lua/completion-nvim' " :MasonUpdate updates registry contents Plug 'williamboman/mason.nvim', { 'do': ':MasonUpdate' } Plug 'jose-elias-alvarez/null-ls.nvim' endif " if has('nvim') " Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } " else " Plug 'Shougo/deoplete.nvim' " Plug 'roxma/nvim-yarp' " Plug 'roxma/vim-hug-neovim-rpc' " endif " let g:deoplete#enable_at_startup = 1 call plug#end() luafile ~/.vim/lsp_config.lua " call deoplete#custom#option('sources', { " \ '_': ['ale'], " \ }) " }}} " MAPPINGS ----------------------------------------------------------------- {{{ " Mappings code goes here " Set backslash as leader key let mapleader = '\' " Press \\ to jump back to last cursor position nnoremap \ `` " Type jj to exit insert mode quickly inoremap jj " Press the space bar to type the : char in command mode nnoremap : " Press the letter o will open a new line below the current one " Exit insert mode after creating a new line above or below current line nnoremap o o nnoremap O O " Center the cursor vertically when moving to next word during search nnoremap n nzz nnoremap N Nzz " Yank from cursor to the end of line nnoremap Y y$ " Map F5 key to run a Python script " F5 is mapped with a chain of commands " :w saves file " is like pressing enter " !clear runs the external clear screen command " !python3 % executes current file with python nnoremap :w :!clear :!python3 % nnoremap :bel term N :res 5 " You can split window in Vim by typing :split or :vsplit " Navigate the split view easier by pressing CTRL+j CTRL+k CTRL+h CTRL+l nnoremap j nnoremap k nnoremap h nnoremap l " Resize split windows using arrow keys by pressing: " CTRL+UP CTRL+DOWN CTRL+LEFT CTRL+RIGHT nnoremap + nnoremap - nnoremap > nnoremap < " Ctrl c ctrl v ecc vmap yi vmap di map Pi imap Pi imap ui " Word wrap navigation nnoremap j v:count ? 'j' : 'gj' nnoremap k v:count ? 'k' : 'gk' " Overwrite arrow navigation " Move text left and right nmap << nmap >> vmap >gv " Move text up and down nmap [e nmap ]e vmap [egv vmap ]egv nmap ]e nmap [e vmap ]egv vmap [egv " fzf specific mappings nnoremap b :Buffer nnoremap :Files nnoremap f :Rg nnoremap / :BLines nnoremap ' :Marks nnoremap g :Commits nnoremap H :Helptags nnoremap hh :History nnoremap h: :History: nnoremap h/ :History/ " Terminal specific mappings " vim-powered terminal in new window map t :term ++close tmap t :term ++close " vim-powered terminal in new tab map T :tab term ++close tmap T :tab term ++close " Goyo specific mappings nnoremap z :Goyo " NERDTree specific mappings " Map the F3 key to toggle NERDTree open and close nnoremap :NERDTreeToggle " Have nerdtree ignore certain files and directories let NERDTreeIgnore=['\.git$', '\.mp4$', '\.ogg$', '\.iso$', '\.pdf$', '\.pyc$', '\.odt$', '\.db$'] nnoremap :UndotreeToggle " ALE specific mappings nmap (ale_next_wrap) " lspconfig mappings nnoremap gd lua vim.lsp.buf.definition() nnoremap gi lua vim.lsp.buf.implementation() nnoremap gr lua vim.lsp.buf.references() nnoremap gD lua vim.lsp.buf.declaration() nnoremap ge lua vim.lsp.diagnostic.set_loclist() nnoremap K lua vim.lsp.buf.hover() nnoremap f lua vim.lsp.buf.formatting() nnoremap rn lua vim.lsp.buf.rename() nnoremap a lua vim.lsp.buf.code_action() xmap a lua vim.lsp.buf.range_code_action() " }}} " VIMSCRIPT ----------------------------------------------------------------- {{{ " This will enable code folding " Use the marker method of folding augroup filetype_vim autocmd! autocmd FileType vim setlocal foldmethod=marker augroup END " If the current file type is MD, set line wrap autocmd FileType markdown setlocal wrap linebreak nolist set backup if !isdirectory($HOME."/.vim/backup") silent! execute "!mkdir ~/.vim/backup" endif set backupdir=~/.vim/backup "not generate .swap set noswapfile " More Vimscripts code goes here " }}} " " STATUS LINE ----------------------------------------------------------------- {{{ " " Status bar code goes here " set statusline= " " Status line left side " set statusline+=\ %F\ %M\ %Y\ %R " " Use a divider to separate left side from right side " set statusline+=%= " " Status line right side " set statusline+=\ ascii:\ %b\ hex:\ 0x%B\ row:\ %l\ col:\ %c\ percent:\ %p%% " " Show status on second to last line " set laststatus=2 " " }}}