-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.lua
More file actions
69 lines (57 loc) · 2.12 KB
/
init.lua
File metadata and controls
69 lines (57 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
-- This file simply bootstraps the installation of Lazy.nvim and then calls other files for execution
-- This file doesn't necessarily need to be touched, BE CAUTIOUS editing this file and proceed at your own risk.
local lazypath = vim.env.LAZY or vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
if not (vim.env.LAZY or (vim.uv or vim.loop).fs_stat(lazypath)) then
-- stylua: ignore
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(lazypath)
-- validate that lazy is available
if not pcall(require, "lazy") then
-- stylua: ignore
vim.api.nvim_echo({ { ("Unable to load lazy from: %s\n"):format(lazypath), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } }, true, {})
vim.fn.getchar()
vim.cmd.quit()
end
require "lazy_setup"
require "polish"
require "user.autocmds"
local function export_keymaps()
local modes = {
n = "Normal",
i = "Insert",
v = "Visual",
c = "Command",
t = "Terminal",
x = "Visual Block"
}
local filename = vim.fn.expand("~/.config/nvim/astrovim_keymaps.md")
local file = io.open(filename, "w")
if not file then
print("Error: Could not create file")
return
end
file:write("# AstroVim Keymaps\n\n")
file:write("Generated on: " .. os.date() .. "\n\n")
for mode, name in pairs(modes) do
file:write("## " .. name .. " Mode\n\n")
file:write("| Key | Command | Description |\n")
file:write("|-----|---------|-------------|\n")
local keymaps = vim.api.nvim_get_keymap(mode)
for _, keymap in ipairs(keymaps) do
local key = keymap.lhs or ""
local cmd = keymap.rhs or ""
local desc = keymap.desc or ""
-- Escape markdown special characters
key = key:gsub("|", "\\|")
cmd = cmd:gsub("|", "\\|")
desc = desc:gsub("|", "\\|")
file:write(string.format("| `%s` | `%s` | %s |\n", key, cmd, desc))
end
file:write("\n")
end
file:close()
print("Keymaps exported to: " .. filename)
end
-- Create command
vim.api.nvim_create_user_command("ExportKeymapsMarkdown", export_keymaps, {})