(let [mod {} keymap vim.keymap substitute (require :substitute) telescope (require :telescope) telescope-builtin (require :telescope.builtin) telescope-themes (require :telescope.themes) telescope-nifoc (require :nifoc.telescope) telescope-toggleterm (require :telescope-toggleterm) telescope-ivy (telescope-themes.get_ivy) telescope-dropdown (telescope-themes.get_dropdown) npairs (require :nvim-autopairs) gitsigns (require :gitsigns) repl (require :nifoc.repl) formatting (require :nifoc.formatting) nifoc-lsp (require :nifoc.lsp)] (fn map-entry [key cmd opts] (vim.tbl_extend :keep {1 key 2 cmd} opts)) (fn mod.setup [] (keymap.set :n : : {:noremap true}) (set vim.g.mapleader " ") (set vim.opt.timeoutlen 400) ;; Leader Mappings (keymap.set :n :o telescope-nifoc.project-files {:desc "Find Files"}) (keymap.set :n :s #(telescope-builtin.live_grep telescope-ivy) {:desc "Live Grep"}) (keymap.set :n :fn :enew {:desc "New File"}) (keymap.set :n :u :UrlView {:desc "Open UrlView"}) (keymap.set :n :ut :UndotreeToggle {:desc "Toggle Undotree"}) (keymap.set :n :c repl.toggle-shell {:desc "Toggle Shell"}) (keymap.set :n :cs #(telescope-toggleterm.open telescope-dropdown) {:desc "Select Terminal"}) (keymap.set :n :r repl.toggle-repl {:desc "Toggle REPL"}) (keymap.set :n :bl #(telescope-builtin.buffers telescope-dropdown) {:desc "List Buffers"}) (keymap.set :n :bn :BufferLineCycleNext {:desc "Next Buffer"}) (keymap.set :n :bp :BufferLineCyclePrev {:desc "Previous Buffer"}) (keymap.set :n :bf #(telescope-builtin.current_buffer_fuzzy_find telescope-dropdown) {:desc "Find In Buffer"}) (keymap.set :n :bt #(telescope-builtin.treesitter telescope-dropdown) {:desc "Find via Treesitter"}) (keymap.set :n :pt :TodoTelescope {:desc "TODO Comments"}) (keymap.set :n :vs #(telescope-builtin.git_status telescope-ivy) {:desc "VCS Status"}) (keymap.set :n :vb #(telescope-builtin.git_branches telescope-dropdown) {:desc "List VCS Branches"}) (keymap.set :n :vl gitsigns.blame_line {:desc "Blame Line"}) (keymap.set :n :vn :Neogit {:desc "Open Neogit"}) (keymap.set :n :vc "Neogit commit" {:desc "Neogit Commit"}) (keymap.set :n :vp "Neogit pull" {:desc "Neogit Pull"}) (keymap.set :n :vP "Neogit push" {:desc "Neogit Push"}) (keymap.set :n :lk telescope-builtin.keymaps {:desc "Show Keymappings"}) (keymap.set :n :ld #(telescope-builtin.diagnostics telescope-ivy) {:desc "Show Diagnostics"}) (keymap.set :n :dli :LspInfo {:desc "LSP Info"}) (keymap.set :n :dlr :LspRestart {:desc "Restart LSP"}) (keymap.set :n :dt :TSPlaygroundToggle {:desc "Toggle Treetsitter Playground"}) (keymap.set :n :dn telescope.extensions.notify.notify {:desc "Display Notifications"}) ;; Other Mappings (keymap.set :n : ":nohlsearch" {:silent true}) (keymap.set :i : npairs.autopairs_cr {:expr true :silent true}) (keymap.set :n :F formatting.maybe-format-buffer {:desc "Format Buffer"}) (keymap.set :n : :b) (keymap.set :n : :w) (keymap.set :n : "^") (keymap.set :n : "$") (keymap.set :i : :b) (keymap.set :i : :w) (keymap.set :i : :^) (keymap.set :i : :$) (keymap.set :n :p "(YankyPutAfter)") (keymap.set :n :P "(YankyPutBefore)") (keymap.set :x :p substitute.visual) (keymap.set :x :P "(YankyPutBefore)") (keymap.set :n :gp "(YankyGPutAfter)") (keymap.set :n :gP "(YankyGPutBefore)") (keymap.set :x :gp "(YankyGPutAfter)") (keymap.set :x :gP "(YankyGPutBefore)") (keymap.set :n :y "(YankyYank)") (keymap.set :x :y "(YankyYank)")) (fn mod.lsp-attach [client bufnr] (keymap.set :n :t #(telescope-builtin.lsp_document_symbols telescope-dropdown) {:buffer bufnr :desc "LSP Document Symbols"}) (keymap.set :n :tw #(telescope-builtin.lsp_dynamic_workspace_symbols telescope-dropdown) {:buffer bufnr :desc "LSP Workspace Symbols"}) (keymap.set :n :lca #(telescope-builtin.lsp_code_actions telescope-dropdown) {:buffer bufnr :desc "LSP Code Action"}) (keymap.set :n :lfr #(telescope-builtin.lsp_references telescope-dropdown) {:buffer bufnr :desc "Find References"}) (keymap.set :n :lfd #(telescope-builtin.lsp_definitions telescope-dropdown) {:buffer bufnr :desc "Find Definitions"}) (keymap.set :n :lfi #(telescope-builtin.lsp_implementations telescope-dropdown) {:buffer bufnr :desc "Find Implementations"}) (keymap.set :n :K vim.lsp.buf.hover {:buffer bufnr :desc "Show Documentation"}) (keymap.set :n :ddsc nifoc-lsp.symbols-under-cursor {:buffer bufnr :desc "Document Symbols Under Cursor"})) (fn mod.terminal-open [bufnr] (let [map-opts {:buffer bufnr}] (keymap.set :t : "" map-opts) (keymap.set :t : "h" map-opts) (keymap.set :t : "j" map-opts) (keymap.set :t : "k" map-opts) (keymap.set :t : "l" map-opts))) mod)