# HG changeset patch # User zegervdv # Date 1659039929 -7200 # Node ID a2a5862a3bd3b168e4d942454f56f81b64f0565c # Parent f795168ece65081172aa81be9da2f7c8a989e8c3 convert more vimscript to lua diff -r f795168ece65 -r a2a5862a3bd3 .chezmoitemplates/config.vim --- a/.chezmoitemplates/config.vim Tue Jul 26 22:33:25 2022 +0200 +++ b/.chezmoitemplates/config.vim Thu Jul 28 22:25:29 2022 +0200 @@ -25,38 +25,21 @@ " Mappings -" Highlight VCS conflict markers -match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' -" Search for selected text, forwards or backwards. -vnoremap * : - \let old_reg=getreg('"')let old_regtype=getregtype('"') - \gvy/=substitute( - \escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g') - \gV:call setreg('"', old_reg, old_regtype) -vnoremap # : - \let old_reg=getreg('"')let old_regtype=getregtype('"') - \gvy?=substitute( - \escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g') - \gV:call setreg('"', old_reg, old_regtype) - -xnoremap p p:if v:register == '"'let @@=@0endif - - -if has('nvim') - tnoremap h - tnoremap j - tnoremap k - tnoremap l - augroup enter_term - au! - autocmd TermOpen * startinsert! - autocmd BufEnter * if &buftype ==# 'terminal' | :startinsert! | endif - autocmd BufLeave * if &buftype ==# 'terminal' | :stopinsert! | endif - augroup END - let $GIT_EDITOR = 'nvr -cc split --remote-wait' -endif +" if has('nvim') +" tnoremap h +" tnoremap j +" tnoremap k +" tnoremap l +" augroup enter_term +" au! +" autocmd TermOpen * startinsert! +" autocmd BufEnter * if &buftype ==# 'terminal' | :startinsert! | endif +" autocmd BufLeave * if &buftype ==# 'terminal' | :stopinsert! | endif +" augroup END +" let $GIT_EDITOR = 'nvr -cc split --remote-wait' +" endif " @@ -129,7 +112,7 @@ return "\" endif endfunction -cnoremap CCR() +" cnoremap CCR() " " Filetype specific settings diff -r f795168ece65 -r a2a5862a3bd3 .chezmoitemplates/init.lua --- a/.chezmoitemplates/init.lua Tue Jul 26 22:33:25 2022 +0200 +++ b/.chezmoitemplates/init.lua Thu Jul 28 22:25:29 2022 +0200 @@ -906,11 +906,28 @@ desc = 'Search word under cursor without moving to first results', }) +map('x', 'p', [[ p:if v:register == '"'let @@=@0endif ]], { silent = true }) + map('n', '', ':cprev', { desc = 'Go to previous error/match' }) map('n', '', ':cnext', { desc = 'Go to next error/match' }) map('n', '', ':cpf', { desc = 'Go to previous error/match in previous file' }) map('n', '', ':cnf', { desc = 'Go to next error/match in next file' }) +map('t', '', 'h') +map('t', '', 'j') +map('t', '', 'k') +map('t', '', 'l') + +map('c', '', function() + local cmdline = vim.fn.getcmdline() + print(cmdline) + if cmdline == 'ls' or cmdline == 'buffers' or cmdline == 'files' then return ':b' end + return '' +end, { expr = true }) + +-- Special highlighting +vim.cmd.match { 'ErrorMsg', [[ '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' ]] } + local au = require 'au' -- Highlight yanked text @@ -946,6 +963,25 @@ if vim.o.diff then vim.cmd.diffupdate() end end +-- Terminal +au.group('enter_term', { + { 'TermOpen', '*', 'startinsert!' }, + { + 'BufEnter', + '*', + function() + if vim.bo.buftype == 'terminal' then vim.cmd.startinsert { bang = true } end + end, + }, + { + 'BufLeave', + '*', + function() + if vim.bo.buftype == 'terminal' then vim.cmd.stopinsert { bang = true } end + end, + }, +}) + -- Snippets local ls = require 'luasnip' -- Expand snippet or jump to next placeholder