Mercurial > dotfiles
annotate dot_config/nvim/init.lua @ 426:53a73096981a
Prefer single line comments
author | zegervdv <zegervdv@me.com> |
---|---|
date | Wed, 28 Jul 2021 18:24:39 +0200 |
parents | 10916f9b1676 |
children | 3cd158f2c6f9 |
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 | |
426 | 76 use { |
77 'b3nj5m1n/kommentary', | |
78 config = function() | |
79 require('kommentary.config').configure_language('default', { prefer_single_line_comments = true }) | |
80 end, | |
81 } | |
411 | 82 |
83 -- Undoing | |
84 use { 'sjl/gundo.vim', cmd = { 'GundoToggle' } } | |
85 | |
86 -- Parentheses etc | |
87 use { 'tpope/vim-surround' } | |
423 | 88 use { |
425
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
89 'windwp/nvim-autopairs', |
423 | 90 config = function() |
425
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
91 local npairs = require 'nvim-autopairs' |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
92 local Rule = require 'nvim-autopairs.rule' |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
93 |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
94 npairs.setup() |
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 require('nvim-autopairs.completion.compe').setup { |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
97 map_cr = true, |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
98 map_complete = true, |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
99 } |
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 npairs.add_rules { |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
102 Rule(' ', ' '):with_pair(function(opts) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
103 local pair = opts.line:sub(opts.col - 1, opts.col) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
104 return vim.tbl_contains({ '()', '[]', '{}' }, pair) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
105 end), |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
106 Rule('( ', ' )') |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
107 :with_pair(function() |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
108 return false |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
109 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
110 :with_move(function(opts) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
111 return opts.prev_char:match '.%)' ~= nil |
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 :use_key ')', |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
114 Rule('{ ', ' }') |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
115 :with_pair(function() |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
116 return false |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
117 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
118 :with_move(function(opts) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
119 return opts.prev_char:match '.%}' ~= nil |
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 :use_key '}', |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
122 Rule('[ ', ' ]') |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
123 :with_pair(function() |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
124 return false |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
125 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
126 :with_move(function(opts) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
127 return opts.prev_char:match '.%]' ~= nil |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
128 end) |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
129 :use_key ']', |
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
130 } |
423 | 131 end, |
132 } | |
411 | 133 |
134 -- Moving around within lines | |
135 use { 'wellle/targets.vim', event = 'InsertEnter *' } | |
136 | |
137 -- Searching | |
138 use { 'mhinz/vim-grepper', cmd = { 'Grepper' } } | |
139 | |
140 -- Keymaps TODO: to be removed when #13823 is merged | |
141 use { | |
142 'tjdevries/astronauta.nvim', | |
143 config = function() | |
144 require 'astronauta.keymap' | |
145 end, | |
146 } | |
147 | |
148 -- Opening files | |
149 use { 'wsdjeg/vim-fetch' } | |
150 | |
151 -- Indent lines | |
152 use { | |
153 'lukas-reineke/indent-blankline.nvim', | |
154 config = function() | |
155 vim.g.indent_blankline_buftype_exclude = { 'terminal', 'help', 'nofile' } | |
156 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
|
157 vim.g.indent_blankline_char = '│' |
411 | 158 end, |
159 } | |
160 | |
161 -- Increment/decrement | |
162 use { | |
163 'zegervdv/nrpattern.nvim', | |
164 requires = 'tpope/vim-repeat', | |
165 config = function() | |
166 local nrpattern = require 'nrpattern' | |
167 local defaults = require 'nrpattern.default' | |
168 | |
169 defaults[{ 'input', 'output' }] = { priority = 12, filetypes = { 'verilog', 'systemverilog' } } | |
170 defaults[{ "'1", "'0" }] = { priority = 9, filetypes = { 'verilog', 'systemverilog' } } | |
171 | |
172 nrpattern.setup(defaults) | |
173 end, | |
174 } | |
175 | |
176 -- Tmux | |
177 use { | |
178 'numtostr/navigator.nvim', | |
179 config = function() | |
180 require('Navigator').setup { auto_save = 'current', disable_on_zoom = true } | |
181 | |
182 local nnoremap = vim.keymap.nnoremap | |
183 nnoremap { '<c-h>', require('Navigator').left, silent = true } | |
184 nnoremap { '<c-j>', require('Navigator').down, silent = true } | |
185 nnoremap { '<c-k>', require('Navigator').up, silent = true } | |
186 nnoremap { '<c-l>', require('Navigator').right, silent = true } | |
187 end, | |
188 requires = 'tjdevries/astronauta.nvim', | |
189 after = 'astronauta.nvim', | |
190 } | |
191 | |
192 -- Completion/snippets/LSP | |
193 use { 'neovim/nvim-lspconfig' } | |
194 use { | |
195 'hrsh7th/nvim-compe', | |
196 config = function() | |
197 require('compe').setup { | |
198 enabled = true, | |
199 autocomplete = true, | |
200 debug = false, | |
201 min_length = 1, | |
202 preselect = 'enable', | |
203 throttle_time = 80, | |
204 source_timeout = 1000, | |
205 incomplete_delay = 400, | |
206 max_abbr_width = 100, | |
207 max_kind_width = 100, | |
208 max_menu_width = 100, | |
209 documentation = true, | |
210 | |
211 source = { | |
212 path = true, | |
213 buffer = true, | |
214 nvim_lsp = true, | |
415
85832377f39e
Disable compe's built-in lua completion
zegervdv <zegervdv@me.com>
parents:
413
diff
changeset
|
215 nvim_lua = false, |
411 | 216 spell = false, |
217 vsnip = true, | |
218 }, | |
219 } | |
220 | |
221 vim.cmd [[ inoremap <silent><expr> <C-y> compe#complete() ]] | |
425
10916f9b1676
Replace delimitMate with nvim-autopairs
zegervdv <zegervdv@me.com>
parents:
424
diff
changeset
|
222 vim.cmd [[ inoremap <silent><expr> <C-e> compe#close('<C-e>') ]] |
411 | 223 end, |
224 } | |
225 use { | |
226 { | |
227 'nvim-treesitter/nvim-treesitter', | |
228 config = function() | |
229 require 'nvim-treesitter.highlight' | |
230 | |
231 require('nvim-treesitter.configs').setup { | |
232 highlight = { enable = false }, | |
233 incremental_selection = { | |
234 enable = true, | |
235 keymaps = { | |
236 init_selection = 'gnn', | |
237 node_incremental = 'grn', | |
238 scope_incremental = 'grc', | |
239 node_decremental = 'grm', | |
240 }, | |
241 }, | |
242 refactor = { | |
243 highlight_definitions = { enable = true }, | |
244 smart_rename = { enable = true, keymaps = { smart_rename = 'gsr' } }, | |
245 navigation = { | |
246 enable = true, | |
247 keymaps = { goto_definition = 'gnd', list_definitions = 'gnD' }, | |
248 }, | |
249 }, | |
250 textobjects = { | |
251 move = { | |
252 enable = true, | |
253 goto_next_start = { [']]'] = '@block.outer' }, | |
254 goto_previous_start = { ['[['] = '@block.outer' }, | |
255 goto_next_end = { [']['] = '@block.outer' }, | |
256 goto_previous_end = { ['[]'] = '@block.outer' }, | |
257 }, | |
258 }, | |
259 playground = { enable = true, disable = {}, updatetime = 25, persist_queries = false }, | |
260 } | |
261 end, | |
262 }, | |
263 'nvim-treesitter/nvim-treesitter-refactor', | |
264 'nvim-treesitter/nvim-treesitter-textobjects', | |
265 { 'nvim-treesitter/playground', opt = true }, | |
266 } | |
267 use { 'hrsh7th/vim-vsnip', requires = 'hrsh7th/vim-vsnip-integ' } | |
268 use { | |
269 'rmagatti/goto-preview', | |
270 config = function() | |
271 require('goto-preview').setup {} | |
272 end, | |
273 } | |
274 use { | |
275 'jose-elias-alvarez/null-ls.nvim', | |
276 requires = 'nvim-lua/plenary.nvim', | |
277 } | |
278 use { | |
279 'folke/lua-dev.nvim', | |
280 } | |
281 | |
424 | 282 use { 'vimjas/vim-python-pep8-indent', ft = { 'python' } } |
283 | |
411 | 284 -- Vanity |
285 use { | |
286 'yamatsum/nvim-web-nonicons', | |
287 requires = 'kyazdani42/nvim-web-devicons', | |
288 config = function() | |
289 require 'nvim-nonicons' | |
290 end, | |
291 } | |
292 | |
293 use { | |
294 'glepnir/galaxyline.nvim', | |
295 branch = 'main', | |
296 -- your statusline | |
297 config = function() | |
298 local gl = require 'galaxyline' | |
299 local colors = require('galaxyline.theme').default | |
300 local condition = require 'galaxyline.condition' | |
301 local gls = gl.section | |
302 | |
303 colors.bg = '#2C323C' | |
304 | |
305 gls.left[1] = { | |
306 RainbowRed = { | |
307 provider = function() | |
308 return '▊ ' | |
309 end, | |
310 highlight = { colors.blue, colors.bg }, | |
311 }, | |
312 } | |
313 | |
314 gls.left[2] = { | |
315 FileIcon = { | |
316 provider = 'FileIcon', | |
317 condition = condition.buffer_not_empty, | |
318 highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, colors.bg }, | |
319 }, | |
320 } | |
321 | |
322 gls.left[3] = { | |
323 FileName = { | |
324 provider = 'FileName', | |
325 condition = condition.buffer_not_empty, | |
326 highlight = { colors.magenta, colors.bg, 'bold' }, | |
327 }, | |
328 } | |
329 | |
330 gls.right[1] = { | |
331 ShowLspClient = { | |
332 provider = 'GetLspClient', | |
333 condition = function() | |
334 local tbl = { ['dashboard'] = true, [''] = true } | |
335 if tbl[vim.bo.filetype] then | |
336 return false | |
337 end | |
338 return true | |
339 end, | |
340 icon = require('nvim-nonicons').get 'server' .. ' LSP:', | |
341 highlight = { colors.green, colors.bg, 'bold' }, | |
342 }, | |
343 } | |
344 | |
345 gls.right[2] = { | |
346 LineInfo = { | |
347 provider = 'LineColumn', | |
348 separator = ' ', | |
349 separator_highlight = { 'NONE', colors.bg }, | |
350 highlight = { colors.fg, colors.bg }, | |
351 }, | |
352 } | |
353 | |
354 gls.right[3] = { | |
355 PerCent = { | |
356 provider = 'LinePercent', | |
357 separator = ' ', | |
358 separator_highlight = { 'NONE', colors.bg }, | |
359 highlight = { colors.fg, colors.bg, 'bold' }, | |
360 }, | |
361 } | |
362 gls.right[8] = { | |
363 RainbowBlue = { | |
364 provider = function() | |
365 return ' ▊' | |
366 end, | |
367 highlight = { colors.blue, colors.bg }, | |
368 }, | |
369 } | |
370 | |
371 gls.short_line_left[1] = { | |
372 BufferType = { | |
373 provider = 'FileTypeName', | |
374 separator = ' ', | |
375 separator_highlight = { 'NONE', colors.bg }, | |
376 highlight = { colors.blue, colors.bg, 'bold' }, | |
377 }, | |
378 } | |
379 | |
380 gls.short_line_left[2] = { | |
381 SFileName = { | |
382 provider = 'SFileName', | |
383 condition = condition.buffer_not_empty, | |
384 highlight = { colors.fg, colors.bg, 'bold' }, | |
385 }, | |
386 } | |
387 | |
388 gls.short_line_right[1] = { | |
389 BufferIcon = { provider = 'BufferIcon', highlight = { colors.fg, colors.bg } }, | |
390 } | |
391 end, | |
392 } | |
393 | |
394 -- File navigation | |
395 use { 'justinmk/vim-dirvish' } | |
396 | |
397 -- Colorscheme | |
398 use { | |
399 'zegervdv/one-lush', | |
400 requires = 'rktjmp/lush.nvim', | |
401 config = function() | |
402 require 'lush_theme.one-lush' | |
403 vim.cmd [[ colorscheme one-lush ]] | |
404 end, | |
405 } | |
406 | |
407 -- Terminal | |
408 use { | |
409 'akinsho/nvim-toggleterm.lua', | |
410 config = function() | |
411 require('toggleterm').setup { | |
412 size = 15, | |
413 open_mapping = [[<F12>]], | |
414 shade_filetypes = { 'none' }, | |
415 shade_terminals = true, | |
416 persist_size = true, | |
417 direction = 'horizontal', | |
418 } | |
419 end, | |
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 | |
480 opt.wildmode = { longest = 'full', 'full' } -- Complete the fullest match | |
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 |