summaryrefslogtreecommitdiff
path: root/nvim/init.vim
blob: 211452efa19eb683d398f83def4b5741330cfe89 (plain)
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
" vimplugs {{{
call plug#begin('~/.config/nvim/plugged')
" colorschemes {{{
Plug 'tomasiser/vim-code-dark'                          " codedark color scheme
Plug 'flazz/vim-colorschemes'                           " meta-color scheme package
Plug 'ZachIndigo/vim-preglow'                           " my old color scheme
" }}}
" language support {{{
Plug 'axvr/org.vim'                                     " basic org markup language implementation
Plug 'ziglang/zig.vim'                                  " zig programming language
Plug 'jdonaldson/vaxe'                                  " haxe programming language
Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' }  " latex live preview support
Plug 'waycrate/swhkd-vim'                               " swhkd syntax highlighting
Plug 'HiPhish/guile.vim'                                " guile syntax highlighting
" }}}
" utility {{{
Plug 'preservim/nerdtree'                               " directory tree interface
Plug 'Xuyuanp/nerdtree-git-plugin'                      " git status indicator for nerdtree
Plug 'PhilRunninger/nerdtree-visual-selection'          " allows visual selection mode in nerdtree
Plug 'tpope/vim-fugitive'                               " git command interface
Plug 'junegunn/goyo.vim'                                " simplify the user interface (distraction-free)  [BROKEN]
Plug 'junegunn/limelight.vim'                           " focus on single paragraph of text at a time
Plug 'vim-airline/vim-airline'                          " powerline the vim bottom bar
Plug 'nathanaelkane/vim-indent-guides'                  " indent guides for vim
Plug 'mhinz/vim-signify'                                " use signs to show diffs
Plug 'tpope/vim-endwise'                                " auto end functions/if statements
Plug 'tpope/vim-surround'                               " auto close stuff
Plug 'mattn/emmet-vim'                                  " html css easy formating
Plug 'godlygeek/tabular'                                " Needed for vim-markdown
Plug 'plasticboy/vim-markdown'                          " Better markdown support
Plug 'ryanoasis/vim-devicons'                           " dev icons for nerdtree
" }}}
call plug#end()

" }}}
" nvim options {{{

"" nvimrc:
"" General

set showmatch " Highlight matching brace

set number
set relativenumber

"colorscheme CandyPaper
"colorscheme SlateDark
colorscheme preglow
 
set hlsearch                    " Highlight all search results
set smartcase                   " Enable smart-case search
set incsearch                   " Searches for strings incrementally
 
set autoindent                  " Enable auto-indent
"set smartindent                " Enable smart-indent
"set nosmarttab                 " Enable smart-tabs
set expandtab                   " Use spaces instead of tabs
set tabstop=2                   " Number of spaces per tab
set shiftwidth=2                " Number of auto-indent spaces


"" Advanced
set ruler                       " Show row and column ruler information
set undolevels=1000             " Number of undo levels
set backspace=indent,eol,start  " Backspace behaviour
filetype plugin indent on
 
"" GUI Config
set guifont=mononoki\ Nerd\ Font\ Mono:h12

set foldmethod=marker

set conceallevel=2

" set leader key

let mapleader="'"

" emmet {{{
let g:user_emmet_leader_key='<C-a>'
" }}}

" zig config {{{
let g:zig_fmt_autosave = 1
" }}}

" latex live preview {{{
let g:livepreview_previewer = 'zathura'
let g:livepreview_use_biber = 1
let g:livepreview_cursorhold_recompile = 0
" }}}

" vim-markdown {{{
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_folding_level = 3
let g:vim_markdown_toc_autofit = 1
let g:vim_markdown_emphasis_multiline = 0
let g:tex_conceal = ""
let g:vim_markdown_math = 1
let g:vim_markdown_conceal_code_blocks = 1
let g:vim_markdown_fenced_languages = ['c++=cpp', 'viml=vim', 'bash=sh', 'ini=dosini']
let g:vim_markdown_follow_anchor = 1
let g:vim_markdown_math = 1
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_toml_frontmatter = 1
let g:vim_markdown_strikethrough = 1
let g:vim_markdown_no_extensions_in_markdown = 1
let g:vim_markdown_autowrite = 1
let g:vim_markdown_auto_insert_bullets = 0
let g:vim_markdown_new_list_item_indent = 0
let g:vim_markdown_edit_url_in = 'tab'
" }}}

" NERDTree config {{{
let g:NERDTreeGitStatusUseNerdFonts = 1 " use nerd fonts
let g:NERDTreeGitStatusShowClean = 1 " default: 0
let g:NERDTreeDirArrowExpandable = '>'
let g:NERDTreeDirArrowCollapsible = '<'
let g:NERDTreeMapToggleHidden = 'z'
" }}}

