Skip to content

Commit

Permalink
style: renderRender
Browse files Browse the repository at this point in the history
All the modules in the `ui` module use capital letters for their names.
In a followup PR I can normalize the naming convention of:

* POD → snake_case
* Data + behavior → CamelCase
  • Loading branch information
Iron-E committed Apr 9, 2023
1 parent 50192a1 commit bc33c5a
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 66 deletions.
6 changes: 3 additions & 3 deletions lua/barbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local api = require'barbar.api'
local bbye = require'barbar.bbye'
local events = require'barbar.events'
local notify = require'barbar.utils'.notify
local render = require'barbar.ui.render'
local Render = require'barbar.ui.render'
local state = require'barbar.state'
local utils = require'barbar.utils'

Expand Down Expand Up @@ -188,13 +188,13 @@ function barbar.setup(options)

create_user_command(
'BufferScrollLeft',
function(tbl) render.scroll(-max(1, tbl.count)) end,
function(tbl) Render.scroll(-max(1, tbl.count)) end,
{count = true, desc = 'Scroll the bufferline left'}
)

create_user_command(
'BufferScrollRight',
function(tbl) render.scroll(max(1, tbl.count)) end,
function(tbl) Render.scroll(max(1, tbl.count)) end,
{count = true, desc = 'Scroll the bufferline right'}
)

Expand Down
44 changes: 22 additions & 22 deletions lua/barbar/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ local Buffer = require'barbar.buffer'
local config = require'barbar.config'
local JumpMode = require'barbar.jump_mode'
local Layout = require'barbar.ui.layout'
local render = require'barbar.ui.render'
local Render = require'barbar.ui.render'
local state = require'barbar.state'
local utils = require'barbar.utils'

Expand All @@ -37,12 +37,12 @@ local function pick_buffer_wrap(fn)
end

state.is_picking_buffer = true
render.update()
Render.update()

fn()

state.is_picking_buffer = false
render.update()
Render.update()
end

--- Shows an error that `bufnr` was not among the `state.buffers`
Expand Down Expand Up @@ -87,7 +87,7 @@ function api.close_all_but_current()
end
end

render.update()
Render.update()
end

--- Close all open buffers, except those in visible windows.
Expand All @@ -100,7 +100,7 @@ function api.close_all_but_visible()
end
end

render.update()
Render.update()
end

--- Close all open buffers, except pinned ones.
Expand All @@ -112,7 +112,7 @@ function api.close_all_but_pinned()
end
end

render.update()
Render.update()
end

--- Close all open buffers, except pinned ones or the current one.
Expand All @@ -126,7 +126,7 @@ function api.close_all_but_current_or_pinned()
end
end

render.update()
Render.update()
end

--- Close all buffers which are visually left of the current buffer.
Expand All @@ -141,7 +141,7 @@ function api.close_buffers_left()
bbye.bdelete(false, state.buffers[i])
end

render.update()
Render.update()
end

--- Close all buffers which are visually right of the current buffer.
Expand All @@ -156,7 +156,7 @@ function api.close_buffers_right()
bbye.bdelete(false, state.buffers[i])
end

render.update()
Render.update()
end

-- Restore last recently closed buffer
Expand Down Expand Up @@ -192,13 +192,13 @@ end
--- @param steps integer
--- @return nil
function api.goto_buffer_relative(steps)
render.get_updated_buffers()
Render.get_updated_buffers()

if #state.buffers < 1 then
return utils.notify('E85: There is no listed buffer', vim.log.levels.ERROR)
end

local current_bufnr = render.set_current_win_listed_buffer()
local current_bufnr = Render.set_current_win_listed_buffer()
local idx = utils.index_of(state.buffers, current_bufnr)

if not idx then -- fall back to: 1. the alternate buffer, 2. the first buffer
Expand Down Expand Up @@ -237,7 +237,7 @@ local function move_buffer_animated_tick(ratio, current_animation)
end
end

render.update()
Render.update()

if current_animation.running == false then
move_animation = nil
Expand Down Expand Up @@ -305,14 +305,14 @@ local function move_buffer(from_idx, to_idx)
function(ratio, current_animation) move_buffer_animated_tick(ratio, current_animation) end)
end

render.update()
Render.update()
end

--- Move the current buffer to the index specified.
--- @param idx integer
--- @return nil
function api.move_current_buffer_to(idx)
render.update()
Render.update()

if idx == -1 then
idx = #state.buffers
Expand All @@ -332,7 +332,7 @@ end
--- @param steps integer
--- @return nil
function api.move_current_buffer(steps)
render.update()
Render.update()

local current_bufnr = get_current_buf()
local idx = utils.index_of(state.buffers, current_bufnr)
Expand All @@ -348,7 +348,7 @@ end
--- @return nil
function api.order_by_buffer_number()
table_sort(state.buffers, function(a, b) return a < b end)
render.update()
Render.update()
end

