helm/home/profiles/nvim/config/fnl/conf/mappings.fnl

136 lines
4.6 KiB
Plaintext
Raw Normal View History

2024-08-24 03:51:29 -07:00
(local nvim (require :lib/nvim))
(import-macros {: do-req } :lib/macros)
2024-08-24 03:51:29 -07:00
(local wk (require :which-key))
;; Convenient way to indent stuff in visual mode
(nvim.keymap [:v] "<" "<gv" {:noremap true})
(nvim.keymap [:v] ">" ">gv" {:noremap true})
(nvim.keymap [:n] "<space>" "<NOP>" {:noremap true :silent true})
2024-08-25 23:44:07 -07:00
;; Convenient way to move stuff in visual mode
(nvim.keymap [:v] "J" ":m '>+1<CR>gv=gv" {:noremap true})
(nvim.keymap [:v] "K" ":m '>-2<CR>gv=gv" {:noremap true})
;; Convientent screen shifting
(nvim.keymap [:n] "n" "nzzzv" {:noremap true})
(nvim.keymap [:n] "N" "Nzzzv" {:noremap true})
(nvim.keymap [:n] "J" "mzJ'z" {:noremap true})
; Fix Y
(nvim.keymap [:n] "Y" "y$")
; Unmap Q
(nvim.keymap [] "Q" "<Nop>")
2024-08-25 23:44:07 -07:00
; FTerm
(vim.api.nvim_create_user_command "FTermToggle" (fn [_]
((-> (require :FTerm)
(. :toggle))))
{:bang true})
(nvim.keymap [:t] "<TAB>" "<cmd>:FTermToggle<CR>")
2024-08-25 23:44:07 -07:00
(nvim.keymap [:n] "<TAB>" "<cmd>:FTermToggle<CR>" {:noremap true})
; Buffer Movement
(nvim.keymap [:n] "gT" ":BufferPrevious<CR>" {:silent true :noremap true})
(nvim.keymap [:n] "gt" ":BufferNext<CR>" {:silent true :noremap true})
(nvim.keymap [:n] "gj" ":BufferPick<CR>" {:silent true :noremap true})
(nvim.keymap [:n] "gb" ":Telescope buffers<CR>" {:silent true :noremap true})
(nvim.keymap [:n] "gq" ":BufferClose<CR>" {:silent true :noremap true})
2024-08-25 23:44:07 -07:00
; Flash
(vim.api.nvim_create_user_command "Flash" (fn [_] (do-req :flash :jump)) {})
(vim.api.nvim_create_user_command "FlashTreesitter" (fn [] (do-req :flash :treesitter)) {})
(nvim.keymap [:n] "f" "<cmd>Flash<CR>")
(nvim.keymap [:n] "s" "<cmd>FlashTreesitter<CR>")
2024-08-24 03:51:29 -07:00
(local
normal-map-leader
{"t" [":Neotree toggle<CR>"
2024-08-24 03:51:29 -07:00
"Toggle neo-tree"]
"w" ["<cmd>:w<cr>"
"Write file"]
"q" ["<cmd>:q<cr>"
"Quit"]
"r" [":RainbowParenthesesToggleAll<CR>"
"Toggle Rainbow Parens"]
2024-08-25 23:44:07 -07:00
"u" [":UndotreeToggle<CR>"
"Toggle Undo Tree"]
2024-08-24 03:51:29 -07:00
; Telescope
"f" {:name "Files"
2024-08-24 03:51:29 -07:00
:f ["<cmd>Telescope find_files<cr>"
"Find Files (in Telescope)"]
:g ["<cmd>Telescope live_grep<cr>"
"Find Grep (in Telescope)"]
:b ["<cmd>Telescope buffers<cr>"
"Find Buffers"]
:h ["<cmd>Telescope help_tags<cr>"
"Find Help"]
:t ["<cmd>Telescope tags<cr>"
"Find Tags"]
:r ["<cmd>Telescope oldfiles<CR>"
"Recent files"]}
; Git
"g" {:name "Git"
2024-08-24 03:51:29 -07:00
"s" [":G<CR>"
"Git Status"]
"f" [":G fetch --all<cr>"
2024-08-24 03:51:29 -07:00
"Git Fetch"]
"b" [":GBranches<cr>"
2024-08-24 03:51:29 -07:00
"Git Branch"]
"p" [":Git! push<cr>"
2024-08-24 03:51:29 -07:00
"Git Push"]
"d" [":GDiff<cr>"
2024-08-24 03:51:29 -07:00
"Git Diff"]
"h" [""
"Commit Hunk under Cursor"]}
2024-08-25 23:44:07 -07:00
; For handling merges
; nmap <leader>gl :diffget //3<CR>
; nmap <leader>gh :diffget //2<CR>
; nnoremap <leader>gc :G commit -v -q %:p<CR>
2024-08-24 03:51:29 -07:00
; Buffers
"b" {:name "Buffer"
2024-08-25 23:44:07 -07:00
:b ["<cmd>:Telescope buffers<CR>"
"Buffer List"]
:q ["<cmd>:BufferClose<CR>"
2024-08-24 03:51:29 -07:00
"Buffer Quit"]
2024-08-25 23:44:07 -07:00
:n ["<cmd>:BufferNext<CR>"
2024-08-24 03:51:29 -07:00
"Buffer Next"]
:N ["<cmd>:tabp<CR>"
"Buffer Previous"]
:p ["<cmd>:tabp<CR>"
"Buffer Previous"]}
; Search
"s" {:name "Search"
2024-08-24 03:51:29 -07:00
:b ["<cmd>Telescope current_buffer_fuzzy_find<CR>"
"Search in current buffer"]
:s ["<cmd>Telescope live_grep<CR>"
"Search in project"]
:t ["<cmd>TodoTelescope<CR>"
"Search TODOs in project"]
:c ["<cmd>let @/ = \"\"<CR>:echo 'Search highlight cleared'<CR>"
"Clear search"]}
; Code
"c" {:name "Code"
2024-08-24 03:51:29 -07:00
:d [":lua vim.lsp.buf.definition()<CR>"
"Go to Definition"]
:i [":lua require('telescope.builtin').lsp_implementation()<CR>"
"Implementation"]
:s [":lua vim.lsp.buf.signature_help()<CR>"
"Signature Help"]
:r [":Lspsaga rename<CR>"
"Rename Symbol"]
:h [":Lspsaga hover_doc<CR>"
"Hover doc"]
:o ["<cmd>AerialToggle!<CR>"
2024-08-25 23:44:07 -07:00
"Outline"]
:t [":LspDiagnostics 0"
"Find Errors in Buffer"]}
2024-08-24 03:51:29 -07:00
; Kitaab
2024-08-25 23:44:07 -07:00
"z" {:name "Kitaab"
:n [":ZettelNew<CR>"
"Zettel New"]}
"v" {:name "Tabs"
:v [":vnew<CR>"
"Vertical Split"]
:h [":new<CR>"
"Horizontal Split"]}})
2024-08-24 03:51:29 -07:00
(wk.register normal-map-leader {:prefix "<leader>"})