Mercurial > dotfiles
comparison .chezmoitemplates/init.lua @ 489:1635e29e0ed4
Move autocmds to init.lua
author | zegervdv <zegervdv@me.com> |
---|---|
date | Sun, 14 Nov 2021 09:34:26 +0100 |
parents | 8edc5f86e9c3 |
children | 6d2e5337e8b2 |
comparison
equal
deleted
inserted
replaced
488:8edc5f86e9c3 | 489:1635e29e0ed4 |
---|---|
610 opt.foldminlines = 1 | 610 opt.foldminlines = 1 |
611 opt.foldtext = | 611 opt.foldtext = |
612 [[substitute(getline(v:foldstart),'\\t',repeat('\ ',&tabstop),'g').'...'.trim(getline(v:foldend)) . ' (' . (v:foldend - v:foldstart + 1) . ' lines)']] | 612 [[substitute(getline(v:foldstart),'\\t',repeat('\ ',&tabstop),'g').'...'.trim(getline(v:foldend)) . ' (' . (v:foldend - v:foldstart + 1) . ' lines)']] |
613 opt.foldenable = false | 613 opt.foldenable = false |
614 | 614 |
615 local au = require 'au' | |
616 | |
617 -- Highlight yanked text | |
618 au.TextYankPost = function() | |
619 vim.highlight.on_yank { timeout = 120 } | |
620 end | |
621 | |
622 -- Automatic cursorline | |
623 au.group('cline', { | |
624 { | |
625 'WinEnter', | |
626 '*', | |
627 function() | |
628 vim.opt_local.cursorline = true | |
629 end, | |
630 }, | |
631 { | |
632 'WinLeave', | |
633 '*', | |
634 function() | |
635 vim.opt_local.cursorline = false | |
636 end, | |
637 }, | |
638 }) | |
639 | |
640 -- Save files on focus lost | |
641 au.FocusLost = function() | |
642 if not vim.o.readonly and vim.api.nvim_buf_get_name(0) ~= '' then | |
643 vim.cmd [[ wa ]] | |
644 end | |
645 end | |
646 | |
647 -- Equalize splits after resizing | |
648 au.VimResized = [[ exe "normal! \<c-w>=" ]] | |
649 | |
650 -- Reload diffs after editing | |
651 au.BufWritePost = function() | |
652 if vim.o.diff then | |
653 vim.cmd [[ diffupdate ]] | |
654 end | |
655 end | |
656 | |
615 -- LSP config | 657 -- LSP config |
616 local lsp = require 'lspconfig' | 658 local lsp = require 'lspconfig' |
617 local null_ls = require 'null-ls' | 659 local null_ls = require 'null-ls' |
618 | 660 |
619 -- Use builtin tagfunc to query LSP | 661 -- Use builtin tagfunc to query LSP |
774 end) | 816 end) |
775 end | 817 end |
776 | 818 |
777 vim.cmd [[command! LspRename lua LspRename()]] | 819 vim.cmd [[command! LspRename lua LspRename()]] |
778 | 820 |
779 local au = require 'au' | |
780 | |
781 au.TextYankPost = function() | |
782 vim.highlight.on_yank { timeout = 120 } | |
783 end | |
784 | |
785 vim.diagnostic.config { | 821 vim.diagnostic.config { |
786 underline = true, | 822 underline = true, |
787 update_in_insert = false, | 823 update_in_insert = false, |
788 virtual_text = { severity = { min = vim.diagnostic.severity.WARN }, source = 'always' }, | 824 virtual_text = { severity = { min = vim.diagnostic.severity.WARN }, source = 'always' }, |
789 severity_sort = true, | 825 severity_sort = true, |