-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgitignore.lua
More file actions
48 lines (39 loc) · 873 Bytes
/
Copy pathgitignore.lua
File metadata and controls
48 lines (39 loc) · 873 Bytes
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
--[[
-- File preview for .gitignore files in Git repositories
--]]
local function isSpecialChar(char)
return char == '/' or char == '*' or char == '?'
end
-- Customize the colors here:
local commentColor = "[teal]"
local specialCharColor = "[orange]"
local captureColor = "[aqua]"
local y = 0
local inCapture = false
for line in io.lines(fen.SelectedFile) do
if line:sub(1,1) == '#' then
fen:PrintSimple(commentColor..line, 0, y)
goto continue
end
for i = 1, #line do
local style = ""
local c = line:sub(i,i)
if not inCapture and c == '[' then
inCapture = true
end
if inCapture then
style = captureColor
elseif isSpecialChar(c) then
style = specialCharColor
end
if inCapture and c == ']' then
inCapture = false
end
fen:PrintSimple(style..c, i-1, y)
end
::continue::
y = y + 1
if y >= fen.Height then
break
end
end