From 93173acedc826536553e5752e3385ef290b67188 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Sat, 6 Aug 2022 12:34:41 +0200 Subject: Update which-key --- fnl/config/which-key.fnl | 151 +++++++++++++++++++++++++++-------------------- 1 file changed, 88 insertions(+), 63 deletions(-) (limited to 'fnl/config') diff --git a/fnl/config/which-key.fnl b/fnl/config/which-key.fnl index 65997b3..4508f58 100644 --- a/fnl/config/which-key.fnl +++ b/fnl/config/which-key.fnl @@ -28,36 +28,41 @@ :triggers :auto :triggers_blacklist {:i [:j :k] :v [:j :k]}}) -(def- opts {:mode :n - :prefix : - :buffer nil - :silent true - :noremap true - :nowait true}) +(def- nopts {:mode :n + :prefix : + :buffer nil + :silent true + :noremap true + :nowait true}) + +(def- vopts {:mode :v + :prefix : + :buffer nil + :silent true + :noremap true + :nowait true}) + +(def- aerial {:name :Aerial + :a [:AerialToggle! "Toggle Aerial"] + :c [:AerialClose "Close Aerial"]}) -(def- mappings - {:k ["lua require('Comment.api').toggle_current_linewise()" - :Comment] - :A [:Alpha :Alpha] - :a {:name :Aerial - :a [:AerialToggle! "Toggle Aerial"] - :c [:AerialClose "Close Aerial"]} - :e [:NvimTreeToggle :Explorer] - :c [:Bdelete! "Close Buffer"] - :P ["Telescope projects" :Projects] - :z [:ZenMode "Zen Mode"] - :b ["lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{sort_lastused = true, initial_mode = 'normal', previewer = false})" - "Switch buffers"] - :f ["lua require('telescope.builtin').find_files(require('telescope.themes').get_dropdown{previewer = false})" - "Find files"] - :t ["Telescope live_grep theme=ivy" "Find text"] - :p {:name :Packer - :c [:PackerCompile :Compile] - :i [:PackerInstall :Install] - :s [:PackerSync :Sync] - :S [:PackerStatus :Status] - :u [:PackerUpdate :Update]} - :g {:name :Git +(def- find {:name :Find + :b ["Telescope git_branches" "Checkout branch"] + :c ["Telescope colorscheme" :Colorscheme] + :f ["lua require('telescope.builtin').find_files(require('telescope.themes').get_dropdown{previewer = false})" + "Find files"] + :t ["Telescope live_grep theme=ivy" "Find text"] + :s ["Telescope grep_string" "Find String"] + :h ["Telescope help_tags" :Help] + :H ["Telescope highlights" :Highlights] + :l ["Telescope resume" "Last Search"] + :M ["Telescope man_pages" "Man Pages"] + :r ["Telescope oldfiles" "Recent File"] + :R ["Telescope registers" :Registers] + :k ["Telescope keymaps" :Keymaps] + :C ["Telescope commands" :Commands]}) + +(def- git {:name :Git :g ["lua _LAZYGIT_TOGGLE()" :Lazygit] :j ["lua require 'gitsigns'.next_hunk()" "Next Hunk"] :k ["lua require 'gitsigns'.prev_hunk()" "Prev Hunk"] @@ -72,8 +77,9 @@ :b ["Telescope git_branches" "Checkout branch"] :c ["Telescope git_commits" "Checkout commit"] :d ["Gitsigns diffthis HEAD" :Diff] - :n [:Neogit :Neogit]} - :l {:name :LSP + :n [:Neogit :Neogit]}) + +(def- lsp {:name :LSP :a ["lua vim.lsp.buf.code_action()" "Code Action"] :d ["Telescope lsp_document_diagnostics" "Document Diagnostics"] @@ -81,50 +87,69 @@ "Workspace Diagnostics"] :f ["lua vim.lsp.buf.format { async = true }" :Format] :i [:LspInfo :Info] - :j ["lua vim.lsp.diagnostic.goto_next({buffer=0})" "Next Diagnostic"] - :k ["lua vim.lsp.diagnostic.goto_prev({buffer=0})" "Prev Diagnostic"] + :j ["lua vim.lsp.diagnostic.goto_next({buffer=0})" + "Next Diagnostic"] + :k ["lua vim.lsp.diagnostic.goto_prev({buffer=0})" + "Prev Diagnostic"] :l ["lua vim.lsp.codelens.run()" "CodeLens Action"] :q ["lua vim.lsp.diagnostic.set_loclist()" :Quickfix] :r ["lua vim.lsp.buf.rename()" :Rename] :s ["Telescope lsp_document_symbols" "Document Symbols"] :S ["Telescope lsp_dynamic_workspace_symbols" - "Workspace Symbols"]} - :s [(fn switch-window [] - (let [window-picker (require :window-picker)] - (let [win (window-picker.pick_window)] - (if (not= win nil) - (nvim.set_current_win win))))) - "Switch window"] - :o {:name :Orgmode + "Workspace Symbols"]}) + +(def- org {:name :Orgmode :a ["lua require('orgmode').action('agenda.prompt')" "Open agenda prompt"] :c ["lua require('orgmode').action('capture.prompt')" - "Open capture prompt"]} - :r {:name :Replace - :r ["lua require('spectre').open()" :Replace] - :w ["lua require('spectre').open_visual({select_word=true})" - "Replace Word"] - :f ["lua require('spectre').open_file_search()" - "Replace Buffer"]} - :s [(fn switch-window [] - (let [window-picker (require :window-picker)] - (let [win (window-picker.pick_window)] - (if (not= win nil) - (nvim.set_current_win win))))) - "Switch window"] - :T {:name :Treesitter :p [:TSPlaygroundToggle :Playground]}}) + "Open capture prompt"]}) -(def- vopts {:mode :v - :prefix : - :buffer nil - :silent true - :noremap true - :nowait true}) +(def- packer {:name :Packer + :c [:PackerCompile :Compile] + :i [:PackerInstall :Install] + :s [:PackerSync :Sync] + :S [:PackerStatus :Status] + :u [:PackerUpdate :Update]}) + +(def- replace {:name :Replace + :r ["lua require('spectre').open()" :Replace] + :w ["lua require('spectre').open_visual({select_word=true})" + "Replace Word"] + :f ["lua require('spectre').open_file_search()" + "Replace Buffer"]}) + +(def- treesitter + {:name :Treesitter :p [:TSPlaygroundToggle :Playground]}) + +(defn- switch-window [] + (let [window-picker (require :window-picker)] + (let [win (window-picker.pick_window)] + (if (not= win nil) + (nvim.set_current_win win))))) + +(def- nmappings {:a aerial + :b ["lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{sort_lastused = true, initial_mode = 'normal', previewer = false})" + "Switch buffers"] + :c [:Bdelete! "Close Buffer"] + :e [:NvimTreeToggle :Explorer] + :f find + :g git + :h [:Alpha :Alpha] + :l lsp + :n ["lua require('Comment.api').toggle_current_linewise()" + :Comment] + :o org + :p packer + :r replace + :s [switch-window "Switch window"] + :t [:ToggleTerm :Terminal] + :T treesitter + :z [:ZenMode "Zen Mode"]}) -(def- vmappings {:k ["lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())" +(def- vmappings {:n ["lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())" :Comment]}) (let [which-key (util.load-plugin :which-key)] (which-key.setup setup) - (which-key.register mappings opts) + (which-key.register nmappings nopts) (which-key.register vmappings vopts)) -- cgit v1.2.3-70-g09d2