-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
54 lines (43 loc) · 1.4 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
50
51
52
53
54
---------- START FUNCTIONS ----------
function vim_profile()
return os.getenv("VIM_PROFILE") or "default"
end
function last_used_vim_profile_path()
local vimrc_directory = vimrc_directory()
return vimrc_directory .. "last_used_vim_profile.txt"
end
function read_last_used_vim_profile()
local vimrc_directory = vimrc_directory()
local handle = io.open(last_used_vim_profile_path(), "r")
if handle ~= nil then
local last_used_vim_profile = handle:read("*line")
handle:close()
return last_used_vim_profile
else
return nil
end
end
function update_last_used_vim_profile()
io.output(last_used_vim_profile_path())
io.write(vim_profile() .. "\n")
end
function vimrc_directory()
local vimrc_path = os.getenv("MYVIMRC")
local path_separator = package.config:sub(1,1) -- https://stackoverflow.com/a/14425862/7933478
local index_of_last_path_separator = vimrc_path:len() - (vimrc_path:reverse():find(path_separator) - 1)
return vimrc_path:sub(1, index_of_last_path_separator)
end
---------- END FUNCTIONS ----------
local last_used_vim_profile = read_last_used_vim_profile()
update_last_used_vim_profile()
local profile = require("profiles/".. vim_profile())
local packer = require('packer')
packer.init({ autoremove = true })
packer.reset()
packer.use('wbthomason/packer.nvim')
profile.packer_spec(packer.use)
packer.install()
if last_used_vim_profile ~= vim_profile() then
packer.clean()
end
packer.compile()