comparison dot_config/nvim/init.lua @ 423:5683e8e3e361

Use lua to configure
author zegervdv <zegervdv@me.com>
date Sun, 25 Jul 2021 18:16:46 +0200
parents 24330d37c9e3
children f42ea4c4a78c
comparison
equal deleted inserted replaced
422:24330d37c9e3 423:5683e8e3e361
54 -- Spelling/autocorrection 54 -- Spelling/autocorrection
55 use { 'tpope/vim-abolish' } 55 use { 'tpope/vim-abolish' }
56 56
57 -- Git/VCS 57 -- Git/VCS
58 use { 'vim-scripts/gitignore' } 58 use { 'vim-scripts/gitignore' }
59 use { 'sjl/splice.vim', opt = true, cmd = { 'SpliceInit' } } 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 }
60 use { 'tpope/vim-git' } 73 use { 'tpope/vim-git' }
61 74
62 -- Comments 75 -- Comments
63 use { 'b3nj5m1n/kommentary' } 76 use { 'b3nj5m1n/kommentary' }
64 77
65 -- Undoing 78 -- Undoing
66 use { 'sjl/gundo.vim', cmd = { 'GundoToggle' } } 79 use { 'sjl/gundo.vim', cmd = { 'GundoToggle' } }
67 80
68 -- Parentheses etc 81 -- Parentheses etc
69 use { 'tpope/vim-surround' } 82 use { 'tpope/vim-surround' }
70 use { 'raimondi/delimitMate' } 83 use {
84 'raimondi/delimitMate',
85 config = function()
86 vim.g.delimitMate_expand_cr = 1
87 vim.g.delimitMate_expand_space = 1
88 end,
89 }
71 90
72 -- Moving around within lines 91 -- Moving around within lines
73 use { 'wellle/targets.vim', event = 'InsertEnter *' } 92 use { 'wellle/targets.vim', event = 'InsertEnter *' }
74 93
75 -- Searching 94 -- Searching
359 -- Filetypes 378 -- Filetypes
360 use { 'lepture/vim-jinja' } 379 use { 'lepture/vim-jinja' }
361 end) 380 end)
362 end, 0) 381 end, 0)
363 382
383 -- Configuration
384 local opt = vim.opt
385
386 opt.backspace = { 'indent', 'eol', 'start' } -- Backspace everything
387
388 opt.autoread = true -- Read changed files
389 opt.hidden = true -- Allow to move away from modified files
390 opt.autowriteall = true -- Write changes when losing focus
391
392 -- Visuals
393 opt.number = true
394 opt.relativenumber = true
395 opt.scrolloff = 4
396 opt.showcmd = true -- Show incomplete commands while typing
397
398 opt.termguicolors = true
399 opt.background = 'dark'
400
401 opt.showmatch = true -- Highligh matching braces
402
403 opt.wrap = true -- Wrap lines
404 opt.wrapmargin = 2 -- Stay 2 chars from side
405 opt.textwidth = 79
406 opt.colorcolumn = '81' -- Show indication of 81 chars
407 opt.linebreak = true -- Smarter wrapping
408 opt.breakindent = true -- Indent wrapped lines to same level
409
410 opt.fixendofline = true -- Add EOL when missing
411
412 opt.expandtab = true -- Add spaces when pressing tab
413 opt.tabstop = 2 -- Tab is 2 spaces
414 opt.shiftwidth = 2 -- Shift per 2 spaces
415 opt.shiftround = true -- Round shifts to allign (1 space + tab = 2 spaces)
416
417 -- Searching and substitute
418 opt.magic = true -- Enable regexes
419 opt.hlsearch = true -- Highlight all matches
420 opt.incsearch = true -- Show matches while typing
421 opt.ignorecase = true
422 opt.smartcase = true -- When search pattern contains cases, be case sensitive
423 opt.gdefault = true -- Use global flag for substitute: replace all matches on line
424 opt.inccommand = 'nosplit' -- Show live replacements directly in text
425
426 opt.autoindent = true
427 opt.cindent = true -- C-syntax based indenting
428
429 opt.updatetime = 300 -- Faster triggering of CursorHold events
430
431 opt.errorbells = false -- Don't you beep to me
432
433 opt.history = 1000 -- Remember last commands
434
435 opt.wildmenu = true -- Command completion
436 opt.wildmode = { longest = 'full', 'full' } -- Complete the fullest match
437 opt.shortmess:append 'c' -- Hide ins-completion messages
438
439 opt.ttyfast = true -- fast terminal
440 opt.lazyredraw = true
441 opt.ttimeoutlen = -1 -- Minimum timeout
442
443 opt.diffopt:append 'iwhite' -- Ignore whitespace in diffs
444 opt.diffopt:append 'internal' -- Internal diff engine
445 opt.diffopt:append 'algorithm:patience' -- Use patience algorithm
446
447 opt.tags = { '.git/tags', 'tags' }
448
449 opt.path:append '**' -- Recursively search current directory
450
451 opt.formatoptions = {
452 c = true, -- Wrap comments
453 r = true, -- Continue comments
454 o = true, -- Insert comment with o/O
455 q = true, -- Format comments with gq
456 n = true, -- Indent numbered lists
457 [2] = true, -- Indent from 2nd line of paragraph
458 [1] = true, -- Don't break before one letter words
459 }
460
461 opt.signcolumn = 'yes' -- Always show signcolumn
462
463 opt.cursorline = true
464
465 -- Show certain characters
466 opt.list = true
467 opt.listchars = { trail = 'ยท', extends = '>', precedes = '<', nbsp = '+' }
468
469 opt.sessionoptions:remove 'options' -- Remove options from saved sessions (reload from config)
470
471 opt.completeopt = { 'menu', 'menuone', 'noselect' }
472
473 opt.splitright = true -- Open new splits to right
474 opt.virtualedit = 'block' -- Enable block editting
475
476 opt.conceallevel = 0 -- Disable conceal
477
478 opt.pastetoggle = '<F2>' -- Enable paste mode
479
480 opt.undofile = true -- Persistently remember undos
481 opt.undolevels = 1000
482 opt.undodir = os.getenv 'HOME' .. '/.config/nvim/tmp/undo//'
483 opt.swapfile = false -- Disable swap files
484 opt.backup = true -- Keep backups
485 opt.backupdir = os.getenv 'HOME' .. '/.config/nvim/tmp/backup//'
486
487 -- Files to ignore from completion
488 opt.wildignore:append {
489 '*/tmp/*',
490 '*.so',
491 '*.swp',
492 '*.zip',
493 '*.o',
494 '*.bin',
495 '*.elf',
496 '*.hex',
497 '*.eps',
498 '.git/*',
499 '*.dup',
500 '.hg/**',
501 '*.orig',
502 '*.*~',
503 }
504
505 opt.mouse = {
506 n = true, -- Normal mode
507 i = true, -- Insert mode
508 c = true, -- Commandline mode
509 }
510
364 -- LSP config 511 -- LSP config
365 local lsp = require 'lspconfig' 512 local lsp = require 'lspconfig'
366 local null_ls = require 'null-ls' 513 local null_ls = require 'null-ls'
367 514
368 local on_attach = function(client) 515 local on_attach = function(client)