-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.vim
225 lines (178 loc) · 5.18 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
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
" {{{ internal vim packages
packadd matchit
packadd packer.nvim
" }}}
" lua config
lua require("init")
" Basic vim settings {{{
" line numbers and relative line numbers
set nu rnu
" update file if content changed outside
set autoread
set autoindent smartindent
set expandtab smarttab
set shiftwidth=4
set tabstop=4
set softtabstop=4
set hlsearch incsearch ignorecase smartcase
" nice persistent undo
set undolevels=999 history=999
set undofile
" theme
set t_Co=256
set background=dark
colo srcery
let g:srcery_italic = 1
let g:srcery_transparent_background = 1
set termguicolors
hi Normal guibg=NONE ctermbg=NONE
hi Comment gui=italic
" statusline already shows this
set noshowmode
set showcmd
set laststatus=2
" I disables the vim intro message
" c disables insertion complete menu messages
set shortmess+=Ic
" show splits on the right and below
set spr sb
set viminfo='100,<1000,s100,h
set cursorline
let mapleader=" "
let g:netrw_banner=0
set dictionary+=/usr/share/dict/words
let g:python3_host_prog='/usr/bin/python'
" for live-previewing effects of commands, mostly for :s
set inccommand=nosplit
set completeopt=menu,menuone,noselect,noinsert,preview
set sessionoptions+=winpos,terminal,folds
set updatetime=250
set signcolumn=number
" }}}
" maps {{{
" for spellings
nnoremap <F7> :setlocal spell! spelllang=en<cr>
inoremap <C-l> <c-g>u<Esc>[s1z=`]i<c-g>u
" for split navigation
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
tnoremap <C-j> <C-w>j
tnoremap <C-k> <C-w>k
tnoremap <C-h> <C-w>h
" tnoremap <C-l> <C-w>l
" for doing some things faster
nnoremap <leader>q :Bdelete<cr>
nnoremap <leader>x :x<cr>
nnoremap <leader>w :w<cr>
" Useful
nnoremap H ^
nnoremap L $
nnoremap <leader><space> :noh<cr>
" telescope
nnoremap <F2> <cmd>Telescope buffers<cr>
nnoremap <leader>j <cmd>lua require('telescope.builtin').live_grep()<cr>
nnoremap <leader>k <cmd>lua require('telescope.builtin').lsp_dynamic_workspace_symbols()<cr>
nnoremap <leader>l <cmd>Telescope find_files<cr>
" edit init.vim
nnoremap <leader>ev :vs ~/.config/nvim/init.vim<cr>
" make commenting easier
nnoremap <leader>/ :Commentary<cr>
vnoremap <leader>/ :Commentary<cr>
" cd to dir containing this file
nnoremap <leader>cd :cd %:p:h<cr>
" move (selected) line(s) up or down
nnoremap <silent> + :m .+1<cr>==
nnoremap <silent> - :m .-2<cr>==
vnoremap <silent> + :m '>+1<cr>gv=gv
vnoremap <silent> - :m '<-2<cr>gv=gv
" for buffer navigation
nnoremap ]b :bn!<cr>
nnoremap [b :bp!<cr>
tnoremap ]b <C-\><C-n>:bn!<cr>
tnoremap [b <C-\><C-n>:bp!<cr>
" quickfix maps
nnoremap ]q :cnext<cr>
nnoremap [q :cprev<cr>
nnoremap [Q :cfirst<cr>
nnoremap ]Q :clast<cr>
" location list maps
nnoremap ]l :lnext<cr>
nnoremap [l :lprev<cr>
nnoremap [L :lfirst<cr>
nnoremap ]L :llast<cr>
" make escape work inside terminal
tnoremap <Esc> <C-\><C-n>
" debugging
nnoremap <leader>b :lua require'dap'.toggle_breakpoint()<cr>
nnoremap <leader>c :lua require'dap'.continue()<cr>
nnoremap <leader>n :lua require'dap'.step_over()<cr>
nnoremap <leader>s :lua require'dap'.step_into()<cr>
" }}}
" Emmet {{{
let g:user_emmet_leader_key=','
let g:user_emmet_install_global = 0
let g:user_emmet_settings = {
\ 'javascript.jsx' : {
\ 'extends' : 'jsx',
\ },
\}
" }}}
" vimtex {{{
let g:tex_flavor='latex'
let g:vimtex_view_method='zathura'
let g:vimtex_quickfix_open_on_warning = 0
let g:vimtex_fold_enabled = 1
" }}}
" autocmds {{{
if has("autocmd")
" jump to the last known location
augroup vimStartup
au!
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe "normal! g`\""
\ | endif
augroup END
" vim pretty display md
augroup markDown
au!
autocmd BufReadPre *.md setlocal conceallevel=2
augroup end
augroup filetypeVim
au!
autocmd FileType vim setlocal foldmethod=marker
augroup end
augroup emmetEnable
au!
autocmd FileType html,css,php,javascript.jsx EmmetInstall
augroup end
augroup sourceVimrc
au!
autocmd BufWritePost init.vim source %
augroup end
augroup orgmode
au!
autocmd BufWritePost *.org call jobstart(['emacs', '-nw', '--batch', '--eval', '(setq org-confirm-babel-evaluate nil)', '--visit=' . expand('%'), '-f', 'org-latex-export-to-pdf'])
autocmd CursorHold *.org if &modified | w | call jobstart(['emacs', '-nw', '--batch', '--eval', '(setq org-confirm-babel-evaluate nil)', '--visit=' . expand('%'), '-f', 'org-latex-export-to-pdf']) | endif
autocmd CursorHoldI *.org if &modified | w | call jobstart(['emacs', '-nw', '--batch', '--eval', '(setq org-confirm-babel-evaluate nil)', '--visit=' . expand('%'), '-f' ,'org-latex-export-to-pdf']) | endif
augroup end
augroup jsx
au!
autocmd BufNewFile,BufRead *.tsx,*.jsx set filetype=typescriptreact
augroup end
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end
endif
" }}}
" live markdown preview {{{
" let g:mkdp_browser = 'qutebrowser'
" }}}
set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr()
set exrc
set secure
set shell=/usr/bin/bash