1
0
Fork 0
dotfiles/home/config/nvim/nifoc/keymap.fnl

126 lines
6.3 KiB
Text
Raw Normal View History

2022-04-05 19:57:44 +00:00
(let [mod {}
keymap vim.keymap
substitute (require :substitute)
2024-12-26 19:33:55 +00:00
fzf (require :fzf-lua)
fzf-layout-bottom {:winopts_fn #(let [height (math.floor (* vim.o.lines
0.4))]
{:split (.. "belowright new | resize "
(tostring height))})}
fzf-layout-dropdown {:winopts {:height 0.4
:width 0.6
:preview {:hidden :hidden}}}
2023-10-31 20:24:26 +00:00
npairs (require :nvim-autopairs)
2024-07-09 22:45:24 +00:00
hover (require :hover)
2022-04-20 14:27:26 +00:00
gitsigns (require :gitsigns)
2023-12-29 00:26:11 +00:00
neogit (require :neogit)
2023-11-29 14:52:16 +00:00
wk (require :which-key)
repl (require :nifoc.repl)
2024-04-22 21:14:48 +00:00
repo (require :nifoc.repo)
2022-09-22 20:35:10 +00:00
formatting (require :nifoc.formatting)]
2022-04-05 19:57:44 +00:00
(fn mod.setup []
(keymap.set :n :<space> :<nop> {:noremap true})
;; Leader Mappings
2024-12-26 19:33:55 +00:00
(keymap.set :n :<leader>o fzf.files {:desc "Find Files"})
(keymap.set :n :<leader>s #(fzf.live_grep fzf-layout-bottom)
{:desc "Live Grep"})
(keymap.set :n :<leader>fn :<cmd>enew<CR> {:desc "New File"})
2023-06-27 18:26:17 +00:00
(keymap.set :n :<leader>u "<cmd>UrlView buffer<CR>" {:desc "Open UrlView"})
(keymap.set :n :<leader>c repl.open-shell {:desc "Open Shell"})
(keymap.set :n :<leader>r repl.open-repl {:desc "Open REPL"})
2024-12-26 19:33:55 +00:00
(keymap.set :n :<leader>bl fzf.buffers {:desc "List Buffers"})
(keymap.set :n :<leader>bf fzf.grep_curbuf {:desc "Find In Buffer"})
(keymap.set :n :<leader>bt fzf.treesitter {:desc "Find via Treesitter"})
2023-12-29 23:58:48 +00:00
(keymap.set :n :<leader>g #(neogit.open {:kind :split})
{:desc "Open Neogit"})
2023-12-29 00:26:11 +00:00
(keymap.set :n :<leader>vs #(neogit.open {:kind :split})
{:desc "VCS Status"})
2024-12-26 19:33:55 +00:00
(keymap.set :n :<leader>vb #(fzf.git_branches fzf-layout-dropdown)
{:desc "List VCS Branches"})
2023-01-14 16:07:11 +00:00
(keymap.set :n :<leader>vl #(gitsigns.blame_line {:full true})
{:desc "Blame Line"})
2024-01-02 22:35:15 +00:00
(keymap.set :n :<leader>vd :<cmd>DiffviewOpen<CR> {:desc "Open DiffView"})
2024-04-22 21:14:48 +00:00
(keymap.set :n :<leader>vvr #(repo.open-repo) {:desc "Open repository"})
(keymap.set :n :<leader>vvm #(repo.open-merge-request) {:desc "Open MR"})
(keymap.set :n :<leader>vvc #(repo.open-ci) {:desc "Open CI"})
(keymap.set :n :<leader>vtc #(repo.run-ci) {:desc "Trigger CI"})
2024-12-26 19:33:55 +00:00
(keymap.set :n :<leader>lk fzf.keymaps {:desc "Show Keymappings"})
(keymap.set :n :<leader>ld #(fzf.diagnostics_document fzf-layout-bottom)
{:desc "Show Diagnostics"})
2024-12-26 19:33:55 +00:00
(keymap.set :n :<leader>lt :<cmd>TodoFzfLua<CR>
2023-11-30 09:39:37 +00:00
{:desc "Show Todo Comments"})
(keymap.set :n :<leader>dli :<cmd>LspInfo<CR> {:desc "LSP Info"})
(keymap.set :n :<leader>dlr :<cmd>LspRestart<CR> {:desc "Restart LSP"})
2023-01-11 22:48:51 +00:00
(keymap.set :n :<leader>ds #(vim.diagnostic.open_float {:scope :line})
2024-06-19 08:10:24 +00:00
{:desc "Show Line Diagnostics"})
2022-11-11 14:06:11 +00:00
(keymap.set :n :<leader>dtp :<cmd>TSPlaygroundToggle<CR>
{:desc "Toggle Treetsitter Playground"})
2022-04-05 19:57:44 +00:00
;; Other Mappings
2023-11-20 20:59:54 +00:00
(keymap.set :i :<CR> npairs.autopairs_cr
{:expr true :replace_keycodes false :silent true})
2023-10-18 21:18:10 +00:00
(keymap.set :n :F #(formatting.maybe-format-buffer 0)
{:desc "Format Buffer"})
(keymap.set :n :<A-Left> :b)
(keymap.set :n :<A-Right> :w)
(keymap.set :n :<S-Left> "^")
(keymap.set :n :<S-Right> "$")
(keymap.set :i :<A-Left> :<C-o>b)
(keymap.set :i :<A-Right> :<C-o>w)
(keymap.set :i :<S-Left> :<C-o>^)
(keymap.set :i :<S-Right> :<C-o>$)
2023-11-29 14:52:16 +00:00
(keymap.set :n :<A-Up> "<cmd>MoveLine -1<CR>" {:noremap true :silent true})
(keymap.set :n :<A-Down> "<cmd>MoveLine 1<CR>" {:noremap true :silent true})
(keymap.set :x :<A-Up> "<cmd>MoveBlock -1<CR>" {:noremap true :silent true})
(keymap.set :x :<A-Down> "<cmd>MoveBlock 1<CR>"
{:noremap true :silent true})
(keymap.set :n :p "<Plug>(YankyPutAfter)")
(keymap.set :n :P "<Plug>(YankyPutBefore)")
(keymap.set :x :p substitute.visual)
(keymap.set :x :P "<Plug>(YankyPutBefore)")
(keymap.set :n :gp "<Plug>(YankyGPutAfter)")
(keymap.set :n :gP "<Plug>(YankyGPutBefore)")
(keymap.set :x :gp "<Plug>(YankyGPutAfter)")
(keymap.set :x :gP "<Plug>(YankyGPutBefore)")
(keymap.set :n :y "<Plug>(YankyYank)")
2023-11-20 20:59:54 +00:00
(keymap.set :x :y "<Plug>(YankyYank)")
2023-11-29 14:52:16 +00:00
(keymap.set :n "-" :<cmd>Oil<CR> {:desc "Open Oil"})
2024-07-09 22:45:24 +00:00
;; hover.nvim
(keymap.set :n :K hover.hover {:desc "Show Documentation"})
(keymap.set :n :gK hover.hover_select {:desc "hover.nvim selection"})
2024-12-17 15:06:31 +00:00
(keymap.set :n :<C-p> #(hover.hover_switch :previous)
{:desc "hover.nvim previous source"})
(keymap.set :n :<C-n> #(hover.hover_switch :next)
{:desc "hover.nvim next source"})
(keymap.set :n :<MouseMove> hover.hover_mouse {:desc "hover.nvim mouse"})
2023-11-29 14:52:16 +00:00
;; Label
2024-07-21 19:54:20 +00:00
(wk.add [{1 :<leader>v :group :vcs}
{1 :<leader>l :group :list/lsp}
{1 :<leader>d :group :debug}]))
2022-04-05 19:57:44 +00:00
2023-10-25 13:58:46 +00:00
(fn mod.lsp-attach [_client bufnr]
2024-12-26 19:33:55 +00:00
(keymap.set :n :<leader>t #(fzf.lsp_document_symbols fzf-layout-dropdown)
{:buffer bufnr :desc "LSP Document Symbols"})
2024-12-26 19:33:55 +00:00
(keymap.set :n :<leader>tw #(fzf.lsp_workspace_symbols fzf-layout-dropdown)
2022-04-23 22:15:57 +00:00
{:buffer bufnr :desc "LSP Workspace Symbols"})
2023-11-14 20:47:20 +00:00
(keymap.set :n :<leader>th
#(vim.lsp.inlay_hint.enable (not (vim.lsp.inlay_hint.is_enabled bufnr))
{: bufnr})
2023-06-26 11:07:19 +00:00
{:buffer bufnr :desc "Toggle Inlay Hints"})
2024-12-26 19:33:55 +00:00
(keymap.set :n :<leader>lca fzf.lsp_code_actions
{:buffer bufnr :desc "LSP Code Action"})
2024-12-26 19:33:55 +00:00
(keymap.set :n :<leader>lfr fzf.lsp_references
{:buffer bufnr :desc "Find References"})
2024-12-26 19:33:55 +00:00
(keymap.set :n :<leader>lfd fzf.lsp_definitions
{:buffer bufnr :desc "Find Definitions"})
2024-12-26 19:33:55 +00:00
(keymap.set :n :<leader>lfi fzf.lsp_implementations
2024-07-09 22:45:24 +00:00
{:buffer bufnr :desc "Find Implementations"}))
2022-04-05 19:57:44 +00:00
2022-04-20 14:27:26 +00:00
(fn mod.terminal-open [bufnr]
(let [map-opts {:buffer bufnr}]
2022-04-20 14:27:26 +00:00
(keymap.set :t :<esc> "<C-\\><C-n>" map-opts)
(keymap.set :t :<C-h> "<C-\\><C-n><C-W>h" map-opts)
(keymap.set :t :<C-j> "<C-\\><C-n><C-W>j" map-opts)
(keymap.set :t :<C-k> "<C-\\><C-n><C-W>k" map-opts)
(keymap.set :t :<C-l> "<C-\\><C-n><C-W>l" map-opts)))
2022-04-05 19:57:44 +00:00
mod)