1
1
local M = {}
2
2
---- ----------------------------------------------------------------------------
3
3
4
+ local fallbackBorder = " rounded"
5
+
6
+ --- @return string
7
+ local function getBorder ()
8
+ local hasWinborder , winborder = pcall (function () return vim .o .winborder end )
9
+ if not hasWinborder or winborder == " " or winborder == " none" then return fallbackBorder end
10
+ return winborder
11
+ end
12
+
13
+ ---- ----------------------------------------------------------------------------
14
+
4
15
--- @class Tinygit.Config
5
16
local defaultConfig = {
6
17
stage = { -- requires `telescope.nvim`
@@ -26,7 +37,7 @@ local defaultConfig = {
26
37
},
27
38
commit = {
28
39
keepAbortedMsgSecs = 300 ,
29
- border = vim . fn . has ( " nvim-0.11 " ) == 1 and vim .o .winborder or " rounded" ,
40
+ border = getBorder (), -- ` vim.o.winborder` on nvim 0.11, otherwise "rounded"
30
41
spellcheck = false , -- vim's builtin spellcheck
31
42
wrap = " hard" , --- @type " hard" | " soft" | " none"
32
43
keymaps = {
@@ -75,7 +86,7 @@ local defaultConfig = {
75
86
diffPopup = {
76
87
width = 0.8 , -- between 0-1
77
88
height = 0.8 ,
78
- border = vim . fn . has ( " nvim-0.11 " ) == 1 and vim .o .winborder or " rounded" ,
89
+ border = getBorder (), -- ` vim.o.winborder` on nvim 0.11, otherwise "rounded"
79
90
},
80
91
autoUnshallowIfNeeded = false ,
81
92
},
@@ -168,15 +179,13 @@ function M.setup(userConfig)
168
179
--- @diagnostic enable : undefined-field
169
180
170
181
-- VALIDATE border `none` does not work with and title/footer used by this plugin
171
- if M .config .history .diffPopup .border == " none" then
172
- local fallback = defaultConfig .history .diffPopup .border
173
- M .config .history .diffPopup .border = fallback
174
- warn ((' Border type "none" is not supported, falling back to %q.' ):format (fallback ))
182
+ if M .config .history .diffPopup .border == " none" or M .config .history .diffPopup .border == " " then
183
+ M .config .history .diffPopup .border = fallbackBorder
184
+ warn ((' Border type "none" is not supported, falling back to %q.' ):format (fallbackBorder ))
175
185
end
176
- if M .config .commit .border == " none" then
177
- local fallback = defaultConfig .commit .border
178
- M .config .commit .border = fallback
179
- warn ((' Border type "none" is not supported, falling back to %q.' ):format (fallback ))
186
+ if M .config .commit .border == " none" or M .config .commit .border == " " then
187
+ M .config .commit .border = fallbackBorder
188
+ warn ((' Border type "none" is not supported, falling back to %q.' ):format (fallbackBorder ))
180
189
end
181
190
182
191
-- VALIDATE `context` > 0 (0 is not supported without `--unidiff-zero`)
0 commit comments