-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
156 lines (139 loc) · 3.76 KB
/
init.vim
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
command! Vimrc :e $MYVIMRC
command! Source :source %
call plug#begin(stdpath("data") . "/plugged")
Plug 'dracula/vim'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-repeat'
Plug 'terryma/vim-multiple-cursors'
Plug 'easymotion/vim-easymotion'
Plug 'preservim/nerdtree'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'jiangmiao/auto-pairs'
Plug 'vim-airline/vim-airline'
Plug 'tpope/vim-fugitive'
Plug 'ncm2/float-preview.nvim'
Plug 'vim-scripts/CursorLineCurrentWindow'
Plug 'sheerun/vim-polyglot'
call plug#end()
" Load project specific vimrc
if filereadable('.vimrc')
execute 'source .vimrc'
endif
set termguicolors
colorscheme dracula
set number
set cursorline
set showcmd
set mouse=a
set lazyredraw
set scrolloff=5
set tabstop=4
set shiftwidth=4
set expandtab
filetype indent plugin on
" Indent case labels in the same level as switch
set cindent
set cinoptions=:0
syntax enable
let g:vim_markdown_math = 1
let g:vim_markdown_frontmatter = 1
let g:vimsyn_embed = 'P'
set completeopt=menu,menuone,noselect
set pumheight=20
set smartcase
let mapleader = '\'
" Clear search register (highlight) after doing a search
nnoremap <Leader>h :let @/ = ""<CR>
" Force clearing search register after reloading vimrc
call feedkeys("\\h")
noremap Y y$
noremap j gj
noremap k gk
noremap gy "+y
nmap gY "+Y
noremap gp "+p
noremap gP "+P
inoremap <A-h> <C-\><C-o>b
inoremap <A-l> <C-\><C-o>w
inoremap <A-BS> <C-w>
set splitbelow
set splitright
nnoremap <A-h> <C-w>h
nnoremap <A-j> <C-w>j
nnoremap <A-k> <C-w>k
nnoremap <A-l> <C-w>l
" Swap window
nnoremap <A-r> <C-w>r
" :help NERDTree
" Toggle nerdtree and refresh
function! ToggleTree()
NERDTreeToggle
if g:NERDTree.IsOpen()
call feedkeys('R')
endif
endfunction
nnoremap <Leader>e :call ToggleTree()<CR>
let g:NERDTreeShowHidden = 1
let g:NERDTreeWinPos = "right"
" Open terminal and start insertion
function! OpenTerminal()
terminal
call feedkeys('a')
endfunction
nnoremap <Leader>s :call OpenTerminal()<CR>
" Exit from terminal
tnoremap <C-e> <C-\><C-n>
" :help easymotion
nmap <Leader>/ <Plug>(easymotion-bd-w)
" :help vim-multiple-cursors
" Explicitly define key mappings to prevent some key mapping collisions
let g:multi_cursor_use_default_mapping = 0
let g:multi_cursor_start_word_key = '<C-n>'
let g:multi_cursor_next_key = '<C-n>'
let g:multi_cursor_prev_key = '<C-p>'
let g:multi_cursor_skip_key = '<C-x>'
let g:multi_cursor_quit_key = '<Esc>'
" Explicitly define key mappings to prevent some key mapping collisions
let g:AutoPairsShortcutToggle = ''
let g:AutoPairsShortcutFastWrap = ''
let g:AutoPairsShortcutJump = ''
" :help ctrlp
let g:ctrlp_map = '<Leader>p'
" Force searching files under cwd
let g:ctrlp_working_path_mode = ''
" List all files ignoring .git and files in .gitignore
let g:ctrlp_user_command = "if git rev-parse --git-dir &> /dev/null ; for file in (git ls-files --exclude-standard --cached --others) ; if test -f $file ; echo $file ; end ; end ; else ; find %s -type f ; end"
" Refresh files on open
function! CtrlpRefresh()
CtrlPClearCache
endfunction
let g:ctrlp_buffer_func = { 'enter': 'CtrlpRefresh' }
function! OpenOtherWindow(...)
let split_command = get(a:, 1, 'split')
let curr_winnr = winnr()
wincmd o
execute 'vertical '.split_command
if curr_winnr > 1
wincmd r
endif
endfunction
" :help quickfix
" Call build script and show quickfix in the other window if error happens
function! Build()
execute '!'.g:project_build_script.' 2>.vimqf'
call feedkeys('\<CR>')
echom v:shell_error
if v:shell_error == 0
cclose
else
cfile .vimqf
call OpenOtherWindow('copen')
wincmd p
wincmd =
endif
endfunction
if exists("g:project_build_script")
nnoremap <Leader>b :call Build()<CR>
nnoremap <Leader>n :cnext<CR>
endif