" ~~~ Plugins ~~~ " call plug#begin('~/.local/share/nvim/plugged') " Plug 'shougo/deoplete.nvim' " Plug 'ctrlpvim/ctrlp.vim' " Plug 'itchyny/lightline.vim' " Plug 'tpope/vim-commentary' " Plug 'tpope/vim-surround' " Plug 'lambdalisue/suda.vim' " Plug 'jiangmiao/auto-pairs' " Plug 'machakann/vim-highlightedyank' " Plug 'vimwiki/vimwiki' " Plug 'tpope/vim-markdown' " Plug 'nelstrom/vim-markdown-folding' " call plug#end() " Highlight the line on which the cursor lives. set nocursorline " Always show at least one line above/below the cursor. set scrolloff=1 " Always show at least one line left/right of the cursor. set sidescrolloff=5 " Relative line numbers set number relativenumber " Highlight matching pairs of brackets. Use the '%' character to jump between them. set matchpairs+=<:> " Display different types of white spaces. set list set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Use system clipboard set clipboard=unnamedplus " Remove timeout for partially typed commands set notimeout " F keys " Quick write session with F2 map :mksession! ~/.vim_session " And load session with F3 map :source ~/.vim_session " Fix indentation map gg=G " Toggle auto change directory map :set autochdir! autochdir? " Toggle vertical line set colorcolumn= fun! ToggleCC() if &cc == '' " set cc=1,4,21 set cc=80 else set cc= endif endfun nnoremap :call ToggleCC() " Beginning and end of line imap imap cmap cmap " Control-S Save nmap :w vmap :w imap :w " Save + back into insert " imap :wa " Control-C Copy in visual mode vmap y " Control-V Paste in insert and command mode imap pa cmap 0 " Window Movement nmap h nmap j nmap k nmap l " Resizing nmap 2< nmap 2> nmap - nmap + " Insert mode movement imap imap imap imap imap imap " Spacemacs-like keybinds " Change bind from default \ " nnoremap " let mapleader=" " " Make ci( work like quotes do function! New_cib() if search("(","bn") == line(".") sil exe "normal! f)ci(" sil exe "normal! l" startinsert else sil exe "normal! f(ci(" sil exe "normal! l" startinsert endif endfunction " And for curly brackets function! New_ciB() if search("{","bn") == line(".") sil exe "normal! f}ci{" sil exe "normal! l" startinsert else sil exe "normal! f{ci{" sil exe "normal! l" startinsert endif endfunction nnoremap ci( :call New_cib() nnoremap cib :call New_cib() nnoremap ci{ :call New_ciB() nnoremap ciB :call New_ciB() " Alt-m for creating a new line in insert mode imap o " netrw configuration let g:netrw_browse_split = 0 let g:netrw_altfile = 1 " Cycle windows nmap w vmap w tmap w imap w " Command mode history cmap cmap cmap cmap " Back to normal mode from insert " inoremap jk " inoremap JK " Manually refresh file nmap :e! " Indentation set smarttab set expandtab set tabstop=8 set softtabstop=4 set shiftwidth=4 "set smartindent set autoindent "set cindent set nocompatible filetype plugin indent on " Write buffer through sudo (works on vim but not neovim) " cnoreabbrev w!! w !sudo -S tee % >/dev/null " Neovim: suda plugin cnoreabbrev w!! w suda://% " Allow switching between buffers without saving set hidden " Mouse support set mouse=a "Case insensitive searching set ignorecase "Will automatically switch to case sensitive if you use any capitals set smartcase " Auto toggle smart case of for ex commands " Assumes 'set ignorecase smartcase' augroup dynamic_smartcase autocmd! autocmd CmdLineEnter : set nosmartcase autocmd CmdLineLeave : set smartcase augroup END " Substitute live preview set inccommand=nosplit " Markdown Folding let g:markdown_fold_style = 'nested' " Vimwiki " let g:vimwiki_list = [{'path': '~/dox/vimwiki/', 'syntax': 'markdown', 'ext': '.md'}] let g:vimwiki_global_ext=0 let g:vimwiki_table_mappings=0 let g:vimwiki_folding='expr' nmap vv VimwikiIndex nmap vV VimwikiTabIndex nmap vs VimwikiUISelect nmap vi VimwikiDiaryIndex nmap vdd VimwikiMakeDiaryNote nmap vDD VimwikiTabMakeDiaryNote nmap vdy VimwikiMakeYesterdayDiaryNote nmap vdt VimwikiMakeTomorrowDiaryNote nmap VimwikiToggleListItem " Highlighted yank (-1 for persistent) let g:highlightedyank_highlight_duration = 400 " If lightline/airline is enabled, don't show mode under it set noshowmode " Shell set shell=/bin/zsh " Ctrlp let g:ctrlp_switch_buffer = '0' " Useful for large projects let g:ctrlp_max_files=0 let g:ctrlp_max_depth=10 " So that it does not only index starting from current directory let g:ctrlp_working_path_mode = "" let g:ctrlp_cache_dir = $HOME . '/.cache/ctrlp' " Use ag AKA the_silver_searcher for indexing. Faster!!! " TIP: Use ~/.ignore to ignore directories/files " set grepprg=ag\ --nogroup\ --nocolor " let g:ctrlp_user_command = 'ag %s -l --hidden --nocolor -g ""' ""if executable('ag') "" let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' ""endif let g:ctrlp_show_hidden =1 let g:ctrlp_clear_cache_on_exit = 0 " Lightline " Get default from :h lightline let g:lightline = { \ 'colorscheme': 'lena', \ } let g:lightline.active = { \ 'left': [ [ 'mode', 'paste', 'sep1' ], \ [ 'readonly', 'filename', 'modified' ], \ [ ] ], \ 'right': [ [ 'lineinfo' ], \ [ 'percent' ], \ [ 'filetype' ] ] \ } let g:lightline.inactive = { \ 'left': [ [ 'mode', 'paste', 'sep1' ], \ [ 'readonly', 'filename', 'modified' ] ], \ 'right': [ [ 'lineinfo' ], \ [ 'percent' ], \ [ 'filetype' ] ] \ } let g:lightline.tabline = { \ 'left': [ [ 'tabs' ] ], \ 'right': [ ] } let g:lightline.tab = { \ 'active': [ 'tabnum', 'filename', 'modified' ], \ 'inactive': [ 'tabnum', 'filename', 'modified' ] } let g:lightline.component = { \ 'mode': '%{lightline#mode()}', \ 'absolutepath': '%F', \ 'relativepath': '%f', \ 'filename': '%t', \ 'modified': '%M', \ 'bufnum': '%n', \ 'paste': '%{&paste?"PASTE":""}', \ 'readonly': '%R', \ 'charvalue': '%b', \ 'charvaluehex': '%B', \ 'fileencoding': '%{&fenc!=#""?&fenc:&enc}', \ 'fileformat': '%{&ff}', \ 'filetype': '%{&ft!=#""?&ft:"no ft"}', \ 'percent': '%3p%%', \ 'percentwin': '%P', \ 'spell': '%{&spell?&spelllang:""}', \ 'lineinfo': '%3l:%-2v', \ 'line': '%l', \ 'column': '%c', \ 'close': '%999X X ', \ 'winnr': '%{winnr()}', \ 'sep1': '' \} let g:lightline.mode_map = { \ 'n' : 'N', \ 'i' : 'I', \ 'R' : 'R', \ 'v' : 'V', \ 'V' : 'L', \ "\": 'B', \ 'c' : 'C', \ 's' : 'S', \ 'S' : 'S-LINE', \ "\": 'S-BLOCK', \ 't': 'T', \ } let g:lightline.separator = { \ 'left': '', 'right': '' \} let g:lightline.subseparator = { \ 'left': '', 'right': '' \} let g:lightline.tabline_separator = g:lightline.separator let g:lightline.tabline_subseparator = g:lightline.subseparator let g:lightline.enable = { \ 'statusline': 1, \ 'tabline': 1 \ } " deoplete let g:deoplete#enable_at_startup = 1 inoremap pumvisible() ? "\" : "\" " Clear search highlighting with Escape key nnoremap :noh " Allow color schemes to do bright colors without forcing bold. if &t_Co == 8 && $TERM !~# '^linux\|^Eterm' set t_Co=16 endif set wildmenu set encoding=utf8 scriptencoding utf-8 " Colorscheme colorscheme lena set fillchars=vert:: " Restore last cursor position and marks on open au BufReadPost * \ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit' \ | exe "normal! g`\"" \ | endif