Mercurial > dotfiles
comparison .chezmoitemplates/init.lua @ 627:a2a5862a3bd3
convert more vimscript to lua
author | zegervdv <zegervdv@me.com> |
---|---|
date | Thu, 28 Jul 2022 22:25:29 +0200 |
parents | c8960ba7f019 |
children | af14855ab067 |
comparison
equal
deleted
inserted
replaced
626:f795168ece65 | 627:a2a5862a3bd3 |
---|---|
904 end, { | 904 end, { |
905 silent = true, | 905 silent = true, |
906 desc = 'Search word under cursor without moving to first results', | 906 desc = 'Search word under cursor without moving to first results', |
907 }) | 907 }) |
908 | 908 |
909 map('x', 'p', [[ p:if v:register == '"'<Bar>let @@=@0<Bar>endif<CR> ]], { silent = true }) | |
910 | |
909 map('n', '<UP>', ':cprev<CR>', { desc = 'Go to previous error/match' }) | 911 map('n', '<UP>', ':cprev<CR>', { desc = 'Go to previous error/match' }) |
910 map('n', '<DOWN>', ':cnext<CR>', { desc = 'Go to next error/match' }) | 912 map('n', '<DOWN>', ':cnext<CR>', { desc = 'Go to next error/match' }) |
911 map('n', '<LEFT>', ':cpf<CR>', { desc = 'Go to previous error/match in previous file' }) | 913 map('n', '<LEFT>', ':cpf<CR>', { desc = 'Go to previous error/match in previous file' }) |
912 map('n', '<RIGHT>', ':cnf<CR>', { desc = 'Go to next error/match in next file' }) | 914 map('n', '<RIGHT>', ':cnf<CR>', { desc = 'Go to next error/match in next file' }) |
915 | |
916 map('t', '<C-h>', '<C-\\><C-n><C-w>h') | |
917 map('t', '<C-j>', '<C-\\><C-n><C-w>j') | |
918 map('t', '<C-k>', '<C-\\><C-n><C-w>k') | |
919 map('t', '<C-l>', '<C-\\><C-n><C-w>l') | |
920 | |
921 map('c', '<CR>', function() | |
922 local cmdline = vim.fn.getcmdline() | |
923 print(cmdline) | |
924 if cmdline == 'ls' or cmdline == 'buffers' or cmdline == 'files' then return '<CR>:b' end | |
925 return '<CR>' | |
926 end, { expr = true }) | |
927 | |
928 -- Special highlighting | |
929 vim.cmd.match { 'ErrorMsg', [[ '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' ]] } | |
913 | 930 |
914 local au = require 'au' | 931 local au = require 'au' |
915 | 932 |
916 -- Highlight yanked text | 933 -- Highlight yanked text |
917 au.TextYankPost = function() vim.highlight.on_yank { timeout = 120 } end | 934 au.TextYankPost = function() vim.highlight.on_yank { timeout = 120 } end |
943 | 960 |
944 -- Reload diffs after editing | 961 -- Reload diffs after editing |
945 au.BufWritePost = function() | 962 au.BufWritePost = function() |
946 if vim.o.diff then vim.cmd.diffupdate() end | 963 if vim.o.diff then vim.cmd.diffupdate() end |
947 end | 964 end |
965 | |
966 -- Terminal | |
967 au.group('enter_term', { | |
968 { 'TermOpen', '*', 'startinsert!' }, | |
969 { | |
970 'BufEnter', | |
971 '*', | |
972 function() | |
973 if vim.bo.buftype == 'terminal' then vim.cmd.startinsert { bang = true } end | |
974 end, | |
975 }, | |
976 { | |
977 'BufLeave', | |
978 '*', | |
979 function() | |
980 if vim.bo.buftype == 'terminal' then vim.cmd.stopinsert { bang = true } end | |
981 end, | |
982 }, | |
983 }) | |
948 | 984 |
949 -- Snippets | 985 -- Snippets |
950 local ls = require 'luasnip' | 986 local ls = require 'luasnip' |
951 -- Expand snippet or jump to next placeholder | 987 -- Expand snippet or jump to next placeholder |
952 vim.keymap.set({ 'i', 's' }, '<c-k>', function() | 988 vim.keymap.set({ 'i', 's' }, '<c-k>', function() |