From a6fb4ffbb2f51849bb49797fc15dcd2e64139ea3 Mon Sep 17 00:00:00 2001
From: Matei Adriel <rafaeladriel11@gmail.com>
Date: Thu, 13 Oct 2022 01:05:38 +0200
Subject: [PATCH] Big backup I guess

---
 dotfiles/neovim/ftplugin/lua.lua              | 34 ++++++++++++++++
 dotfiles/neovim/ftplugin/tex.lua              | 16 +++++++-
 dotfiles/neovim/lua/my/keymaps.lua            | 11 +++++
 dotfiles/neovim/lua/my/paq.lua                |  5 ++-
 dotfiles/neovim/lua/my/plugins/cmp.lua        | 12 ++----
 dotfiles/neovim/lua/my/plugins/easymotion.lua |  9 ++---
 dotfiles/neovim/lua/my/plugins/init.lua       | 12 +++++-
 dotfiles/neovim/lua/my/plugins/luasnip.lua    | 17 ++++++++
 dotfiles/neovim/lua/my/plugins/neogit.lua     |  3 ++
 dotfiles/neovim/lua/my/plugins/surround.lua   |  8 ++++
 dotfiles/tmux/tmux.conf                       |  3 +-
 .../vscode-snippets/snippets/latex/core.json  | 40 +++++--------------
 flake.lock                                    | 18 ++++-----
 13 files changed, 130 insertions(+), 58 deletions(-)
 create mode 100644 dotfiles/neovim/ftplugin/lua.lua
 create mode 100644 dotfiles/neovim/lua/my/plugins/luasnip.lua
 create mode 100644 dotfiles/neovim/lua/my/plugins/surround.lua

diff --git a/dotfiles/neovim/ftplugin/lua.lua b/dotfiles/neovim/ftplugin/lua.lua
new file mode 100644
index 0000000..5427c03
--- /dev/null
+++ b/dotfiles/neovim/ftplugin/lua.lua
@@ -0,0 +1,34 @@
+local opts = function(desc)
+  return { desc = desc, buffer = true }
+end
+
+vim.keymap.set("n", "<leader>lf", ":source %<cr>", opts("Run current lua file"))
+vim.keymap.set("n", "<leader>ls", function()
+  local path = vim.api.nvim_buf_get_name(0)
+  local status, M = pcall(dofile, path)
+
+  if status then
+    if M ~= nil then
+      if type(M.setup) == "function" then
+        M.setup()
+        print("M.setup() executed succesfully!")
+      else
+        print("Module does not return a setup function")
+      end
+    else
+      print("Module returned nil")
+    end
+  else
+    print("Cannot import current file :(")
+  end
+end, opts("Run .setup() in current file"))
+
+local status, wk = pcall(require, "which-key")
+
+if status then
+  wk.register({
+    ["<leader>l"] = {
+      name = "Local commands"
+    }
+  })
+end
diff --git a/dotfiles/neovim/ftplugin/tex.lua b/dotfiles/neovim/ftplugin/tex.lua
index ac10e23..332ea40 100644
--- a/dotfiles/neovim/ftplugin/tex.lua
+++ b/dotfiles/neovim/ftplugin/tex.lua
@@ -25,6 +25,14 @@ local abbreviations = {
   { "lam", "\\lambda" },
   { "nuls", "\\varnothing" },
 
+  -- Other fancy symvols
+  { "ints", "\\mathbb{I}" },
+  { "nats", "\\mathbb{N}" },
+  { "rats", "\\mathbb{Q}" },
+  { "rreal", "\\mathbb{R}" },
+  { "ffield", "\\mathbb{F}" },
+  { "ccom", "\\mathbb{C}" },
+
   -- Exponents
   { "ei", "^{-1}" },
   { "e0", "^{0}" },
@@ -38,7 +46,6 @@ local abbreviations = {
   { "tmat", "^{T}" }, -- Tranpose of a matrix
   { "etp", "^{+}" },
 
-
   -- Subscripts
   { "s0", "_{0}" },
   { "s1", "_{1}" },
@@ -80,6 +87,8 @@ local abbreviations = {
   { "lor", "\\lor" },
   { "ssin", "\\sin" },
   { "ccos", "\\cos" },
+  { "ttan", "\\ttan" },
+  { "ssec", "\\sec" },
   { "lln", "\\ln" },
   { "frl", "\\forall" },
   { "exs", "\\exists" },
@@ -96,13 +105,16 @@ local abbreviations = {
   { "smul", "\\times" },
   { "texpl", "&& \\text{}" },
   { "card", "\\#" },
+  { "div", "|" },
+  { "ndiv", "\\not|\\:" },
 
   -- words
   { "rref", "reduced row echalon form" }
 }
 
 local abolishAbbreviations = {
-  { "egv{a,e}{,s}", "eigenv{alue,ector}{}" }
+  { "egv{a,e}{,s}", "eigenv{alue,ector}{}" },
+  { "ib{p,s}", "integration by {parts,substitution}" }
 }
 
 AB.abolishMany(abolishAbbreviations)
diff --git a/dotfiles/neovim/lua/my/keymaps.lua b/dotfiles/neovim/lua/my/keymaps.lua
index f13bef2..e581745 100644
--- a/dotfiles/neovim/lua/my/keymaps.lua
+++ b/dotfiles/neovim/lua/my/keymaps.lua
@@ -26,6 +26,13 @@ function M.move(from, to, opts)
   vim.keymap.set("n", from, "<Nop>")
 end
 
+function M.delimitedTextobject(from, to, name, perhapsOpts)
+  local opts = helpers.mergeTables(perhapsOpts or {}, { desc = name })
+
+  vim.keymap.set({ "v", "o" }, "i" .. from, "i" .. to, opts)
+  vim.keymap.set({ "v", "o" }, "a" .. from, "a" .. to, opts)
+end
+
 function M.setup()
   M.move("q", "yq", { desc = "Record macro" })
   M.move("Q", "yQ")
@@ -36,6 +43,10 @@ function M.setup()
     desc = "Replace word in file"
   })
 
+  M.delimitedTextobject("q", '"', "quotes")
+  M.delimitedTextobject("a", "'", "'")
+  M.delimitedTextobject("r", "[", "square brackets")
+
   -- Create chords
   if arpeggio ~= nil then
     arpeggio.chordSilent("n", "ji", ":silent :write<cr>") -- Saving
diff --git a/dotfiles/neovim/lua/my/paq.lua b/dotfiles/neovim/lua/my/paq.lua
index c22c119..9cf8a92 100644
--- a/dotfiles/neovim/lua/my/paq.lua
+++ b/dotfiles/neovim/lua/my/paq.lua
@@ -59,10 +59,13 @@ function M.setup()
     "lewis6991/impatient.nvim", -- faster startup times
     "tpope/vim-abolish", -- abbreviations on steroids
     "mrjones2014/smart-splits.nvim", -- the name says it all
+    "phaazon/mind.nvim", -- Organize shit as trees
+    "bfredl/nvim-luadev", -- lua repl thingy
+    "akinsho/toggleterm.nvim", -- cool terminal thingy
 
     -- Git stuff
     "ruifm/gitlinker.nvim", -- generate permalinks for code
-    -- "TimUntersberger/neogit" -- magit clone
+    { "TimUntersberger/neogit", opt = true } -- magit clone
   }
 
   table.insert(base, 2, { "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" })
