diff options
author | max397574 <[email protected]> | 2021-10-24 15:22:47 +0200 |
---|---|---|
committer | max397574 <[email protected]> | 2021-10-24 15:22:47 +0200 |
commit | e54b4af46f8a658e4d3c5144828c7859a59461cc (patch) | |
tree | b4809075256a991851b9d84fd5b1fe9c24fe5582 /lua | |
parent | e216cf6121aab25e7a19ccbd04cc56dfecacfacf (diff) |
feat(plugins): ✨added key help
Diffstat (limited to 'lua')
-rw-r--r-- | lua/startup.lua | 7 | ||||
-rw-r--r-- | lua/startup/themes/default.lua | 1 | ||||
-rw-r--r-- | lua/startup/utils.lua | 40 |
3 files changed, 48 insertions, 0 deletions
diff --git a/lua/startup.lua b/lua/startup.lua index 87bf597..23a4917 100644 --- a/lua/startup.lua +++ b/lua/startup.lua @@ -84,6 +84,13 @@ local function create_mappings(mappings) "<cmd>lua require('startup').open_file_vsplit()<CR>", opts ) + vim.api.nvim_buf_set_keymap( + 0, + "n", + settings.mappings.open_help, + "<cmd>lua require'startup.utils'.key_help()<CR>", + opts + ) if mappings ~= {} then for _, cmd in pairs(mappings) do vim.api.nvim_buf_set_keymap( diff --git a/lua/startup/themes/default.lua b/lua/startup/themes/default.lua index 407cdba..43dc299 100644 --- a/lua/startup/themes/default.lua +++ b/lua/startup/themes/default.lua @@ -55,6 +55,7 @@ local settings = { open_file = "o", open_file_split = "<c-o>", open_section = "<TAB>", + open_help = "?", }, colors = { background = "#1f2227", diff --git a/lua/startup/utils.lua b/lua/startup/utils.lua index aa343b8..eb522b5 100644 --- a/lua/startup/utils.lua +++ b/lua/startup/utils.lua @@ -1,5 +1,6 @@ U = {} local flag = false +local settings = require "startup.config" local function start_timeout() flag = true vim.defer_fn(function() @@ -20,6 +21,45 @@ function U.spaces(amount) return string.rep(" ", amount) end +function U.key_help() + local buf = vim.api.nvim_create_buf(false, true) + vim.api.nvim_buf_set_option(buf, "bufhidden", "wipe") + vim.api.nvim_buf_set_keymap( + buf, + "n", + "<ESC>", + "<cmd>q<CR>", + { noremap = true, silent = true, nowait = true } + ) + vim.api.nvim_buf_set_keymap( + buf, + "n", + "q", + "<cmd>q<CR>", + { noremap = true, silent = true, nowait = true } + ) + local lines = { + "startup.nvim mapping:", + "", + "Execute command: " .. settings.mappings.execute_command, + "Open file: " .. settings.mappings.open_file, + "Open file in split: " .. settings.mappings.open_file_split, + "Open section: " .. settings.mappings.open_section, + } + vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines) + local win = vim.api.nvim_open_win(buf, true, { + relative = "cursor", + width = 30, + height = 6, + col = 1, + row = 1, + border = "shadow", + style = "minimal", + }) + vim.api.nvim_win_set_option(win, "winblend", 20) + vim.api.nvim_buf_set_option(buf, "modifiable", false) +end + function U.default_header() local header = { " /$$ ", |