diff .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
line wrap: on
line diff
--- 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 == '"'<Bar>let @@=@0<Bar>endif<CR> ]], { silent = true })
+
 map('n', '<UP>', ':cprev<CR>', { desc = 'Go to previous error/match' })
 map('n', '<DOWN>', ':cnext<CR>', { desc = 'Go to next error/match' })
 map('n', '<LEFT>', ':cpf<CR>', { desc = 'Go to previous error/match in previous file' })
 map('n', '<RIGHT>', ':cnf<CR>', { desc = 'Go to next error/match in next file' })
 
+map('t', '<C-h>', '<C-\\><C-n><C-w>h')
+map('t', '<C-j>', '<C-\\><C-n><C-w>j')
+map('t', '<C-k>', '<C-\\><C-n><C-w>k')
+map('t', '<C-l>', '<C-\\><C-n><C-w>l')
+
+map('c', '<CR>', function()
+  local cmdline = vim.fn.getcmdline()
+  print(cmdline)
+  if cmdline == 'ls' or cmdline == 'buffers' or cmdline == 'files' then return '<CR>:b' end
+  return '<CR>'
+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