diff --git a/dotfiles/neovim/lua/my/plugins/cmp.lua b/dotfiles/neovim/lua/my/plugins/cmp.lua
index f2ee2c9..0a40da5 100644
--- a/dotfiles/neovim/lua/my/plugins/cmp.lua
+++ b/dotfiles/neovim/lua/my/plugins/cmp.lua
@@ -11,7 +11,7 @@ end
 function M.setup()
   local cmp = require("cmp")
   local lspkind = require('lspkind')
-  local luasnip = require("luasnip")
+  -- local luasnip = require("luasnip")
 
   local options = {
     window = {
@@ -44,22 +44,18 @@ function M.setup()
       end
     },
     mapping = {
-      ["<Tab>"] = cmp.mapping(function(fallback)
+      ["<C-d>"] = cmp.mapping(function(fallback)
         if cmp.visible() then
           cmp.select_next_item()
-        elseif luasnip.expand_or_jumpable() then
-          luasnip.expand_or_jump()
         elseif has_words_before() then
           cmp.complete()
         else
           fallback()
         end
       end, { "i", "s" }),
-      ["<S-Tab>"] = cmp.mapping(function(fallback)
+      ["<C-s>"] = cmp.mapping(function(fallback)
         if cmp.visible() then
           cmp.select_prev_item()
-        elseif luasnip.jumpable(-1) then
-          luasnip.jump(-1)
         else
           fallback()
         end
@@ -73,8 +69,6 @@ function M.setup()
     }, { { name = 'buffer' } })
   }
 
-  cmp.setup(options)
-
   -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
   cmp.setup.cmdline('/', {
     mapping = cmp.mapping.preset.cmdline(),
diff --git a/dotfiles/neovim/lua/my/plugins/easymotion.lua b/dotfiles/neovim/lua/my/plugins/easymotion.lua
index b2bdb69..61be052 100644
--- a/dotfiles/neovim/lua/my/plugins/easymotion.lua
+++ b/dotfiles/neovim/lua/my/plugins/easymotion.lua
@@ -7,11 +7,10 @@ function M.setup()
       silent = true
     }
   end
-  -- vim.keymap.set("n", "q", "<Plug>(easymotion-prefix)")
-  vim.keymap.set("n", "qf", "<Plug>(easymotion-bd-f)", opts("Hop to char"))
-  vim.keymap.set("n", "qj", "<Plug>(easymotion-overwin-f2)", opts("Hop to char pair"))
-  vim.keymap.set("n", "qw", ":silent <Plug>(easymotion-bd-w)", opts("Hop to word"))
-  vim.keymap.set("n", "qL", "silent <Plug>(easymotion-bd-L)", opts("Hop to line (?)"))
+  vim.keymap.set({ "n", "v", "o" }, "qf", "<Plug>(easymotion-bd-f)", opts("Hop to char"))
+  vim.keymap.set({ "n", "v", "o" }, "qj", "<Plug>(easymotion-overwin-f2)", opts("Hop to char pair"))
+  vim.keymap.set({ "n", "v", "o" }, "qw", ":silent <Plug>(easymotion-bd-w)", opts("Hop to word"))
+  vim.keymap.set({ "n", "v", "o" }, "qL", "silent <Plug>(easymotion-bd-L)", opts("Hop to line (?)"))
 
   local status, wk = pcall(require, "which-key")
 
diff --git a/dotfiles/neovim/lua/my/plugins/init.lua b/dotfiles/neovim/lua/my/plugins/init.lua
index a352803..eabc966 100644
--- a/dotfiles/neovim/lua/my/plugins/init.lua
+++ b/dotfiles/neovim/lua/my/plugins/init.lua
@@ -13,11 +13,15 @@ function M.setup()
       require("my.plugins.lualine").setup()
       require("my.plugins.vimux").setup()
       require("my.plugins.whichkey").setup()
+      require("toggleterm").setup()
+
+      require("my.plugins.neogit").setup()
     end)
 
     require("my.plugins.dashboard").setup()
     require("my.plugins.treesitter").setup()
     require("my.plugins.cmp").setup()
+    require("my.plugins.luasnip").setup()
     require("my.plugins.lspconfig").setup()
     require("my.plugins.null-ls").setup()
     require("my.plugins.vimtex").setup()
@@ -28,16 +32,22 @@ function M.setup()
     require("my.plugins.firevim").setup()
   else
     require("gitlinker").setup()
-    -- require("my.plugins.neogit").setup()
     require("my.plugins.paperplanes").setup()
   end
 
   require("my.plugins.easymotion").setup()
   require("my.plugins.autopairs").setup()
   require("my.plugins.telescope").setup()
+  require("my.plugins.surround").setup()
 
   require("my.plugins.hydra").setup()
   require("my.plugins.clipboard-image").setup()
+  require("mind").setup({
+    persistence = {
+      state_path = "~/Mind/mind.json",
+      data_dir = "~/Mind/data"
+    }
+  })
 
   -- require("my.plugins.slam").setup()
 end
diff --git a/dotfiles/neovim/lua/my/plugins/luasnip.lua b/dotfiles/neovim/lua/my/plugins/luasnip.lua
new file mode 100644
index 0000000..54c0b57
--- /dev/null
+++ b/dotfiles/neovim/lua/my/plugins/luasnip.lua
@@ -0,0 +1,17 @@
+local M = {}
+local luasnip = require("luasnip")
+
+function M.setup()
+  vim.keymap.set("i", "<Tab>", function()
+    if luasnip.jumpable(1) then
+      return "<cmd>lua require('luasnip').jump(1)<cr>"
+    else
+      return "<Tab>"
+    end
+  end, { expr = true })
+  vim.keymap.set("i", "<S-Tab>", function()
+    luasnip.jump(-1)
+  end)
+end
+
+return M
diff --git a/dotfiles/neovim/lua/my/plugins/neogit.lua b/dotfiles/neovim/lua/my/plugins/neogit.lua
index b3c6811..42c6e60 100644
--- a/dotfiles/neovim/lua/my/plugins/neogit.lua
+++ b/dotfiles/neovim/lua/my/plugins/neogit.lua
@@ -1,6 +1,9 @@
 local M = {}
 
 function M.setup()
+  -- This is here because we do not want to use neogit inside firenvim or vscode!
+  vim.cmd [[packadd! neogit]]
+
   local neogit = require("neogit")
 
   neogit.setup()
diff --git a/dotfiles/neovim/lua/my/plugins/surround.lua b/dotfiles/neovim/lua/my/plugins/surround.lua
new file mode 100644
index 0000000..3c6b099
--- /dev/null
+++ b/dotfiles/neovim/lua/my/plugins/surround.lua
@@ -0,0 +1,8 @@
+local M = {}
+
+function M.setup()
+  vim.g.surround_113 = '"\r"'
+  vim.g.surround_97 = "'\r'"
+end
+
+return M
diff --git a/dotfiles/tmux/tmux.conf b/dotfiles/tmux/tmux.conf
index 55140db..b938902 100644
--- a/dotfiles/tmux/tmux.conf
+++ b/dotfiles/tmux/tmux.conf
@@ -53,8 +53,9 @@ bind -T copy-mode-vi y send-keys -X copy-selection
 
 # Smart pane switching with awareness of Vim splits.
 # See: https://github.com/christoomey/vim-tmux-navigator
+# Also see: https://github.com/christoomey/vim-tmux-navigator/issues/264
 is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
-    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
+    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|\.?n?vim?x?(-wrapped)?)(diff)?$'"
 bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h'  'select-pane -L'
 bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j'  'select-pane -D'
 bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k'  'select-pane -U'
diff --git a/dotfiles/vscode-snippets/snippets/latex/core.json b/dotfiles/vscode-snippets/snippets/latex/core.json
index e96fb13..2b0e4b4 100644
--- a/dotfiles/vscode-snippets/snippets/latex/core.json
+++ b/dotfiles/vscode-snippets/snippets/latex/core.json
@@ -178,36 +178,6 @@
     "description": "Create a ln call",
     "body": "\\ln($1)$0"
   },
