<commit_before>local M = {}

local keymap = vim.keymap.set
local wk = require("which-key")
local wk_operators = require("which-key.plugins.presets").operators

local opts = { noremap = true, silent = true }
local leader_opts = { noremap = true, silent = true, prefix = "<Leader>" }
local leader_vopts = { mode = "v", noremap = true, silent = true, prefix = "<Leader>" }
local term_opts = { silent = true }

-- Navigation
-- {{{

-- Dont move with the arrows
keymap("n", "<Up>", "<NOP>", opts)
keymap("n", "<Down>", "<NOP>", opts)
keymap("n", "<Left>", "<NOP>", opts)
keymap("n", "<Right>", "<NOP>", opts)

-- Fold movement
-- Replace the zj zk calls to move to next closed fold
wk.register({
  z = {
    j = { ":call NextClosedFold('j')<cr>", "Next closed fold" },
    k = { ":call NextClosedFold('k')<cr>", "Previous closed fold" },
  },
}, opts)

-- Tab movement
keymap("n", "<C-Left>", ":tabp<CR>", opts)
keymap("n", "<C-Right>", ":tabn<CR>", opts)

wk.register({
  t = {
    name = "+tab",
    c = { ":tabclose<cr>", "Close tab" },
    n = { ":tabn<cr>", "Next tab" },
    p = { ":tabp<cr>", "Previous tab" },
  },
}, leader_opts)

-- Split movement
keymap("n", "<C-h>", "<cmd>WinShift left<cr>", opts)
keymap("n", "<C-j>", "<cmd>WinShift down<cr>", opts)
keymap("n", "<C-k>", "<cmd>WinShift up<cr>", opts)
keymap("n", "<C-l>", "<cmd>WinShift right<cr>", opts)

-- Buffer movement
wk.register({
  ["["] = {
    b = { "<Plug>(cokeline-focus-prev)", "Goto previous buffer" },
    B = { "<Plug>(cokeline-switch-prev)", "Switch with previous buffer" },
  },
  ["]"] = {
    b = { "<Plug>(cokeline-focus-next)", "Goto next buffer" },
    B = { "<Plug>(cokeline-switch-next)", "Switch with next buffer" },
  },
}, opts)

-- File navigation
-- {{{

-- Start a :e with the dir of the current buffer already filled in
keymap("n", ",e", ":e <C-R>=Get_Relative_Cwd()<CR>", opts)
-- keymap("n", ",e", ":e <C-R>=lua require('irubataru.functions').get_file_directory()<CR>", opts)

-- File tree
keymap("n", "<C-N>", ":NvimTreeFindFileToggle<CR>", opts)

-- }}}

-- }}}

-- UI Related
-- {{{

-- Resize splits with arrows
keymap("n", "<C-Up>", ":resize -2<CR>", opts)
keymap("n", "<C-Down>", ":resize +2<CR>", opts)
keymap("n", "<C-Left>", ":vertical resize -2<CR>", opts)
keymap("n", "<C-Right>", ":vertical resize +2<CR>", opts)

-- Center the window
wk.register({
  ["<Leader><Leader>"] = { "zz", "Center view" },
}, opts)

wk.register({
  ["["] = {
    o = {
      name = "quickfix",
      q = { ":copen<cr>", "open-quickfix" },
    },
  },
  ["]"] = {
    o = {
      name = "quickfix",
      q = { ":cclose<cr>", "close-quickfix" },
    },
  },
}, opts)

keymap("n", "<C-b>", function()
  require("telescope.builtin").buffers()
end, opts)

-- Window actions
wk.register({
  ["<C-W>"] = {
    m = { "<cmd>WinShift<cr>", "Enter Win-Move mode" },
    z = { "<cmd>NeoZoomToggle<cr>", "Toggle zoom" },
  },
}, opts)

-- Disable EX mode
keymap("n", "Q", "<NOP>", opts)

-- }}}

