Skip to content

Commit

Permalink
feat: make borders configurable
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wincent committed Sep 27, 2024
1 parent 4ee21e2 commit c704d4d
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 1 deletion.
10 changes: 10 additions & 0 deletions doc/command-t.txt
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,19 @@ are documented and they could change without notice at any time; for example:
},
},
margin = 10,
match_listing = {
-- 'double', 'none', 'rounded', 'shadow', 'single', 'solid', or a
-- list of strings.
border = { '', '', '', ' ', '', '', '', ' '},
},
never_show_dot_files = false,
order = 'forward', -- 'forward' or 'reverse'.
position = 'center', -- 'bottom', 'center' or 'top'.
prompt = {
-- 'double', 'none', 'rounded', 'shadow', 'single', 'solid', or a
-- list of strings.
border = 'single',
},
open = function(item, kind)
commandt.open(item, kind)
end,
Expand Down
42 changes: 42 additions & 0 deletions lua/wincent/commandt/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,45 @@ local options_spec = {
end
end,
},
match_listing = {
kind = 'table',
keys = {
border = {
kind = {
one_of = {
'double',
'none',
'rounded',
'shadow',
'single',
'solid',
{ kind = 'list', of = { kind = 'string' } },
},
},
},
},
},
never_show_dot_files = { kind = 'boolean' },
order = { kind = { one_of = { 'forward', 'reverse' } } },
position = { kind = { one_of = { 'bottom', 'center', 'top' } } },
prompt = {
kind = 'table',
keys = {
border = {
kind = {
one_of = {
'double',
'none',
'rounded',
'shadow',
'single',
'solid',
{ kind = 'list', of = { kind = 'string' } },
},
},
},
},
},
open = { kind = 'function' },
scanners = {
kind = 'table',
Expand Down Expand Up @@ -408,9 +444,15 @@ local default_options = {
},
},
margin = 10,
match_listing = {
border = { '', '', '', ' ', '', '', '', ' ' }, -- 'double', 'none', 'rounded', 'shadow', 'single', 'solid', or a list of strings.
},
never_show_dot_files = false,
order = 'forward', -- 'forward', 'reverse'.
position = 'center', -- 'bottom', 'center', 'top'.
prompt = {
border = 'single', -- 'double', 'none', 'rounded', 'shadow', 'single', 'solid', or a list of strings.
},
open = open,
scanners = {
file = {
Expand Down
3 changes: 3 additions & 0 deletions lua/wincent/commandt/private/match_listing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ local mt = {

function MatchListing.new(options)
options = merge({
border = { '', '', '', ' ', '', '', '', ' ' },
height = 15,
margin = 0,
position = 'bottom',
selection_highlight = 'PMenuSel',
}, options or {})
-- TODO: validate options
local m = {
_border = options.border,
_height = options.height,
_margin = options.margin,
_position = options.position,
Expand Down Expand Up @@ -112,6 +114,7 @@ function MatchListing:show()
-- TODO: deal with other options, like reverse
if self._window == nil then
self._window = Window.new({
border = self._border,
bottom = bottom,
description = 'CommandT [match listing]',
filetype = 'CommandTMatchListing',
Expand Down
3 changes: 3 additions & 0 deletions lua/wincent/commandt/private/prompt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ local mt = {

function Prompt.new(options)
options = merge({
border = 'single',
mappings = {},
margin = 0,
height = 15,
Expand All @@ -33,6 +34,7 @@ function Prompt.new(options)
}, options or {})
-- TODO validate options
local p = {
_border = options.border,
_height = options.height,
_mappings = options.mappings,
_margin = options.margin,
Expand Down Expand Up @@ -83,6 +85,7 @@ function Prompt:show()

if self._window == nil then
self._window = Window.new({
border = self._border,
bottom = bottom,
buftype = 'prompt',
filetype = 'CommandTPrompt',
Expand Down
2 changes: 2 additions & 0 deletions lua/wincent/commandt/private/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ ui.show = function(finder, options)
current_window = vim.api.nvim_get_current_win()

match_listing = MatchListing.new({
border = options.match_listing.border,
height = options.height,
margin = options.margin,
position = options.position,
Expand All @@ -90,6 +91,7 @@ ui.show = function(finder, options)
results = nil
selected = nil
prompt = Prompt.new({
border = options.prompt.border,
height = options.height,
mappings = options.mappings,
margin = options.margin,
Expand Down
4 changes: 3 additions & 1 deletion lua/wincent/commandt/private/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ end

function Window.new(options)
options = merge({
border = 'single',
bottom = nil,
buftype = 'nofile', -- Also, 'prompt'.
filetype = nil,
Expand All @@ -74,6 +75,7 @@ function Window.new(options)
}, options)
validate_options(options)
local w = {
_border = options.border,
_bottom = options.bottom,
_buftype = options.buftype,
_description = options.description,
Expand Down Expand Up @@ -266,7 +268,7 @@ function Window:show()
self._main_buffer,
false, -- enter = false
merge({
border = 'rounded', -- TODO make configurable
border = self._border,
focusable = false,
noautocmd = true,
relative = 'editor',
Expand Down

0 comments on commit c704d4d

Please sign in to comment.