dotfiles/vimrc/.vimrc

119 lines
3.0 KiB
VimL

" Set
filetype indent plugin on
" Syntax highlighting
syntax on
" Add number rows
set relativenumber
set scrolloff=999
" No swap file
set noswapfile
" Incremental search & highlight
set incsearch
set hls
" Runtime path
let $RTP=split(&runtimepath, ',')[0]
let $RC="$HOME/.vimrc"
" Set default path
set path=.,**
" Plugin stuff
call plug#begin()
" Colors and stuff
Plug 'vim-airline/vim-airline'
Plug 'dikiaap/minimalist'
Plug 'jacoborus/tender.vim'
Plug 'jpo/vim-railscasts-theme'
Plug 'rainux/vim-desert-warm-256'
Plug 'morhetz/gruvbox'
Plug 'ayu-theme/ayu-vim'
" NerdTree stuff
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'ryanoasis/vim-devicons'
Plug 'ervandew/supertab'
" Auto-complete:
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
" enable ncm2 for all buffers
autocmd BufEnter * call ncm2#enable_for_buffer()
" IMPORTANT: :help Ncm2PopupOpen for more information
set completeopt=noinsert,menuone,noselect
" NOTE: you need to install completion sources to get completions. Check
" our wiki page for a list of sources: https://github.com/ncm2/ncm2/wiki
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'
Plug 'ncm2/ncm2-jedi'
call plug#end()
" Supertab
let g:SuperTabMappingForward = '<s-tab>'
let g:SuperTabMappingBackward = '<tab>'
" Always show file name
set laststatus=2
" Enter to insert blank line below current, Shift+Enter to insert above
map <Enter> o<ESC>
map <s-Enter> O<ESC>
" Folding (move to python specific vim file?)
set foldmethod=indent
set foldnestmax=99
set foldlevelstart=99
nnoremap <space> za
vnoremap <space> zf
" F9 execute current Python file
autocmd FileType python map <buffer> <F5> :w<CR>:exec '!clear;python' shellescape(@%, 1)<CR>
autocmd FileType python imap <buffer> <F5> <esc>:w<CR>:exec '!clear;python' shellescape(@%, 1)<CR>
" Cycle through buffers
map [b :bp<CR>
map ]b :bn<CR>
map db :bd<CR>
" Toggle Nerd tree
map <F4> :NERDTreeToggle<CR>
" Save, Save and quit
map <F1> :w<CR>
map <F2> :wq<CR>
" Lint
autocmd FileType python map <buffer> gl :w<CR>:exec '!python -m black' shellescape(@%, 1)<CR>
" Automatically open NERDTree
autocmd VimEnter * NERDTree | wincmd p
" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree.
autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
" Show hidden
let NERDTreeShowHidden=1
" Color schemes
" colorscheme moonfly
" colorscheme onenord
" colorscheme gruvbox
set background=dark
colorscheme ayu
set termguicolors
let ayucolor="dark"
" colorscheme tender
" colorscheme railscasts
" colorscheme desert-warm-256
" Restore transparent background
" highlight Normal guibg=none
" highlight NonText guibg=none