-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.lua
More file actions
78 lines (65 loc) · 2.69 KB
/
Copy pathinit.lua
File metadata and controls
78 lines (65 loc) · 2.69 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
70
71
72
73
74
75
76
77
78
-- init.lua
--
-- ██╗ ██╗██╗ ██╗██████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗
-- ██║ ██║╚██╗ ██╔╝██╔══██╗██╔══██╗██║ ██║██║████╗ ████║
-- ███████║ ╚████╔╝ ██████╔╝██████╔╝██║ ██║██║██╔████╔██║
-- ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══██╗╚██╗ ██╔╝██║██║╚██╔╝██║
-- ██║ ██║ ██║ ██║ ██║ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║
-- ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
--
-- Set working directory and bust module cache for reload correctness
local root = debug.getinfo(1, "S").source:sub(2):match("(.*/)") or "./"
package.path = root .. "?.lua;" .. root .. "?/init.lua;" .. package.path
for k in pairs(package.loaded) do
if
k == "config"
or k == "hypr"
or k:match("^hypr%.")
or k:match("^lib%.")
or k:match("^whichkey")
or k:match("^vim")
or k:match("^keys")
then
package.loaded[k] = nil
end
end
--- @class HyprVimAPI
--- @field setup fun(overrides?: HyprVimConfig): HyprVimAPI
--- @field config HyprVimInstance
--- @field whichkey WhichKey
--- @field marks any
--- @field registers any
--- @field command any
--- @field editor any
local API = {}
--- @param cfg HyprVimInstance
--- @param Vim Vim
--- @return HyprVimAPI
local function public_api(cfg, Vim)
API.config = cfg
API.whichkey = require("whichkey")
API.marks = Vim.marks
API.registers = Vim.registers
API.command = Vim.command
API.editor = Vim.editor
return API
end
--- @param overrides HyprVimConfig?
--- @return HyprVimAPI
API.setup = function(overrides)
local cfg = require("config").setup(overrides)
require("lib.updater").check_async()
local sh_escape = require("lib.utils").sh_escape
os.execute("mkdir -p " .. sh_escape(cfg.state_dir .. "/registers"))
os.execute("mkdir -p " .. sh_escape(cfg.state_dir .. "/marks"))
require("hypr.rules").setup()
local Vim = require("vim") ---@class Vim
Vim.setup(cfg)
if cfg.which_key and cfg.which_key.enabled then require("whichkey").start(cfg) end
require("keys")
-- Keep Submap.current/previous truthful for transitions dispatched outside Submap.enter
-- (async editor/replace callbacks via hyprctl).
hl.on("keybinds.submap", require("lib.submap").sync)
return public_api(cfg, Vim)
end
return API