-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
354 lines (291 loc) · 11.7 KB
/
vimrc
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
call plug#begin() " Evaluating `nvim` so share plugins with VIM
" Adapted from https://github.com/hrsh7th/nvim-cmp
" Setup LSP servers and auto-completion
Plug 'williamboman/mason.nvim'
Plug 'williamboman/mason-lspconfig.nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'quangnguyen30192/cmp-nvim-ultisnips'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
Plug 'kyazdani42/nvim-web-devicons'
" Telescope
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.1' }
" Misc
Plug 'psf/black'
Plug 'editorconfig/editorconfig-vim' " Consistent configuration per project.
Plug 'ryanoasis/vim-devicons' " Make vim pretty!
Plug 'Yggdroot/indentLine' " Show indent guides
Plug 'tpope/vim-fugitive' " Interact with Git from inside Vim
Plug 'tpope/vim-surround' " Surround existing text, easily
Plug 'tpope/vim-rhubarb' " Open GH links
Plug 'airblade/vim-gitgutter' " Show changes to files in the vim gutter
Plug 'godlygeek/tabular' " Makes lining up text easier
Plug 'kamykn/spelunker.vim' " Nicer spell checking
Plug 'kamykn/popup-menu.nvim' " Required for spelunker
Plug 'Lokaltog/vim-easymotion'
Plug 'mileszs/ack.vim'
Plug 'majutsushi/tagbar'
Plug 'mhinz/vim-startify'
Plug 'airblade/vim-rooter'
Plug 'jvirtanen/vim-hcl'
Plug 'MunifTanjim/nui.nvim'
Plug 'nvim-neo-tree/neo-tree.nvim'
Plug 'Raimondi/delimitMate'
Plug 'benmills/vimux'
Plug 'janko/vim-test' " Execute tests from vim
Plug 'nvim-treesitter/nvim-treesitter'
Plug 'ellisonleao/gruvbox.nvim'
Plug 'nvim-lualine/lualine.nvim'
" If you want to have icons in your statusline choose one of these
Plug 'kyazdani42/nvim-web-devicons'
Plug 'tpope/vim-commentary' " Vim-commentary
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
call plug#end() " vim-plug
" set background=light " or light if you want light mode
colorscheme gruvbox
set completeopt=menu,menuone,noselect
" Bite the bullet.
set spell spelllang=en_us
lua <<EOF
require('lualine').setup()
local cmp_ultisnips_mappings = require("cmp_nvim_ultisnips.mappings")
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)
end,
},
window = {
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<Tab>"] = cmp.mapping(
function(fallback)
cmp_ultisnips_mappings.expand_or_jump_forwards(fallback)
end,
{ "i", "s", --[[ "c" (to enable the mapping in command mode) ]] }
),
["<S-Tab>"] = cmp.mapping(
function(fallback)
cmp_ultisnips_mappings.jump_backwards(fallback)
end,
{ "i", "s", --[[ "c" (to enable the mapping in command mode) ]] }
),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'ultisnips' },
-- { name = 'luasnip' }, -- For luasnip users.
-- { name = 'snippy' }, -- For snippy users.
}, {
{ name = 'buffer' },
})
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
}, {
{ 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')['gopls'].setup {
capabilities = capabilities
}
require('lspconfig')['tailwindcss'].setup {
capabilities = capabilities
}
require('neo-tree').setup {
filesystem = {
filtered_items = {
visible = true,
hide_dotfiles = false,
hide_gitignored = true,
},
}
}
require("mason").setup()
require("mason-lspconfig").setup()
require("mason-lspconfig").setup_handlers {
-- The first entry (without a key) will be the default handler
-- and will be called for each installed server that doesn't have
-- a dedicated handler.
function (server_name) -- default handler (optional)
require("lspconfig")[server_name].setup {}
end,
-- Next, you can provide targeted overrides for specific servers.
-- For example, a handler override for the `rust_analyzer`:
["rust_analyzer"] = function ()
require("rust-tools").setup {}
end
}
EOF
" Turn on filetype plugin and indent loading so that loading the
" vim-misc stuff below loads the proper files.
filetype plugin on
filetype plugin indent on
":=============================================================================
" Misc options
"=============================================================================
scriptencoding utf-8
syntax on " syntax highlighting for files
set wildmode=list:longest " Wildcard /command matches, order by longest first
set showcmd " Show current pending command in the prompt
if !has('nvim') " Defaults which nvim already has
set autoindent " Use spaces not tabs by default
set encoding=utf-8 " Display specal and foreign charecters
set autoread " Reload file after begin written to outside of vim
set backspace=2 " http://vim.wikia.com/wiki/Backspace_and_delete_problems
set history=1000 " Remember commands entered
set hlsearch " Highlight search results
set incsearch " Start showing results as you type
set laststatus=2 " Show the status bar for all windows
set listchars=tab:>.,trail:.,extends:#,nbsp:. " Show traiing whitepace etc
endif
" Disable Mouse Support
set mouse=
" Tab settings
set expandtab " Insert the right number of spaces
set tabstop=4 " Display n spaces for each tab
set softtabstop=4 " Display n spaces for each softtab
set shiftwidth=4 " Amount of spaces when re-indenting
set colorcolumn=80 " Highlight long lines
set nospell " Turn off as it conflicts with https://github.com/kamykn/spelunker.vim
" Search settings
set ignorecase " Ignore casing of searches
set smartcase " Be smart about case sensitivity when searching
"=============================================================================
" Auto Commands
"=============================================================================
autocmd BufWritePre * :%s/\s\+$//e "Remove trailing whitespaces
au BufRead,BufNewFile */ansible/*.yaml set filetype=yaml.ansible softtabstop=2 tabstop=2
"=============================================================================
" Key Bindings
"=============================================================================
"
let mapleader=' ' " Easy access to leader key
" Buffer management
nnoremap <silent> [b :bprevious<CR>
nnoremap <silent> b] :bnext<CR>
nnoremap <silent> [B :bfirst<CR>
nnoremap <silent> B] :blast<CR>
map <Leader>ls :ls<CR>
" Tab management
nnoremap <silent> [t :tabprevious<CR>
nnoremap <silent> t] :tabnext<CR>
nnoremap <silent> [T :tabfirst<CR>
nnoremap <silent> T] :tablast<CR>
" Easy Motion
let g:EasyMotion_do_mapping = 0
let g:EasyMotion_smartcase = 1
nmap <leader>a <Plug>(easymotion-lineanywhere)
nmap <leader>f <Plug>(easymotion-s)
nmap <leader>j <Plug>(easymotion-bd-jk)
nmap <leader>k <Plug>(easymotion-bd-jk)
nmap <leader>w <Plug>(easymotion-bd-w)
nmap <leader>w <Plug>(easymotion-bd-w)
map <Leader>n :NeoTreeShowToggle<CR>
map <Leader>m :NeoTreeFocus<CR>
map <Leader>i :IndentLinesToggle<CR>
map <Leader>s :write<CR>
map <Leader>q :wq<CR>
map <Leader>! :qall<CR>
map <Leader>b :TagbarToggle<CR>
map <leader>h :noh<CR>
" ViMux
map <Leader>vp :VimuxPromptCommand<CR>
map <Leader>vl :VimuxRunLastCommand<CR>
map <Leader>vi :VimuxInspectRunner<CR>
map <Leader>vq :VimuxCloseRunner<CR>
map <Leader>vx :VimuxInterruptRunner<CR>
map <Leader>vz :call VimuxZoomRunner()<CR>
" Fugitive
map <Leader>gw :Gwrite<CR>
" vim-test
map <Leader>tn :TestNearest<CR>
map <Leader>tf :TestFile<CR>
map <Leader>ts :TestSuite<CR>
map <Leader>tl :TestLast<CR>
map <Leader>tv :TestVisit<CR>
" Make navigating panes easier.
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Find files using Telescope command-line sugar.
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
nnoremap <leader>gd <cmd>GoDoc<cr>
nnoremap <leader>gb <cmd>GoDocBrowser<cr>
"=============================================================================
" Plugin Settings
"=============================================================================
let g:python3_host_prog = $HOME . '/.pyenv/versions/neovim3/bin/python3'
let g:python_host_prog = $HOME . '/.pyenv/versions/neovim3/bin/python3'
let $PATH.= ':/home/pmyjavec/.pyenv/versions/neovim3/bin/'
" NERDTree
let NERDTreeIgnore=['\.pyc$', '\.gem$', '\.out', '\~$', '_site', '\.beam$', '__pycache__']
" base16 themes
set termguicolors
" vim-markdown
let g:vim_markdown_folding_disabled = 1
" vim-startify
" let g:startify_change_to_dir = 0
" Syntastic
let g:syntastic_python_checkers = ['pylint']
let g:syntastic_ansible_ansible_lint_exec = '/home/pmyjavec/.pyenv/bin/ansible_lint'
let g:syntastic_ansible_checkers = ['ansible_lint']
" ansible
let g:ansible_unindent_after_newline = 0
" Vim Gutter
let signcolumn="yes:3"
let g:gitgutter_override_sign_column_highlight = 0
highlight LineNr guibg=none
set updatetime=400
"Misc
set smartcase
"=============================================================================
" Display & theme settings
"=============================================================================
set visualbell " Flash screen on notifications
set scrolloff=999 " Centered cursor
set ruler " Show the line numbers
set number " Set line numbers on
set cursorline " Highlight line the cursor is on