;; Which-key provides a pop-up meny for some key mappings. (module config.which-key {autoload {util config.util}}) (def- setup {: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 :margin [1 0 1 0] :padding [2 2 2 2] :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]}}) (def- mopts {:mode :n :prefix :m :buffer nil :silent true :noremap true :nowait true}) (def- mmappings {:a [:HarpoonAdd :Harpoon] :c [:DiffviewClose :DiffviewClose] :d [:DiffviewFileHistory :DiffviewFileHistory] :f [(fn [] (util.telescope-builtin :find_files {:theme :get_dropdown :previewer false})) "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]}) (def- nopts {:mode :n :prefix : :buffer nil :silent true :noremap true :nowait true}) (def- 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 [(fn [] (util.telescope-builtin :find_files {:theme :get_dropdown :previewer false})) "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"]}) (def- diagnostics {:name :Diagnostics :d [:TroubleToggle :Trouble] :D ["Telescope diagnostics theme=dropdown" "Telescope diagnostics"]}) (def- 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"]}) (def- 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"] :m [:Mason :Mason] :r ["lua vim.lsp.buf.rename()" :Rename] :s ["Telescope lsp_document_symbols" "Document Symbols"]}) (def- lazy {:name :Lazy :C ["Lazy check" :Check] :c ["Lazy clean" :Clean] :d ["Lazy debug" :Debug] :h ["Lazy home" :Home] :i ["Lazy install" :Install] :l ["Lazy log" :Log] :p ["Lazy profile" :Profile] :s ["Lazy sync" :Sync] :u ["Lazy update" :Update]}) (def- replace {:name :Replace :f [:ReplaceInBuf "Replace Buffer"] :r [:Replace :Replace] :w [:ReplaceWord "Replace Word"]}) (def- treesitter {:name :Treesitter :p [:TSPlaygroundToggle :Playground]}) (def- nmappings {:a ["Telescope lsp_document_symbols theme=dropdown" "Document Symbols"] :T treesitter : [:BufDel "Close Buffer"] :d diagnostics :f find :g git :h [:ColorizerToggle :Colorizer] :l lsp :n [:CommentNormal :Comment] :r replace :t [:ToggleTerm :Terminal] :u [:UndotreeToggle :Undotree] :y lazy :z [:ZenMode "Zen Mode"]}) (def- vopts {:mode :v :prefix : :buffer nil :silent true :noremap true :nowait true}) (def- vmappings {:n [:CommentVisual :Comment]}) (def- gopts {:mode :n :prefix :g :buffer nil :silent true :noremap true :nowait true}) (def- gmappings {:a [:OrgAgendaPrompt "Open agenda prompt"] :c [:OrgCapturePrompt "Open capture prompt"] :m ["Telescope orgmode search_headings theme=dropdown" "Search Headings"]}) (let [which-key (util.prequire :which-key)] (which-key.setup setup) (which-key.register mmappings mopts) (which-key.register nmappings nopts) (which-key.register vmappings vopts) (which-key.register gmappings gopts))