-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbootstrap-tangerine.lua
168 lines (132 loc) · 5.2 KB
/
bootstrap-tangerine.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
--- HELPERS ---
local nvim_config = vim.fn.stdpath("config")
local nvim_data = vim.fn.stdpath("data")
-- "tangerine", "packer", "paq", "lazy"
local pack = "lazy"
local function bootstrap(url, ref, extra_path)
local name = url:gsub(".*/", "")
local extra_path = extra_path or ""
if pack == "lazy" then
path = vim.fn.stdpath("data") .. "/lazy/" .. name
path = path .. "/" .. extra_path
else
path = vim.fn.stdpath("data") .. "/site/pack/".. pack .. "/start/" .. name .. "/" .. extra_path
end
if vim.fn.isdirectory(path) == 0 then
local p = vim.fn.fnamemodify(path, ":p")
if vim.fn.isdirectory(p) == 0 then
vim.fn.mkdir(p, "p")
end
print(name .. ": installing in data dir...")
vim.fn.system({"git", "clone", "--filter=blob:none", url, path})
print(name .. ": installed")
if ref then
print(name .. ": checking out " .. ref)
vim.fn.system({"git", "-C", path, "checkout", ref})
print(name .. ": checked out " .. ref)
end
vim.cmd("redraw")
print(name .. ": finished installing")
end
vim.opt.rtp:prepend(path)
end
--- BOOTSTRAP TANGERINE ---
bootstrap("https://github.com/udayvir-singh/tangerine.nvim")
--- BOOTSTRAP TYPED-FENNEL ---
bootstrap("https://github.com/reo101/typed-fennel", "subdirectories")
--- CONFIGURE TANGERINE ---
local opt = {
vimrc = nvim_config .. "/init.fnl",
source = nvim_config .. "/fnl",
target = nvim_data .. "/tangerine",
rtpdirs = {
"plugin",
"ftplugin",
"ftdetect",
"luasnippets",
"after/plugin",
"after/ftplugin",
"after/ftdetect",
},
custom = {
-- list of custom [source target] chunks, for example:
-- {"~/.config/awesome/fnl", "~/.config/awesome/lua"}
{ nvim_data .. "/lazy/typed-fennel/fnl", nvim_data .. "/lazy/typed-fennel/lua" },
},
compiler = {
float = true, -- show output in floating window
clean = true, -- delete stale lua files
force = false, -- disable diffing (not recommended)
verbose = true, -- enable messages showing compiled files
globals = vim.tbl_keys(_G), -- list of alowedGlobals
-- wrapper function that provides access to underlying fennel compiler
-- useful if you want to modify fennel API or want to provide your own fennel compiler
adviser = function (fennel)
-- for example, adding a custom macro path:
-- fennel["macro-path"] = fennel["macro-path"] .. ";/custom/path/?.fnl"
-- return fennel
local local_fennel_path = vim.env.HOME .. "/Projects/Home/Fennel/Fennel"
if vim.fn.isdirectory(local_fennel_path) == 1 then
-- Clean tangerine's fennel
vim.iter(package.preload):filter(function (k, v)
return k:match("^fennel%.")
end):each(function (k)
package.preload[k] = nil
package.loaded[k] = nil
end)
-- Bring in ours
package.path = local_fennel_path .. "/?.lua;" .. package.path
local local_fennel = require("fennel")
-- TODO: why is this not needed
for _, attr in ipairs({"path", "macro-path", "macroPath"}) do
local_fennel[attr] = fennel[attr]
end
fennel = local_fennel
end
return fennel
end,
-- version of fennel to use, [ latest, 1-4-0, 1-3-1, 1-3-0, 1-2-1, 1-2-0, 1-1-0, 1-0-0, 0-10-0, 0-9-2 ]
-- version = "1-5-0-dev",
version = "latest",
-- hooks for tangerine to compile on:
-- "onsave" run every time you save fennel file in {source} dir
-- "onload" run on VimEnter event
-- "oninit" run before sourcing init.fnl [recommended than onload]
hooks = { "oninit", "onload", "onsave" },
},
eval = {
float = true, -- show results in floating window
-- luafmt = function() -- function that returns formatter with flags for peeked lua
-- -- optionally install lua-format by `$ luarocks install --local --server=https://luarocks.org/dev luaformatter`
-- return {"~/.luarocks/bin/lua-format", ...}
-- end,
diagnostic = {
virtual = true, -- show errors in virtual text
timeout = 10, -- how long should the error persist
},
},
keymaps = {
-- set them to <Nop> if you want to disable them
eval_buffer = "gE",
peek_buffer = "gL",
goto_output = "gO",
float = {
next = "<C-K>",
prev = "<C-J>",
kill = "<Esc>",
close = "<Enter>",
resizef = "<C-W>=",
resizeb = "<C-W>-",
},
},
highlight = {
float = "Normal",
success = "String",
errors = "DiagnosticError",
},
}
require("tangerine").setup(opt)
--- BOOTSTRAP NIXCATS ---
bootstrap("https://github.com/BirdeeHub/nixCats-nvim", "v6.0.8")
--- BOOTSTRAP LAZY.NVIM ---
bootstrap("https://github.com/folke/lazy.nvim")