-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
init.lua
49 lines (43 loc) · 1.33 KB
/
init.lua
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
local settings = require("configuration")
-- Watch the lua/configuration.lua for changes and
-- re-initialize when changes to that file are detected
if File_watchers == nil then
File_watchers = {}
end
local watch_file_augroup = 'watch_file_augroup'
vim.api.nvim_create_augroup(watch_file_augroup, {clear=true})
vim.api.nvim_create_autocmd('VimLeave', {
group = watch_file_augroup,
callback = function()
for _, watcher in pairs(File_watchers) do
watcher:stop()
end
end
})
local function watch_file(fname, cb, time)
if File_watchers[fname] then
File_watchers[fname]:stop()
File_watchers[fname] = nil
end
File_watchers[fname] = vim.loop.new_fs_poll()
File_watchers[fname]:start(fname, time, vim.schedule_wrap(cb))
end
local init_lua = vim.fn.stdpath('config')..'/init.lua'
local conf_lua = vim.fn.stdpath('config')..'/lua/configuration.lua'
watch_file(conf_lua, function()
dofile(init_lua)
vim.notify('Reloaded init.lua', vim.diagnostic.severity.INFO)
end, 500)
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.g.mapleader = settings.mapleader
vim.g.maplocalleader = settings.maplocalleader
if settings.namespace == "onno" then
require("onno.lazy")
else
if settings.namespace == "ecovim" then
require("ecovim")
else
require("free.config.lazy")
end
end