repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim: make list option toggle

1e162916cebbccbeaab8877d0f1bb55ef90c59de

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (3)

neovim/lua/bugabinga/options/core.lua

Modified
137 137 vim.opt.confirm = true
139 139 -- show trailing whitespace
140 -vim.opt.list = true
140 +vim.opt.list = false
141 141 vim.opt.listchars = {
142 142 space = icon.space,
143 143 eol = icon.eol,
144 144 tab = icon.tab .. icon.middle_ellipsis,
145 - tab = ' ',
145 + -- tab = ' ',
146 146 trail = icon.trail,
147 147 extends = icon.extends,
148 148 precedes = icon.precedes,

neovim/lua/bugabinga/options/togglers.lua

Modified
5 5 local toggle_on_icon = icon.toggle_on
6 6 local toggle_off_icon = icon.toggle_off
8 -local get_option = function ( name ) return vim.api.nvim_get_option_value( name, {} ) end
9 -local set_option = function ( name, value ) vim.api.nvim_set_option_value( name, value, {} ) end
8 +local get_option = function(name) return vim.api.nvim_get_option_value(name, {}) end
9 +local set_option = function(name, value) vim.api.nvim_set_option_value(name, value, {}) end
11 -local toggle = function ( self )
12 - vim.iter( self.options )
13 - :each( function ( option )
14 - local current_value = get_option( option.name )
15 - if current_value == option.default then
16 - set_option( option.name, option.alternative )
17 - vim.notify( self.display_name .. ' ' .. toggle_on_icon )
18 - else
19 - set_option( option.name, option.default )
20 - vim.notify( self.display_name .. ' ' .. toggle_off_icon )
21 - end
22 - end )
11 +local toggle = function(self)
12 + vim.iter(self.options)
13 + :each(function(option)
14 + local current_value = get_option(option.name)
15 + if current_value == option.default then
16 + set_option(option.name, option.alternative)
17 + vim.notify(self.display_name .. ' ' .. toggle_on_icon)
18 + else
19 + set_option(option.name, option.default)
20 + vim.notify(self.display_name .. ' ' .. toggle_off_icon)
21 + end
22 + end)
25 -local toggler_tostring = function ( self )
26 - local all_default = vim.iter( self.options )
27 - :all( function ( option ) return get_option( option.name ) == option.default end )
25 +local toggler_tostring = function(self)
26 + local all_default = vim.iter(self.options)
27 + :all(function(option) return get_option(option.name) == option.default end)
28 28 return self.display_name .. ' ' .. (all_default and toggle_off_icon or toggle_on_icon)
31 -local make_toggler = function ( display_name, options )
31 +local make_toggler = function(display_name, options)
32 32 return {
33 33 display_name = display_name,
34 34 options = options,
40 -local make_option = function ( name, alternative )
41 - local option_value = get_option( name )
40 +local make_option = function(name, alternative)
41 + local option_value = get_option(name)
42 42 alternative = alternative or not option_value
43 43 return {
44 44 name = name,
50 -local add_toggler = function ( display_name, options )
51 - table.insert( togglers, make_toggler( display_name, options ) )
50 +local add_toggler = function(display_name, options)
51 + table.insert(togglers, make_toggler(display_name, options))
54 -add_toggler( icon.spelling, { make_option 'spell' } )
55 -add_toggler( icon.linenumber, { make_option 'number', make_option 'relativenumber' } )
56 -add_toggler( icon.linehighlight, { make_option 'cursorline' } )
57 -add_toggler( icon.wrap, { make_option 'wrap' } )
58 -add_toggler( icon.virtual, { make_option( 'virtualedit', 'all' ) } )
54 +add_toggler(icon.spelling, { make_option 'spell' })
55 +add_toggler(icon.linenumber, { make_option 'number', make_option 'relativenumber' })
56 +add_toggler(icon.linehighlight, { make_option 'cursorline' })
57 +add_toggler(icon.wrap, { make_option 'wrap' })
58 +add_toggler(icon.list, { make_option 'list' })
59 +add_toggler(icon.virtual, { make_option('virtualedit', 'all') })
60 -local tostring = function ( self )
61 - return vim.iter( self )
62 - :map( toggler_tostring )
63 - :fold( '', function ( buffer, text )
64 - return buffer .. (buffer == '' and '' or ' ') .. text
65 - end )
61 +local tostring = function(self)
62 + return vim.iter(self)
63 + :map(toggler_tostring)
64 + :fold('', function(buffer, text)
65 + return buffer .. (buffer == '' and '' or ' ') .. text
66 + end)
68 -return setmetatable( togglers, {
69 +return setmetatable(togglers, {
69 70 __tostring = tostring
70 -} )
71 +})

neovim/lua/std/icon.lua

Modified
50 50 leader_key = '󱁐',
51 51 linehighlight = '󰘤',
52 52 linenumber = '󰉻',
53 + list = '',
53 54 lock = '',
54 55 lsp = '',
55 56 macro = '',
75 76 progress_8 = '⠇',
76 77 progress_9 = '⠏',
77 78 property = ' ',
78 - prompt_caret = '󰗧',
79 - prompt_prefix = '',
79 + prompt_caret = '󰗧',
80 + prompt_prefix = '',
80 81 quot_left = '"',
81 82 quot_right = '"',
82 83 reference = '󰈇 ',