-  "Real numbers": {
-    "prefix": "reals",
-    "description": "ℝ",
-    "body": "\\mathbb{R}"
-  },
-  "Complex numbers": {
-    "prefix": "complex",
-    "description": "Fancy C symbol",
-    "body": "\\mathbb{C}"
-  },
-  "Natural numbers": {
-    "prefix": "nats",
-    "description": "ℕ",
-    "body": "\\mathbb{N}"
-  },
-  "Integers": {
-    "prefix": "ints",
-    "description": "ℤ",
-    "body": "\\mathbb{Z}"
-  },
-  "Rationals": {
-    "prefix": "rats",
-    "description": "ℚ",
-    "body": "\\mathbb{Q}"
-  },
-  "Fields": {
-    "prefix": "fields",
-    "description": "Fanch F symbol",
-    "body": "\\mathbb{F}"
-  },
   "Aligned": {
     "prefix": "aligned",
     "description": "Create an aligned environment",
@@ -290,5 +260,15 @@
       "\\\\\\ $3 & $4",
       "\\end{vmatrix}$0"
     ]
+  },
+  "Definite integral": {
+    "prefix": "dintegral",
+    "description": "Definite integral",
+    "body": "\\int_{$1}^{$2} $3 d${4:x}$0"
+  },
+  "Indefinite integral": {
+    "prefix": "integral",
+    "description": "Integral",
+    "body": "\\int $1 d${2:x}$0"
   }
 }
