Mercurial > dotfiles
annotate dot_config/nvim/init.lua @ 444:9e4933c708e4
Expand vsnip snippets in completion
author | Zeger Van de Vannet <zegervdv@me.com> |
---|---|
date | Tue, 31 Aug 2021 14:41:54 +0200 |
parents | 7e2e4f89c7bc |
children | 34fb1bd9986f |
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 { | |
444
9e4933c708e4
Expand vsnip snippets in completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
443
diff
changeset
|
209 snippet = { |
9e4933c708e4
Expand vsnip snippets in completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
443
diff
changeset
|
210 expand = function(args) |
9e4933c708e4
Expand vsnip snippets in completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
443
diff
changeset
|
211 vim.fn["vsnip#anonymous"](args.body) |
9e4933c708e4
Expand vsnip snippets in completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
443
diff
changeset
|
212 end, |
9e4933c708e4
Expand vsnip snippets in completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
443
diff
changeset
|
213 }, |
439 | 214 mapping = { |
215 ['<C-p>'] = cmp.mapping.select_prev_item(), | |
216 ['<C-n>'] = cmp.mapping.select_next_item(), | |
217 ['<C-d>'] = cmp.mapping.scroll_docs(-4), | |
218 ['<C-f>'] = cmp.mapping.scroll_docs(4), | |
443
7e2e4f89c7bc
Fix mapping for forced completion
zegervdv <zegervdv@me.com>
parents:
442
diff
changeset
|
219 ['<C-y>'] = cmp.mapping.complete(), |
439 | 220 ['<C-e>'] = cmp.mapping.close(), |
221 ['<CR>'] = cmp.mapping.confirm { | |
222 behavior = cmp.ConfirmBehavior.Replace, | |
223 select = true, | |
224 }, | |
225 }, | |
226 sources = { | |
227 { name = 'buffer' }, | |
228 { name = 'nvim_lsp' }, | |
441 | 229 { name = 'vsnip' }, |
230 { name = 'path' }, | |
411 | 231 }, |
232 } | |
233 end, | |
234 } | |
235 use { | |
236 { | |
237 'nvim-treesitter/nvim-treesitter', | |
238 config = function() | |
239 require 'nvim-treesitter.highlight' | |
240 | |
241 require('nvim-treesitter.configs').setup { | |
242 highlight = { enable = false }, | |
243 incremental_selection = { | |
244 enable = true, | |
245 keymaps = { | |
246 init_selection = 'gnn', | |
247 node_incremental = 'grn', | |
248 scope_incremental = 'grc', | |
249 node_decremental = 'grm', | |
250 }, | |
251 }, | |
252 refactor = { | |
253 highlight_definitions = { enable = true }, | |
254 smart_rename = { enable = true, keymaps = { smart_rename = 'gsr' } }, | |
255 navigation = { | |
256 enable = true, | |
257 keymaps = { goto_definition = 'gnd', list_definitions = 'gnD' }, | |
258 }, | |
259 }, | |
260 textobjects = { | |
261 move = { | |
262 enable = true, | |
263 goto_next_start = { [']]'] = '@block.outer' }, | |
264 goto_previous_start = { ['[['] = '@block.outer' }, | |
265 goto_next_end = { [']['] = '@block.outer' }, | |
266 goto_previous_end = { ['[]'] = '@block.outer' }, | |
267 }, | |
268 }, | |
269 playground = { enable = true, disable = {}, updatetime = 25, persist_queries = false }, | |
270 } | |
271 end, | |
272 }, | |
273 'nvim-treesitter/nvim-treesitter-refactor', | |
274 'nvim-treesitter/nvim-treesitter-textobjects', | |
275 { 'nvim-treesitter/playground', opt = true }, | |
276 } | |
277 use { 'hrsh7th/vim-vsnip', requires = 'hrsh7th/vim-vsnip-integ' } | |
278 use { | |
279 'rmagatti/goto-preview', | |
280 config = function() | |
281 require('goto-preview').setup {} | |
282 end, | |
283 } | |
284 use { | |
285 'jose-elias-alvarez/null-ls.nvim', | |
286 requires = 'nvim-lua/plenary.nvim', | |
287 } | |
429
5c72a33ba7d7
Fix lazy loading issues with lua-dev
zegervdv <zegervdv@me.com>
parents:
428
diff
changeset
|
288 use { 'folke/lua-dev.nvim' } |
411 | 289 |
424 | 290 use { 'vimjas/vim-python-pep8-indent', ft = { 'python' } } |
291 | |
411 | 292 -- Vanity |
293 use { | |
294 'yamatsum/nvim-web-nonicons', | |
295 requires = 'kyazdani42/nvim-web-devicons', | |
296 config = function() | |
297 require 'nvim-nonicons' | |
298 end, | |
299 } | |
300 | |
301 use { | |
302 'glepnir/galaxyline.nvim', | |
303 branch = 'main', | |
304 -- your statusline | |
305 config = function() | |
306 local gl = require 'galaxyline' | |
307 local colors = require('galaxyline.theme').default | |
308 local condition = require 'galaxyline.condition' | |
309 local gls = gl.section | |
310 | |
311 colors.bg = '#2C323C' | |
312 | |
313 gls.left[1] = { | |
314 RainbowRed = { | |
315 provider = function() | |
316 return '▊ ' | |
317 end, | |
318 highlight = { colors.blue, colors.bg }, | |
319 }, | |
320 } | |
321 | |
322 gls.left[2] = { | |
323 FileIcon = { | |
324 provider = 'FileIcon', | |
325 condition = condition.buffer_not_empty, | |
326 highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, colors.bg }, | |
327 }, | |
328 } | |
329 | |
330 gls.left[3] = { | |
331 FileName = { | |
332 provider = 'FileName', | |
333 condition = condition.buffer_not_empty, | |
334 highlight = { colors.magenta, colors.bg, 'bold' }, | |
335 }, | |
336 } | |
337 | |
338 gls.right[1] = { | |
339 ShowLspClient = { | |
340 provider = 'GetLspClient', | |
341 condition = function() | |
342 local tbl = { ['dashboard'] = true, [''] = true } | |
343 if tbl[vim.bo.filetype] then | |
344 return false | |
345 end | |
346 return true | |
347 end, | |
348 icon = require('nvim-nonicons').get 'server' .. ' LSP:', | |
349 highlight = { colors.green, colors.bg, 'bold' }, | |
350 }, | |
351 } | |
352 | |
353 gls.right[2] = { | |
354 LineInfo = { | |
355 provider = 'LineColumn', | |
356 separator = ' ', | |
357 separator_highlight = { 'NONE', colors.bg }, | |
358 highlight = { colors.fg, colors.bg }, | |
359 }, | |
360 } | |
361 | |
362 gls.right[3] = { | |
363 PerCent = { | |
364 provider = 'LinePercent', | |
365 separator = ' ', | |
366 separator_highlight = { 'NONE', colors.bg }, | |
367 highlight = { colors.fg, colors.bg, 'bold' }, | |
368 }, | |
369 } | |
370 gls.right[8] = { | |
371 RainbowBlue = { | |
372 provider = function() | |
373 return ' ▊' | |
374 end, | |
375 highlight = { colors.blue, colors.bg }, | |
376 }, | |
377 } | |
378 | |
379 gls.short_line_left[1] = { | |
380 BufferType = { | |
381 provider = 'FileTypeName', | |
382 separator = ' ', | |
383 separator_highlight = { 'NONE', colors.bg }, | |
384 highlight = { colors.blue, colors.bg, 'bold' }, | |
385 }, | |
386 } | |
387 | |
388 gls.short_line_left[2] = { | |
389 SFileName = { | |
390 provider = 'SFileName', | |
391 condition = condition.buffer_not_empty, | |
392 highlight = { colors.fg, colors.bg, 'bold' }, | |
393 }, | |
394 } | |
395 | |
396 gls.short_line_right[1] = { | |
397 BufferIcon = { provider = 'BufferIcon', highlight = { colors.fg, colors.bg } }, | |
398 } | |
399 end, | |
400 } | |
401 | |
402 -- File navigation | |
403 use { 'justinmk/vim-dirvish' } | |
404 | |
405 -- Colorscheme | |
406 use { | |
407 'zegervdv/one-lush', | |
408 requires = 'rktjmp/lush.nvim', | |
409 config = function() | |
410 require 'lush_theme.one-lush' | |
411 vim.cmd [[ colorscheme one-lush ]] | |
412 end, | |
413 } | |
414 | |
415 -- Terminal | |
416 use { | |
417 'akinsho/nvim-toggleterm.lua', | |
418 config = function() | |
419 require('toggleterm').setup { | |
420 size = 15, | |
421 open_mapping = [[<F12>]], | |
422 shade_filetypes = { 'none' }, | |
423 shade_terminals = true, | |
424 persist_size = true, | |
425 direction = 'horizontal', | |
426 } | |
427 end, | |
427 | 428 keys = { [[<F12>]] }, |
411 | 429 } |
430 | |
431 -- Filetypes | |
416 | 432 use { 'lepture/vim-jinja' } |
411 | 433 end) |
434 end, 0) | |
435 | |
423 | 436 -- Configuration |
437 local opt = vim.opt | |
438 | |
439 opt.backspace = { 'indent', 'eol', 'start' } -- Backspace everything | |
440 | |
441 opt.autoread = true -- Read changed files | |
442 opt.hidden = true -- Allow to move away from modified files | |
443 opt.autowriteall = true -- Write changes when losing focus | |
444 | |
445 -- Visuals | |
446 opt.number = true | |
447 opt.relativenumber = true | |
448 opt.scrolloff = 4 | |
449 opt.showcmd = true -- Show incomplete commands while typing | |
450 | |
451 opt.termguicolors = true | |
452 opt.background = 'dark' | |
453 | |
454 opt.showmatch = true -- Highligh matching braces | |
455 | |
456 opt.wrap = true -- Wrap lines | |
457 opt.wrapmargin = 2 -- Stay 2 chars from side | |
458 opt.textwidth = 79 | |
459 opt.colorcolumn = '81' -- Show indication of 81 chars | |
460 opt.linebreak = true -- Smarter wrapping | |
461 opt.breakindent = true -- Indent wrapped lines to same level | |
462 | |
463 opt.fixendofline = true -- Add EOL when missing | |
464 | |
465 opt.expandtab = true -- Add spaces when pressing tab | |
466 opt.tabstop = 2 -- Tab is 2 spaces | |
467 opt.shiftwidth = 2 -- Shift per 2 spaces | |
468 opt.shiftround = true -- Round shifts to allign (1 space + tab = 2 spaces) | |
469 | |
470 -- Searching and substitute | |
471 opt.magic = true -- Enable regexes | |
472 opt.hlsearch = true -- Highlight all matches | |
473 opt.incsearch = true -- Show matches while typing | |
474 opt.ignorecase = true | |
475 opt.smartcase = true -- When search pattern contains cases, be case sensitive | |
476 opt.gdefault = true -- Use global flag for substitute: replace all matches on line | |
477 opt.inccommand = 'nosplit' -- Show live replacements directly in text | |
478 | |
479 opt.autoindent = true | |
480 opt.cindent = true -- C-syntax based indenting | |
481 | |
482 opt.updatetime = 300 -- Faster triggering of CursorHold events | |
483 | |
484 opt.errorbells = false -- Don't you beep to me | |
485 | |
486 opt.history = 1000 -- Remember last commands | |
487 | |
488 opt.wildmenu = true -- Command completion | |
430
5d6bfec9cb5a
Restore old behaviour of wildmenu
zegervdv <zegervdv@me.com>
parents:
429
diff
changeset
|
489 opt.wildmode = 'longest:full,full' |
423 | 490 opt.shortmess:append 'c' -- Hide ins-completion messages |
491 | |
492 opt.ttyfast = true -- fast terminal | |
493 opt.lazyredraw = true | |
494 opt.ttimeoutlen = -1 -- Minimum timeout | |
495 | |
496 opt.diffopt:append 'iwhite' -- Ignore whitespace in diffs | |
497 opt.diffopt:append 'internal' -- Internal diff engine | |
498 opt.diffopt:append 'algorithm:patience' -- Use patience algorithm | |
499 | |
500 opt.tags = { '.git/tags', 'tags' } | |
501 | |
502 opt.path:append '**' -- Recursively search current directory | |
503 | |
504 opt.formatoptions = { | |
505 c = true, -- Wrap comments | |
506 r = true, -- Continue comments | |
507 o = true, -- Insert comment with o/O | |
508 q = true, -- Format comments with gq | |
509 n = true, -- Indent numbered lists | |
510 [2] = true, -- Indent from 2nd line of paragraph | |
511 [1] = true, -- Don't break before one letter words | |
512 } | |
513 | |
514 opt.signcolumn = 'yes' -- Always show signcolumn | |
515 | |
516 opt.cursorline = true | |
517 | |
518 -- Show certain characters | |
519 opt.list = true | |
520 opt.listchars = { trail = '·', extends = '>', precedes = '<', nbsp = '+' } | |
521 | |
522 opt.sessionoptions:remove 'options' -- Remove options from saved sessions (reload from config) | |
523 | |
524 opt.completeopt = { 'menu', 'menuone', 'noselect' } | |
525 | |
526 opt.splitright = true -- Open new splits to right | |
527 opt.virtualedit = 'block' -- Enable block editting | |
528 | |
529 opt.conceallevel = 0 -- Disable conceal | |
530 | |
531 opt.pastetoggle = '<F2>' -- Enable paste mode | |
532 | |
533 opt.undofile = true -- Persistently remember undos | |
534 opt.undolevels = 1000 | |
535 opt.undodir = os.getenv 'HOME' .. '/.config/nvim/tmp/undo//' | |
536 opt.swapfile = false -- Disable swap files | |
537 opt.backup = true -- Keep backups | |
538 opt.backupdir = os.getenv 'HOME' .. '/.config/nvim/tmp/backup//' | |
539 | |
540 -- Files to ignore from completion | |
541 opt.wildignore:append { | |
542 '*/tmp/*', | |
543 '*.so', | |
544 '*.swp', | |
545 '*.zip', | |
546 '*.o', | |
547 '*.bin', | |
548 '*.elf', | |
549 '*.hex', | |
550 '*.eps', | |
551 '.git/*', | |
552 '*.dup', | |
553 '.hg/**', | |
554 '*.orig', | |
555 '*.*~', | |
556 } | |
557 | |
558 opt.mouse = { | |
559 n = true, -- Normal mode | |
560 i = true, -- Insert mode | |
561 c = true, -- Commandline mode | |
562 } | |
563 | |
411 | 564 -- LSP config |
565 local lsp = require 'lspconfig' | |
566 local null_ls = require 'null-ls' | |
567 | |
568 local on_attach = function(client) | |
569 local nnoremap = vim.keymap.nnoremap | |
570 local inoremap = vim.keymap.inoremap | |
571 nnoremap { 'gd', vim.lsp.buf.declaration, silent = true } | |
572 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
|
573 nnoremap { 'K', vim.lsp.buf.hover, silent = true } |
411 | 574 nnoremap { 'gD', vim.lsp.buf.implementation, silent = true } |
575 nnoremap { '1gD', vim.lsp.buf.type_definition, silent = true } | |
576 nnoremap { 'gr', vim.lsp.buf.references, silent = true } | |
577 nnoremap { 'g0', vim.lsp.buf.document_symbol, silent = true } | |
578 nnoremap { | |
579 '<c-p>', | |
580 function() | |
581 vim.lsp.buf.formatting_sync({}, 5000) | |
582 end, | |
583 silent = true, | |
584 } | |
585 -- nnoremap { 'gp', require'lspsaga.provider'.preview_definition, silent = true } | |
586 nnoremap { 'gp', require('goto-preview').goto_preview_definition, silent = true } | |
587 nnoremap { 'gP', require('goto-preview').close_all_win, silent = true } | |
588 | |
589 inoremap { '<c-l>', vim.lsp.buf.signature_help, silent = true } | |
590 | |
591 vim.fn.sign_define( | |
592 'LspDiagnosticsSignError', | |
593 { texthl = 'LspDiagnosticsSignError', linehl = '', numhl = '', text = '▎' } | |
594 ) | |
595 vim.fn.sign_define('LspDiagnosticsSignWarning', { | |
596 texthl = 'LspDiagnosticsSignWarning', | |
597 linehl = '', | |
598 numhl = '', | |
599 text = '▎', | |
600 }) | |
601 vim.fn.sign_define('LspDiagnosticsSignInformation', { | |
602 texthl = 'LspDiagnosticsSignInformation', | |
603 linehl = '', | |
604 numhl = '', | |
605 text = '▎', | |
606 }) | |
607 vim.fn.sign_define( | |
608 'LspDiagnosticsSignHint', | |
609 { texthl = 'LspDiagnosticsSignHint', linehl = '', numhl = '', text = '▎' } | |
610 ) | |
412
ad54efacea8a
Remove lspsaga in favour of built-in hover windows
zegervdv <zegervdv@me.com>
parents:
411
diff
changeset
|
611 |
ad54efacea8a
Remove lspsaga in favour of built-in hover windows
zegervdv <zegervdv@me.com>
parents:
411
diff
changeset
|
612 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
|
613 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
|
614 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
|
615 underline = true, |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
616 update_in_insert = false, |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
617 virtual_text = { severity_limit = 'Warning' }, |
32f1aecb9d01
Only show virtual_text diagnostics for Warnings or worse
zegervdv <zegervdv@me.com>
parents:
412
diff
changeset
|
618 }) |
411 | 619 end |
620 | |
621 local capabilities = vim.lsp.protocol.make_client_capabilities() | |
622 capabilities.textDocument.completion.completionItem.snippetSupport = true | |
623 capabilities.textDocument.completion.completionItem.resolveSupport = { | |
624 properties = { | |
625 'documentation', | |
626 'detail', | |
627 'additionalTextEdits', | |
628 }, | |
629 } | |
442
e830ae093010
Add capabilities from cmp_nvim_lsp
zegervdv <zegervdv@me.com>
parents:
441
diff
changeset
|
630 capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) |
411 | 631 |
632 lsp.pyright.setup { on_attach = on_attach, capabilities = capabilities } | |
633 | |
417
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
634 null_ls.config { |
411 | 635 sources = { |
636 null_ls.builtins.formatting.black, | |
637 null_ls.builtins.formatting.stylua, | |
638 }, | |
639 } | |
417
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
640 lsp['null-ls'].setup { |
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
641 on_attach = on_attach, |
8dd914d43a65
Use lspconfig to configure null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
416
diff
changeset
|
642 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
|
643 } |
411 | 644 |
645 local luadev = require('lua-dev').setup { | |
646 lspconfig = { | |
647 cmd = { 'lua-language-server' }, | |
648 on_attach = on_attach, | |
649 capabilities = capabilities, | |
650 settings = { | |
651 Lua = { | |
652 diagnostics = { | |
653 globals = { 'use' }, | |
654 }, | |
655 }, | |
656 }, | |
657 }, | |
658 } | |
659 | |
660 lsp.sumneko_lua.setup(luadev) | |
661 | |
662 -- Try importing local config | |
663 local ok, localconfig = pcall(require, 'localconfig') | |
664 if ok then | |
665 localconfig.setup { on_attach = on_attach, capabilities = capabilities } | |
666 end |