Skip to content

Commit c704d4d

Browse files
committed
feat: make borders configurable
And switch to a more compact default: ┌─ CommandT [rg] ───────────────────────────────────────────┐ │> │ └───────────────────────────────────────────────────────────┘ > CODE_OF_CONDUCT.md CONTRIBUTING.md Gemfile Gemfile.lock LICENSE.md Makefile README.md appstream/vim-command-t.metainfo.xml autoload/commandt.vim autoload/commandt/private.vim bin/benchmarks/matcher.lua bin/benchmarks/matcher.rb bin/benchmarks/scanner.lua bin/benchmarks/watchman.rb bin/check-format bin/check-tag bin/create-archive bin/format bin/help bin/spec bin/symbolicate-dtrace bin/test bin/test.lua compile_flags.txt data/benchmark.yml data/wincent/commandt/benchmark/configs/matcher.lua data/wincent/commandt/benchmark/configs/scanner.lua doc/command-t-ruby.txt doc/command-t.txt fixtures/bar/abc ie. - prompt goes from "rounded" to "single" - match listing goes from "rounded" to: - no border on top or bottom - blank space on right and left
1 parent 4ee21e2 commit c704d4d

File tree

6 files changed

+63
-1
lines changed

6 files changed

+63
-1
lines changed

doc/command-t.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,19 @@ are documented and they could change without notice at any time; for example:
412412
},
413413
},
414414
margin = 10,
415+
match_listing = {
416+
-- 'double', 'none', 'rounded', 'shadow', 'single', 'solid', or a
417+
-- list of strings.
418+
border = { '', '', '', ' ', '', '', '', ' '},
419+
},
415420
never_show_dot_files = false,
416421
order = 'forward', -- 'forward' or 'reverse'.
417422
position = 'center', -- 'bottom', 'center' or 'top'.
423+
prompt = {
424+
-- 'double', 'none', 'rounded', 'shadow', 'single', 'solid', or a
425+
-- list of strings.
426+
border = 'single',
427+
},
418428
open = function(item, kind)
419429
commandt.open(item, kind)
420430
end,

lua/wincent/commandt/init.lua

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,45 @@ local options_spec = {
114114
end
115115
end,
116116
},
117+
match_listing = {
118+
kind = 'table',
119+
keys = {
120+
border = {
121+
kind = {
122+
one_of = {
123+
'double',
124+
'none',
125+
'rounded',
126+
'shadow',
127+
'single',
128+
'solid',
129+
{ kind = 'list', of = { kind = 'string' } },
130+
},
131+
},
132+
},
133+
},
134+
},
117135
never_show_dot_files = { kind = 'boolean' },
118136
order = { kind = { one_of = { 'forward', 'reverse' } } },
119137
position = { kind = { one_of = { 'bottom', 'center', 'top' } } },
138+
prompt = {
139+
kind = 'table',
140+
keys = {
141+
border = {
142+
kind = {
143+
one_of = {
144+
'double',
145+
'none',
146+
'rounded',
147+
'shadow',
148+
'single',
149+
'solid',
150+
{ kind = 'list', of = { kind = 'string' } },
151+
},
152+
},
153+
},
154+
},
155+
},
120156
open = { kind = 'function' },
121157
scanners = {
122158
kind = 'table',
@@ -408,9 +444,15 @@ local default_options = {
408444
},
409445
},
410446
margin = 10,
447+
match_listing = {
448+
border = { '', '', '', ' ', '', '', '', ' ' }, -- 'double', 'none', 'rounded', 'shadow', 'single', 'solid', or a list of strings.
449+
},
411450
never_show_dot_files = false,
412451
order = 'forward', -- 'forward', 'reverse'.
413452
position = 'center', -- 'bottom', 'center', 'top'.
453+
prompt = {
454+
border = 'single', -- 'double', 'none', 'rounded', 'shadow', 'single', 'solid', or a list of strings.
455+
},
414456
open = open,
415457
scanners = {
416458
file = {

lua/wincent/commandt/private/match_listing.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ local mt = {
1717

1818
function MatchListing.new(options)
1919
options = merge({
20+
border = { '', '', '', ' ', '', '', '', ' ' },
2021
height = 15,
2122
margin = 0,
2223
position = 'bottom',
2324
selection_highlight = 'PMenuSel',
2425
}, options or {})
2526
-- TODO: validate options
2627
local m = {
28+
_border = options.border,
2729
_height = options.height,
2830
_margin = options.margin,
2931
_position = options.position,
@@ -112,6 +114,7 @@ function MatchListing:show()
112114
-- TODO: deal with other options, like reverse
113115
if self._window == nil then
114116
self._window = Window.new({
117+
border = self._border,
115118
bottom = bottom,
116119
description = 'CommandT [match listing]',
117120
filetype = 'CommandTMatchListing',

lua/wincent/commandt/private/prompt.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ local mt = {
2121

2222
function Prompt.new(options)
2323
options = merge({
24+
border = 'single',
2425
mappings = {},
2526
margin = 0,
2627
height = 15,
@@ -33,6 +34,7 @@ function Prompt.new(options)
3334
}, options or {})
3435
-- TODO validate options
3536
local p = {
37+
_border = options.border,
3638
_height = options.height,
3739
_mappings = options.mappings,
3840
_margin = options.margin,
@@ -83,6 +85,7 @@ function Prompt:show()
8385

8486
if self._window == nil then
8587
self._window = Window.new({
88+
border = self._border,
8689
bottom = bottom,
8790
buftype = 'prompt',
8891
filetype = 'CommandTPrompt',

lua/wincent/commandt/private/ui.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ ui.show = function(finder, options)
8080
current_window = vim.api.nvim_get_current_win()
8181

8282
match_listing = MatchListing.new({
83+
border = options.match_listing.border,
8384
height = options.height,
8485
margin = options.margin,
8586
position = options.position,
@@ -90,6 +91,7 @@ ui.show = function(finder, options)
9091
results = nil
9192
selected = nil
9293
prompt = Prompt.new({
94+
border = options.prompt.border,
9395
height = options.height,
9496
mappings = options.mappings,
9597
margin = options.margin,

lua/wincent/commandt/private/window.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ end
5858

5959
function Window.new(options)
6060
options = merge({
61+
border = 'single',
6162
bottom = nil,
6263
buftype = 'nofile', -- Also, 'prompt'.
6364
filetype = nil,
@@ -74,6 +75,7 @@ function Window.new(options)
7475
}, options)
7576
validate_options(options)
7677
local w = {
78+
_border = options.border,
7779
_bottom = options.bottom,
7880
_buftype = options.buftype,
7981
_description = options.description,
@@ -266,7 +268,7 @@ function Window:show()
266268
self._main_buffer,
267269
false, -- enter = false
268270
merge({
269-
border = 'rounded', -- TODO make configurable
271+
border = self._border,
270272
focusable = false,
271273
noautocmd = true,
272274
relative = 'editor',

0 commit comments

Comments
 (0)