From f981cb55e97cb7896e5b39398f08a9b8c87faafa Mon Sep 17 00:00:00 2001
From: Matei Adriel <rafaeladriel11@gmail.com>
Date: Mon, 12 Sep 2022 13:48:29 +0200
Subject: [PATCH] Vim clipboard, fixed esc inside tmux and other stuff

---
 dotfiles/neovim/ftdetect/hkf.lua              |  7 +++++
 .../neovim/lua/my/helpers/wrapMovement.lua    | 21 ++++++++++++++
 .../neovim/lua/my/plugins/clipboard-image.lua | 29 +++++++++++++++++++
 dotfiles/neovim/lua/my/plugins/easymotion.lua | 10 +++++++
 4 files changed, 67 insertions(+)
 create mode 100644 dotfiles/neovim/ftdetect/hkf.lua
 create mode 100644 dotfiles/neovim/lua/my/helpers/wrapMovement.lua
 create mode 100644 dotfiles/neovim/lua/my/plugins/clipboard-image.lua
 create mode 100644 dotfiles/neovim/lua/my/plugins/easymotion.lua

diff --git a/dotfiles/neovim/ftdetect/hkf.lua b/dotfiles/neovim/ftdetect/hkf.lua
new file mode 100644
index 0000000..fdca1d4
--- /dev/null
+++ b/dotfiles/neovim/ftdetect/hkf.lua
@@ -0,0 +1,7 @@
+vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
+  group = vim.api.nvim_create_augroup("Detect hkf", {}),
+  pattern = "*.hkf",
+  callback = function()
+    vim.opt.filetype = "hkf"
+  end
+})
diff --git a/dotfiles/neovim/lua/my/helpers/wrapMovement.lua b/dotfiles/neovim/lua/my/helpers/wrapMovement.lua
new file mode 100644
index 0000000..65da948
--- /dev/null
+++ b/dotfiles/neovim/lua/my/helpers/wrapMovement.lua
@@ -0,0 +1,21 @@
+local M = {}
+
+local function swap(key)
+  vim.keymap.set("n", key, "g" .. key, { buffer = true })
+  vim.keymap.set("n", "g" .. key, key, { buffer = true })
+end
+
+-- Same as swap, but the key is aprt of an arpeggio chord
+local function swapArpeggio(key)
+  vim.keymap.set("n", "<Plug>(arpeggio-default:" .. key .. ")", "g" .. key, { buffer = true })
+  vim.keymap.set("n", "g" .. key, key, { buffer = true })
+end
+
+function M.setup()
+  swapArpeggio("j")
+  swap("k")
+  swap("0")
+  swap("$")
+end
+
+return M
diff --git a/dotfiles/neovim/lua/my/plugins/clipboard-image.lua b/dotfiles/neovim/lua/my/plugins/clipboard-image.lua
new file mode 100644
index 0000000..e26ae69
--- /dev/null
+++ b/dotfiles/neovim/lua/my/plugins/clipboard-image.lua
@@ -0,0 +1,29 @@
+local M = {}
+
+local function img_name()
+  vim.fn.inputsave()
+  local name = vim.fn.input('Name: ')
+  vim.fn.inputrestore()
+
+  if name == nil or name == '' then
+    return os.date('%y-%m-%d-%H-%M-%S')
+  end
+  return name
+end
+
+function M.setup()
+  require 'clipboard-image'.setup {
+
+    default = {
+      img_name = img_name
+    },
+    tex = {
+      img_dir = { "%:p:h", "img" },
+      affix = "\\includegraphics[]{%s}",
+    },
+  }
+
+  vim.keymap.set("n", "<leader>p", ":PasteImg<cr>")
+end
+
+return M
diff --git a/dotfiles/neovim/lua/my/plugins/easymotion.lua b/dotfiles/neovim/lua/my/plugins/easymotion.lua
new file mode 100644
index 0000000..d003407
--- /dev/null
+++ b/dotfiles/neovim/lua/my/plugins/easymotion.lua
@@ -0,0 +1,10 @@
+local M = {}
+
+function M.setup()
+  vim.keymap.set("n", "qf", "<Plug>(easymotion-bd-f)")
+  vim.keymap.set("n", "qj", "<Plug>(easymotion-overwin-f2)")
+  vim.keymap.set("n", "qw", "<Plug>(easymotion-bd-w)")
+  vim.keymap.set("n", "qL", "<Plug>(easymotion-bd-L)")
+end
+
+return M