From fa294ce3a7bb5dfab190bc9f694de5f7ef6d55d1 Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Thu, 29 Apr 2021 20:04:17 +0200 Subject: [PATCH] other which-key plugin --- files/.config/nvim/fnl/keybinds.fnl | 107 +++++++++--------- files/.config/nvim/lua/keybinds.lua | 25 ++-- files/.config/nvim/plugin/packer_compiled.vim | 4 + files/.config/nvim/plugins.lua | 5 +- 4 files changed, 75 insertions(+), 66 deletions(-) diff --git a/files/.config/nvim/fnl/keybinds.fnl b/files/.config/nvim/fnl/keybinds.fnl index de14f04..8d1a2df 100644 --- a/files/.config/nvim/fnl/keybinds.fnl +++ b/files/.config/nvim/fnl/keybinds.fnl @@ -2,79 +2,76 @@ {require {a aniseed.core nvim aniseed.nvim utils utils - fennel aniseed.fennel} + fennel aniseed.fennel + wk which-key} require-macros [macros]}) -(utils.keymap :n : ":WhichKey ''") -(utils.keymap :v : ":WhichKeyVisual ''") - (utils.keymap :i : "compe#complete()" {:expr true}) (utils.keymap :i : "compe#close('')" {:expr true}) -(fn le [s] (.. ":call luaeval(\"" s "\")")) +(wk.setup {}) -(set nvim.g.which_key_map {}) -(nvim.command "call which_key#register('', \"g:which_key_map\")") +(fn cmd [s desc] [(.. "" s "") desc]) +(fn le [s desc] (cmd (.. "call luaeval(\"" s "\")") desc)) +(fn rebind [s desc] [s desc]) -(set nvim.g.which_key_map - { "h" [ ":bprevious" "previous buffer"] - "l" [ ":bnext" "next buffer"] - "f" "which_key_ignore" - "s" "which_key_ignore" - "o" [":Telescope live_grep" "Grep files"] - "p" [":Telescope file_browser" "Open file-browser"] - "[" ["(YoinkPostPasteSwapBack)" "Swap last paste backwards"] - "]" ["(YoinkPostPasteSwapForward)" "Swap last paste backwards"] - ":" [":Commands" "Search command with fzf"] - "c" { :name "+comment_out"} +(wk.register + { "c" { :name "+comment out"} "e" { :name "+emmet"} - "z" { :name "+folds" - "c" ["foldclose" "close fold"] - "o" ["foldopen" "open fold"]} - - "m" { :name "+Code-actions" - "d" [ ":Lspsaga hover_doc" "show documentation"] - "b" [ ":Lspsaga lsp_finder" "find stuff"] - "x" [ ":Lspsaga preview_definition" "Preview definition"] - "o" [ ":SymbolsOutline" "Outline"] - "S" [ ":Telescope lsp_document_symbols" "symbols in document"] - "s" [ ":Telescope lsp_dynamic_workspace_symbols" "symbols in workspace"] - "t" [ ":Lspsaga signature_help" "Show signature help"] - "n" [ ":Lspsaga rename" "rename"] - "v" [ ":Lspsaga code_action" "apply codeaction"] - "a" [ ":Lspsaga show_cursor_diagnostics" "Cursor diagnostics"] - "A" [ ":Lspsaga show_line_diagnostics" "Line diagnostics"] - "E" [ ":Telescope lsp_workspace_diagnostics" "List diagnostics"] - "e" [ (le "vim.lsp.diagnostic.goto_next()") "Jump to the next error"] - "g" [ (le "vim.lsp.buf.definition()") "go to definition"] - "i" [ (le "vim.lsp.buf.implementation()") "show implementation"] - "r" [ ":Telescope lsp_references" "show references"] - "f" [ (le "vim.lsp.buf.formatting()") "format file"]} - + "h" (cmd "bprevious" "previous buffer") + "l" (cmd "bnext" "next buffer") + "o" (cmd "Telescope live_grep" "Grep files") + "p" (cmd "Telescope file_browser" "Open file-browser") + ":" (cmd "Telescope commands" "Search command with fzf") + + "m" { :name "+Code actions" + "d" (cmd "Lspsaga hover_doc" "Show documentation") + "b" (cmd "Lspsaga lsp_finder" "Find stuff") + "x" (cmd "Lspsaga preview_definition" "Preview definition") + "o" (cmd "SymbolsOutline" "Outline") + "S" (cmd "Telescope lsp_document_symbols" "Symbols in document") + "s" (cmd "Telescope lsp_dynamic_workspace_symbols" "Symbols in workspace") + "t" (cmd "Lspsaga signature_help" "Show signature help") + "n" (cmd "Lspsaga rename" "Rename") + "v" (cmd "Lspsaga code_action" "Apply codeaction") + "a" (cmd "Lspsaga show_cursor_diagnostics" "Cursor diagnostics") + "A" (cmd "Lspsaga show_line_diagnostics" "Line diagnostics") + "E" (cmd "Telescope lsp_workspace_diagnostics" "List diagnostics") + "r" (cmd "Telescope lsp_references" "Show references") + "e" (le "vim.lsp.diagnostic.goto_next()" "Jump to the next error") + "g" (le "vim.lsp.buf.definition()" "Go to definition") + "i" (le "vim.lsp.buf.implementation()" "Show implementation") + "f" (le "vim.lsp.buf.formatting()" "format file")} "f" { :name "+folds" - "o" [ ":foldopen" "open fold"] - "n" [ ":foldclose" "close fold"] - "j" [ "zj" "jump to next fold"] - "k" [ "zk" "jump to previous fold"]} + "o" (cmd "foldopen" "open fold") + "n" (cmd "foldclose" "close fold") + "j" (rebind "zj" "jump to next fold") + "k" (rebind "zk" "jump to previous fold")} "v" { :name "+view-and-layout" - "n" [":set relativenumber!" "toggle relative numbers"] - "m" [":set nonumber! norelativenumber" "toggle numbers"] - "g" [":Goyo | set linebreak" "toggle focus mode"] - "i" [":IndentGuidesToggle" "toggle indent guides"]} + "n" (cmd "set relativenumber!" "toggle relative numbers") + "m" (cmd "set nonumber! norelativenumber" "toggle numbers") + "g" (cmd "Goyo | set linebreak" "toggle focus mode") + "i" (cmd "IndentGuidesToggle" "toggle indent guides")} "b" { :name "+buffers" - "b" [":Buffers" "select open buffer"] - "c" [":bdelete!" "close open buffer"] - "w" [":bwipeout!" "wipeout open buffer"]}}) + "b" (cmd "Buffers" "select open buffer") + "c" (cmd "bdelete!" "close open buffer") + "w" (cmd "bwipeout!" "wipeout open buffer")}} + + { :prefix ""}) + +(wk.register + { :name "+folds" + "c" (cmd "foldclose" "close fold") + "o" (cmd "foldopen" "open fold")} + { :prefix "z"}) + (set nvim.o.timeoutlen 200) -(nvim.command - "autocmd! VimEnter * :unmap ig - autocmd! FileType which_key") diff --git a/files/.config/nvim/lua/keybinds.lua b/files/.config/nvim/lua/keybinds.lua index 35dd089..40c35ff 100644 --- a/files/.config/nvim/lua/keybinds.lua +++ b/files/.config/nvim/lua/keybinds.lua @@ -19,11 +19,11 @@ end local function _1_(...) local ok_3f_0_, val_0_ = nil, nil local function _1_() - return {require("aniseed.core"), require("aniseed.fennel"), require("aniseed.nvim"), require("utils")} + return {require("aniseed.core"), require("aniseed.fennel"), require("aniseed.nvim"), require("utils"), require("which-key")} end ok_3f_0_, val_0_ = pcall(_1_) if ok_3f_0_ then - _0_0["aniseed/local-fns"] = {["require-macros"] = {macros = true}, require = {a = "aniseed.core", fennel = "aniseed.fennel", nvim = "aniseed.nvim", utils = "utils"}} + _0_0["aniseed/local-fns"] = {["require-macros"] = {macros = true}, require = {a = "aniseed.core", fennel = "aniseed.fennel", nvim = "aniseed.nvim", utils = "utils", wk = "which-key"}} return val_0_ else return print(val_0_) @@ -34,18 +34,23 @@ local a = _local_0_[1] local fennel = _local_0_[2] local nvim = _local_0_[3] local utils = _local_0_[4] +local wk = _local_0_[5] local _2amodule_2a = _0_0 local _2amodule_name_2a = "keybinds" do local _ = ({nil, _0_0, {{nil}, nil, nil, nil}})[2] end -utils.keymap("n", "", ":WhichKey ''") -utils.keymap("v", "", ":WhichKeyVisual ''") utils.keymap("i", "", "compe#complete()", {expr = true}) utils.keymap("i", "", "compe#close('')", {expr = true}) -local function le(s) - return (":call luaeval(\"" .. s .. "\")") +wk.setup({}) +local function cmd(s, desc) + return {("" .. s .. ""), desc} end -nvim.g.which_key_map = {} -nvim.command("call which_key#register('', \"g:which_key_map\")") -nvim.g.which_key_map = {[":"] = {":Commands", "Search command with fzf"}, ["["] = {"(YoinkPostPasteSwapBack)", "Swap last paste backwards"}, ["]"] = {"(YoinkPostPasteSwapForward)", "Swap last paste backwards"}, b = {b = {":Buffers", "select open buffer"}, c = {":bdelete!", "close open buffer"}, name = "+buffers", w = {":bwipeout!", "wipeout open buffer"}}, c = {name = "+comment_out"}, e = {name = "+emmet"}, f = {j = {"zj", "jump to next fold"}, k = {"zk", "jump to previous fold"}, n = {":foldclose", "close fold"}, name = "+folds", o = {":foldopen", "open fold"}}, h = {":bprevious", "previous buffer"}, l = {":bnext", "next buffer"}, m = {A = {":Lspsaga show_line_diagnostics", "Line diagnostics"}, E = {":Telescope lsp_workspace_diagnostics", "List diagnostics"}, S = {":Telescope lsp_document_symbols", "symbols in document"}, a = {":Lspsaga show_cursor_diagnostics", "Cursor diagnostics"}, b = {":Lspsaga lsp_finder", "find stuff"}, d = {":Lspsaga hover_doc", "show documentation"}, e = {le("vim.lsp.diagnostic.goto_next()"), "Jump to the next error"}, f = {le("vim.lsp.buf.formatting()"), "format file"}, g = {le("vim.lsp.buf.definition()"), "go to definition"}, i = {le("vim.lsp.buf.implementation()"), "show implementation"}, n = {":Lspsaga rename", "rename"}, name = "+Code-actions", o = {":SymbolsOutline", "Outline"}, r = {":Telescope lsp_references", "show references"}, s = {":Telescope lsp_dynamic_workspace_symbols", "symbols in workspace"}, t = {":Lspsaga signature_help", "Show signature help"}, v = {":Lspsaga code_action", "apply codeaction"}, x = {":Lspsaga preview_definition", "Preview definition"}}, o = {":Telescope live_grep", "Grep files"}, p = {":Telescope file_browser", "Open file-browser"}, s = "which_key_ignore", v = {g = {":Goyo | set linebreak", "toggle focus mode"}, i = {":IndentGuidesToggle", "toggle indent guides"}, m = {":set nonumber! norelativenumber", "toggle numbers"}, n = {":set relativenumber!", "toggle relative numbers"}, name = "+view-and-layout"}, z = {c = {"foldclose", "close fold"}, name = "+folds", o = {"foldopen", "open fold"}}} +local function le(s, desc) + return cmd(("call luaeval(\"" .. s .. "\")"), desc) +end +local function rebind(s, desc) + return {s, desc} +end +wk.register({[":"] = cmd("Telescope commands", "Search command with fzf"), b = {b = cmd("Buffers", "select open buffer"), c = cmd("bdelete!", "close open buffer"), name = "+buffers", w = cmd("bwipeout!", "wipeout open buffer")}, c = {name = "+comment out"}, e = {name = "+emmet"}, f = {j = rebind("zj", "jump to next fold"), k = rebind("zk", "jump to previous fold"), n = cmd("foldclose", "close fold"), name = "+folds", o = cmd("foldopen", "open fold")}, h = cmd("bprevious", "previous buffer"), l = cmd("bnext", "next buffer"), m = {A = cmd("Lspsaga show_line_diagnostics", "Line diagnostics"), E = cmd("Telescope lsp_workspace_diagnostics", "List diagnostics"), S = cmd("Telescope lsp_document_symbols", "Symbols in document"), a = cmd("Lspsaga show_cursor_diagnostics", "Cursor diagnostics"), b = cmd("Lspsaga lsp_finder", "Find stuff"), d = cmd("Lspsaga hover_doc", "Show documentation"), e = le("vim.lsp.diagnostic.goto_next()", "Jump to the next error"), f = le("vim.lsp.buf.formatting()", "format file"), g = le("vim.lsp.buf.definition()", "Go to definition"), i = le("vim.lsp.buf.implementation()", "Show implementation"), n = cmd("Lspsaga rename", "Rename"), name = "+Code actions", o = cmd("SymbolsOutline", "Outline"), r = cmd("Telescope lsp_references", "Show references"), s = cmd("Telescope lsp_dynamic_workspace_symbols", "Symbols in workspace"), t = cmd("Lspsaga signature_help", "Show signature help"), v = cmd("Lspsaga code_action", "Apply codeaction"), x = cmd("Lspsaga preview_definition", "Preview definition")}, o = cmd("Telescope live_grep", "Grep files"), p = cmd("Telescope file_browser", "Open file-browser"), v = {g = cmd("Goyo | set linebreak", "toggle focus mode"), i = cmd("IndentGuidesToggle", "toggle indent guides"), m = cmd("set nonumber! norelativenumber", "toggle numbers"), n = cmd("set relativenumber!", "toggle relative numbers"), name = "+view-and-layout"}}, {prefix = ""}) +wk.register({c = cmd("foldclose", "close fold"), name = "+folds", o = cmd("foldopen", "open fold")}, {prefix = "z"}) nvim.o.timeoutlen = 200 -return nvim.command("autocmd! VimEnter * :unmap ig\n autocmd! FileType which_key") \ No newline at end of file +return nil \ No newline at end of file diff --git a/files/.config/nvim/plugin/packer_compiled.vim b/files/.config/nvim/plugin/packer_compiled.vim index a58dc8c..3cae099 100644 --- a/files/.config/nvim/plugin/packer_compiled.vim +++ b/files/.config/nvim/plugin/packer_compiled.vim @@ -310,6 +310,10 @@ _G.packer_plugins = { loaded = true, path = "/home/leon/.local/share/nvim/site/pack/packer/start/webapi-vim" }, + ["which-key.nvim"] = { + loaded = true, + path = "/home/leon/.local/share/nvim/site/pack/packer/start/which-key.nvim" + }, ["yats.vim"] = { loaded = true, path = "/home/leon/.local/share/nvim/site/pack/packer/start/yats.vim" diff --git a/files/.config/nvim/plugins.lua b/files/.config/nvim/plugins.lua index 61b8d18..8d6ed15 100644 --- a/files/.config/nvim/plugins.lua +++ b/files/.config/nvim/plugins.lua @@ -17,6 +17,9 @@ require("packer").startup(function(use) use "simrat39/symbols-outline.nvim" + use "folke/which-key.nvim" + + -- better quickfix window use "kevinhwang91/nvim-bqf" @@ -43,7 +46,7 @@ require("packer").startup(function(use) "junegunn/goyo.vim", cmd = "Goyo", } - use "liuchengxu/vim-which-key" + use "mhinz/vim-signify" use "tpope/vim-fugitive" use "preservim/nerdcommenter"