-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinit.lua
More file actions
36 lines (31 loc) · 1.44 KB
/
Copy pathinit.lua
File metadata and controls
36 lines (31 loc) · 1.44 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
-- Define config table to be able to pass data between scripts.
_G.Config = {}
-- Define custom autocommand group and helper to create an autocommand.
local gr = vim.api.nvim_create_augroup('custom-config', {})
Config.new_autocmd = function(event, pattern, callback, desc)
local opts = { group = gr, pattern = pattern, callback = callback, desc = desc }
vim.api.nvim_create_autocmd(event, opts)
end
-- Define custom `vim.pack.add()` hook helper.
Config.on_packchanged = function(plugin_name, kinds, callback, desc)
local f = function(ev)
local name, kind = ev.data.spec.name, ev.data.kind
if not (name == plugin_name and vim.tbl_contains(kinds, kind)) then return end
if not ev.data.active then vim.cmd.packadd(plugin_name) end
callback(ev.data)
end
Config.new_autocmd('PackChanged', '*', f, desc)
end
-- Added: Optimize( a bit )..
for _, disable in ipairs({ 'gzip', 'tarPlugin', 'tutor', 'zipPlugin' }) do
vim.g['loaded_' .. disable] = 0
end
-- Load 'mini.nvim'.
vim.pack.add({ 'https://github.com/nvim-mini/mini.nvim' })
-- Loading helpers used to organize config into fail-safe parts.
local misc = require('mini.misc')
Config.now = function(f) misc.safely('now', f) end
Config.later = function(f) misc.safely('later', f) end
Config.now_if_args = vim.fn.argc(-1) > 0 and Config.now or Config.later
Config.on_event = function(ev, f) misc.safely('event:' .. ev, f) end
Config.on_filetype = function(ft, f) misc.safely('filetype:' .. ft, f) end