-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
105 lines (81 loc) · 3.25 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
" Install and run vim-plug on first run
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
endif
" Run PlugInstall if there are missing plugins
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
\| PlugInstall --sync | source $MYVIMRC
\| endif
so ~/.vim/plugins.vim
" ================ General Config ====================
set number "Line numbers are good
set relativenumber "Line numbers good, relative line numbers better
set backspace=indent,eol,start "Allow backspace in insert mode
set history=1000 "Store lots of :cmdline history
set showcmd "Show incomplete cmds down the bottom
set showmode "Show current mode down the bottom
set visualbell "No sounds
set autoread "Reload files changed outside vim
set mouse=a "Enable mouse scroll and commit blasphemy
set incsearch "Highlight as you type
set hlsearch "Highlight items found, NOTE: vim-cool plugin automatically removes highlights post search
set termguicolors "Set colours for theme
set background=dark "Fix vim colours within tmux
" Turn on syntax highlighting
syntax on
" This makes vim act like all other editors, buffers can
" exist in the background without being in a window.
" http://items.sjbach.com/319/configuring-vim-right
set hidden
" ================ Indentation ======================
set autoindent
set smartindent
set smarttab
set shiftwidth=2
set softtabstop=2
set tabstop=2
set expandtab
" Auto indent pasted text
nnoremap p p=`]<C-o>
nnoremap P P=`]<C-o>
" ================ Others ===========================
" Vim-airline config
let g:airline_powerline_fonts = 1
let g:airline_section_z = '%p%% %l:%c'
let g:airline#extensions#ale#enabled = 1
" Fail-safe for vim-airline symbols incase locale is not set (eg. on remote)
set encoding=utf-8
" To get rid of thing like --INSERT--
set noshowmode
" To get rid of display of last command
set noshowcmd
" To get rid of the file name displayed in the command line bar
set shortmess+=F
" To setup fzf in vim
set rtp+=/opt/homebrew/opt/fzf
" Define keybindings for fzf
nnoremap <C-p> :FZF<CR>
nnoremap <C-b> :Buffers<CR>
nnoremap <C-f> :Files<CR>
" Easily toggle NERDTree on/off
noremap <F10> :NERDTreeToggle<CR>
" 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
" Close the tab if NERDTree is the only window remaining in it.
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" Easily toggle Markdown Preview
nmap <F6> <Plug>MarkdownPreviewToggle<CR>
"" Persistent undo
if has("persistent_undo")
let target_path = expand('~/.undodir')
" create the directory and any parent directories
" if the location does not exist.
if !isdirectory(target_path)
call mkdir(target_path, "p", 0700)
endif
let &undodir=target_path
set undofile
endif
"" Toggle Undotree
nnoremap <F5> :UndotreeToggle<CR>