-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc_source
178 lines (153 loc) · 5.58 KB
/
.vimrc_source
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
set runtimepath+=~/.vim_runtime
source ~/.vim_runtime/vimrcs/basic.vim
source ~/.vim_runtime/vimrcs/filetypes.vim
source ~/.vim_runtime/vimrcs/plugins_config.vim
source ~/.vim_runtime/vimrcs/extended.vim
try
source ~/.vim_runtime/my_configs.vim
catch
endtry
" Solarized dark colorscheme
syntax enable
set background=dark
colorscheme solarized
" Mac OSX clipboard fix...
set clipboard=unnamed
" Ubuntu clipboard fix...
" set clipboard=unnamedplus
""" Custom keys/shortcuts
" NERD tree toggle
map <C-n> :NERDTreeToggle<CR>
" Moving between windows with ALT+<arrow keys>
" >>> in retrospect this is unnecessary since CTRL+<arrow key>
" is already bound to this functionality?
" nmap <silent> <A-Up> :wincmd k<CR>
" nmap <silent> <A-Down> :wincmd j<CR>
" nmap <silent> <A-Left> :wincmd h<CR>
" nmap <silent> <A-Right> :wincmd l<CR>
" highlight any characters over the 100 character line!
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%100v.\+/
" highlight ColorColumn ctermbg=235 guibg=#2c2d27
let &colorcolumn=join(range(101,999),",")
let &colorcolumn="80,".join(range(120,999),",")
" LaTeX section jumping
" noremap <buffer> <silent> ]] :<c-u>call TexJump2Section( v:count1, '' )<CR>
" noremap <buffer> <silent> [[ :<c-u>call TexJump2Section( v:count1, 'b' )<CR>
" function! TexJump2Section( cnt, dir )
" let i = 0
" let pat = '^\s*\\\(part\|chapter\|\(sub\)*section\|paragraph\)\>\|\%$\|\%^'
" let flags = 'W' . a:dir
" while i < a:cnt && search( pat, flags ) > 0
" let i = i+1
" endwhile
" let @/ = pat
" endfunction
" vim zathura viewer
" let g:vimtex_view_method = 'zathura'
let g:vimtex_view_method = 'skim'
" change to Dropbox folder
map <leader>dr :cd ~/Dropbox/<cr>
" set default NERDTree size
let g:NERDTreeWinSize = 30
" recognize MD files
au BufNewFile,BufFilePre,BufRead *.md set filetype=markdown
" code block syntax highlighting
let g:markdown_fenced_languages = ['html', 'python', 'bash=sh']
" Inspired by: https://jeffkreeftmeijer.com/vim-number/
" Hybrid relative & absolute line numbers
" Turned off upon entering insert mode & buffer no longer in focus
:set number relativenumber
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
""" vim-snippets, ultisnips configuration
" Trigger configuration. Do not use <tab> if you use
" https://github.com/Valloric/YouCompleteMe.
" let g:UltiSnipsExpandTrigger="<tab>"
" let g:UltiSnipsJumpForwardTrigger="<c-b>"
" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
let g:UltiSnipsExpandTrigger = "<C-l>"
let g:UltiSnipsJumpForwardTrigger = "<C-j>"
let g:UltiSnipsJumpBackwardTrigger = "<C-k>"
" let g:ycm_key_list_select_completion = ['<C-j>']
" let g:ycm_key_list_previous_completion = ['<C-k>']
" function! g:UltiSnips_Complete()
" call UltiSnips#ExpandSnippet()
" if g:ulti_expand_res == 0
" if pumvisible()
" return "\<C-n>"
" else
" call UltiSnips#JumpForwards()
" if g:ulti_jump_forwards_res == 0
" return "\<TAB>"
" endif
" endif
" endif
" return ""
" endfunction
" au BufEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
" let g:UltiSnipsJumpForwardTrigger="<tab>"
" let g:UltiSnipsListSnippets="<c-e>"
" this mapping Enter key to <C-y> to chose the current highlight item
" and close the selection list, same as other IDEs.
" CONFLICT with some plugins like tpope/Endwise
" inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
""" Markdown folding with https://github.com/nelstrom/vim-markdown-folding
" set nocompatible
" if has("autocmd")
" filetype plugin indent on
" endif
" Use F9 to toggle folding!
" inoremap <F9> <C-O>za
" nnoremap <F9> za
" onoremap <F9> <C-C>za
" vnoremap <F9> zf
" Normal mode Space to toggle folding
nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
vnoremap <Space> zf
" Make views automatic (to save folds when you close a file)
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent loadview
" # Function to permanently delete views created by 'mkview'
" https://stackoverflow.com/questions/28384159/vim-how-to-remove-clear-views-created-by-mkview-from-inside-of-vim
function! MyDeleteView()
let path = fnamemodify(bufname('%'),':p')
" vim's odd =~ escaping for /
let path = substitute(path, '=', '==', 'g')
if empty($HOME)
else
let path = substitute(path, '^'.$HOME, '\~', '')
endif
let path = substitute(path, '/', '=+', 'g') . '='
" view directory
let path = &viewdir.'/'.path
call delete(path)
echo "Deleted: ".path
endfunction
" # Command Delview (and it's abbreviation 'delview')
command Delview call MyDeleteView()
" Lower-case user commands: http://vim.wikia.com/wiki/Replace_a_builtin_command_using_cabbrev
cabbrev delview <c-r>=(getcmdtype()==':' && getcmdpos()==1 ? 'Delview' : 'delview')<CR>
" Enable FZF for Mac as installed via Homebrew
" https://github.com/junegunn/fzf
set rtp+=/usr/local/opt/fzf
" Further setup for Vim
" https://realpython.com/vim-and-python-a-match-made-in-heaven/#lets-make-an-ide
" Enable folding & fold with spacebar
set foldmethod=indent
set foldlevel=99
" nnoremap <space> za
set encoding=utf-8
au BufNewFile,BufRead *.py
\ set tabstop=4 |
\ set softtabstop=4 |
\ set shiftwidth=4 |
\ set textwidth=99 |
\ set expandtab |
\ set autoindent |
\ set fileformat=unix