yveslange

NVIM

Nov 23rd, 2018
2,876
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 4.08 KB | None | 0 0
  1. let mapleader=","                " Map the leader key to comma.
  2.  
  3.  
  4. """ PLUGINS
  5. call plug#begin('~/.local/share/nvim/plugged')
  6.  
  7.   " Colorschemes collection
  8.   Plug 'morhetz/gruvbox'
  9.   set background=dark
  10.  
  11.   " File explorer
  12.   Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
  13.   Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' }
  14.   nnoremap <Leader>e :NERDTreeToggle<CR>
  15.  
  16.   " Comment functions
  17.   Plug 'tomtom/tcomment_vim'
  18.   map <Leader>c :TComment<CR>
  19.  
  20.   " Javascript
  21.   Plug 'pangloss/vim-javascript'
  22.   Plug 'othree/javascript-libraries-syntax.vim'
  23.   Plug 'othree/html5.vim'
  24.   Plug 'kchmck/vim-coffee-script'
  25.  
  26. call plug#end()
  27.  
  28. """ OPTIONS
  29.   colorscheme gruvbox
  30.   set nowrap                       " Do not wrap the text
  31.   set linebreak                    " Wrap lines at convenient points
  32.   set mouse=a                      " Enable mouse interactivity.
  33.   set showmatch                    " Show matching brackets.
  34.   set number                       " Show the line numbers on the left.
  35.   set formatoptions+=o             " Continue comment marker in new line.
  36.   set expandtab                    " Insert spaces when TAB is pressed.
  37.   set tabstop=2                    " Render TABs using this many spaces.
  38.   set shiftwidth=2                 " Indenfation amount for < and > commands.
  39.   set ignorecase                   " Make searching case insensitive.
  40.   set smartcase                    " ... unless the search query has capital letters.
  41.   set gdefault                     " Use 'g' flag by default with :s/foo/bar/.
  42.   set cursorline                   " Highlight current line
  43.   set synmaxcol=200                " Use syntax highlighting only for 128 columns. Note: changing this with cursoline enabled can make scroll choppy
  44.   set timeoutlen=900 ttimeoutlen=0 " Reduce Command timeout for faster escape and O
  45.   set splitright                   " Set up new vertical splits positions
  46.   set splitbelow                   " Set up new horizontal splits positions
  47.   set lazyredraw                   " Do not redraw on registers and macros
  48.   set updatetime=500               " Cursor hold timeout
  49.   command! W  write                " :W will work like :w
  50.   command! Q  close                " :Q will work like :q
  51.  
  52.   " Turn of swap files
  53.   set noswapfile nobackup nowb
  54.  
  55.   " Keep undo history across sessions, by storing in file.
  56.   silent !mkdir ~/.config/nvim/backups > /dev/null 2>&1
  57.   set undodir=~/.config/nvim/backups undofile
  58.  
  59.   if has("autocmd")
  60.     " au vimrc FocusGained,BufEnter * checktime             " Refresh file when vim gets focus
  61.     au BufWinEnter * syntax sync minlines=3000              " Sync syntax highlighting
  62.     au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif " Jump to previous position
  63.   endif
  64.  
  65. """ KEYBINDINGS
  66.   " Redraw screen
  67.   nnoremap <Leader>r :redraw<CR>
  68.  
  69.   " Toggle number
  70.   nnoremap <Leader>n :setlocal number!<CR>
  71.  
  72.   " Toggle paste
  73.   nnoremap <Leader>p :set paste!<CR>       " Toggle paste mode
  74.  
  75.   " Search and replace
  76.   nnoremap <Leader>s :%s/\<<C-r><C-w>\>//cg<Left><Left><Left>
  77.  
  78.   " Navigation through splits (not working with TMUX)
  79.   nnoremap <A-Right> <C-w><Right>
  80.   nnoremap <A-Left> <C-w><Left>
  81.   inoremap <A-Right> <Esc><C-w><Right>i
  82.   inoremap <A-Left> <Esc><C-w><Left>i
  83.   nnoremap <A-Up> <C-w><Up>
  84.   nnoremap <A-Down> <C-w><Down>
  85.   inoremap <A-Up> <Esc><C-w><Up>i
  86.   inoremap <A-Down> <Esc><C-w><Down>i
  87.  
  88.   " Tabs navigation and move
  89.   map <C-S-Down> <Esc>:m +1<CR>
  90.   map <C-S-Up> <Esc>:m -2<CR>
  91.   map <A-S-Left> <Esc>:tabm -1<CR>
  92.   map <A-S-Right> <Esc>:tabm +1<CR>
  93.   map <C-A-Right> <Esc>:tabn<CR>
  94.   map <C-A-Left> <Esc>:tabp<CR>
  95.   imap <C-A-Right> <Esc>:tabn<CR>i
  96.   imap <C-A-Left> <Esc>:tabp<CR>i
  97.  
  98.   " Allow saving of files as sudo when I forgot to start vim using sudo.
  99.   cmap w!! w !sudo tee > /dev/null %
  100.  
  101.   " Map save to Ctrl + S
  102.   map <c-s> :w<CR>
  103.   imap <c-s> <C-o>:w<CR>
  104.   nnoremap <Leader>s :w<CR>
  105.  
  106.   " Redo shortcut
  107.   map <c-r> <Nop>
  108.   map <c-u> <Esc>:redo<CR>
  109.   map <s-u> <Esc>:redo<CR>
  110.  
  111.   "make < > shifts keep selection
  112.   vnoremap < <gv
  113.   vnoremap > >gv
Advertisement