-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
181 lines (152 loc) · 5.37 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
" Vim config file
" Nicolas Williams. December 19th, 2017
" ============================= Plugins ==============================
" Better Vim
set nocompatible
" For plugin manager
filetype off
" TODO:
" Plugins
" If Vim.plug is not already installed
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
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin()
Plug 'tpope/vim-commentary'
Plug 'mhinz/vim-startify'
Plug 'cespare/vim-toml'
Plug 'micha/vim-colors-solarized'
" Plug 'romainl/flattened'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'vim-scripts/Rainbow-Parenthesis'
Plug 'mattn/emmet-vim'
Plug 'scrooloose/nerdtree'
Plug 'Glench/Vim-Jinja2-Syntax'
" python linter
Plug 'dense-analysis/ale'
Plug 'vim-python/python-syntax'
" Plug 'psf/black'
Plug 'vim-test/vim-test'
call plug#end()
"TODO: Add the Plugin manager/plugins
filetype plugin indent on
" ============================= Plugin Configs =========================
" flattened theme
" colorscheme flattened_dark
" account for terminal colorscheme
colorscheme solarized
set background=dark
" vim-cpp-enhanced-highlight
let g:cpp_class_scope_highlight = 0
let g:cpp_member_variable_highlight = 0
let g:cpp_class_decl_highlight = 0
" Neomake
" call neomake#configure#automake('rw', 1000)
" C++ syntax
let g:neomake_cpp_enable_markers=['g++']
let g:neomake_cpp_clang_args = ["-std=c++11"]
" ale python syntax checker
let g:ale_virtualenv_dir_names = ["env"]
let g:ale_linters = { 'python': ['flake8'] }
let g:ale_python_flake8_options = '--max-line-length=88'
let g:ale_fixers = { 'python': ['black', 'trim_whitespace', 'remove_trailing_lines', 'isort'] }
let g:ale_fix_on_save = 1
function Py3()
let g:syntastic_python_python_exec = '/usr/local/bin/python3.6'
endfunction
" TODO: Add python syntax highlighting for f-strings
call Py3() " Default to Py3
" ============================= Interface ==============================
syntax enable
set autoindent
set backspace=indent,eol,start
set colorcolumn=88
" set expandtab
set incsearch
set matchpairs+=<:>
set number
set pastetoggle=<f5>
set ruler
set shiftwidth=2
set smartcase
set smarttab
set smartindent
set tabstop=2
set ttyfast
set wrap
set clipboard=unnamed
" Allow a large global buffer
set viminfo+=<1000
set visualbell "Disable Windows terminal bell
" Language specific shift/tab widths
" au FileType python setl shiftwidth=2 tabstop=2
au FileType rust setl shiftwidth=4 tabstop=4
au FileType atlas setl shiftwidth=8 tabstop=8
au FileType cs setl shiftwidth=4 tabstop=4
" FORMATTERS (REQUIRES PRETTIER via 'npm install -g prettier')
au FileType javascript setlocal formatprg=prettier
au FileType javascript.jsx setlocal formatprg=prettier
au FileType typescript setlocal formatprg=prettier\ --parser\ typescript
au FileType html setlocal formatprg=js-beautify\ --type\ html
au FileType scss setlocal formatprg=prettier\ --parser\ css
au FileType css setlocal formatprg=prettier\ --parser\ css
" Jump to where you left off when opening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif
highlight Comment cterm=italic
"#############################################################################
"############################ SYNTAX HIGHLIGHTING ############################
"#############################################################################
let g:python_highlight_all = 1
" ============================== Keymappings ==============================
" nmap means 'map a key sequence when in normal mode' (see vim's docs).
" <silent> tells vim to show no message when this key sequence is used.
" <leader> means the key sequence starts with the character assigned to
" variable mapleader -- a backslash, if no let mapleader = statement has
" executed yet at the point nmap executes.
vnoremap <C-y> :w! ~/.vbuf<CR>
nnoremap <C-p> :r ~/.vbuf<CR>
" Easier exiting insert mode
:imap jk <Esc>
:imap JK <Esc>
" Better mark jumping
:nnoremap ` ;
:nnoremap ; `
" Space is easier than ':'
:noremap <Space> :
"Enter to insert a new line w/o entering insert mode
:nmap <Enter> o<Esc>
" Smart paste when pasting
nmap <silent> ,p :SmartPaste<cr>
" Copy and paste to system keyboard
vmap <C-c> :w! ~/.vbuf<CR>
nmap <C-v> :r ~/.vbuf<CR>
map <C-n> :NERDTreeToggle<CR>
" Control + Backspace deletes word-by-word
imap <C-BS> <C-W>
noremap! <C-BS> <C-w>
noremap! <C-h> <C-w>
" vim-test shortcuts
nmap <silent> <leader>t :TestNearest<CR>
nmap <silent> <leader>T :TestFile<CR>
nmap <silent> <leader>l :TestLast<CR>
" =========================== Custom Functions ============================
" Create comment headers (triple lined comment surrounded by # symbol
function CommentHeader(title)
let commentString = '##############################################################################'
let currLine = line(".")
" string lengths
let comStrLen = strlen(commentString)
let titleStrLen = strlen(a:title)
let numHashes = comStrLen - (titleStrLen + 2)
" if even number of hashes
let evenOddEqualizer = (numHashes % 2) == 0 ? 0 : 1
let leftHash = commentString[0:float2nr(numHashes / 2 + evenOddEqualizer - 1)]
let rightHash = commentString[0:float2nr(numHashes / 2 - 1)]
let middleLine = join([leftHash, toupper(a:title), rightHash])
call append(currLine, [commentString, middleLine, commentString])
endfunction