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