File tree Expand file tree Collapse file tree 5 files changed +44
-22
lines changed
Expand file tree Collapse file tree 5 files changed +44
-22
lines changed Original file line number Diff line number Diff line change @@ -38,9 +38,7 @@ function M:set_filter(filter)
3838end
3939
4040function M :build ()
41- local config = vim .tbl_deep_extend (' force' , dconfig , self .config or {})
42-
43- local configurer = self .configurer or dconfigurer :new (config )
41+ local configurer = self .configurer or dconfigurer :new (self .config )
4442
4543 local hint = configurer :config_hint (self .hint or dhint :new ())
4644 local filter = configurer :config_filter (self .filter or dfilter :new ())
Original file line number Diff line number Diff line change 11local config = {
2+ -- type of hints you want to get
3+ -- following types are supported
4+ -- 'statusline-winbar' | 'statusline' | 'floating-big-letter'
5+ hint = ' floating-big-letter' ,
6+
27 -- when you go to window selection mode, status bar will show one of
38 -- following letters on them so you can use that letter to select the window
49 selection_chars = ' FJDKSLA;CMRUEIWOQP' ,
@@ -20,7 +25,7 @@ local config = {
2025 use_winbar = ' never' , -- "always" | "never" | "smart"
2126 },
2227
23- floating_window_picker = {
28+ floating_big_letter = {
2429 -- window picker plugin provides bunch of big letter fonts
2530 -- fonts will be lazy loaded as they are being requested
2631 -- additionally, user can pass in a table of fonts in to font
Original file line number Diff line number Diff line change 1- local util = require (' window-picker.util' )
2- local dconfig = require (' window-picker.config' )
3-
41--- @class Configurer
52--- @field config any
63local M = {}
74
85function M :new (config )
9- config = config and util .merge_config (dconfig , config ) or dconfig
106 config = M ._backward_compatibility_config_changes (config )
117 config = M ._basic_config_manipulations (config )
128
@@ -15,7 +11,6 @@ function M:new(config)
1511 }
1612
1713 setmetatable (o , self )
18-
1914 self .__index = self
2015
2116 return o
Original file line number Diff line number Diff line change 1- local ansi_shadow = require (' window-picker.hints.data.ansi-shadow' )
21local utf8 = require (' window-picker.utf-8' )
32
43--- @class FloatingBigLetterHint
@@ -33,21 +32,21 @@ function M:new()
3332 windows = {},
3433 }
3534
36- setmetatable (o , M )
35+ setmetatable (o , self )
3736 self .__index = self
3837
3938 return o
4039end
4140
4241function M :set_config (config )
4342 self .chars = config .chars
44- local font = config .picker_config .floating_window_picker .font
43+ local font = config .picker_config .floating_big_letter .font
4544
4645 if type (font ) == ' string' then
4746 self .big_chars = require ((' window-picker.hints.data.%s' ):format (font ))
4847 end
4948
50- if type (font ) == ' table' then
49+ if type (font ) == ' table' then
5150 self .big_chars = font
5251 end
5352end
Original file line number Diff line number Diff line change 1- local FloatingHint = require (' window-picker.hints.floating-big-letter-hint' )
21local builder = require (' window-picker.builder' )
2+ local dconfig = require (' window-picker.config' )
33
44local M = {}
55
66function M .pick_window (custom_config )
7- return builder
8- :new ()
9- :set_config (custom_config )
10- :set_hint (FloatingHint :new ())
11- :set_picker ()
12- :set_filter ()
13- :build ()
14- :pick_window ()
7+ local config = dconfig
8+
9+ -- merge the config
10+ if custom_config then
11+ config = vim .tbl_deep_extend (' force' , config , custom_config )
12+ end
13+
14+ local hint
15+
16+ if type (config .hint ) == ' string' then
17+ local ok , result = pcall (
18+ require ,
19+ (' window-picker.hints.%s-hint' ):format (config .hint )
20+ )
21+
22+ if not ok then
23+ vim .notify (
24+ (' No hint found by the name "%s"\n Error: %s' ):format (
25+ config .hint ,
26+ result
27+ ),
28+ vim .log .levels .ERROR
29+ )
30+
31+ return
32+ end
33+
34+ hint = result :new ()
35+ else
36+ hint = config .hint
37+ end
38+
39+ return builder :new ():set_config (config ):set_hint (hint ):build ():pick_window ()
1540end
1641
1742function M .setup () end
You can’t perform that action at this time.
0 commit comments