<commit_before>local opts = { noremap = true, silent = true }
local keymap = vim.api.nvim_set_keymap

-- <Space> as leader key
vim.g.mapleader = " "
vim.g.maplocalleader = " "

-- # Normal
-- Better window navigation
keymap("n", "<C-h>", "<C-w>h", opts)
keymap("n", "<C-j>", "<C-w>j", opts)
keymap("n", "<C-k>", "<C-w>k", opts)
keymap("n", "<C-l>", "<C-w>l", opts)

-- Resize
--   ref. https://iterm2.com/faq.html
--     Q: How do I make the option/alt key act like Meta or send escape codes?
--     A: Go to Preferences > Profiles tab. Select your profile on the left, and then open the Keyboard tab.
--        At the bottom is a set of buttons that lets you select the behavior of the Option key.
--        For most users, Esc+ will be the best choice.
keymap("n", "<A-k>", "<Cmd>resize -2<CR>", opts)
keymap("n", "<A-j>", "<Cmd>resize +2<CR>", opts)
keymap("n", "<A-h>", "<Cmd>vertical resize -2<CR>", opts)
keymap("n", "<A-l>", "<Cmd>vertical resize +2<CR>", opts)

-- Disable EX-mode (if you enter EX-mode, push gQ)
keymap("n", "Q", "<Nop>", opts)

-- Save
keymap("n", ";", "<Nop>", opts)
keymap("n", ";;", "<Cmd>write<CR>", { noremap = true })

-- Quit
keymap("n", "<Leader>q", "<Cmd>bd<CR>", opts)
keymap("n", "<Leader>Q", "<Cmd>qa<CR>", opts)

-- Windows
keymap("n", ",s", "<Cmd>split<CR>", opts)
keymap("n", "<C-w>-", "<Cmd>split<CR>", opts)
keymap("n", ",v", "<Cmd>vsplit<CR>", opts)
keymap("n", "<C-w>|", "<Cmd>vsplit<CR>", opts)
keymap("n", "<C-w>o", "<NOP>", opts)
keymap("n", "<C-w>O", "<Cmd>only<CR>", opts)

-- Tabs
keymap("n", ",t", "<Cmd>tabedit %:p<CR>", opts)
keymap("n", "<C-t><C-n>", "<Cmd>tabnext<CR>", opts)
keymap("n", "<C-t><C-p>", "<Cmd>tabprevious<CR>", opts)
keymap("n", "<C-t>N", "<Cmd>tabmove +<CR>", opts)
keymap("n", "<C-t>P", "<Cmd>tabmove -<CR>", opts)

keymap("n", "[t", "<Cmd>tabprevious<CR>", opts)
keymap("n", "]t", "<Cmd>tabnext<CR>", opts)
keymap("n", "[T", "<Cmd>tabfirst<CR>", opts)
keymap("n", "]T", "<Cmd>tablast<CR>", opts)

-- Location list
keymap("n", "[l", "<Cmd>lpreious<CR>", opts)
keymap("n", "]l", "<Cmd>lnext<CR>", opts)
keymap("n", "[L", "<Cmd>lfirst<CR>", opts)
keymap("n", "]L", "<Cmd>llast<CR>", opts)

-- Reload vimrc
keymap("n", "<Leader>R", "<Cmd>source $MYVIMRC<CR> <Cmd>echom 'Reload ' .. $MYVIMRC<CR>", { noremap = true })

-- Replace
keymap("n", "<Leader>re", ":<C-u>%s;<C-r><C-w>;g<Left><Left>;", opts)

-- Toggle relativenumber
keymap("n", "<Leader>N", "<Cmd>setlocal relativenumber!<CR>", opts)

-- Folding
keymap("n", "z-", "zr", opts)
keymap("n", "z_", "zm", opts)

keymap("n", "<Leader>p", "<Cmd>cd \\$PWD<CR><Cmd>pwd<CR>", opts)
keymap("n", "<Leader>s", "<Cmd>cd \\$SCRAPBOOK_DIR<CR><Cmd>pwd<CR>", opts)

-- # Insert
keymap("i", "<C-b>", "<Left>", opts)
keymap("i", "<C-f>", "<Right>", opts)
keymap("i", "<C-a>", "<Esc>I", opts)
keymap("i", "<C-d>", "<Del>", opts)
keymap("i", "<C-g><C-h>", "<Esc>bi", opts)
keymap("i", "<C-g><C-l>", "<Esc>ea", opts)

-- Indent
keymap("i", "<C-g><C-n>", "<Esc>v>gi<Right><Right>", opts)<commit_msg>[nvim] Fix keymaps<commit_after>local opts = { noremap = true, silent = true }
local keymap = vim.api.nvim_set_keymap

-- <Space> as leader key
vim.g.mapleader = " "
vim.g.maplocalleader = " "

