forked from hgaiser/neovim-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
199 lines (148 loc) · 6.65 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
" {{{ Change default vim settings.
set mouse=a " Enable mouse mode.
set number " Set line numbers at the left.
set noexpandtab " Use tabs for indentation.
set tabstop=4 " Tabs are 4 spaces.
set shiftwidth=4 " Number of spaces to insert when pressing TAB.
set copyindent " Use the indentation from the previous line.
let g:python_recommended_style = 0 " Don't use PEP8 (forces spaces).
let g:rust_recommended_style = 0 " Don't use Rust style (forces spaces).
set list " Show tab and trailing spaces.
set listchars=tab:›─,trail:␣ " Show tabs and trailing whitespaces.
set nowrap " Disable wrapping of lines.
set nrformats=bin,hex,alpha " Also consider the alphabet when incrementing/decrementing.
set updatetime=500 " Reduce the time before a backup is saved to disk.
set undofile " Remain persistent undo file between vim sessions.
set splitbelow " Split files below current open file.
set splitright " Split files right of current open file.
set signcolumn=yes " Always show the sign column (GitGutter / Coc).
set noshowmode " Don't show the mode (like `-- INSERT --`), because this is shown in lightline.
set cursorline " Highlight the line the cursor is on.
" }}}
" {{{ Install extensions.
" Specify a directory for plugins
call plug#begin(stdpath('data') . '/plugged')
" Code completion.
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'neoclide/coc-vimtex', {'do': 'yarn install --frozen-lockfile'}
Plug 'fannheyward/coc-rust-analyzer', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-snippets', {'do': 'yarn install --frozen-lockfile'}
Plug 'Maxattax97/coc-ccls', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-tsserver', {'do': 'yarn install --frozen-lockfile'}
Plug 'morhetz/gruvbox' " Gruvbox color theme.
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " Fuzzy finding.
Plug 'junegunn/fzf.vim' " Fuzzy finding tools.
Plug 'junegunn/vim-easy-align' " Alignment around operator
Plug 'preservim/nerdtree' " File tree.
Plug 'tpope/vim-commentary' " Comment code.
Plug 'tpope/vim-surround' " Extension for changing surroundings.
Plug 'tpope/vim-repeat' " Allow repeating of commands like change surroundings.
Plug 'tpope/vim-sleuth' " Automatically find the indentation given the file and neighbouring files.
Plug 'lambdalisue/suda.vim' " Write as sudo, workaround for https://github.com/neovim/neovim/issues/8527 .
Plug 'tpope/vim-fugitive' " Git support inside vim.
Plug 'cespare/vim-toml' " Formatting for (Cargo).toml files.
Plug 'rust-lang/rust.vim' " Formatting for rust files.
Plug 'airblade/vim-gitgutter' " Git gutter.
Plug 'itchyny/lightline.vim' " Fancy status bar.
Plug 'shinchu/lightline-gruvbox.vim' " Gruvbox theme for lightline.
Plug 'markstory/vim-zoomwin' " Allow temporarily zooming in on a buffer.
Plug 'PeterRincker/vim-argumentative' " Adds functionality to work with arguments.
" Initialize plugin system
call plug#end()
" }}}
" {{{ Navigational key mappings.
" Remap Ctrl+w, <hjkl> to Ctrl+<hjkl>
nnoremap <c-h> <c-w>h
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-l> <c-w>l
" Map Ctrl+<hjkl> to exit insert mode and move window.
tnoremap <c-h> <C-\><C-n><c-w>h
tnoremap <c-j> <C-\><C-n><c-w>j
tnoremap <c-k> <C-\><C-n><c-w>k
tnoremap <c-l> <C-\><C-n><c-w>l
" }}}
" {{{ Edit related key mappings.
" Map K to split line.
nnoremap K i<Cr><Esc>
" Alignment extension.
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
" Allow pasting multiple times without yanking the replaced text.
xnoremap p pgvy
" }}}
" {{{ Terminal related settings.
augroup TerminalNoSignColumn
au!
autocmd TermOpen * setlocal nonumber norelativenumber signcolumn=no
augroup END
" Add SplitTerminal to open a new split terminal.
command! SplitTerminal 10split | :term
autocmd BufEnter term://* startinsert
" Map Esc or Ctrl-d to exit terminal insert mode.
tnoremap <leader><Esc> <C-\><C-n>
tnoremap <C-d> <C-\><C-n>
" }}}
" {{{ Color scheme.
let g:gruvbox_contrast_dark = 'hard'
colorscheme gruvbox-custom
set termguicolors
" }}}
" {{{ Git gutter settings.
let g:gitgutter_sign_added = '▌'
let g:gitgutter_sign_modified = '▌'
let g:gitgutter_sign_removed = '▁'
let g:gitgutter_sign_removed_first_line = '▌'
let g:gitgutter_sign_modified_removed = '▌'
let g:gitgutter_map_keys = 0
let g:gitgutter_realtime = 1
" }}}
" {{{ Code completion (coc) settings.
" Ctrl+Space to trigger Coc.
inoremap <silent><expr> <c-space> coc#refresh()
" Tab to cycle through options, enter to select.
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() : "\<C-g>u\<CR>"
" Use `[g` and `]g` to navigate diagnostics.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use ? to show documentation in preview window.
nnoremap <silent> ? :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Highlight variable on cursor hold.
autocmd CursorHold * silent call CocActionAsync('highlight')
" }}}
" {{{ NERDTree.
map <silent> <Leader>n :NERDTreeToggle<CR>
map <silent> ` :NERDTreeToggle<CR>
" }}}
" {{{ Sudo write to file.
" Sudo write.
cmap w!! w suda://%
" }}}
" {{{ Lightline settings.
let g:lightline = {}
let g:lightline.colorscheme = 'gruvbox'
let g:lightline.inactive = {'left': [['modified']]} " Show modified marker (`+`) on inactive buffers.
" }}}
" {{{ Buffer / file searching.
nnoremap <silent> <Tab> :Buffers<CR>
nnoremap <silent> <S-Tab> :Files<CR>
" }}}
" vim: foldmethod=marker