| 1 |
local Window = require('lualine.components.buffers.buffer'):extend() |
| 2 |
|
| 3 |
---initialize a new buffer from opts |
| 4 |
---@param opts table |
| 5 |
function Window:init(opts) |
| 6 |
assert(opts.winnr, 'Cannot create Window without winnr') |
| 7 |
opts.bufnr = vim.api.nvim_win_get_buf(opts.winnr) |
| 8 |
|
| 9 |
Window.super.init(self, opts) |
| 10 |
|
| 11 |
self.winnr = opts.winnr |
| 12 |
self.win_number = vim.api.nvim_win_get_number(self.winnr) |
| 13 |
end |
| 14 |
|
| 15 |
function Window:is_current() |
| 16 |
return vim.api.nvim_get_current_win() == self.winnr |
| 17 |
end |
| 18 |
|
| 19 |
function Window:apply_mode(name) |
| 20 |
if self.options.mode == 0 then |
| 21 |
return string.format('%s%s%s', self.icon, name, self.modified_icon) |
| 22 |
end |
| 23 |
|
| 24 |
if self.options.mode == 1 then |
| 25 |
return string.format('%s %s%s', self.win_number, self.icon, self.modified_icon) |
| 26 |
end |
| 27 |
|
| 28 |
return string.format('%s %s%s%s', self.win_number, self.icon, name, self.modified_icon) |
| 29 |
end |
| 30 |
|
| 31 |
function Window:configure_mouse_click(name) |
| 32 |
return string.format('%%%s@LualineSwitchWindow@%s%%T', self.win_number, name) |
| 33 |
end |
| 34 |
|
| 35 |
return Window |