-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
executable file
·193 lines (162 loc) · 5.82 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
if exists('g:fvim_loaded') || exists('g:neovide_loaded') || exists('g:nvy')
" FIX: made path generic.
source ~\AppData\Local\nvim\ginit.vim
endif
" Enable Adaptive cursor in iTerm2.
" let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
" let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
" let &t_SR = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
" let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
" Sets cursor styles
" Block in normal, line in insert, underline in replace
set guicursor=n-v-c-sm:block,i-ci-ve:ver25-Cursor,r-cr-o:hor20
set nocompatible
" Settings that I don't know how to translate to lua.
" - Enable settings for specific filetypes.
filetype plugin on
" Don't parse long lines for syntax highlight.
set synmaxcol=256
syntax sync minlines=256
" Lua config.
lua << EOF
require('init');
EOF
" General keybindings.
" * Integration with system.
let g:omnipresence_hotkey = 'f11'
" Search for item under cursor in vim docs (:help).
" - 'investigate help'
noremap <leader>gih K
" # Custom commands.
" * File related.
" - Move visually selected chunk of text into a new file.
:command! -bang -range -nargs=1 -complete=file MoveWrite <line1>,<line2>write<bang> <args> | <line1>,<line2>delete _
" - Append visually selected chunk of text to a file.
:command! -bang -range -nargs=1 -complete=file MoveAppend <line1>,<line2>write<bang> >> <args> | <line1>,<line2>delete _
if exists('g:started_by_firenvim')
" Disable status line.
set laststatus=0
endif
augroup Dashboard
autocmd! * <buffer>
autocmd User dashboardReady let &l:stl = 'Dashboard'
autocmd User dashboardReady nnoremap <buffer> <leader>qe :exit<cr>
"autocmd User dashboardReady nnoremap <buffer> <leader>u <cmd>PackerUpdate<CR>
autocmd User dashboardReady nnoremap <buffer> <leader>l <cmd>SessionLoad<CR>
augroup END
" LSP
" * Autocomplete.
set completeopt=menu,menuone,noselect
let g:autopep8_disable_show_diff=1
" Use omni completion provided by lsp.
autocmd Filetype python setlocal omnifunc=v:lua.vim.lsp.omnifunc
" Coding
" * Wordmotion.
" let g:wordmotion_prefix = ','
let g:wordmotion_nomap = 1
" * Matching braces.
packadd! matchit
" * Surround.
" HELP: *surround-customizing*, *curly-braces-names*
" - visually select what you want to wrap and then press S- to tigger
" the - surrounding. It will then prompt you for a 'start' and 'ending' text.
let g:surround_{char2nr('-')} = "\1start: \1\r\2end: \2"
" - **L**ua anonymous function.
let g:surround_{char2nr('la')} = "function() \r end"
" * Keep visual mode after indent.
" TODO: `>` overlaps with put commands => delay is added.
vnoremap > >gv
vnoremap < <gv
" * Select just pasted text in last used mode [if you used linewise selection
" - V, if characterwise - v,..].
" FIX: `[ marks get rewritten during autosave.
nnoremap <expr> gp '`[' . strpart(getregtype(), 0, 1) . '`]'
" * Yanking.
" * Remaping line concatenation for use of j with modifier in non-vim apps.
noremap <a-j> J
augroup Markdown
" Clear all autocommands that were set before that.
autocmd!
"autocmd BufNewFile,BufReadPost *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md
"autocmd Filetype markdown set filetype=markdown
let g:markdown_fenced_languages = [
\'sh',
\'bash=sh',
\
\'css',
\'sass',
\
\'javascript',
\'js=javascript',
\'json=javascript',
\
\'python',
\'py=python',
\
\'xml',
\'html'
\]
" - Folding
let g:vim_markdown_folding_level=3
" - Enabling conceal for ~~strikethroughText~~
let g:vim_markdown_strikethrough = 1
" - Disabling autoindentation on `o`.
let g:vim_markdown_new_list_item_indent = 0
" - Autofit table of contents.
let g:vim_markdown_toc_autofit = 1
" - Enable follow the anchors (links) inside file.
let g:vim_markdown_follow_anchor = 1
" * mkdx settings.
" - Highlighting.
" - Enable shift+enter to create a new line with indentation but without new
" item in list.
" - Enable dead link detection for external links.
" - Updates TOC before saving the file.
" - Enabling folding of inline code blocks and TOC.
let g:mkdx#settings = { 'highlight': { 'enable': 1 },
\ 'enter': { 'shift': 1 },
\ 'links': { 'external': { 'enable': 1 } },
\ 'toc': { 'position': 1, 'text': 'Table of Contents', 'update_on_write': 1 },
\ 'fold': { 'enable': 1 }}
" - Concealing things like **bold**.
autocmd FileType markdown setlocal conceallevel=2
" - Disabling concealing on current line for all mods.
autocmd FileType markdown setlocal concealcursor=
" # Markdown Preview.
" Echo preview page url in command line when open preview page.
let g:mkdp_echo_preview_url = 1
augroup END
" Navigation.
" # Across files.
" * Rel.
" - Jump to link (have to define here too because which_key doesn't handle
" conflicts occured by <unique> mapping of a Rel.vim).
nnoremap <leader>gl <Plug>(Rel)
" - Url encode / decode.
vnoremap <leader>en :!python3 -c 'import sys; from urllib import parse; print(parse.quote_plus(sys.stdin.read().strip()))'<cr>
vnoremap <leader>de :!python3 -c 'import sys; from urllib import parse; print(parse.unquote_plus(sys.stdin.read().strip()))'<cr>
" # Inside file.
" * Matching targets
" (jumping nicely, but only inside []).
nnoremap ]b :call searchpair('\[','','\]')<cr>
nnoremap [b :call searchpair('\[','','\]','b')<cr>
" Abbreviations
runtime abbreviations.vim
"" TODO: What it does?
cmap <F7> <C-\>eAppendSome()<CR>
func AppendSome()
let cmd = getcmdline()
<c-\>e
" place the cursor on the )
" call setcmdpos(strlen(cmd))
" return cmd
endfunc
" Highlight
augroup HighlightLeadingWhiteSpace
" Clear all autocommands that were set before that.
autocmd!
autocmd ColorScheme highlight WhiteSpaceLeading guifg=#918278
autocmd ColorScheme highlight WhiteSpace guifg=#efe0b9
autocmd ColorScheme match WhiteSpace / /
autocmd ColorScheme 2match WhiteSpaceLeading /^ \+/
augroup END