-- Other keymaps
-- {{{

-- Yank to clipboard
keymap("n", "<leader>y", '"+y', opts)
keymap("v", "<leader>y", '"+y', opts)
keymap("n", "<leader>Y", 'gg"+yG', opts)

-- Better cursor positioning on searching
keymap("n", "n", "nzzzv", opts)
keymap("n", "N", "Nzzzv", opts)
keymap("n", "J", "miJ`i", opts)

-- Moving text
keymap("v", "<C-j>", ":m '>+1<cr>gv=gv", opts)
keymap("v", "<C-k>", ":m '<-2<cr>gv=gv", opts)
keymap("i", "<C-j>", "<esc>:m .+1<cr>==", opts)
keymap("i", "<C-k>", "<esc>:m .-2<cr>==", opts)
keymap("n", "<leader>j", ":m .+1<cr>==", opts)
keymap("n", "<leader>k", ":m .-2<cr>==", opts)

-- Undo break points
keymap("i", ",", ",<c-g>u", opts)
keymap("i", " ", " <c-g>u", opts)
keymap("i", "!", "!<c-g>u", opts)
keymap("i", "?", "?<c-g>u", opts)

-- Unknown next greatest remap
keymap("x", "<leader>p", '"_dP', opts)

-- Register replace
wk.register({
  gx = { "<Plug>ReplaceWithRegisterOperator", "Replace with register" },
  gxx = { "<Plug>ReplaceWithRegisterLine", "Replace line with register" },
}, opts)

wk.register({
  gx = { "<Plug>ReplaceWithRegisterVisual", "Replace with register" },
}, { mode = "x" })

wk_operators["gx"] = "Replace with register"

-- }}}

