411
|
1 --
|
|
2 -- Neovim dotfiles
|
|
3 --
|
|
4 --
|
|
5 local execute = vim.api.nvim_command
|
|
6 local fn = vim.fn
|
|
7
|
|
8 -- Bootstrap package manager
|
|
9 local install_path = fn.stdpath 'data' .. '/site/pack/packer/opt/packer.nvim'
|
|
10
|
|
11 if fn.empty(fn.glob(install_path)) > 0 then
|
|
12 execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path)
|
|
13 end
|
|
14
|
|
15 vim.defer_fn(function()
|
|
16 -- Packer configuration is compiled and only needs to be loaded on changes
|
|
17 vim.cmd 'packadd packer.nvim'
|
|
18
|
|
19 require('packer').startup(function()
|
|
20 use { 'wbthomason/packer.nvim', opt = true }
|
|
21
|
|
22 -- General plugins
|
|
23 use { 'tpope/vim-sensible' }
|
|
24 use { 'tpope/vim-repeat' }
|
|
25 use { 'tpope/vim-rsi' }
|
|
26 use { 'sgur/vim-editorconfig' }
|
|
27 use { 'ShikChen/osc52.vim' }
|
|
28 use { 'einfachtoll/didyoumean' }
|
|
29
|
|
30 use { 'tpope/vim-obsession' }
|
|
31 use {
|
|
32 'tpope/vim-eunuch',
|
|
33 cmd = {
|
|
34 'Delete',
|
|
35 'Unlink',
|
|
36 'Move',
|
|
37 'Rename',
|
|
38 'Mkdir',
|
|
39 'Chmod',
|
|
40 'Cfind',
|
|
41 'Clocate',
|
|
42 'Lfind',
|
|
43 'Llocate',
|
|
44 'SudoEdit',
|
|
45 'SudoWrite',
|
|
46 'Wall',
|
|
47 },
|
|
48 }
|
|
49
|
|
50 use { 'psliwka/vim-smoothie' }
|
|
51
|
|
52 use { 'nvim-lua/plenary.nvim' }
|
|
53
|
|
54 -- Spelling/autocorrection
|
|
55 use { 'tpope/vim-abolish' }
|
|
56
|
|
57 -- Git/VCS
|
|
58 use { 'vim-scripts/gitignore' }
|
|
59 use { 'sjl/splice.vim', opt = true, cmd = { 'SpliceInit' } }
|
|
60 use { 'tpope/vim-git' }
|
|
61
|
|
62 -- Comments
|
|
63 use { 'b3nj5m1n/kommentary' }
|
|
64
|
|
65 -- Undoing
|
|
66 use { 'sjl/gundo.vim', cmd = { 'GundoToggle' } }
|
|
67
|
|
68 -- Parentheses etc
|
|
69 use { 'tpope/vim-surround' }
|
|
70 use { 'raimondi/delimitMate' }
|
|
71
|
|
72 -- Moving around within lines
|
|
73 use { 'wellle/targets.vim', event = 'InsertEnter *' }
|
|
74
|
|
75 -- Searching
|
|
76 use { 'mhinz/vim-grepper', cmd = { 'Grepper' } }
|
|
77
|
|
78 -- Keymaps TODO: to be removed when #13823 is merged
|
|
79 use {
|
|
80 'tjdevries/astronauta.nvim',
|
|
81 config = function()
|
|
82 require 'astronauta.keymap'
|
|
83 end,
|
|
84 }
|
|
85
|
|
86 -- Opening files
|
|
87 use { 'wsdjeg/vim-fetch' }
|
|
88
|
|
89 -- Indent lines
|
|
90 use {
|
|
91 'lukas-reineke/indent-blankline.nvim',
|
|
92 config = function()
|
|
93 vim.g.indent_blankline_buftype_exclude = { 'terminal', 'help', 'nofile' }
|
|
94 vim.g.indent_blankline_show_first_indent_level = false
|
|
95 end,
|
|
96 }
|
|
97
|
|
98 -- Increment/decrement
|
|
99 use {
|
|
100 'zegervdv/nrpattern.nvim',
|
|
101 requires = 'tpope/vim-repeat',
|
|
102 config = function()
|
|
103 local nrpattern = require 'nrpattern'
|
|
104 local defaults = require 'nrpattern.default'
|
|
105
|
|
106 defaults[{ 'input', 'output' }] = { priority = 12, filetypes = { 'verilog', 'systemverilog' } }
|
|
107 defaults[{ "'1", "'0" }] = { priority = 9, filetypes = { 'verilog', 'systemverilog' } }
|
|
108
|
|
109 nrpattern.setup(defaults)
|
|
110 end,
|
|
111 }
|
|
112
|
|
113 -- Tmux
|
|
114 use {
|
|
115 'numtostr/navigator.nvim',
|
|
116 config = function()
|
|
117 require('Navigator').setup { auto_save = 'current', disable_on_zoom = true }
|
|
118
|
|
119 local nnoremap = vim.keymap.nnoremap
|
|
120 nnoremap { '<c-h>', require('Navigator').left, silent = true }
|
|
121 nnoremap { '<c-j>', require('Navigator').down, silent = true }
|
|
122 nnoremap { '<c-k>', require('Navigator').up, silent = true }
|
|
123 nnoremap { '<c-l>', require('Navigator').right, silent = true }
|
|
124 end,
|
|
125 requires = 'tjdevries/astronauta.nvim',
|
|
126 after = 'astronauta.nvim',
|
|
127 }
|
|
128
|
|
129 -- Completion/snippets/LSP
|
|
130 use { 'neovim/nvim-lspconfig' }
|
|
131 use {
|
|
132 'hrsh7th/nvim-compe',
|
|
133 config = function()
|
|
134 require('compe').setup {
|
|
135 enabled = true,
|
|
136 autocomplete = true,
|
|
137 debug = false,
|
|
138 min_length = 1,
|
|
139 preselect = 'enable',
|
|
140 throttle_time = 80,
|
|
141 source_timeout = 1000,
|
|
142 incomplete_delay = 400,
|
|
143 max_abbr_width = 100,
|
|
144 max_kind_width = 100,
|
|
145 max_menu_width = 100,
|
|
146 documentation = true,
|
|
147
|
|
148 source = {
|
|
149 path = true,
|
|
150 buffer = true,
|
|
151 nvim_lsp = true,
|
|
152 nvim_lua = true,
|
|
153 spell = false,
|
|
154 vsnip = true,
|
|
155 },
|
|
156 }
|
|
157
|
|
158 vim.cmd [[ inoremap <silent><expr> <C-y> compe#complete() ]]
|
|
159 vim.cmd [[ inoremap <silent><expr> <CR> compe#confirm({ 'keys': "\<Plug>delimitMateCR", 'mode': '' }) ]]
|
|
160 vim.cmd [[ inoremap <silent><expr> <C-e> compe#close('<C-e>') ]]
|
|
161 end,
|
|
162 }
|
|
163 use {
|
|
164 {
|
|
165 'nvim-treesitter/nvim-treesitter',
|
|
166 config = function()
|
|
167 require 'nvim-treesitter.highlight'
|
|
168
|
|
169 require('nvim-treesitter.configs').setup {
|
|
170 highlight = { enable = false },
|
|
171 incremental_selection = {
|
|
172 enable = true,
|
|
173 keymaps = {
|
|
174 init_selection = 'gnn',
|
|
175 node_incremental = 'grn',
|
|
176 scope_incremental = 'grc',
|
|
177 node_decremental = 'grm',
|
|
178 },
|
|
179 },
|
|
180 refactor = {
|
|
181 highlight_definitions = { enable = true },
|
|
182 smart_rename = { enable = true, keymaps = { smart_rename = 'gsr' } },
|
|
183 navigation = {
|
|
184 enable = true,
|
|
185 keymaps = { goto_definition = 'gnd', list_definitions = 'gnD' },
|
|
186 },
|
|
187 },
|
|
188 textobjects = {
|
|
189 move = {
|
|
190 enable = true,
|
|
191 goto_next_start = { [']]'] = '@block.outer' },
|
|
192 goto_previous_start = { ['[['] = '@block.outer' },
|
|
193 goto_next_end = { [']['] = '@block.outer' },
|
|
194 goto_previous_end = { ['[]'] = '@block.outer' },
|
|
195 },
|
|
196 },
|
|
197 playground = { enable = true, disable = {}, updatetime = 25, persist_queries = false },
|
|
198 }
|
|
199 end,
|
|
200 },
|
|
201 'nvim-treesitter/nvim-treesitter-refactor',
|
|
202 'nvim-treesitter/nvim-treesitter-textobjects',
|
|
203 { 'nvim-treesitter/playground', opt = true },
|
|
204 }
|
|
205 use { 'hrsh7th/vim-vsnip', requires = 'hrsh7th/vim-vsnip-integ' }
|
|
206 use {
|
|
207 'glepnir/lspsaga.nvim',
|
|
208 config = function()
|
|
209 require('lspsaga').init_lsp_saga {}
|
|
210 end,
|
|
211 }
|
|
212 use {
|
|
213 'rmagatti/goto-preview',
|
|
214 config = function()
|
|
215 require('goto-preview').setup {}
|
|
216 end,
|
|
217 }
|
|
218 use {
|
|
219 'jose-elias-alvarez/null-ls.nvim',
|
|
220 requires = 'nvim-lua/plenary.nvim',
|
|
221 }
|
|
222 use {
|
|
223 'folke/lua-dev.nvim',
|
|
224 }
|
|
225
|
|
226 -- Vanity
|
|
227 use {
|
|
228 'yamatsum/nvim-web-nonicons',
|
|
229 requires = 'kyazdani42/nvim-web-devicons',
|
|
230 config = function()
|
|
231 require 'nvim-nonicons'
|
|
232 end,
|
|
233 }
|
|
234
|
|
235 use {
|
|
236 'glepnir/galaxyline.nvim',
|
|
237 branch = 'main',
|
|
238 -- your statusline
|
|
239 config = function()
|
|
240 local gl = require 'galaxyline'
|
|
241 local colors = require('galaxyline.theme').default
|
|
242 local condition = require 'galaxyline.condition'
|
|
243 local gls = gl.section
|
|
244
|
|
245 colors.bg = '#2C323C'
|
|
246
|
|
247 gls.left[1] = {
|
|
248 RainbowRed = {
|
|
249 provider = function()
|
|
250 return '▊ '
|
|
251 end,
|
|
252 highlight = { colors.blue, colors.bg },
|
|
253 },
|
|
254 }
|
|
255
|
|
256 gls.left[2] = {
|
|
257 FileIcon = {
|
|
258 provider = 'FileIcon',
|
|
259 condition = condition.buffer_not_empty,
|
|
260 highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, colors.bg },
|
|
261 },
|
|
262 }
|
|
263
|
|
264 gls.left[3] = {
|
|
265 FileName = {
|
|
266 provider = 'FileName',
|
|
267 condition = condition.buffer_not_empty,
|
|
268 highlight = { colors.magenta, colors.bg, 'bold' },
|
|
269 },
|
|
270 }
|
|
271
|
|
272 gls.right[1] = {
|
|
273 ShowLspClient = {
|
|
274 provider = 'GetLspClient',
|
|
275 condition = function()
|
|
276 local tbl = { ['dashboard'] = true, [''] = true }
|
|
277 if tbl[vim.bo.filetype] then
|
|
278 return false
|
|
279 end
|
|
280 return true
|
|
281 end,
|
|
282 icon = require('nvim-nonicons').get 'server' .. ' LSP:',
|
|
283 highlight = { colors.green, colors.bg, 'bold' },
|
|
284 },
|
|
285 }
|
|
286
|
|
287 gls.right[2] = {
|
|
288 LineInfo = {
|
|
289 provider = 'LineColumn',
|
|
290 separator = ' ',
|
|
291 separator_highlight = { 'NONE', colors.bg },
|
|
292 highlight = { colors.fg, colors.bg },
|
|
293 },
|
|
294 }
|
|
295
|
|
296 gls.right[3] = {
|
|
297 PerCent = {
|
|
298 provider = 'LinePercent',
|
|
299 separator = ' ',
|
|
300 separator_highlight = { 'NONE', colors.bg },
|
|
301 highlight = { colors.fg, colors.bg, 'bold' },
|
|
302 },
|
|
303 }
|
|
304 gls.right[8] = {
|
|
305 RainbowBlue = {
|
|
306 provider = function()
|
|
307 return ' ▊'
|
|
308 end,
|
|
309 highlight = { colors.blue, colors.bg },
|
|
310 },
|
|
311 }
|
|
312
|
|
313 gls.short_line_left[1] = {
|
|
314 BufferType = {
|
|
315 provider = 'FileTypeName',
|
|
316 separator = ' ',
|
|
317 separator_highlight = { 'NONE', colors.bg },
|
|
318 highlight = { colors.blue, colors.bg, 'bold' },
|
|
319 },
|
|
320 }
|
|
321
|
|
322 gls.short_line_left[2] = {
|
|
323 SFileName = {
|
|
324 provider = 'SFileName',
|
|
325 condition = condition.buffer_not_empty,
|
|
326 highlight = { colors.fg, colors.bg, 'bold' },
|
|
327 },
|
|
328 }
|
|
329
|
|
330 gls.short_line_right[1] = {
|
|
331 BufferIcon = { provider = 'BufferIcon', highlight = { colors.fg, colors.bg } },
|
|
332 }
|
|
333 end,
|
|
334 }
|
|
335
|
|
336 -- File navigation
|
|
337 use { 'justinmk/vim-dirvish' }
|
|
338
|
|
339 -- Colorscheme
|
|
340 use {
|
|
341 'zegervdv/one-lush',
|
|
342 requires = 'rktjmp/lush.nvim',
|
|
343 config = function()
|
|
344 require 'lush_theme.one-lush'
|
|
345 vim.cmd [[ colorscheme one-lush ]]
|
|
346 end,
|
|
347 }
|
|
348
|
|
349 -- Terminal
|
|
350 use {
|
|
351 'akinsho/nvim-toggleterm.lua',
|
|
352 config = function()
|
|
353 require('toggleterm').setup {
|
|
354 size = 15,
|
|
355 open_mapping = [[<F12>]],
|
|
356 shade_filetypes = { 'none' },
|
|
357 shade_terminals = true,
|
|
358 persist_size = true,
|
|
359 direction = 'horizontal',
|
|
360 }
|
|
361 end,
|
|
362 }
|
|
363
|
|
364 -- Filetypes
|
|
365 use { 'Glench/Vim-Jinja2-Syntax' }
|
|
366 end)
|
|
367 end, 0)
|
|
368
|
|
369 -- LSP config
|
|
370 local lsp = require 'lspconfig'
|
|
371 local null_ls = require 'null-ls'
|
|
372
|
|
373 local on_attach = function(client)
|
|
374 local nnoremap = vim.keymap.nnoremap
|
|
375 local inoremap = vim.keymap.inoremap
|
|
376 -- nnoremap { '', require'lspsaga.diagnostic'.show_line_diagnostics, silent = true }
|
|
377 nnoremap { 'gd', vim.lsp.buf.declaration, silent = true }
|
|
378 nnoremap { '<c-]>', vim.lsp.buf.definition, silent = true }
|
|
379 nnoremap { 'K', require('lspsaga.hover').render_hover_doc, silent = true }
|
|
380 nnoremap { 'gD', vim.lsp.buf.implementation, silent = true }
|
|
381 nnoremap { '1gD', vim.lsp.buf.type_definition, silent = true }
|
|
382 nnoremap { 'gr', vim.lsp.buf.references, silent = true }
|
|
383 nnoremap { 'g0', vim.lsp.buf.document_symbol, silent = true }
|
|
384 nnoremap {
|
|
385 '<c-p>',
|
|
386 function()
|
|
387 vim.lsp.buf.formatting_sync({}, 5000)
|
|
388 end,
|
|
389 silent = true,
|
|
390 }
|
|
391 -- nnoremap { 'gp', require'lspsaga.provider'.preview_definition, silent = true }
|
|
392 nnoremap { 'gp', require('goto-preview').goto_preview_definition, silent = true }
|
|
393 nnoremap { 'gP', require('goto-preview').close_all_win, silent = true }
|
|
394
|
|
395 inoremap { '<c-l>', vim.lsp.buf.signature_help, silent = true }
|
|
396
|
|
397 vim.fn.sign_define(
|
|
398 'LspDiagnosticsSignError',
|
|
399 { texthl = 'LspDiagnosticsSignError', linehl = '', numhl = '', text = '▎' }
|
|
400 )
|
|
401 vim.fn.sign_define('LspDiagnosticsSignWarning', {
|
|
402 texthl = 'LspDiagnosticsSignWarning',
|
|
403 linehl = '',
|
|
404 numhl = '',
|
|
405 text = '▎',
|
|
406 })
|
|
407 vim.fn.sign_define('LspDiagnosticsSignInformation', {
|
|
408 texthl = 'LspDiagnosticsSignInformation',
|
|
409 linehl = '',
|
|
410 numhl = '',
|
|
411 text = '▎',
|
|
412 })
|
|
413 vim.fn.sign_define(
|
|
414 'LspDiagnosticsSignHint',
|
|
415 { texthl = 'LspDiagnosticsSignHint', linehl = '', numhl = '', text = '▎' }
|
|
416 )
|
|
417 end
|
|
418
|
|
419 vim.lsp.handlers['textDocument/formatting'] = function(err, _, result, _, bufnr)
|
|
420 if err ~= nil or result == nil then
|
|
421 return
|
|
422 end
|
|
423 if not vim.api.nvim_buf_get_option(bufnr, 'modified') then
|
|
424 local view = vim.fn.winsaveview()
|
|
425 vim.lsp.util.apply_text_edits(result, bufnr)
|
|
426 -- Fix to reload Treesitter
|
|
427 -- vim.api.nvim_command("edit")
|
|
428 vim.fn.winrestview(view)
|
|
429 end
|
|
430 end
|
|
431
|
|
432 vim.lsp.handlers['textDocument/publishDiagnostics'] = function(...)
|
|
433 vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { underline = true, update_in_insert = false })(...)
|
|
434 end
|
|
435
|
|
436 local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
437 capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
438 capabilities.textDocument.completion.completionItem.resolveSupport = {
|
|
439 properties = {
|
|
440 'documentation',
|
|
441 'detail',
|
|
442 'additionalTextEdits',
|
|
443 },
|
|
444 }
|
|
445
|
|
446 lsp.pyright.setup { on_attach = on_attach, capabilities = capabilities }
|
|
447
|
|
448 null_ls.setup {
|
|
449 on_attach = on_attach,
|
|
450 sources = {
|
|
451 null_ls.builtins.formatting.black,
|
|
452 null_ls.builtins.formatting.stylua,
|
|
453 },
|
|
454 }
|
|
455
|
|
456 local luadev = require('lua-dev').setup {
|
|
457 lspconfig = {
|
|
458 cmd = { 'lua-language-server' },
|
|
459 on_attach = on_attach,
|
|
460 capabilities = capabilities,
|
|
461 settings = {
|
|
462 Lua = {
|
|
463 diagnostics = {
|
|
464 globals = { 'use' },
|
|
465 },
|
|
466 },
|
|
467 },
|
|
468 },
|
|
469 }
|
|
470
|
|
471 lsp.sumneko_lua.setup(luadev)
|
|
472
|
|
473 -- Try importing local config
|
|
474 local ok, localconfig = pcall(require, 'localconfig')
|
|
475 if ok then
|
|
476 localconfig.setup { on_attach = on_attach, capabilities = capabilities }
|
|
477 end
|