;; Which-key provides a pop-up menu for some key mappings. (local opts {:plugins {:marks true :registers true :spelling {:enabled true :suggestions 20} :presets {:operators false :motions false :text_objects false :windows true :nav true :z true :g true}} :icons {:breadcrumb "»" :separator "" :group "+"} :popup_mappings {:scroll_down : :scroll_up :} :window {:border :rounded :position :bottom :winblend 0} :layout {:height {:min 4 :max 25} :width {:min 20 :max 50} :spacing 3 :align :left} :ignore_missing true :hidden [: : : : :call :lua "^:" "^ "] :show_help true :triggers :auto :disable {:filetypes [:netrw]} :triggers_blacklist {:i [:j :k] :v [:j :k]}}) (local mopts {:mode :n :prefix :m :buffer nil :silent true :noremap true :nowait true}) (local mmappings {:a [:HarpoonAdd :Harpoon] :d [:DiffviewFileHistory :DiffviewFileHistory] :f [:FindFiles "Find files"] :g ["Telescope live_grep theme=dropdown" "Find text"] :n [:Neogit :Neogit] :p [:SaveSession "Save Session"] :q ["Gitsigns diffthis HEAD" "Gitsigns diff"] :r [:HarpoonUI "Harpoon UI"] :s [:HarpoonPrev "Harpoon Prev"] :t [:HarpoonNext "Harpoon Next"] :v ["lua vim.lsp.buf.rename()" :Rename] :x ["DiffviewOpen -uno" :DiffviewOpen] :z [:DiffviewClose :DiffviewClose]}) (local nopts {:mode :n :prefix : :buffer nil :silent true :noremap true :nowait true}) (local find {:name :find :C ["Telescope commands theme=dropdown" :Commands] :H ["Telescope highlights" :Highlights] :R ["Telescope registers theme=dropdown" :Registers] :S ["Telescope grep_string theme=dropdown" "Find String"] :b ["Telescope git_branches theme=dropdown" "Checkout branch"] :c ["Telescope colorscheme theme=dropdown" :Colorscheme] :f [:FindFiles "Find files"] :h ["Telescope help_tags theme=dropdown" :Help] :k ["Telescope keymaps theme=dropdown" :Keymaps] :l ["Telescope resume theme=dropdown" "Last Search"] :p ["Telescope projects theme=dropdown" "Find project"] :r ["Telescope oldfiles theme=dropdown" "Recent File"] :s [:SearchSession "Find Session"] :t ["Telescope live_grep theme=dropdown" "Find text"]}) (local diagnostics {:name :diagnostics :t [:TroubleToggle :Trouble] :g ["Telescope diagnostics theme=dropdown" "Telescope diagnostics"]}) (local git {:name :git :R ["lua require 'gitsigns'.reset_buffer()" "Reset Buffer"] :b ["Telescope git_branches theme=dropdown" "Checkout branch"] :c ["Telescope git_commits theme=dropdown" "Checkout commit"] :d ["Gitsigns diffthis HEAD" :Diff] :j ["lua require 'gitsigns'.next_hunk()" "Next Hunk"] :k ["lua require 'gitsigns'.prev_hunk()" "Prev Hunk"] :l ["lua require 'gitsigns'.blame_line()" :Blame] :o ["Telescope git_status theme=dropdown" "Open changed file"] :p ["lua require 'gitsigns'.preview_hunk()" "Preview Hunk"] :r ["lua require 'gitsigns'.reset_hunk()" "Reset Hunk"] :s ["lua require 'gitsigns'.stage_hunk()" "Stage Hunk"] :u ["lua require 'gitsigns'.undo_stage_hunk()" "Undo Stage Hunk"]}) (local lsp {:name :lsp :S ["Telescope lsp_dynamic_workspace_symbols" "Workspace Symbols"] :a ["lua vim.lsp.buf.code_action()" "Code Action"] :f ["lua vim.lsp.buf.format { async = true }" :Format] :i [:LspInfo :Info] :l ["lua vim.lsp.codelens.run()" "CodeLens Action"] :r ["lua vim.lsp.buf.rename()" :Rename] :s ["Telescope lsp_document_symbols" "Document Symbols"]}) (local replace {:name :replace :m [:ReplaceInBuf "Replace in Buffer"] :n [:Replace :Replace] :e [:ReplaceWord "Replace Word"]}) (local session {:name :session :m [:RestoreSession "Restore session"] :n [:RestoreLastSession "Restore last session"] :e [:IgnoreSession "Ignore current session"]}) (local treesitter {:name :Treesitter :p [:TSPlaygroundToggle :Playground]}) (local nmappings {:a ["Telescope lsp_document_symbols theme=dropdown" "Document Symbols"] :T treesitter : [:BufDel "Close Buffer"] :j diagnostics :f find :g git :h [:ColorizerToggle :Colorizer] :l lsp :m [:Mason :Mason] :n [:SymbolsOutline "Symbols outline"] :r replace :s session :t [:ToggleTerm :Terminal] :u [:UndotreeToggle :Undotree] :y ["Lazy home" :Home] :z [:ZenMode "Zen Mode"]}) (local vopts {:mode :v :prefix : :buffer nil :silent true :noremap true :nowait true}) (local vmappings {:n [:CommentVisual :Comment]}) (local gopts {:mode :n :prefix :g :buffer nil :silent true :noremap true :nowait true}) (local gmappings {:a [:OrgAgendaPrompt "Open agenda prompt"] :c [:OrgCapturePrompt "Open capture prompt"] :m ["Telescope orgmode search_headings theme=dropdown" "Search headings"]}) (fn setup [] (let [which-key (require :which-key)] (which-key.setup opts) (which-key.register mmappings mopts) (which-key.register nmappings nopts) (which-key.register vmappings vopts) (which-key.register gmappings gopts))) {1 :folke/which-key.nvim :event :VeryLazy :config (fn [] (setup))}