-- # Normal
-- Better window navigation
keymap("n", "<C-h>", "<C-w>h", opts)
keymap("n", "<C-j>", "<C-w>j", opts)
keymap("n", "<C-k>", "<C-w>k", opts)
keymap("n", "<C-l>", "<C-w>l", opts)

-- Resize
--   ref. https://iterm2.com/faq.html
--     Q: How do I make the option/alt key act like Meta or send escape codes?
--     A: Go to Preferences > Profiles tab. Select your profile on the left, and then open the Keyboard tab.
--        At the bottom is a set of buttons that lets you select the behavior of the Option key.
--        For most users, Esc+ will be the best choice.
keymap("n", "<A-k>", "<Cmd>resize -2<CR>", opts)
keymap("n", "<A-j>", "<Cmd>resize +2<CR>", opts)
keymap("n", "<A-h>", "<Cmd>vertical resize -2<CR>", opts)
keymap("n", "<A-l>", "<Cmd>vertical resize +2<CR>", opts)

-- Disable EX-mode (if you enter EX-mode, push gQ)
keymap("n", "Q", "<Nop>", opts)

-- Save
keymap("n", ";", "<Nop>", opts)
keymap("n", ";;", "<Cmd>write<CR>", { noremap = true })

-- Quit
keymap("n", "<Leader>q", "<Cmd>bd<CR>", opts)
keymap("n", "<Leader>Q", "<Cmd>qa<CR>", opts)

-- Windows
keymap("n", ",s", "<Cmd>split<CR>", opts)
keymap("n", "<C-w>-", "<Cmd>split<CR>", opts)
keymap("n", ",v", "<Cmd>vsplit<CR>", opts)
keymap("n", "<C-w>|", "<Cmd>vsplit<CR>", opts)
keymap("n", "<C-w>o", "<NOP>", opts)
keymap("n", "<C-w>O", "<Cmd>only<CR>", opts)

-- Tabs
keymap("n", ",t", "<Cmd>tabedit %:p<CR>", opts)
keymap("n", "<C-t><C-n>", "<Cmd>tabnext<CR>", opts)
keymap("n", "<C-t><C-p>", "<Cmd>tabprevious<CR>", opts)
keymap("n", "<C-t>N", "<Cmd>tabmove +<CR>", opts)
keymap("n", "<C-t>P", "<Cmd>tabmove -<CR>", opts)

keymap("n", "[t", "<Cmd>tabprevious<CR>", opts)
keymap("n", "]t", "<Cmd>tabnext<CR>", opts)
keymap("n", "[T", "<Cmd>tabfirst<CR>", opts)
keymap("n", "]T", "<Cmd>tablast<CR>", opts)

-- Location list
keymap("n", "[l", "<Cmd>lpreious<CR>", opts)
keymap("n", "]l", "<Cmd>lnext<CR>", opts)
keymap("n", "[L", "<Cmd>lfirst<CR>", opts)
keymap("n", "]L", "<Cmd>llast<CR>", opts)

-- Reload vimrc
keymap("n", "<Leader>R", "<Cmd>source $MYVIMRC<CR> <Cmd>echom 'Reload ' .. $MYVIMRC<CR>", { noremap = true })

-- Replace
keymap("n", ",re", ":<C-u>%s;<C-r><C-w>;g<Left><Left>;", opts)

-- Toggle relativenumber
keymap("n", "<Leader>N", "<Cmd>setlocal relativenumber!<CR>", opts)

-- Folding
keymap("n", "z-", "zr", opts)
keymap("n", "z_", "zm", opts)

keymap("n", ",p", "<Cmd>cd \\$PWD<CR><Cmd>pwd<CR>", opts)
keymap("n", ",s", "<Cmd>cd \\$SCRAPBOOK_DIR<CR><Cmd>pwd<CR>", opts)

-- # Insert
keymap("i", "<C-b>", "<Left>", opts)
keymap("i", "<C-f>", "<Right>", opts)
keymap("i", "<C-a>", "<Esc>I", opts)
keymap("i", "<C-d>", "<Del>", opts)
keymap("i", "<C-g><C-h>", "<Esc>bi", opts)
keymap("i", "<C-g><C-l>", "<Esc>ea", opts)

-- Indent
keymap("i", "<C-g><C-n>", "<Esc>v>gi<Right><Right>", opts)
{'fraction_non_alphanumeric': 0.3079105473965287, 'fraction_numerical': 0.0016688918558077437, 'mean_word_length': 5.011033099297894, 'pattern_counts': {'":': 2, '<': 242, '<?xml version=': 0, '>': 246, 'https://': 2, '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': '3499721', 'n_tokens_mistral': 2687, 'n_tokens_neox': 2664, 'n_words': 609}