" Goyo config {{{
let g:goyo_width = '90%'
let g:goyo_height = '100%'
" }}}

" limelight config {{{
let g:limelight_conceal_ctermfg = 'gray'
let g:limelight_conceal_guifg = 'gray'
" }}}

" devicon config {{{
let g:airline_powerline_fonts = 1
let g:webdevicons_enable_nerdtree = 1
" }}}

" vim-indent-guides config {{{
let g:indent_guides_enable_on_vim_startup = 0
" }}}

" vim-signify config {{{
set updatetime=100
" }}}

" }}}
" Functions {{{
" Goyo functions {{{
function! s:goyo_enter()
  if executable('tmux') && strlen($TMUX)
    silent !tmux set status off
    silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
  endif
  set noshowmode
  set noshowcmd
  set scrolloff=999
  Limelight
  NERDTreeClose
endfunction
function! s:goyo_leave()
  if executable('tmux') && strlen('$TMUX')
    silent !tmux set status on
    silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
  endif
  set showmode
  set showcmd
  set scrolloff=5
  Limelight!
  NERDTree
endfunction
" }}}
" }}}
" Autocommands {{{
" Goyo autocommands {{{
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
" }}}
" NERDTree autocmds {{{
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | wincmd p | endif
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') |
      \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
"autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
      "\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer;.buf | endif
autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif
" }}}
" custom augroup {{{
augroup custom
  autocmd!
  " au BufEnter     *.tex :LLPStartPreview
  au BufEnter     *.md :set textwidth=80
  au BufEnter     *.ms :set textwidth=80
  " au BufEnter     *.c :colo DevC++
  " au BufEnter     *.h :colo DevC++
  " au BufEnter     *.cc :colo DevC++
  " au BufEnter     *.hh :colo DevC++
  " au BufEnter     *.cpp :colo DevC++
  " au BufEnter     *.hpp :colo DevC++
  au BufWritePost init.vim :source %
  " au BufWritePost *.tex :make
  au BufWritePost *sxhkdrc* :!pkill -USR1 -x sxhkd
  au BufWritePost .Xresources :!xrdb ~/.Xresources
  au BufWritePost .gitignore :!git add .gitignore
augroup end
" }}}
" }}}
" keybindings {{{

" direction keys

inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
inoremap <Home> <C-o>g<Home>
inoremap <End> <C-o>g<End>
vnoremap <Down> <C-o>gj
vnoremap <Up> <C-o>gk
vnoremap <Home> <C-o>g<Home>
vnoremap <End> <C-o>g<End>
nnoremap <Down> gj
nnoremap <Up> gk

" clear search highlights
nnoremap <leader>/ :noh<CR>

" toggles
nnoremap <leader>tn :set number!<CR>
nnoremap <leader>tr :set relativenumber!<CR>
nnoremap <leader>tt :NERDTreeToggle<CR>

" tabs
nnoremap <leader>th :tabprevious<CR>
nnoremap <leader>tl :tabnext<CR>
nnoremap <leader>tk :tabnew<CR>
nnoremap <leader>tj :tabclose<CR>

" splits
nnoremap <leader>wh :vertical resize -1<CR>
nnoremap <leader>wj :resize -1<CR>
nnoremap <leader>wk :resize +1<CR>
nnoremap <leader>wl :vertical resize +1<CR>

" config
nnoremap <leader>en :e ~/.config/nvim/init.vim<CR>
nnoremap <leader>ec :source %<CR>

" write as root
nnoremap ZW :w !pkexec tee % >/dev/null

" Goyo
nnoremap <leader>G :Goyo<CR>

" windows
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
vnoremap <C-h> <C-w>h
vnoremap <C-j> <C-w>j
vnoremap <C-k> <C-w>k
vnoremap <C-l> <C-w>l

" files
" these may go away soon
nnoremap <leader>xx :q<CR>
nnoremap <leader>x! :q!<CR>
" these are the new standard
nnoremap <leader>qq :q<CR>
nnoremap <leader>q! :q!<CR>
nnoremap <leader>wq :wq<CR>
nnoremap <leader>ww :w<CR>
nnoremap <leader>ee :e 

" escape for term windows
tnoremap <Esc> <C-\><C-n>

" vim-plug
nnoremap <leader>pi :PlugInstall<CR>
nnoremap <leader>pu :PlugUpdate<CR>
nnoremap <leader>pU :PlugUpgrade<CR>
nnoremap <leader>pc :PlugClean<CR>

" fugitive
nnoremap <leader>gp :G pull<CR>
nnoremap <leader>gd :G diff %<CR>

" }}}