-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
executable file
·356 lines (301 loc) · 9.2 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
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
" NVIM Config
" Author: @klercke
" Credits:
" Initially based on https://github.com/theniceboy/nvim
" === Auto install plugins ===
" Install vim-plug if it isn't already installed
if has('win32') || has('win64')
" Windows
if empty(glob('$LOCALAPPDATA\nvim\autoload\plug.vim'))
silent ! powershell -Command "
\ New-Item -Path ~\AppData\Local\nvim -Name autoload -Type Directory -Force;
\ Invoke-WebRequest
\ -Uri 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
\ -OutFile ~\AppData\Local\nvim\autoload\plug.vim
\ "
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
else
" *nix
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
endif
" Check if all plugins are installed. If not, install them (we check wildfire
" because it alphabetically the last plugin ((I think))
let g:nvim_plugins_installation_completed=1
if has('win32') || has('win64')
" Windows
if empty(glob('$LOCALAPPDATA\nvim-data\plugged\wildfire.vim\autoload\wildfire.vim'))
let g:nvim_plugins_installation_complete=0
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
else
" Unix
if empty(glob('~/.local/share/nvim/plugged/wildfire.vim'))
let g:nvim_plugins_installation_completed=0
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
endif
" === Colemak Movement ===
" ^
" e
" < h * i >
" n
" v
noremap <silent> n j
noremap <silent> e k
noremap <silent> i l
" Window movement
nnoremap <C-h> <C-w>h
nnoremap <C-n> <C-w>j
nnoremap <C-e> <C-w>k
nnoremap <C-i> <C-w>l
" === Basic Keybinds ===
" Comma as leader
let mapleader=","
" Quicksave and exit
nnoremap Q :q<CR>
nnoremap S :w<CR>
" Quick edit vimrc
nnoremap <LEADER>rc :e $MYVIMRC<CR>
augroup NVIMRC
autocmd!
autocmd BufWritePost *.nvimrc,init.vim exec ":so %"
augroup END
" Insert mode
noremap l i
noremap L I
" Other Colemak fixes
noremap k n
noremap K N
noremap f e
" hh -> esc
imap hh <Esc>
" === Editor Settings
" Hybrid line numbers
set number relativenumber
" Disable bell, keep visual bell
set visualbell
" Set tab width to two spaces
set tabstop=2
set shiftwidth=2
set expandtab
" Enable filetype detection, plugin, and indentation
filetype plugin indent on
" Set status line to always show
set laststatus=2
" Set 24-bit colors for colorschemes to work
set tgc
" Open splits to the bottom and to the right
set splitbelow
set splitright
" Smart case sensitivity in searches
set ignorecase
set smartcase
" Enable spellcheck in certain files
autocmd BufNewFile,BufRead *.md,*.txt setlocal spell
" === Custom commands ===
" Insert datestring for Hugo
command! Date :normal a<C-R>=strftime('%Y-%m-%dT%H:%M:%S%z')<CR>
" === Plugins ===
call plug#begin()
" Libraries
Plug 'nvim-lua/plenary.nvim'
" Editor enhancement
Plug 'gcmt/wildfire.vim' " in Visual mode, type k' to select all text in '', or type k) k] k} kp (not configured yet)
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'norcalli/nvim-colorizer.lua'
Plug 'cohama/lexima.vim'
" Eye candy
Plug 'nvim-lualine/lualine.nvim'
Plug 'nvim-tree/nvim-web-devicons'
Plug 'gbprod/nord.nvim'
Plug 'ellisonleao/gruvbox.nvim'
" Completion
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
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'
" Snippets
Plug 'SirVer/ultisnips'
Plug 'quangnguyen30192/cmp-nvim-ultisnips'
Plug 'honza/vim-snippets'
" Git
Plug 'tpope/vim-fugitive'
Plug 'petertriho/cmp-git'
Plug 'f-person/git-blame.nvim'
" Terraform
Plug 'hashivim/vim-terraform'
" Markdown
Plug 'godlygeek/tabular'
Plug 'preservim/vim-markdown'
" Misc
Plug 'lambdalisue/suda.vim' " On Windows, requires https://github.com/gerardog/gsudo
call plug#end()
" === Plugin Config ===
" Colorscheme
lua << EOF
-- detect os and set colorscheme accordingly
local uname = vim.loop.os_uname().sysname:lower()
if uname == "linux" then
-- check if it's nixos
local handle = io.popen("grep -q NixOS /etc/os-release && echo nixos || echo other-os")
local result = handle:read("*a")
handle:close()
if result:find("nixos") then
vim.cmd("colorscheme gruvbox")
require('lualine').setup {
options = { theme = 'gruvbox' }
}
else
vim.cmd("colorscheme nord")
require('lualine').setup {
options = { theme = 'nord' }
}
end
else
vim.cmd("colorscheme nord") -- default to nord for non-linux systems
require('lualine').setup {
options = { theme = 'nord' }
}
end
EOF
" lualine
"lua << EOF
"require('lualine').setup{
" options = { theme = 'nord' }
"}
"EOF
" suda
let g:suda_smart_edit = 1
" nvim-treesitter
lua << EOF
require 'nvim-treesitter.configs'.setup {
ensure_installed = { "python", "lua", "vim", "vimdoc", "rust", "hcl" },
auto_install = false,
}
EOF
autocmd FileType vim lua vim.treesitter.start()
" Auto-fmt Terraform using vim-terraform
augroup TERRAFORMFMT
autocmd!
autocmd BufWritePost *.tf exec ":Terraform fmt"
augroup END
" Colorizer
lua << EOF
require 'colorizer'.setup ({
filetypes = { "*" },
options = {
names = false
}
})
EOF
" vim-markdown
let g:vim_markdown_folding_disabled = 1
"let g:vim_markdown_folding_level = 2
let g:vim_markdown_toc_autofit = 1
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_strikethrough = 1
let g:vim_markdown_new_list_item_indent = 2
" lexima
let g:lexima_enable_basic_rules = 1
" cmp-git
lua <<EOF
require("cmp").setup({
sources = {
{ name = "git" },
-- more sources
}
})
require("cmp_git").setup()
EOF
" nvim-cmp
lua <<EOF
-- 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.
-- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+)
end,
},
window = {
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = 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' },
})
})
-- To use git you need to install the plugin petertriho/cmp-git and uncomment lines below
-- Set configuration for specific filetype.
--[[ cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'git' },
}, {
{ name = 'buffer' },
})
})
require("cmp_git").setup() ]]
-- 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' }
}),
matching = { disallow_symbol_nonprefix_matching = false }
})
-- Set up lspconfig.
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
require('lspconfig')['pyright'].setup {
capabilities = capabilities
}
EOF
" UltiSnips
" Trigger configuration. You need to change this to something other than <tab> if you use one of the following:
" - https://github.com/Valloric/YouCompleteMe
" - https://github.com/nvim-lua/completion-nvim
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" Easy bold and italics for markdown
call lexima#add_rule({'char': '*', 'input_after': '*', 'filetype': 'markdown'})
call lexima#add_rule({'char': '*', 'at': '\*\%#', 'input': '*', 'input_after': '*', 'priority': 1, 'filetype': 'markdown'})
call lexima#add_rule({'char': '*', 'at': '\*\*\%#', 'input': '*', 'input_after': '*', 'priority': 2, 'filetype': 'markdown'})
call lexima#add_rule({'char': '*', 'at': '\%#\*', 'leave': 1, 'filetype': 'markdown'})
call lexima#add_rule({'char': '*', 'at': '\%#\*\*', 'leave': 2, 'filetype': 'markdown'})
call lexima#add_rule({'char': '*', 'at': '\%#\*\*\*', 'leave': 3, 'filetype': 'markdown'})
call lexima#add_rule({'char': '<BS>', 'at': '\*\%#\*', 'delete': 1, 'filetype': 'markdown'})