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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
" file stuff
filetype plugin on
syntax enable
" Plug plugins
call plug#begin()
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'itchyny/lightline.vim'
Plug 'jceb/vim-orgmode'
" Plug 'tpope/vim-speeddating'
Plug 'ryanoasis/vim-devicons'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'lervag/vimtex'
Plug 'preservim/nerdtree'
Plug 'itchyny/vim-gitbranch'
Plug 'tpope/vim-commentary'
Plug 'godlygeek/tabular'
Plug 'preservim/vim-markdown'
" Plug 'Yggdroot/indentLine'
Plug 'junegunn/fzf.vim'
call plug#end()
" sets
set nocompatible
set ttymouse=sgr
set number
set relativenumber
set bg:dark
set mouse=a
set tabstop=2 softtabstop=2 shiftwidth=2 expandtab
set formatoptions-=t
set linebreak
set cursorline
" set cursorcolumn
set backspace=indent,eol,start
set laststatus=2
set wildmenu
set scrolloff=5
set incsearch
set ttimeout ttimeoutlen=25
" set showtabline=2
set undodir=~/.vim/undo-dir
set undofile
set backupdir=$HOME/.vim/backups
set noshowmode
set showcmd
" set termguicolors
" set clipboard=unnamedplus
" lets
let g:vimtex_compiler_method = 'arara'
let mapleader = " "
let g:gruvbox_contrast_dark = 'soft'
let g:gruvbox_termcolors = '16'
let g:python_recommended_style = 0
let g:NERDTreeFileExtensionHighlightFullName = 1
let g:NERDTreeExactMatchHighlightFullName = 1
let g:NERDTreePatternMatchHighlightFullName = 1
let g:NERDTreeWinPos = 'right'
let g:org_heading_shade_leading_stars = 0
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_new_list_item_indent = 2
" colorscheme stuff
colorscheme gruvbox
" set specific colors
hi Normal ctermbg=NONE
hi Normal guibg=NONE
hi CocUnderline gui=undercurl cterm=underline
hi CocInfoHighlight cterm=underline
hi CocErrorHighlight ctermfg=red gui=underline cterm=underline
hi CocWarningHighlight ctermfg=yellow gui=underline cterm=underline
hi MatchParen cterm=bold ctermfg=cyan
" Custom commands
command Fixtabs :%s/ / /g | echo 'tabs replaced with spaces (like a good programmer)'
command Clipboard :yank + | echo 'Yanked line into system clipboard'
" remaps
nnoremap <SPACE> <Nop>
nnoremap <leader>w :w<CR>
nnoremap <leader>q :q<CR>
nnoremap <leader>! :q!<CR>
nnoremap <leader>x :wq<CR>
nnoremap <leader>b :e#<CR>
nnoremap <leader>e :e<CR>
nnoremap <leader>c gcc<CR>
nnoremap <leader>y :noh<CR>
nnoremap <leader>u :tabp<CR>
nnoremap <leader>o :tabn<CR>
nnoremap <leader>r :Clipboard<CR>
nnoremap <leader>h :wincmd h<CR>
nnoremap <leader>j :wincmd j<CR>
nnoremap <leader>k :wincmd k<CR>
nnoremap <leader>l :wincmd l<CR>
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <leader>t :NERDTreeToggle<CR>
nnoremap <leader>f :Files .<CR>
nnoremap <leader>p :wincmd p<CR>
nnoremap <leader>v :set paste! number! relativenumber!<CR>
nnoremap <leader>i :CocCommand clangd.switchSourceHeader<CR>
" nerdtree stuff
" Start NERDTree. If a file is specified, move the cursor to its window.
"autocmd StdinReadPre * let s:std_in=1
"autocmd VimEnter * NERDTree | if argc() > 0 || exists("s:std_in") | wincmd p | endif
" 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
" Open the existing NERDTree on each new tab.
" autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif
" turn on spell checker for certain files
autocmd FileType markdown setlocal spell
autocmd FileType org setlocal spell
hi clear SpellBad
hi SpellBad cterm=underline ctermfg=red
hi clear SpellRare
hi SpellRare cterm=underline
hi clear SpellCap
hi SpellCap cterm=underline
hi clear SpellLocal
hi SpellLocal cterm=underline
" Coc remaps
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
function! HumanSize() abort
let l:bytes = line2byte('$') + len(getline('$'))
let l:sizes = ['B', 'KB', 'MB', 'GB']
let l:i = 0
while l:bytes >= 1024
let l:bytes = l:bytes / 1024.0
let l:i += 1
endwhile
return printf('%.0f%s', l:bytes, l:sizes[l:i])
endfunction
" lightline config
if expand('$UID') == 0
let g:lightline = {
\ 'colorscheme': 'molokai',
\ 'active': {
\ 'left': [ [ 'root', 'mode', 'paste' ],
\ [ 'filename', 'readonly', 'modified' ],
\ [ 'gitbranch'] ],
\ 'right': [ [ 'lineinfo' ],
\ [ 'filesize', 'fileformat', 'filetype' ],
\ [ 'percent' ] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'gitbranch#name',
\ 'filesize': 'HumanSize'
\ },
\ }
let g:lightline.component = {
\ 'close': ' %n | X ',
\ 'root': '!!root!!', }
else
let g:lightline = {
\ 'colorscheme': 'gruvbox',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'filename', 'readonly', 'modified' ],
\ [ 'gitbranch'] ],
\ 'right': [ [ 'lineinfo' ],
\ [ 'filesize', 'fileformat', 'filetype' ],
\ [ 'percent' ] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'gitbranch#name',
\ 'filesize': 'HumanSize'
\ },
\ }
let g:lightline.component = {
\ 'close': ' %n | X ', }
endif
|