-- Plugin keymaps
-- {{{

wk.register({ -- Normal mode leader keymaps
  c = {
    name = "+toggle",
    b = {function() require('nvim-biscuits').toggle_biscuits() end, "Toggle biscuits"},
  },
  d = {
    name = "+diff",
    r = { ":LinediffReset<cr>", "Linediff reset" },
  },
  f = {
    name = "+find",
    b = {
      function()
        require("telescope.builtin").buffers()
      end,
      "Find buffers",
    },
    C = { "<cmd>Telescope commands<cr>", "Find commands" },
    d = {
      function()
        require("telescope.builtin").lsp_definitions()
      end,
      "Find definitions",
    },
    e = {
      function()
        require("telescope.builtin").lsp_workspace_diagnostics({ severity = 1 })
      end,
      "Find errors",
    },
    E = {
      function()
        require("telescope.builtin").lsp_workspace_diagnostics()
      end,
      "Find all diagnostics",
    },
    f = {
      function()
        require("telescope.builtin").find_files(require("telescope.themes").get_dropdown({ previewer = false }))
      end,
      "Find files",
    },
    g = {
      function()
        require("telescope.builtin").live_grep(require("telescope.themes").get_ivy())
      end,
      "Find text",
    },
    h = {
      function()
        require("telescope.builtin").help_tags()
      end,
      "Find help",
    },
    i = {
      function()
        require("telescope.builtin").lsp_implementations()
      end,
      "Find implementations",
    },
    k = { "<cmd>Telescope keymaps<cr>", "Find keymaps" },
    p = { "<cmd>Telescope projects<cr>", "Find projects" },
    r = { "<cmd>Telescope oldfiles<cr>", "Open recent file" },
    R = {
      function()
        require("telescope.builtin").lsp_references()
      end,
      "Find references",
    },
    v = {
      function()
        require("irubataru.plugins.telescope").search_dotfiles()
      end,
      "Vim dotfiles",
    },
  },
  F = {
    function()
      require("telescope.builtin").live_grep(require("telescope.themes").get_ivy())
    end,
    "Find text",
  },
  g = {
    name = "+git",
    b = {
      function()
        require("gitsigns").blame_line()
      end,
      "Blame",
    },
    c = { ":Gcommit<CR>", "git commit" },
    j = {
      function()
        require("gitsigns").next_hunk()
      end,
      "Next hunk",
    },
    k = {
      function()
        require("gitsigns").prev_hunk()
      end,
      "Prev hunk",
    },
    d = { ":Gdiffsplit<CR>", "git diff" },
    g = { ":aboveleft 16split|0Git<CR>", "git status" },
    h = { ":DiffviewFileHistory<CR>", "git file history" },
    l = { ":DiffviewOpen<CR>", "git diff log" },
  },
  i = {
    name = "+insert",
    s = { "<cmd>IconPickerNormal symbols nerd_font<cr>", "Insert symbol" },
    e = { "<cmd>IconPickerNormal emoji<cr>", "Insert emoji" },
    y = {
      name = "+yank",
      s = { "<cmd>IconPickerYank symbols nerd_font<cr>", "Yank symbol" },
      e = { "<cmd>IconPickerYank emoji<cr>", "Yank emoji" },
    }
  },
  p = {
    name = "Packer",
    c = { "<cmd>PackerCompile<cr>", "Compile" },
    i = { "<cmd>PackerInstall<cr>", "Install" },
    r = {
      function()
        require("irubataru.plugins.telescope.reload").reload()
      end,
      "Reload lua module",
    },
    R = {
      function()
        require("irubataru.functions").reload()
      end,
      "Reload all modules",
    },
    s = { "<cmd>PackerSync<cr>", "Sync" },
    S = { "<cmd>PackerStatus<cr>", "Status" },
    u = { "<cmd>PackerUpdate<cr>", "Update" },
  },
  t = {
    name = "Terminal",
    n = {
      function()
        require("irubataru.plugins.toggleterm").node_toggle()
      end,
      "Node",
    },
    g = {
      function()
        require("irubataru.plugins.toggleterm").lazy_git_toggle()
      end,
      "Lazygit",
    },
    p = {
      function()
        require("irubataru.plugins.toggleterm").python_toggle()
      end,
      "Python",
    },
    f = { "<cmd>ToggleTerm direction=float<cr>", "Float" },
    h = { "<cmd>ToggleTerm size=10 direction=horizontal<cr>", "Horizontal" },
    v = { "<cmd>ToggleTerm size=80 direction=vertical<cr>", "Vertical" },
  },
  w = {
    name = "+windows",
    G = { "<cmd>lua require('shade').toggle()<cr>", "Toggle shade" },
    o = { "<cmd>only<cr>", "Only this window" },
    w = { "<cmd>WinShift<cr>", "Enter Win-Move mode" },
    z = { "<cmd>NeoZoomToggle<cr>", "Toggle zoom" },
    ["+"] = { "<cmd>lua require('shade').brightness_up()<cr>", "Brightness up (shade)" },
    ["-"] = { "<cmd>lua require('shade').brightness_down()<cr>", "Brightness down (shade)" },
  },
  x = {
    name = "+diagnostics",
    d = { "<cmd>Trouble lsp_document_diagnostics<cr>", "Document diagnostics" },
    l = { "<cmd>Trouble loclist<cr>", "Location list" },
    q = { "<cmd>Trouble quickfix<cr>", "To quickfix list" },
    w = { "<cmd>Trouble lsp_workspace_diagnostics<cr>", "Workspace diagnostics" },
    x = { "<cmd>Trouble<cr>", "Open diagnostics" },
  },
  z = {
    name = "+folds",
    z = { ":let &scrolloff=810-&scrolloff<CR>", "toogle-scroll-distance" },
  },
}, leader_opts)<commit_msg>feat(nvim): keybinds for folding entire document<commit_after>local M = {}

local keymap = vim.keymap.set
local wk = require("which-key")
local wk_operators = require("which-key.plugins.presets").operators

local opts = { noremap = true, silent = true }
local leader_opts = { noremap = true, silent = true, prefix = "<Leader>" }
local leader_vopts = { mode = "v", noremap = true, silent = true, prefix = "<Leader>" }
local term_opts = { silent = true }

-- Navigation
-- {{{

-- Dont move with the arrows
keymap("n", "<Up>", "<NOP>", opts)
keymap("n", "<Down>", "<NOP>", opts)
keymap("n", "<Left>", "<NOP>", opts)
keymap("n", "<Right>", "<NOP>", opts)

-- Fold movement
-- Replace the zj zk calls to move to next closed fold
wk.register({
  z = {
    j = { ":call NextClosedFold('j')<cr>", "Next closed fold" },
    k = { ":call NextClosedFold('k')<cr>", "Previous closed fold" },
  },
}, opts)

-- Tab movement
keymap("n", "<C-Left>", ":tabp<CR>", opts)
keymap("n", "<C-Right>", ":tabn<CR>", opts)

wk.register({
  t = {
    name = "+tab",
    c = { ":tabclose<cr>", "Close tab" },
    n = { ":tabn<cr>", "Next tab" },
    p = { ":tabp<cr>", "Previous tab" },
  },
}, leader_opts)

-- Split movement
keymap("n", "<C-h>", "<cmd>WinShift left<cr>", opts)
keymap("n", "<C-j>", "<cmd>WinShift down<cr>", opts)
keymap("n", "<C-k>", "<cmd>WinShift up<cr>", opts)
keymap("n", "<C-l>", "<cmd>WinShift right<cr>", opts)

-- Buffer movement
wk.register({
  ["["] = {
    b = { "<Plug>(cokeline-focus-prev)", "Goto previous buffer" },
    B = { "<Plug>(cokeline-switch-prev)", "Switch with previous buffer" },
  },
  ["]"] = {
    b = { "<Plug>(cokeline-focus-next)", "Goto next buffer" },
    B = { "<Plug>(cokeline-switch-next)", "Switch with next buffer" },
  },
}, opts)

-- File navigation
-- {{{

-- Start a :e with the dir of the current buffer already filled in
keymap("n", ",e", ":e <C-R>=Get_Relative_Cwd()<CR>", opts)
-- keymap("n", ",e", ":e <C-R>=lua require('irubataru.functions').get_file_directory()<CR>", opts)

-- File tree
keymap("n", "<C-N>", ":NvimTreeFindFileToggle<CR>", opts)

-- }}}

-- }}}

-- UI Related
-- {{{

-- Resize splits with arrows
keymap("n", "<C-Up>", ":resize -2<CR>", opts)
keymap("n", "<C-Down>", ":resize +2<CR>", opts)
keymap("n", "<C-Left>", ":vertical resize -2<CR>", opts)
keymap("n", "<C-Right>", ":vertical resize +2<CR>", opts)

-- Center the window
wk.register({
  ["<Leader><Leader>"] = { "zz", "Center view" },
}, opts)

wk.register({
  ["["] = {
    o = {
      name = "quickfix",
      q = { ":copen<cr>", "open-quickfix" },
    },
  },
  ["]"] = {
    o = {
      name = "quickfix",
      q = { ":cclose<cr>", "close-quickfix" },
    },
  },
}, opts)

keymap("n", "<C-b>", function()
  require("telescope.builtin").buffers()
end, opts)

-- Window actions
wk.register({
  ["<C-W>"] = {
    m = { "<cmd>WinShift<cr>", "Enter Win-Move mode" },
    z = { "<cmd>NeoZoomToggle<cr>", "Toggle zoom" },
  },
}, opts)

-- Disable EX mode
keymap("n", "Q", "<NOP>", opts)

-- }}}

-- Other keymaps
-- {{{

-- Yank to clipboard
keymap("n", "<leader>y", '"+y', opts)
keymap("v", "<leader>y", '"+y', opts)
keymap("n", "<leader>Y", 'gg"+yG', opts)

-- Better cursor positioning on searching
keymap("n", "n", "nzzzv", opts)
keymap("n", "N", "Nzzzv", opts)
keymap("n", "J", "miJ`i", opts)

-- Moving text
keymap("v", "<C-j>", ":m '>+1<cr>gv=gv", opts)
keymap("v", "<C-k>", ":m '<-2<cr>gv=gv", opts)
keymap("i", "<C-j>", "<esc>:m .+1<cr>==", opts)
keymap("i", "<C-k>", "<esc>:m .-2<cr>==", opts)
keymap("n", "<leader>j", ":m .+1<cr>==", opts)
keymap("n", "<leader>k", ":m .-2<cr>==", opts)

-- Undo break points
keymap("i", ",", ",<c-g>u", opts)
keymap("i", " ", " <c-g>u", opts)
keymap("i", "!", "!<c-g>u", opts)
keymap("i", "?", "?<c-g>u", opts)

-- Unknown next greatest remap
keymap("x", "<leader>p", '"_dP', opts)

-- Register replace
wk.register({
  gx = { "<Plug>ReplaceWithRegisterOperator", "Replace with register" },
  gxx = { "<Plug>ReplaceWithRegisterLine", "Replace line with register" },
}, opts)

wk.register({
  gx = { "<Plug>ReplaceWithRegisterVisual", "Replace with register" },
}, { mode = "x" })

wk_operators["gx"] = "Replace with register"

-- }}}

wk.register({ -- Normal mode leader keymaps
  c = {
    name = "+toggle",
    b = {function() require('nvim-biscuits').toggle_biscuits() end, "Toggle biscuits"},
  },
  d = {
    name = "+diff",
    r = { ":LinediffReset<cr>", "Linediff reset" },
  },
  f = {
    name = "+find",
    b = {
      function()
        require("telescope.builtin").buffers()
      end,
      "Find buffers",
    },
    C = { "<cmd>Telescope commands<cr>", "Find commands" },
    d = {
      function()
        require("telescope.builtin").lsp_definitions()
      end,
      "Find definitions",
    },
    e = {
      function()
        require("telescope.builtin").lsp_workspace_diagnostics({ severity = 1 })
      end,
      "Find errors",
    },
    E = {
      function()
        require("telescope.builtin").lsp_workspace_diagnostics()
      end,
      "Find all diagnostics",
    },
    f = {
      function()
        require("telescope.builtin").find_files(require("telescope.themes").get_dropdown({ previewer = false }))
      end,
      "Find files",
    },
    g = {
      function()
        require("telescope.builtin").live_grep(require("telescope.themes").get_ivy())
      end,
      "Find text",
    },
    h = {
      function()
        require("telescope.builtin").help_tags()
      end,
      "Find help",
    },
    i = {
      function()
        require("telescope.builtin").lsp_implementations()
      end,
      "Find implementations",
    },
    k = { "<cmd>Telescope keymaps<cr>", "Find keymaps" },
    p = { "<cmd>Telescope projects<cr>", "Find projects" },
    r = { "<cmd>Telescope oldfiles<cr>", "Open recent file" },
    R = {
      function()
        require("telescope.builtin").lsp_references()
      end,
      "Find references",
    },
    v = {
      function()
        require("irubataru.plugins.telescope").search_dotfiles()
      end,
      "Vim dotfiles",
    },
  },
  F = {
    function()
      require("telescope.builtin").live_grep(require("telescope.themes").get_ivy())
    end,
    "Find text",
  },
  g = {
    name = "+git",
    b = {
      function()
        require("gitsigns").blame_line()
      end,
      "Blame",
    },
    c = { ":Gcommit<CR>", "git commit" },
    j = {
      function()
        require("gitsigns").next_hunk()
      end,
      "Next hunk",
    },
    k = {
      function()
        require("gitsigns").prev_hunk()
      end,
      "Prev hunk",
    },
    d = { ":Gdiffsplit<CR>", "git diff" },
    g = { ":aboveleft 16split|0Git<CR>", "git status" },
    h = { ":DiffviewFileHistory<CR>", "git file history" },
    l = { ":DiffviewOpen<CR>", "git diff log" },
  },
  i = {
    name = "+insert",
    s = { "<cmd>IconPickerNormal symbols nerd_font<cr>", "Insert symbol" },
    e = { "<cmd>IconPickerNormal emoji<cr>", "Insert emoji" },
    y = {
      name = "+yank",
      s = { "<cmd>IconPickerYank symbols nerd_font<cr>", "Yank symbol" },
      e = { "<cmd>IconPickerYank emoji<cr>", "Yank emoji" },
    }
  },
  p = {
    name = "Packer",
    c = { "<cmd>PackerCompile<cr>", "Compile" },
    i = { "<cmd>PackerInstall<cr>", "Install" },
    r = {
      function()
        require("irubataru.plugins.telescope.reload").reload()
      end,
      "Reload lua module",
    },
    R = {
      function()
        require("irubataru.functions").reload()
      end,
      "Reload all modules",
    },
    s = { "<cmd>PackerSync<cr>", "Sync" },
    S = { "<cmd>PackerStatus<cr>", "Status" },
    u = { "<cmd>PackerUpdate<cr>", "Update" },
  },
  t = {
    name = "Terminal",
    n = {
      function()
        require("irubataru.plugins.toggleterm").node_toggle()
      end,
      "Node",
    },
    g = {
      function()
        require("irubataru.plugins.toggleterm").lazy_git_toggle()
      end,
      "Lazygit",
    },
    p = {
      function()
        require("irubataru.plugins.toggleterm").python_toggle()
      end,
      "Python",
    },
    f = { "<cmd>ToggleTerm direction=float<cr>", "Float" },
    h = { "<cmd>ToggleTerm size=10 direction=horizontal<cr>", "Horizontal" },
    v = { "<cmd>ToggleTerm size=80 direction=vertical<cr>", "Vertical" },
  },
  w = {
    name = "+windows",
    G = { "<cmd>lua require('shade').toggle()<cr>", "Toggle shade" },
    o = { "<cmd>only<cr>", "Only this window" },
    w = { "<cmd>WinShift<cr>", "Enter Win-Move mode" },
    z = { "<cmd>NeoZoomToggle<cr>", "Toggle zoom" },
    ["+"] = { "<cmd>lua require('shade').brightness_up()<cr>", "Brightness up (shade)" },
    ["-"] = { "<cmd>lua require('shade').brightness_down()<cr>", "Brightness down (shade)" },
  },
  x = {
    name = "+diagnostics",
    d = { "<cmd>Trouble lsp_document_diagnostics<cr>", "Document diagnostics" },
    l = { "<cmd>Trouble loclist<cr>", "Location list" },
    q = { "<cmd>Trouble quickfix<cr>", "To quickfix list" },
    w = { "<cmd>Trouble lsp_workspace_diagnostics<cr>", "Workspace diagnostics" },
    x = { "<cmd>Trouble<cr>", "Open diagnostics" },
  },
  z = {
    name = "+folds",
    c = { "<cmd>set foldlevel=0<cr>", "Close all folds" },
    o = { "<cmd>set foldlevel=99<cr>", "Open all folds" },
    z = { ":let &scrolloff=810-&scrolloff<CR>", "Toggle scroll distance" },
  },
}, leader_opts)
{'fraction_non_alphanumeric': 0.22930210068231882, 'fraction_numerical': 0.0024176650727985817, 'mean_word_length': 3.003010752688172, 'pattern_counts': {'":': 54, '<': 301, '<?xml version=': 0, '>': 301, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4432029', 'n_tokens_mistral': 7019, 'n_tokens_neox': 6912, 'n_words': 1438}