Mercurial > dotfiles
annotate dot_config/nvim/init.lua @ 441:8b5c7359dd86
Add vsnip and path cmp plugins
author | zegervdv <zegervdv@me.com> |
---|---|
date | Fri, 27 Aug 2021 17:37:11 +0200 |
parents | 84b4f33c0403 |
children | e830ae093010 |
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' } | |
423 | 59 use { |
60 'sjl/splice.vim', | |
61 opt = true, | |
62 cmd = { 'SpliceInit' }, | |
63 config = function() | |
64 vim.g.splice_initial_diff_grid = 1 | |
65 vim.g.splice_initial_diff_compare = 1 | |
66 vim.g.splice_initial_diff_path = 0 | |
67 vim.g.splice_initial_scrollbind_grid = 1 | |
68 vim.g.splice_initial_scrollbind_compare = 1 | |
69 vim.g.splice_initial_scrollbind_path = 1 | |
70 vim.g.splice_wrap = 'nowrap' | |
71 end, | |
72 } | |
427 | 73 use { 'tpope/vim-git', ft = { 'gitcommit', 'gitrebase' } } |
411 | 74 |
75 -- Comments | |
426 | 76 use { |
77 'b3nj5m1n/kommentary', | |
78 config = function() | |
79 require('kommentary.config').configure_language('default', { prefer_single_line_comments = true }) | |
80 end, | |
433
4a539353bd54
Load kommentary on visual selection mappings too
Zeger Van de Vannet <zegervdv@me.com>
parents:
432
diff
changeset
|
81 keys = { |
435
e67efbc7de41
Complete pairs inside python f-strings
zegervdv <zegervdv@me.com>
parents:
433
diff
changeset
|
82 { 'n', 'gcc' }, |
433
4a539353bd54
Load kommentary on visual selection mappings too
Zeger Van de Vannet <zegervdv@me.com>
parents:
432
diff
changeset
|
83 { 'v', 'gc' }, |
4a539353bd54
Load kommentary on visual selection mappings too
Zeger Van de Vannet <zegervdv@me.com>
parents:
432
diff
changeset
|
84 }, |
426 | 85 } |
411 | 86 |
87 -- Undoing | |
88 use { 'sjl/gundo.vim', cmd = { 'GundoToggle' } } | |
89 | |
90 -- Parentheses etc | |
91 use { 'tpope/vim-surround' } | |
423 | 92 use { |
425
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
93 'windwp/nvim-autopairs', |
423 | 94 config = function() |
425
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
95 local npairs = require 'nvim-autopairs' |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
96 local Rule = require 'nvim-autopairs.rule' |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
97 |
435
e67efbc7de41
Complete pairs inside python f-strings
zegervdv <zegervdv@me.com>
parents:
433
diff
changeset
|
98 npairs.setup { |
e67efbc7de41
Complete pairs inside python f-strings
zegervdv <zegervdv@me.com>
parents:
433
diff
changeset
|
99 ignored_next_char = string.gsub([[ [%w%%%'%[%.] ]], '%s+', ''), |
e67efbc7de41
Complete pairs inside python f-strings
zegervdv <zegervdv@me.com>
parents:
433
diff
changeset
|
100 } |
425
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
101 |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
102 npairs.add_rules { |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
103 Rule(' ', ' '):with_pair(function(opts) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
104 local pair = opts.line:sub(opts.col - 1, opts.col) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
105 return vim.tbl_contains({ '()', '[]', '{}' }, pair) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
106 end), |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
107 Rule('( ', ' )') |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
108 :with_pair(function() |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
109 return false |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
110 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
111 :with_move(function(opts) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
112 return opts.prev_char:match '.%)' ~= nil |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
113 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
114 :use_key ')', |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
115 Rule('{ ', ' }') |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
116 :with_pair(function() |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
117 return false |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
118 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
119 :with_move(function(opts) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
120 return opts.prev_char:match '.%}' ~= nil |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
121 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
122 :use_key '}', |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
123 Rule('[ ', ' ]') |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
124 :with_pair(function() |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
125 return false |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
126 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
127 :with_move(function(opts) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
128 return opts.prev_char:match '.%]' ~= nil |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
129 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
130 :use_key ']', |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
131 } |
432
b6d669b13e1e
Disable ` pairing for systemverilog
Zeger Van de Vannet <zegervdv@me.com>
parents:
430
diff
changeset
|
132 |
435
e67efbc7de41
Complete pairs inside python f-strings
zegervdv <zegervdv@me.com>
parents:
433
diff
changeset
|
133 npairs.get_rule('`'):with_pair(function() |
e67efbc7de41
Complete pairs inside python f-strings
zegervdv <zegervdv@me.com>
parents:
433
diff
changeset
|
134 return vim.bo.filetype ~= 'systemverilog' |
e67efbc7de41
Complete pairs inside python f-strings
zegervdv <zegervdv@me.com>
parents:
433
diff
changeset
|
135 end) |
438
766e63b3a8fc
Exclude ' from autopairing in systemverilog
zegervdv <zegervdv@me.com>
parents:
435
diff
changeset
|
136 |
766e63b3a8fc
Exclude ' from autopairing in systemverilog
zegervdv <zegervdv@me.com>
parents:
435
diff
changeset
|
137 npairs.get_rule("'"):with_pair(function() |
766e63b3a8fc
Exclude ' from autopairing in systemverilog
zegervdv <zegervdv@me.com>
parents:
435
diff
changeset
|
138 return vim.bo.filetype ~= 'systemverilog' |
766e63b3a8fc
Exclude ' from autopairing in systemverilog
zegervdv <zegervdv@me.com>
parents:
435
diff
changeset
|
139 end) |
423 | 140 end, |
141 } | |
411 | 142 |
143 -- Moving around within lines | |
144 use { 'wellle/targets.vim', event = 'InsertEnter *' } | |
145 | |
146 -- Searching | |
147 use { 'mhinz/vim-grepper', cmd = { 'Grepper' } } | |
148 | |
149 -- Keymaps TODO: to be removed when #13823 is merged | |
150 use { | |
151 'tjdevries/astronauta.nvim', | |
152 config = function() | |
153 require 'astronauta.keymap' | |
154 end, | |
155 } | |
156 | |
157 -- Opening files | |
158 use { 'wsdjeg/vim-fetch' } | |
159 | |
160 -- Indent lines | |
161 use { | |
162 'lukas-reineke/indent-blankline.nvim', | |
163 config = function() | |
164 vim.g.indent_blankline_buftype_exclude = { 'terminal', 'help', 'nofile' } | |
165 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
|
166 vim.g.indent_blankline_char = '│' |
411 | 167 end, |
168 } | |
169 | |
170 -- Increment/decrement | |
171 use { | |
172 'zegervdv/nrpattern.nvim', | |
173 requires = 'tpope/vim-repeat', | |
174 config = function() | |
175 local nrpattern = require 'nrpattern' | |
176 local defaults = require 'nrpattern.default' | |
177 | |
178 defaults[{ 'input', 'output' }] = { priority = 12, filetypes = { 'verilog', 'systemverilog' } } | |
179 defaults[{ "'1", "'0" }] = { priority = 9, filetypes = { 'verilog', 'systemverilog' } } | |
180 | |
181 nrpattern.setup(defaults) | |
182 end, | |
183 } | |
184 | |
185 -- Tmux | |
186 use { | |
187 'numtostr/navigator.nvim', | |
188 config = function() | |
189 require('Navigator').setup { auto_save = 'current', disable_on_zoom = true } | |
190 | |
191 local nnoremap = vim.keymap.nnoremap | |
192 nnoremap { '<c-h>', require('Navigator').left, silent = true } | |
193 nnoremap { '<c-j>', require('Navigator').down, silent = true } | |
194 nnoremap { '<c-k>', require('Navigator').up, silent = true } | |
195 nnoremap { '<c-l>', require('Navigator').right, silent = true } | |
196 end, | |
197 requires = 'tjdevries/astronauta.nvim', | |
198 after = 'astronauta.nvim', | |
199 } | |
200 | |
201 -- Completion/snippets/LSP | |
202 use { 'neovim/nvim-lspconfig' } | |
203 use { | |
439 | 204 'hrsh7th/nvim-cmp', |
441 | 205 requires = { 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-vsnip', 'hrsh7th/cmp-path' }, |
411 | 206 config = function() |
439 | 207 local cmp = require 'cmp' |
208 cmp.setup { | |
209 mapping = { | |
210 ['<C-p>'] = cmp.mapping.select_prev_item(), | |
211 ['<C-n>'] = cmp.mapping.select_next_item(), | |
212 ['<C-d>'] = cmp.mapping.scroll_docs(-4), | |
213 ['<C-f>'] = cmp.mapping.scroll_docs(4), | |
214 ['<C-Space>'] = cmp.mapping.complete(), | |
215 ['<C-e>'] = cmp.mapping.close(), | |
216 ['<CR>'] = cmp.mapping.confirm { | |
217 behavior = cmp.ConfirmBehavior.Replace, | |
218 select = true, | |
219 }, | |
220 }, | |
221 sources = { | |
222 { name = 'buffer' }, | |
223 { name = 'nvim_lsp' }, | |
441 | 224 { name = 'vsnip' }, |
225 { name = 'path' }, | |
411 | 226 }, |
227 } | |
228 end, | |
229 } | |
230 use { | |
231 { | |
232 'nvim-treesitter/nvim-treesitter', | |
233 config = function() | |
234 require 'nvim-treesitter.highlight' | |
235 | |
236 require('nvim-treesitter.configs').setup { | |
237 highlight = { enable = false }, | |
238 incremental_selection = { | |
239 enable = true, | |
240 keymaps = { | |
241 init_selection = 'gnn', | |
242 node_incremental = 'grn', | |
243 scope_incremental = 'grc', | |
244 node_decremental = 'grm', | |
245 }, | |
246 }, | |
247 refactor = { | |
248 highlight_definitions = { enable = true }, | |
249 smart_rename = { enable = true, keymaps = { smart_rename = 'gsr' } }, | |
250 navigation = { | |
251 enable = true, | |
252 keymaps = { goto_definition = 'gnd', list_definitions = 'gnD' }, | |
253 }, | |
254 }, | |
255 textobjects = { | |
256 move = { | |
257 enable = true, | |
258 goto_next_start = { [']]'] = '@block.outer' }, | |
259 goto_previous_start = { ['[['] = '@block.outer' }, | |
260 goto_next_end = { [']['] = '@block.outer' }, | |
261 goto_previous_end = { ['[]'] = '@block.outer' }, | |
262 }, | |
263 }, | |
264 playground = { enable = true, disable = {}, updatetime = 25, persist_queries = false }, | |
265 } | |
266 end, | |
267 }, | |
268 'nvim-treesitter/nvim-treesitter-refactor', | |
269 'nvim-treesitter/nvim-treesitter-textobjects', | |
270 { 'nvim-treesitter/playground', opt = true }, | |
271 } | |
272 use { 'hrsh7th/vim-vsnip', requires = 'hrsh7th/vim-vsnip-integ' } | |
273 use { | |
274 'rmagatti/goto-preview', | |
275 config = function() | |
276 require('goto-preview').setup {} | |
277 end, | |
278 } | |
279 use { | |
280 'jose-elias-alvarez/null-ls.nvim', | |
281 requires = 'nvim-lua/plenary.nvim', | |
282 } | |
429
5c72a33ba7d7
Fix lazy loading issues with lua-dev
zegervdv <zegervdv@me.com>
parents:
428
diff
changeset
|
283 use { 'folke/lua-dev.nvim' } |
411 | 284 |
424 | 285 use { 'vimjas/vim-python-pep8-indent', ft = { 'python' } } |
286 | |
411 | 287 -- Vanity |
288 use { | |
289 'yamatsum/nvim-web-nonicons', | |
290 requires = 'kyazdani42/nvim-web-devicons', | |
291 config = function() | |
292 require 'nvim-nonicons' | |
293 end, | |
294 } | |
295 | |
296 use { | |
297 'glepnir/galaxyline.nvim', | |
298 branch = 'main', | |
299 -- your statusline | |
300 config = function() | |
301 local gl = require 'galaxyline' | |
302 local colors = require('galaxyline.theme').default | |
303 local condition = require 'galaxyline.condition' | |
304 local gls = gl.section | |
305 | |
306 colors.bg = '#2C323C' | |
307 | |
308 gls.left[1] = { | |
309 RainbowRed = { | |
310 provider = function() | |
311 return '▊ ' | |
312 end, | |
313 highlight = { colors.blue, colors.bg }, | |
314 }, | |
315 } | |
316 | |
317 gls.left[2] = { | |
318 FileIcon = { | |
319 provider = 'FileIcon', | |
320 condition = condition.buffer_not_empty, | |
321 highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, colors.bg }, | |
322 }, | |
323 } | |
324 | |
325 gls.left[3] = { | |
326 FileName = { | |
327 provider = 'FileName', | |
328 condition = condition.buffer_not_empty, | |
329 highlight = { colors.magenta, colors.bg, 'bold' }, | |
330 }, | |
331 } | |
332 | |
333 gls.right[1] = { | |
334 ShowLspClient = { | |
335 provider = 'GetLspClient', | |
336 condition = function() | |
337 local tbl = { ['dashboard'] = true, [''] = true } | |
338 if tbl[vim.bo.filetype] then | |
339 return false | |
340 end | |
341 return true | |
342 end, | |
343 icon = require('nvim-nonicons').get 'server' .. ' LSP:', | |
344 highlight = { colors.green, colors.bg, 'bold' }, | |
345 }, | |
346 } | |
347 | |
348 gls.right[2] = { | |
349 LineInfo = { | |
350 provider = 'LineColumn', | |
351 separator = ' ', | |
352 separator_highlight = { 'NONE', colors.bg }, | |
353 highlight = { colors.fg, colors.bg }, | |
354 }, | |
355 } | |
356 | |
357 gls.right[3] = { | |
358 PerCent = { | |
359 provider = 'LinePercent', | |
360 separator = ' ', | |
361 separator_highlight = { 'NONE', colors.bg }, | |
362 highlight = { colors.fg, colors.bg, 'bold' }, | |
363 }, | |
364 } | |
365 gls.right[8] = { | |
366 RainbowBlue = { | |
367 provider = function() | |
368 return ' ▊' | |
369 end, | |
370 highlight = { colors.blue, colors.bg }, | |
371 }, | |
372 } | |
373 | |
374 gls.short_line_left[1] = { | |
375 BufferType = { | |
376 provider = 'FileTypeName', | |
377 separator = ' ', | |
378 separator_highlight = { 'NONE', colors.bg }, | |
379 highlight = { colors.blue, colors.bg, 'bold' }, | |
380 }, | |
381 } | |
382 | |
383 gls.short_line_left[2] = { | |
384 SFileName = { | |
385 provider = 'SFileName', | |
386 condition = condition.buffer_not_empty, | |
387 highlight = { colors.fg, colors.bg, 'bold' }, | |
388 }, | |
389 } | |
390 | |
391 gls.short_line_right[1] = { | |
392 BufferIcon = { provider = 'BufferIcon', highlight = { colors.fg, colors.bg } }, | |
393 } | |
394 end, | |
395 } | |
396 | |
397 -- File navigation | |
398 use { 'justinmk/vim-dirvish' } | |
399 | |
400 -- Colorscheme | |
401 use { | |
402 'zegervdv/one-lush', | |
403 requires = 'rktjmp/lush.nvim', | |
404 config = function() | |
405 require 'lush_theme.one-lush' | |
406 vim.cmd [[ colorscheme one-lush ]] | |
407 end, | |
408 } | |
409 | |
410 -- Terminal | |
411 use { | |
412 'akinsho/nvim-toggleterm.lua', | |
413 config = function() | |
414 require('toggleterm').setup { | |
415 size = 15, | |
416 open_mapping = [[<F12>]], | |
417 shade_filetypes = { 'none' }, | |
418 shade_terminals = true, | |
419 persist_size = true, | |
420 direction = 'horizontal', | |
421 } | |
422 end, | |
427 | 423 keys = { [[<F12>]] }, |
411 | 424 } |
425 | |
426 -- Filetypes | |
416 | 427 use { 'lepture/vim-jinja' } |
411 | 428 end) |
429 end, 0) | |
430 | |
423 | 431 -- Configuration |
432 local opt = vim.opt | |
433 | |
434 opt.backspace = { 'indent', 'eol', 'start' } -- Backspace everything | |
435 | |
436 opt.autoread = true -- Read changed files | |
437 opt.hidden = true -- Allow to move away from modified files | |
438 opt.autowriteall = true -- Write changes when losing focus | |
439 | |
440 -- Visuals | |
441 opt.number = true | |
442 opt.relativenumber = true | |
443 opt.scrolloff = 4 | |
444 opt.showcmd = true -- Show incomplete commands while typing | |
445 | |
446 opt.termguicolors = true | |
447 opt.background = 'dark' | |
448 | |
449 opt.showmatch = true -- Highligh matching braces | |
450 | |
451 opt.wrap = true -- Wrap lines | |
452 opt.wrapmargin = 2 -- Stay 2 chars from side | |
453 opt.textwidth = 79 | |
454 opt.colorcolumn = '81' -- Show indication of 81 chars | |
455 opt.linebreak = true -- Smarter wrapping | |
456 opt.breakindent = true -- Indent wrapped lines to same level | |
457 | |
458 opt.fixendofline = true -- Add EOL when missing | |
459 | |
460 opt.expandtab = true -- Add spaces when pressing tab | |
461 opt.tabstop = 2 -- Tab is 2 spaces | |
462 opt.shiftwidth = 2 -- Shift per 2 spaces | |
463 opt.shiftround = true -- Round shifts to allign (1 space + tab = 2 spaces) | |
464 | |
465 -- Searching and substitute | |
466 opt.magic = true -- Enable regexes | |
467 opt.hlsearch = true -- Highlight all matches | |
468 opt.incsearch = true -- Show matches while typing | |
469 opt.ignorecase = true | |
470 opt.smartcase = true -- When search pattern contains cases, be case sensitive | |
471 opt.gdefault = true -- Use global flag for substitute: replace all matches on line | |
472 opt.inccommand = 'nosplit' -- Show live replacements directly in text | |
473 | |
474 opt.autoindent = true | |
475 opt.cindent = true -- C-syntax based indenting | |
476 | |
477 opt.updatetime = 300 -- Faster triggering of CursorHold events | |
478 | |
479 opt.errorbells = false -- Don't you beep to me | |
480 | |
481 opt.history = 1000 -- Remember last commands | |
482 | |
483 opt.wildmenu = true -- Command completion | |
430
5d6bfec9cb5a
Restore old behaviour of wildmenu
zegervdv <zegervdv@me.com>
parents:
429
diff
changeset
|
484 opt.wildmode = 'longest:full,full' |
423 | 485 opt.shortmess:append 'c' -- Hide ins-completion messages |
486 | |
487 opt.ttyfast = true -- fast terminal | |
488 opt.lazyredraw = true | |
489 opt.ttimeoutlen = -1 -- Minimum timeout | |
490 | |
491 opt.diffopt:append 'iwhite' -- Ignore whitespace in diffs | |
492 opt.diffopt:append 'internal' -- Internal diff engine | |
493 opt.diffopt:append 'algorithm:patience' -- Use patience algorithm | |
494 | |
495 opt.tags = { '.git/tags', 'tags' } | |
496 | |
497 opt.path:append '**' -- Recursively search current directory | |
498 | |
499 opt.formatoptions = { | |
500 c = true, -- Wrap comments | |
501 r = true, -- Continue comments | |
502 o = true, -- Insert comment with o/O | |
503 q = true, -- Format comments with gq | |
504 n = true, -- Indent numbered lists | |
505 [2] = true, -- Indent from 2nd line of paragraph | |
506 [1] = true, -- Don't break before one letter words | |
507 } | |
508 | |
509 opt.signcolumn = 'yes' -- Always show signcolumn | |
510 | |
511 opt.cursorline = true | |
512 | |
513 -- Show certain characters | |
514 opt.list = true | |
515 opt.listchars = { trail = '·', extends = '>', precedes = '<', nbsp = '+' } | |
516 | |
517 opt.sessionoptions:remove 'options' -- Remove options from saved sessions (reload from config) | |
518 | |
519 opt.completeopt = { 'menu', 'menuone', 'noselect' } | |
520 | |
521 opt.splitright = true -- Open new splits to right | |
522 opt.virtualedit = 'block' -- Enable block editting | |
523 | |
524 opt.conceallevel = 0 -- Disable conceal | |
525 | |
526 opt.pastetoggle = '<F2>' -- Enable paste mode | |
527 | |
528 opt.undofile = true -- Persistently remember undos | |
529 opt.undolevels = 1000 | |
530 opt.undodir = os.getenv 'HOME' .. '/.config/nvim/tmp/undo//' | |
531 opt.swapfile = false -- Disable swap files | |
532 opt.backup = true -- Keep backups | |
533 opt.backupdir = os.getenv 'HOME' .. '/.config/nvim/tmp/backup//' | |
534 | |
535 -- Files to ignore from completion | |
536 opt.wildignore:append { | |
537 '*/tmp/*', | |
538 '*.so', | |
539 '*.swp', | |
540 '*.zip', | |
541 '*.o', | |
542 '*.bin', | |
543 '*.elf', | |
544 '*.hex', | |
545 '*.eps', | |
546 '.git/*', | |
547 '*.dup', | |
548 '.hg/**', | |
549 '*.orig', | |
550 '*.*~', | |
551 } | |
552 | |
553 opt.mouse = { | |
554 n = true, -- Normal mode | |
555 i = true, -- Insert mode | |
556 c = true, -- Commandline mode | |
557 } | |
558 | |
411 | 559 -- LSP config |
560 local lsp = require 'lspconfig' | |
561 local null_ls = require 'null-ls' | |
562 | |
563 local on_attach = function(client) | |
564 local nnoremap = vim.keymap.nnoremap | |
565 local inoremap = vim.keymap.inoremap | |
566 nnoremap { 'gd', vim.lsp.buf.declaration, silent = true } | |
567 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
|
568 nnoremap { 'K', vim.lsp.buf.hover, silent = true } |
411 | 569 nnoremap { 'gD', vim.lsp.buf.implementation, silent = true } |
570 nnoremap { '1gD', vim.lsp.buf.type_definition, silent = true } | |
571 nnoremap { 'gr', vim.lsp.buf.references, silent = true } | |
572 nnoremap { 'g0', vim.lsp.buf.document_symbol, silent = true } | |
573 nnoremap { | |
574 '<c-p>', | |
575 function() | |
576 vim.lsp.buf.formatting_sync({}, 5000) | |
577 end, | |
578 silent = true, | |
579 } | |
580 -- nnoremap { 'gp', require'lspsaga.provider'.preview_definition, silent = true } | |
581 nnoremap { 'gp', require('goto-preview').goto_preview_definition, silent = true } | |
582 nnoremap { 'gP', require('goto-preview').close_all_win, silent = true } | |
583 | |
584 inoremap { '<c-l>', vim.lsp.buf.signature_help, silent = true } | |
585 | |
586 vim.fn.sign_define( | |
587 'LspDiagnosticsSignError', | |
588 { texthl = 'LspDiagnosticsSignError', linehl = '', numhl = '', text = '▎' } | |
589 ) | |
590 vim.fn.sign_define('LspDiagnosticsSignWarning', { | |
591 texthl = 'LspDiagnosticsSignWarning', | |
592 linehl = '', | |
593 numhl = '', | |
594 text = '▎', | |
595 }) | |
596 vim.fn.sign_define('LspDiagnosticsSignInformation', { | |
597 texthl = 'LspDiagnosticsSignInformation', | |
598 linehl = '', | |
599 numhl = '', | |
600 text = '▎', | |
601 }) | |
602 vim.fn.sign_define( | |
603 'LspDiagnosticsSignHint', | |
604 { texthl = 'LspDiagnosticsSignHint', linehl = '', numhl = '', text = '▎' } | |
605 ) | |
412
ad54efacea8a
Remove lspsaga in favour of built-in hover windows
zegervdv <zegervdv@me.com>
parents:
411
diff
changeset
|
606 |
ad54efacea8a
Remove lspsaga in favour of built-in hover windows
zegervdv <zegervdv@me.com>
parents:
411
diff
changeset
|
607 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
|
608 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
|
609 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
|
610 underline = true, |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
611 update_in_insert = false, |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
612 virtual_text = { severity_limit = 'Warning' }, |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
613 }) |
411 | 614 end |
615 | |
616 local capabilities = vim.lsp.protocol.make_client_capabilities() | |
617 capabilities.textDocument.completion.completionItem.snippetSupport = true | |
618 capabilities.textDocument.completion.completionItem.resolveSupport = { | |
619 properties = { | |
620 'documentation', | |
621 'detail', | |
622 'additionalTextEdits', | |
623 }, | |
624 } | |
625 | |
626 lsp.pyright.setup { on_attach = on_attach, capabilities = capabilities } | |
627 | |
417
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
628 null_ls.config { |
411 | 629 sources = { |
630 null_ls.builtins.formatting.black, | |
631 null_ls.builtins.formatting.stylua, | |
632 }, | |
633 } | |
417
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
634 lsp['null-ls'].setup { |
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
635 on_attach = on_attach, |
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
636 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
|
637 } |
411 | 638 |
639 local luadev = require('lua-dev').setup { | |
640 lspconfig = { | |
641 cmd = { 'lua-language-server' }, | |
642 on_attach = on_attach, | |
643 capabilities = capabilities, | |
644 settings = { | |
645 Lua = { | |
646 diagnostics = { | |
647 globals = { 'use' }, | |
648 }, | |
649 }, | |
650 }, | |
651 }, | |
652 } | |
653 | |
654 lsp.sumneko_lua.setup(luadev) | |
655 | |
656 -- Try importing local config | |
657 local ok, localconfig = pcall(require, 'localconfig') | |
658 if ok then | |
659 localconfig.setup { on_attach = on_attach, capabilities = capabilities } | |
660 end |