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