From 86fc163e549d78136855ac2b45e91ffb2f43affc Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Sun, 8 Jan 2023 02:49:49 +0100 Subject: Refactor config loading --- fnl/config/which-key.fnl | 291 +++++++++++++++++++++++------------------------ 1 file changed, 145 insertions(+), 146 deletions(-) (limited to 'fnl/config/which-key.fnl') diff --git a/fnl/config/which-key.fnl b/fnl/config/which-key.fnl index 405fb1c..588869d 100644 --- a/fnl/config/which-key.fnl +++ b/fnl/config/which-key.fnl @@ -1,7 +1,6 @@ ;; Which-key provides a pop-up menu for some key mappings. -(module config.which-key {autoload {util config.util}}) -(def- setup {:plugins {:marks true +(local opts {:plugins {:marks true :registers true :spelling {:enabled true :suggestions 20} :presets {:operators false @@ -25,147 +24,147 @@ :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] - :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] - :z [:DiffviewClose :DiffviewClose]}) - -(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 - :t [:TroubleToggle :Trouble] - :g ["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"] - :r ["lua vim.lsp.buf.rename()" :Rename] - :s ["Telescope lsp_document_symbols" "Document Symbols"]}) - -(def- replace {:name :replace - :m [:ReplaceInBuf "Replace in Buffer"] - :n [:Replace :Replace] - :e [:ReplaceWord "Replace Word"]}) - -(def- session {:name :session - :m [:RestoreSession "Restore session"] - :n [:RestoreLastSession "Restore last session"] - :e [:IgnoreSession "Ignore current session"]}) - -(def- treesitter - {:name :Treesitter :p [:TSPlaygroundToggle :Playground]}) - -(def- 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"]}) - -(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)) +(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))} -- cgit v1.2.3-70-g09d2