--- Order the buffers by their parent directory.
Expand Down Expand Up @@ -379,7 +379,7 @@ function api.order_by_directory()
return a_less_than_b
end))

render.update()
Render.update()
end

--- Order the buffers by filetype.
Expand All @@ -389,7 +389,7 @@ function api.order_by_language()
return buf_get_option(a, 'filetype') < buf_get_option(b, 'filetype')
end))

render.update()
Render.update()
end

--- Order the buffers by their respective window number.
Expand All @@ -399,7 +399,7 @@ function api.order_by_window_number()
return bufwinnr(buf_get_name(a)) < bufwinnr(buf_get_name(b))
end))

render.update()
Render.update()
end

--- Activate the buffer pick mode.
Expand Down Expand Up @@ -437,7 +437,7 @@ function api.pick_buffer_delete()
utils.notify('Invalid input', vim.log.levels.WARN)
end

render.update()
Render.update()
end
end)
end
Expand Down Expand Up @@ -465,15 +465,15 @@ function api.set_offset(width, text, hl, side)
{ hl = hl, text = text, width = width } or
{ hl = nil, text = '', width = 0 }

render.update()
Render.update()
end

--- Toggle the `bufnr`'s "pin" state, visually.
--- @param buffer_number? integer
--- @return nil
function api.toggle_pin(buffer_number)
state.toggle_pin(buffer_number or 0)
render.update()
Render.update()
end

return api
26 changes: 13 additions & 13 deletions lua/barbar/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ local bbye = require'barbar.bbye'
local config = require'barbar.config'
local highlight = require'barbar.highlight'
local JumpMode = require'barbar.jump_mode'
local render = require'barbar.ui.render'
local Render = require'barbar.ui.render'
local state = require'barbar.state'
local utils = require'barbar.utils'

Expand Down Expand Up @@ -65,7 +65,7 @@ end
--- @return nil
events.disable = schedule_wrap(function()
events.augroups() -- clear the autocommands
render.set_tabline(nil) -- clear the tabline
Render.set_tabline(nil) -- clear the tabline
enabled = false -- mark as disabled
end)

Expand All @@ -86,7 +86,7 @@ function events.enable()
callback = vim.schedule_wrap(function(tbl)
JumpMode.unassign_letter_for(tbl.buf)
state.push_recently_closed(tbl.file)
render.update()
Render.update()
end),
group = augroup_render,
})
Expand All @@ -104,14 +104,14 @@ function events.enable()
local is_modified = buf_get_option(tbl.buf, 'modified')
if is_modified ~= vim.b[tbl.buf].checked then
buf_set_var(tbl.buf, 'checked', is_modified)
render.update()
Render.update()
end
end,
group = augroup_render,
})

create_autocmd({'BufEnter', 'BufNew'}, {
callback = function() render.update(true) end,
callback = function() Render.update(true) end,
group = augroup_render,
})

Expand All @@ -124,7 +124,7 @@ function events.enable()
'WinEnter', 'WinLeave',
},
{
callback = function() render.update() end,
callback = function() Render.update() end,
group = augroup_render,
}
)
Expand Down Expand Up @@ -208,7 +208,7 @@ function events.enable()
end

create_autocmd('OptionSet', {
callback = function() render.update() end,
callback = function() Render.update() end,
group = augroup_render,
pattern = 'buflisted',
})
Expand All @@ -225,13 +225,13 @@ function events.enable()
if restore_cmd then command(restore_cmd) end

vim.defer_fn(function() state.loading_session = false end, 100)
schedule(function() render.update(true) end)
schedule(function() Render.update(true) end)
end,
group = augroup_render,
})

create_autocmd('TermOpen', {
callback = function() defer_fn(function() render.update(true) end, 500) end,
callback = function() defer_fn(function() Render.update(true) end, 500) end,
group = augroup_render,
})

Expand Down Expand Up @@ -277,7 +277,7 @@ function events.enable()
})

create_autocmd('WinClosed', {
callback = schedule_wrap(render.update),
callback = schedule_wrap(Render.update),
group = augroup_render,
})

Expand All @@ -299,7 +299,7 @@ function events.enable()
]]
end)

render.update()
Render.update()
enabled = true
end

Expand All @@ -317,7 +317,7 @@ function events.main_click_handler(bufnr, _, btn, _)
if btn == 'm' then
bbye.bdelete(false, bufnr)
else
render.set_current_win_listed_buffer()
Render.set_current_win_listed_buffer()
set_current_buf(bufnr)
end
end
Expand All @@ -333,7 +333,7 @@ function events.on_option_changed(user_config)

-- Don't jump-start barbar if it is disabled
if enabled then
render.update()
Render.update()
end
end

Expand Down
Loading

0 comments on commit bc33c5a

Please sign in to comment.