Skip to content

Commit 3fd2f01

Browse files
authored
Add 'win_border' config option (#509)
1 parent a2bccad commit 3fd2f01

File tree

10 files changed

+50
-19
lines changed

10 files changed

+50
-19
lines changed

DOCS.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,40 @@ Always open horizontally with specific height of 20 lines:
132132
win_split_mode = '20split'
133133
```
134134

135+
#### **win_border**
136+
*type*: `string|string[]`<br />
137+
*default value*: `single`<br />
138+
Border style of floating windows.<br />
139+
Available options:
140+
* `none` - No border (default)
141+
* `single` - A single line box
142+
* `double` - A double line box
143+
* `rounded` - Like "single", but with rounded corners ("╭" etc.)
144+
* `solid` - Adds padding by a single whitespace cell
145+
* `shadow` - A drop shadow effect by blending with the background
146+
* `{'╔', '═' ,'╗', '║', '╝', '═', '╚', '║' }` - Specify border characters in a clock-wise fashion
147+
* `{'/', '-', '\\', '|' }` - If less than eight chars the chars will start repeating
148+
149+
See `:help nvim_open_win()`
150+
151+
Applies to:
152+
always
153+
- calendar pop-up
154+
- help pop-up
155+
- notification pop-up
156+
`win_split_mode` is set to `float`
157+
- agenda window
158+
- capture window
159+
160+
135161
#### **org_todo_keyword_faces**
136162
*type*: `table<string, string>`<br />
137163
*default value*: `{}`<br />
138164
Custom colors for todo keywords.<br />
139165
Available options:
140166
* foreground - `:foreground hex/colorname`. Examples: `:foreground #FF0000`, `:foreground blue`
141167
* background - `:background hex/colorname`. Examples: `:background #FF0000`, `:background blue`
142-
* weight - `:weight bold`.
168+
* weight - `:weight bold`
143169
* underline - `:underline on`
144170
* italic - `:slant italic`
145171

@@ -1290,7 +1316,7 @@ In order to trigger notifications via cron, job needs to be added to the crontab
12901316
This is currently possible only on Linux and MacOS, since I don't know how would this be done on Windows. Any help on this topic is appreciated. <br />
12911317
This works by starting the headless Neovim instance, running one off function inside orgmode, and quitting the Neovim.
12921318

1293-
Here's maximum simplified **Linux** example (Tested on Manjaro/Arch), but least optimized:
1319+
Here's maximum simplified **Linux** example (Tested on Manjaro/Arch/Ubuntu), but least optimized:
12941320

12951321
Run this to open crontab:
12961322
```

lua/orgmode/agenda/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function Agenda:open_window()
7777
end
7878
end
7979

80-
utils.open_window('orgagenda', math.max(34, config.org_agenda_min_height), config.win_split_mode)
80+
utils.open_window('orgagenda', math.max(34, config.org_agenda_min_height), config.win_split_mode, config.win_border)
8181

8282
vim.cmd([[setf orgagenda]])
8383
vim.cmd([[setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap nospell]])

lua/orgmode/capture/closing_note.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ end
1414

1515
function ClosingNote:open()
1616
self._resolve_fn = nil
17-
self._close_tmp = utils.open_tmp_org_window(16, config.win_split_mode)
17+
self._close_tmp = utils.open_tmp_org_window(16, config.win_split_mode, config.win_border)
1818
config:setup_mappings('note')
1919
vim.api.nvim_buf_set_var(0, 'org_note', true)
2020
vim.api.nvim_buf_set_lines(0, 0, -1, false, { '# Insert note for closed todo item', '', '' })

lua/orgmode/capture/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function Capture:open_template(template)
7272
local on_close = function()
7373
require('orgmode').action('capture.refile', true)
7474
end
75-
self._close_tmp = utils.open_tmp_org_window(16, config.win_split_mode, on_close)
75+
self._close_tmp = utils.open_tmp_org_window(16, config.win_split_mode, config.win_border, on_close)
7676
vim.api.nvim_buf_set_lines(0, 0, -1, true, content)
7777
self.templates:setup()
7878
vim.api.nvim_buf_set_var(0, 'org_template', template)

lua/orgmode/config/defaults.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ local DefaultConfig = {
4242
org_edit_src_content_indentation = 0,
4343
diagnostics = true,
4444
win_split_mode = 'horizontal',
45+
win_border = 'single',
4546
notifications = {
4647
enabled = false,
4748
cron_enabled = true,

lua/orgmode/notifications/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function Notifications:notify(time)
5555
end
5656

5757
if not vim.tbl_isempty(result) then
58-
NotificationPopup:new({ content = result })
58+
NotificationPopup:new({ content = result, border = config.win_border })
5959
end
6060
end
6161

lua/orgmode/notifications/notification_popup.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ function NotificationPopup:new(opts)
66
hide_after = opts.hide_after or 15000,
77
buf = nil,
88
win = nil,
9+
border = opts.border,
910
}
1011
setmetatable(data, self)
1112
self.__index = self
@@ -22,7 +23,7 @@ function NotificationPopup:show()
2223
width = 50,
2324
height = #self.content,
2425
style = 'minimal',
25-
border = 'single',
26+
border = self.border,
2627
anchor = 'NE',
2728
row = 0,
2829
col = vim.o.columns - 1,

lua/orgmode/objects/calendar.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function Calendar.open()
4343
width = width,
4444
height = Calendar.clearable and height + 1 or height,
4545
style = 'minimal',
46-
border = 'single',
46+
border = config.win_border,
4747
row = vim.o.lines / 2 - (y_offset + height) / 2,
4848
col = vim.o.columns / 2 - (x_offset + width) / 2,
4949
}

lua/orgmode/objects/help.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ function Help.show(opts)
322322
height = math.min(#content + 1, vim.o.lines - 2),
323323
anchor = 'NW',
324324
style = 'minimal',
325-
border = 'single',
325+
border = config.win_border,
326326
row = 5,
327327
col = vim.o.columns / 4,
328328
}

lua/orgmode/utils/init.lua

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,8 @@ end
495495
---@param name string
496496
---@param height number
497497
---@param split_mode string|function|table
498-
function utils.open_window(name, height, split_mode)
498+
---@param border string|table
499+
function utils.open_window(name, height, split_mode, border)
499500
local cmd_by_split_mode = {
500501
horizontal = string.format('%dsplit %s', height, name),
501502
vertical = string.format('vsplit %s', name),
@@ -524,19 +525,19 @@ function utils.open_window(name, height, split_mode)
524525
end
525526

526527
if split_mode == 'float' then
527-
return utils.open_float(name)
528+
return utils.open_float(name, { border = border })
528529
end
529530

530531
if type(split_mode) == 'table' and split_mode[1] == 'float' then
531-
return utils.open_float(name, split_mode[2])
532+
return utils.open_float(name, { scale = split_mode[2], border = border })
532533
end
533534

534535
return vim.cmd(string.format('%s %s', split_mode, name))
535536
end
536537

537-
function utils.open_tmp_org_window(height, split_mode, on_close)
538+
function utils.open_tmp_org_window(height, split_mode, border, on_close)
538539
local winnr = vim.api.nvim_get_current_win()
539-
utils.open_window(vim.fn.tempname(), height or 16, split_mode)
540+
utils.open_window(vim.fn.tempname(), height or 16, split_mode, border)
540541
vim.cmd([[setf org]])
541542
vim.cmd([[setlocal bufhidden=wipe nobuflisted nolist noswapfile nofoldenable]])
542543
vim.api.nvim_buf_set_var(0, 'org_prev_window', winnr)
@@ -567,11 +568,13 @@ function utils.open_tmp_org_window(height, split_mode, on_close)
567568
end
568569

569570
---@param name string
570-
---@param scale? number
571-
function utils.open_float(name, scale)
572-
scale = scale or 0.7
571+
---@param opts? table
572+
function utils.open_float(name, opts)
573+
opts = opts or { scale = nil, border = nil }
574+
opts.scale = opts.scale or 0.7
575+
opts.border = opts.border or 'single'
573576
-- Make sure number is between 0 and 1
574-
scale = math.min(math.max(0, scale), 1)
577+
local scale = math.min(math.max(0, opts.scale), 1)
575578
local bufnr = vim.api.nvim_create_buf(false, true)
576579
vim.api.nvim_buf_set_name(bufnr, name)
577580

@@ -587,7 +590,7 @@ function utils.open_float(name, scale)
587590
row = row,
588591
col = col,
589592
style = 'minimal',
590-
border = 'rounded',
593+
border = opts.border,
591594
})
592595
end
593596

0 commit comments

Comments
 (0)