Mercurial > dotfiles
annotate dot_config/nvim/init.lua @ 422:24330d37c9e3
Use special char for indentline with no gaps
author | zegervdv <zegervdv@me.com> |
---|---|
date | Tue, 27 Jul 2021 18:31:48 +0200 |
parents | 8dd914d43a65 |
children | 5683e8e3e361 |
rev | line source |
---|---|
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 | |
422
24330d37c9e3
Use special char for indentline with no gaps
zegervdv <zegervdv@me.com>
parents:
417
diff
changeset
|
95 vim.g.indent_blankline_char = '│' |
411 | 96 end, |
97 } | |
98 | |
99 -- Increment/decrement | |
100 use { | |
101 'zegervdv/nrpattern.nvim', | |
102 requires = 'tpope/vim-repeat', | |
103 config = function() | |
104 local nrpattern = require 'nrpattern' | |
105 local defaults = require 'nrpattern.default' | |
106 | |
107 defaults[{ 'input', 'output' }] = { priority = 12, filetypes = { 'verilog', 'systemverilog' } } | |
108 defaults[{ "'1", "'0" }] = { priority = 9, filetypes = { 'verilog', 'systemverilog' } } | |
109 | |
110 nrpattern.setup(defaults) | |
111 end, | |
112 } | |
113 | |
114 -- Tmux | |
115 use { | |
116 'numtostr/navigator.nvim', | |
117 config = function() | |
118 require('Navigator').setup { auto_save = 'current', disable_on_zoom = true } | |
119 | |
120 local nnoremap = vim.keymap.nnoremap | |
121 nnoremap { '<c-h>', require('Navigator').left, silent = true } | |
122 nnoremap { '<c-j>', require('Navigator').down, silent = true } | |
123 nnoremap { '<c-k>', require('Navigator').up, silent = true } | |
124 nnoremap { '<c-l>', require('Navigator').right, silent = true } | |
125 end, | |
126 requires = 'tjdevries/astronauta.nvim', | |
127 after = 'astronauta.nvim', | |
128 } | |
129 | |
130 -- Completion/snippets/LSP | |
131 use { 'neovim/nvim-lspconfig' } | |
132 use { | |
133 'hrsh7th/nvim-compe', | |
134 config = function() | |
135 require('compe').setup { | |
136 enabled = true, | |
137 autocomplete = true, | |
138 debug = false, | |
139 min_length = 1, | |
140 preselect = 'enable', | |
141 throttle_time = 80, | |
142 source_timeout = 1000, | |
143 incomplete_delay = 400, | |
144 max_abbr_width = 100, | |
145 max_kind_width = 100, | |
146 max_menu_width = 100, | |
147 documentation = true, | |
148 | |
149 source = { | |
150 path = true, | |
151 buffer = true, | |
152 nvim_lsp = true, | |
415
85832377f39e
Disable compe's built-in lua completion
zegervdv <zegervdv@me.com>
parents:
413
diff
changeset
|
153 nvim_lua = false, |
411 | 154 spell = false, |
155 vsnip = true, | |
156 }, | |
157 } | |
158 | |
159 vim.cmd [[ inoremap <silent><expr> <C-y> compe#complete() ]] | |
160 vim.cmd [[ inoremap <silent><expr> <CR> compe#confirm({ 'keys': "\<Plug>delimitMateCR", 'mode': '' }) ]] | |
161 vim.cmd [[ inoremap <silent><expr> <C-e> compe#close('<C-e>') ]] | |
162 end, | |
163 } | |
164 use { | |
165 { | |
166 'nvim-treesitter/nvim-treesitter', | |
167 config = function() | |
168 require 'nvim-treesitter.highlight' | |
169 | |
170 require('nvim-treesitter.configs').setup { | |
171 highlight = { enable = false }, | |
172 incremental_selection = { | |
173 enable = true, | |
174 keymaps = { | |
175 init_selection = 'gnn', | |
176 node_incremental = 'grn', | |
177 scope_incremental = 'grc', | |
178 node_decremental = 'grm', | |
179 }, | |
180 }, | |
181 refactor = { | |
182 highlight_definitions = { enable = true }, | |
183 smart_rename = { enable = true, keymaps = { smart_rename = 'gsr' } }, | |
184 navigation = { | |
185 enable = true, | |
186 keymaps = { goto_definition = 'gnd', list_definitions = 'gnD' }, | |
187 }, | |
188 }, | |
189 textobjects = { | |
190 move = { | |
191 enable = true, | |
192 goto_next_start = { [']]'] = '@block.outer' }, | |
193 goto_previous_start = { ['[['] = '@block.outer' }, | |
194 goto_next_end = { [']['] = '@block.outer' }, | |
195 goto_previous_end = { ['[]'] = '@block.outer' }, | |
196 }, | |
197 }, | |
198 playground = { enable = true, disable = {}, updatetime = 25, persist_queries = false }, | |
199 } | |
200 end, | |
201 }, | |
202 'nvim-treesitter/nvim-treesitter-refactor', | |
203 'nvim-treesitter/nvim-treesitter-textobjects', | |
204 { 'nvim-treesitter/playground', opt = true }, | |
205 } | |
206 use { 'hrsh7th/vim-vsnip', requires = 'hrsh7th/vim-vsnip-integ' } | |
207 use { | |
208 'rmagatti/goto-preview', | |
209 config = function() | |
210 require('goto-preview').setup {} | |
211 end, | |
212 } | |
213 use { | |
214 'jose-elias-alvarez/null-ls.nvim', | |
215 requires = 'nvim-lua/plenary.nvim', | |
216 } | |
217 use { | |
218 'folke/lua-dev.nvim', | |
219 } | |
220 | |
221 -- Vanity | |
222 use { | |
223 'yamatsum/nvim-web-nonicons', | |
224 requires = 'kyazdani42/nvim-web-devicons', | |
225 config = function() | |
226 require 'nvim-nonicons' | |
227 end, | |
228 } | |
229 | |
230 use { | |
231 'glepnir/galaxyline.nvim', | |
232 branch = 'main', | |
233 -- your statusline | |
234 config = function() | |
235 local gl = require 'galaxyline' | |
236 local colors = require('galaxyline.theme').default | |
237 local condition = require 'galaxyline.condition' | |
238 local gls = gl.section | |
239 | |
240 colors.bg = '#2C323C' | |
241 | |
242 gls.left[1] = { | |
243 RainbowRed = { | |
244 provider = function() | |
245 return '▊ ' | |
246 end, | |
247 highlight = { colors.blue, colors.bg }, | |
248 }, | |
249 } | |
250 | |
251 gls.left[2] = { | |
252 FileIcon = { | |
253 provider = 'FileIcon', | |
254 condition = condition.buffer_not_empty, | |
255 highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, colors.bg }, | |
256 }, | |
257 } | |
258 | |
259 gls.left[3] = { | |
260 FileName = { | |
261 provider = 'FileName', | |
262 condition = condition.buffer_not_empty, | |
263 highlight = { colors.magenta, colors.bg, 'bold' }, | |
264 }, | |
265 } | |
266 | |
267 gls.right[1] = { | |
268 ShowLspClient = { | |
269 provider = 'GetLspClient', | |
270 condition = function() | |
271 local tbl = { ['dashboard'] = true, [''] = true } | |
272 if tbl[vim.bo.filetype] then | |
273 return false | |
274 end | |
275 return true | |
276 end, | |
277 icon = require('nvim-nonicons').get 'server' .. ' LSP:', | |
278 highlight = { colors.green, colors.bg, 'bold' }, | |
279 }, | |
280 } | |
281 | |
282 gls.right[2] = { | |
283 LineInfo = { | |
284 provider = 'LineColumn', | |
285 separator = ' ', | |
286 separator_highlight = { 'NONE', colors.bg }, | |
287 highlight = { colors.fg, colors.bg }, | |
288 }, | |
289 } | |
290 | |
291 gls.right[3] = { | |
292 PerCent = { | |
293 provider = 'LinePercent', | |
294 separator = ' ', | |
295 separator_highlight = { 'NONE', colors.bg }, | |
296 highlight = { colors.fg, colors.bg, 'bold' }, | |
297 }, | |
298 } | |
299 gls.right[8] = { | |
300 RainbowBlue = { | |
301 provider = function() | |
302 return ' ▊' | |
303 end, | |
304 highlight = { colors.blue, colors.bg }, | |
305 }, | |
306 } | |
307 | |
308 gls.short_line_left[1] = { | |
309 BufferType = { | |
310 provider = 'FileTypeName', | |
311 separator = ' ', | |
312 separator_highlight = { 'NONE', colors.bg }, | |
313 highlight = { colors.blue, colors.bg, 'bold' }, | |
314 }, | |
315 } | |
316 | |
317 gls.short_line_left[2] = { | |
318 SFileName = { | |
319 provider = 'SFileName', | |
320 condition = condition.buffer_not_empty, | |
321 highlight = { colors.fg, colors.bg, 'bold' }, | |
322 }, | |
323 } | |
324 | |
325 gls.short_line_right[1] = { | |
326 BufferIcon = { provider = 'BufferIcon', highlight = { colors.fg, colors.bg } }, | |
327 } | |
328 end, | |
329 } | |
330 | |
331 -- File navigation | |
332 use { 'justinmk/vim-dirvish' } | |
333 | |
334 -- Colorscheme | |
335 use { | |
336 'zegervdv/one-lush', | |
337 requires = 'rktjmp/lush.nvim', | |
338 config = function() | |
339 require 'lush_theme.one-lush' | |
340 vim.cmd [[ colorscheme one-lush ]] | |
341 end, | |
342 } | |
343 | |
344 -- Terminal | |
345 use { | |
346 'akinsho/nvim-toggleterm.lua', | |
347 config = function() | |
348 require('toggleterm').setup { | |
349 size = 15, | |
350 open_mapping = [[<F12>]], | |
351 shade_filetypes = { 'none' }, | |
352 shade_terminals = true, | |
353 persist_size = true, | |
354 direction = 'horizontal', | |
355 } | |
356 end, | |
357 } | |
358 | |
359 -- Filetypes | |
416 | 360 use { 'lepture/vim-jinja' } |
411 | 361 end) |
362 end, 0) | |
363 | |
364 -- LSP config | |
365 local lsp = require 'lspconfig' | |
366 local null_ls = require 'null-ls' | |
367 | |
368 local on_attach = function(client) | |
369 local nnoremap = vim.keymap.nnoremap | |
370 local inoremap = vim.keymap.inoremap | |
371 nnoremap { 'gd', vim.lsp.buf.declaration, silent = true } | |
372 nnoremap { '<c-]>', vim.lsp.buf.definition, silent = true } | |
412
ad54efacea8a
Remove lspsaga in favour of built-in hover windows
zegervdv <zegervdv@me.com>
parents:
411
diff
changeset
|
373 nnoremap { 'K', vim.lsp.buf.hover, silent = true } |
411 | 374 nnoremap { 'gD', vim.lsp.buf.implementation, silent = true } |
375 nnoremap { '1gD', vim.lsp.buf.type_definition, silent = true } | |
376 nnoremap { 'gr', vim.lsp.buf.references, silent = true } | |
377 nnoremap { 'g0', vim.lsp.buf.document_symbol, silent = true } | |
378 nnoremap { | |
379 '<c-p>', | |
380 function() | |
381 vim.lsp.buf.formatting_sync({}, 5000) | |
382 end, | |
383 silent = true, | |
384 } | |
385 -- nnoremap { 'gp', require'lspsaga.provider'.preview_definition, silent = true } | |
386 nnoremap { 'gp', require('goto-preview').goto_preview_definition, silent = true } | |
387 nnoremap { 'gP', require('goto-preview').close_all_win, silent = true } | |
388 | |
389 inoremap { '<c-l>', vim.lsp.buf.signature_help, silent = true } | |
390 | |
391 vim.fn.sign_define( | |
392 'LspDiagnosticsSignError', | |
393 { texthl = 'LspDiagnosticsSignError', linehl = '', numhl = '', text = '▎' } | |
394 ) | |
395 vim.fn.sign_define('LspDiagnosticsSignWarning', { | |
396 texthl = 'LspDiagnosticsSignWarning', | |
397 linehl = '', | |
398 numhl = '', | |
399 text = '▎', | |
400 }) | |
401 vim.fn.sign_define('LspDiagnosticsSignInformation', { | |
402 texthl = 'LspDiagnosticsSignInformation', | |
403 linehl = '', | |
404 numhl = '', | |
405 text = '▎', | |
406 }) | |
407 vim.fn.sign_define( | |
408 'LspDiagnosticsSignHint', | |
409 { texthl = 'LspDiagnosticsSignHint', linehl = '', numhl = '', text = '▎' } | |
410 ) | |
412
ad54efacea8a
Remove lspsaga in favour of built-in hover windows
zegervdv <zegervdv@me.com>
parents:
411
diff
changeset
|
411 |
ad54efacea8a
Remove lspsaga in favour of built-in hover windows
zegervdv <zegervdv@me.com>
parents:
411
diff
changeset
|
412 vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' }) |
ad54efacea8a
Remove lspsaga in favour of built-in hover windows
zegervdv <zegervdv@me.com>
parents:
411
diff
changeset
|
413 vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' }) |
413
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
414 vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
415 underline = true, |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
416 update_in_insert = false, |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
417 virtual_text = { severity_limit = 'Warning' }, |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
418 }) |
411 | 419 end |
420 | |
421 local capabilities = vim.lsp.protocol.make_client_capabilities() | |
422 capabilities.textDocument.completion.completionItem.snippetSupport = true | |
423 capabilities.textDocument.completion.completionItem.resolveSupport = { | |
424 properties = { | |
425 'documentation', | |
426 'detail', | |
427 'additionalTextEdits', | |
428 }, | |
429 } | |
430 | |
431 lsp.pyright.setup { on_attach = on_attach, capabilities = capabilities } | |
432 | |
417
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
433 null_ls.config { |
411 | 434 sources = { |
435 null_ls.builtins.formatting.black, | |
436 null_ls.builtins.formatting.stylua, | |
437 }, | |
438 } | |
417
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
439 lsp['null-ls'].setup { |
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
440 on_attach = on_attach, |
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
441 root_dir = require('lspconfig.util').root_pattern('.hg', '.git'), |
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
442 } |
411 | 443 |
444 local luadev = require('lua-dev').setup { | |
445 lspconfig = { | |
446 cmd = { 'lua-language-server' }, | |
447 on_attach = on_attach, | |
448 capabilities = capabilities, | |
449 settings = { | |
450 Lua = { | |
451 diagnostics = { | |
452 globals = { 'use' }, | |
453 }, | |
454 }, | |
455 }, | |
456 }, | |
457 } | |
458 | |
459 lsp.sumneko_lua.setup(luadev) | |
460 | |
461 -- Try importing local config | |
462 local ok, localconfig = pcall(require, 'localconfig') | |
463 if ok then | |
464 localconfig.setup { on_attach = on_attach, capabilities = capabilities } | |
465 end |