diff --git a/flake.lock b/flake.lock
index d0e433c..ae6c9e5 100644
--- a/flake.lock
+++ b/flake.lock
@@ -203,11 +203,11 @@
     },
     "flake-utils_3": {
       "locked": {
-        "lastModified": 1644229661,
-        "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
+        "lastModified": 1659877975,
+        "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
         "owner": "numtide",
         "repo": "flake-utils",
-        "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
+        "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
         "type": "github"
       },
       "original": {
@@ -529,11 +529,11 @@
       },
       "locked": {
         "dir": "contrib",
-        "lastModified": 1662451801,
-        "narHash": "sha256-/k86NFXnZEcVXNzDdifxd9cQ5gZzLc0qqNDztYmM+mg=",
+        "lastModified": 1665548414,
+        "narHash": "sha256-MZTZLz4DTGnehY6JCbJzx9EtvNuOPg/dOMvMKawaFBY=",
         "owner": "neovim",
         "repo": "neovim",
-        "rev": "5b8d6e0b3200c5cb9d98cbdb4ed0afe2b4edd38d",
+        "rev": "f175ca9f7cc29054b1c6fe1fd1076edd78af5684",
         "type": "github"
       },
       "original": {
@@ -552,11 +552,11 @@
         ]
       },
       "locked": {
-        "lastModified": 1662452250,
-        "narHash": "sha256-0qP89RrJ71sj6/oWRuC5oJXZ+q37DovGUworw46O15s=",
+        "lastModified": 1665562768,
+        "narHash": "sha256-/2wag5vXeieg7YRR431tMaZwB9oAnrQ2Hy7zriRWjd4=",
         "owner": "nix-community",
         "repo": "neovim-nightly-overlay",
-        "rev": "ffbbedc805ee3e7bf5937dd4f5140bd542de6751",
+        "rev": "e3841a95c1b6bb49ef634ed496c9489c5f48d8cf",
         "type": "github"
       },
       "original": {