-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.vim
More file actions
executable file
·418 lines (330 loc) · 12.6 KB
/
init.vim
File metadata and controls
executable file
·418 lines (330 loc) · 12.6 KB
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
"============================= Plugins ========================================"
call plug#begin('~/.local/share/nvim/plugged')
"---------- elm (has to come before polyglot plugin or stuff blows up) ----------"
Plug 'elmcast/elm-vim'
"---------- autocomplete ----------"
"Plug 'ncm2/ncm2'
"Plug 'roxma/nvim-yarp'
"Plug 'roxma/vim-hug-neovim-rpc'
"Plug 'roxma/nvim-yarp', { 'do': 'pip install -r requirements.txt' }
"Plug 'ncm2/ncm2-bufword'
"Plug 'ncm2/ncm2-cssomni'
"Plug 'ncm2/ncm2-tern', {'do': 'npm install'}
"Plug 'ncm2/nvim-typescript', {'do': './install.sh'}
"Plug 'Valloric/YouCompleteMe'
"Plug 'Valloric/YouCompleteMe', { 'dir': '~/.local/share/nvim/plugged/YouCompleteMe', 'do': './install --clang-completer --tern-completer --racer-completer'}
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
" For vsnip users.
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'
"---------- syntax checker and linter ----------"
"Plug 'scrooloose/syntastic'
"Plug 'folke/trouble.nvim'
Plug 'mfussenegger/nvim-lint'
Plug 'dense-analysis/ale'
"---------- language pack for syntax highlighting ----------"
Plug 'sheerun/vim-polyglot'
"---------- formatting ----------"
Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
Plug 'junegunn/vim-easy-align'
"---------- navigation and files ----------"
Plug 'scrooloose/nerdtree'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
"---------- git ----------"
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
"---------- language server protocol (required by ncm2 and other tools that follow LSP in the future) ----------"
"Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': 'bash install.sh'}
"---------- utility ----------"
Plug 'vim-airline/vim-airline'
Plug 'tpope/vim-surround'
Plug 'scrooloose/nerdcommenter'
Plug 'unblevable/quick-scope'
"---------- terminal theme ----------"
Plug 'joshdick/onedark.vim'
"---------- miscellaneous ----------"
Plug 'rust-lang/rust.vim'
"Plug 'reasonml-editor/vim-reason-plus'
call plug#end()
"============================= General ========================================"
filetype plugin indent on
syntax on
set expandtab
set number
"set nohlsearch
set shiftwidth=2
set tabstop=2
set cursorline
set showmatch
set ignorecase
set smartcase
"set foldmethod=indent
"set foldnestmax=3
"set nofoldenable
"set foldlevel=0
"set foldopen-=block
"set relativenumber
"set softtabstop=2
let mapleader = "\<Space>"
"Remap i to h because we are using i as up now
noremap h i
"Remap
"i=> up
"j=>left
"k=>down
"l=>right
noremap j h
noremap k j
noremap i k
"Remap ctrl+<direction> moves windows
nnoremap <C-k> :wincmd<Space>j<Enter>
nnoremap <C-j> :wincmd<Space>h<Enter>
nnoremap <C-i> :wincmd<Space>k<Enter>
nnoremap <C-l> :wincmd<Space>l<Enter>
"Remap
"shift+k=>down 1 paragraph
"shift+i=>up 1 pargraph
"shift+j=>back 1 word
""shift+l=>forward 1 word
noremap <S-k> }
noremap <S-i> {
noremap <S-j> b
noremap <S-l> w
"Remap
"Leader k=>jump down one page
"Leader i=>jump up one page
"Leader j=>jump to first character on line
"Leader l=>jump to last character on line
noremap <Leader>j ^
noremap <Leader>l g_
noremap <Leader>i <PageUp>
noremap <Leader>k <PageDown>
"Vertical split window and focus it
"nnoremap <C-c> :vs<Enter><C-w><Right>
"Close all buffers
"nnoremap <C-n> :%bd<Enter>
"nnoremap !<C-n> :%bd!<Enter>
"NERDTree
nnoremap <C-n> :NERDTreeToggle<Enter>
nnoremap <Leader><C-n> :NERDTreeFind<Enter>
"Close buffer
nnoremap <expr> <C-d> ( winnr("$") == 2 ? ':bp<bar>sp<bar>bn<bar>bd<Enter>' : ':bd<Enter>')
nnoremap <expr> !<C-d> ( winnr("$") == 2 ? ':bp!<bar>sp!<bar>bn!<bar>bd!<Enter>' : ':bd!<Enter>')
"Quit file
nnoremap <C-q> :q<Enter>
nnoremap !<C-q> :q!<Enter>
"Open terminal tab and focus it
"nnoremap <C-t> :vs<Enter><C-w><Right>:term<Enter>
"Switch buffers
"nnoremap !<Tab> :buffer!<Space>
"nnoremap <Tab> :buffer<Space>
"Use tab to cycle through autocomplete items
"inoremap <expr> <Tab> pumvisible() ? '<C-n>' : '<Tab>'
"inoremap <expr> <S-Tab> pumvisible() ? '<C-p>' : '<S-Tab>'
"Save file
nnoremap <C-s> :w<Enter>
inoremap <C-s> <Esc>:w<Enter>
"nnoremap <C-a> :call LanguageClient_textDocument_formatting()<Enter>
"inoremap <C-a> <Esc>:call LanguageClient_textDocument_formatting()<Enter>
"nnoremap <expr> <C-s> ( expand('%:e') == 're' ? ':call LanguageClient_textDocument_formatting()<Enter>:sleep 500m<Enter>:w<Enter>' : ':w<Enter>' )
"inoremap <expr> <C-s> ( expand('%:e') == 're' ? '<Esc>:call LanguageClient_textDocument_formatting()<Enter>:sleep 500m<Enter>:w<Enter>' : '<Esc>:w<Enter>' )
"Searching project
nnoremap <C-p> :Files<Enter>
nnoremap <C-f> :Find<Space>
"Remove highlighting
nnoremap <C-h> :noh<Enter>
"Open all buffers
"nnoremap <C-b> :bufdo!vs<Enter>:q<Enter>:source ~/.config/nvim/init. vim<Enter>
"Have all buffers do something
"nnoremap b<C-f> :bufdo!<Space>
"Reload vim config
nnoremap <C-\> :source ~/.config/nvim/init.vim<Enter>
"Easy align
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
"inoremap <C-i> <C-o>k
"inoremap <C-j> <C-o>h
"inoremap <C-k> <C-o>j
"inoremap <C-l> <C-o>l
"============================= quickscope ========================================"
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
"============================= onedark ========================================"
set termguicolors
colorscheme onedark
"let g:onedark_terminal_italics=1
"============================= syntastic ========================================"
"let g:syntastic_always_populate_loc_list = 1
"let g:syntastic_auto_loc_list = 1
"let g:syntastic_elm_checkers = ["elm_make"]
"let g:syntastic_python_pyflakes_exe = 'python3 -m pyflakes'
"let g:syntastic_python_checkers = ["pyflakes"]
"let g:syntastic_javascript_checkers = ['eslint']
"let g:syntastic_typescript_checkers = ['eslint']
"let g:syntastic_javascript_eslint_args = ['--fix']
"let g:syntastic_typescript_checkers = ['tsuquyomi']
"let g:elm_syntastic_show_warnings = 1
"let g:syntastic_css_checkers = ["stylelint"]
"let g:syntastic_css_stylelint_exec = 'css-standard'
"let g:tsuquyomi_disable_quickfix = 1
"============================= trouble ========================================"
"let g:trouble_auto_open = 1
"============================= nvim-lint ========================================"
"require('lint').linters_by_ft = {
"typescript = {'eslint'}
"}
"autocmd BufWritePost * lua require('lint').try_lint()
"============================= polyglot ========================================"
"let g:polyglot_disabled = ['elm']
"============================= elm-vim ========================================"
let g:elm_detailed_complete = 1
let g:elm_format_autosave = 1
"============================= YouCompleteMe ========================================"
"let g:ycm_semantic_triggers = {
"\ 'elm' : ['.'],
"\}
"============================= nerdtree ========================================"
"autocmd vimenter * NERDTreeFind
"autocmd bufenter * if &modifiable | NERDTreeFind | wincmd p | endif
"autocmd vimenter * wincmd l
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let g:NERDTreeMinimalUI = 1
let NERDTreeMapOpenSplit = 'h'
"============================= airline ========================================"
let g:airline#extensions#tabline#enabled = 1
"============================= fzf.vim ========================================"
" --column: Show column number
" --line-number: Show line number
" --no-heading: Do not show file headings in results
" --fixed-strings: Search term as a literal string
" --ignore-case: Case insensitive search
" --no-ignore: Do not respect .gitignore, etc...
" --hidden: Search hidden files and folders
" --follow: Follow symlinks
" --glob: Additional conditions for search (in this case ignore everything in the .git/ folder)
" --color: Search color options
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>), 1, <bang>0)
"============================= vim-reason-plus ========================================"
"Reason ML
"let g:LanguageClient_serverCommands = {
"\ 'reason': ['ocaml-language-server', '--stdio'],
"\ 'ocaml': ['ocaml-language-server', '--stdio'],
"\ }
"============================= ncm2 ========================================"
"autocmd BufEnter * call ncm2#enable_for_buffer()
"set completeopt=noinsert,menuone,noselect
"============================= vim-gitgutter ========================================"
autocmd BufWritePost * GitGutter
"set updatetime=100
"============================= rust.vim ========================================"
let g:rustfmt_autosave = 1
"============================= vim-prettier ========================================"
let g:prettier#autoformat = 0
"autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.md,*.vue,*.yaml,*.html Prettier
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html Prettier
lua <<EOF
-- Linters
-- require('lint').linters_by_ft = {
-- typescript = {'eslint'}
--}
--vim.api.nvim_create_autocmd({ "BufWritePost" }, {
-- callback = function()
-- require("lint").try_lint()
-- end,
--})
-- Disable semantic highlighting messing with my colors
-- https://www.reddit.com/r/neovim/comments/12gvms4/this_is_why_your_higlights_look_different_in_90/
for _, group in ipairs(vim.fn.getcompletion("@lsp", "highlight")) do
vim.api.nvim_set_hl(0, group, {})
end
-- Set up nvim-cmp.
local cmp = require'cmp'
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
end,
},
window = {
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
},
mapping = {
-- ... Your other mappings ...
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
--elseif has_words_before() then
--cmp.complete()
else
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, { "i", "s" }),
-- ... Your other mappings ...
},
-- mapping = cmp.mapping.preset.insert({
-- ['<S-Tab>'] = cmp.mapping.scroll_docs(-1),
-- ['<Tab>'] = cmp.mapping.scroll_docs(1),
-- ['<C-Space>'] = cmp.mapping.complete(),
-- ['<C-a>'] = cmp.mapping.abort(),
-- ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
-- }),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' }, -- For vsnip users.
-- { name = 'luasnip' }, -- For luasnip users.
-- { name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
}, {
{ name = 'buffer' },
})
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- Set up lspconfig.
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
require('lspconfig')['tsserver'].setup {
capabilities = capabilities
}
EOF