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