61ac665774
- includes modified class implementation from https://github.com/rxi/classic/blob/master/classic.lua - now base component class is created from classic. - change to how component classes are created. - Don't overwrite new method to initialize a component. Overwrite the init method. new is responsible for creating class object and calling init on it. Unlike previous new overwrite you don't need to create the class (table) and return it. Instead you will recive the object as self and do required manipulation on that just like any most other oop langs. Also don't need to return anything from init. init's job is to initialize. remember to call classes init before running your operations unfortunately lua isn't full fledged oop lang and I don't how to automate this. - changes how super classes are accesed. - rename Component._parent -> Component.super - methods on super classes now ran through super class instead of objects _parent self._parent as that can lead to recursive inf loop. See branch, diff, tabs, buffer classes call to init for example on pattern. - All components updated to reflect current logic - component loader updated to use new initialization procedure. - updated tests - updated BREAKING_CHANGES.md - plus quite a bit of formatting changes in the components - comp.method = function(self, ...) -> function M:method(...) BREAKING_CHANGE
94 lines
3.4 KiB
Markdown
94 lines
3.4 KiB
Markdown
This file contains breaking changes that have been made in this branch to
|
|
make it easier to switch from [hoob3rt/lualine.nvim](https://github.com/hoob3rt/lualine.nvim)
|
|
This file contains changes in chronological order. It's possible breaking change
|
|
has been made several times to the same thing. In that case the one nearest the
|
|
bottom indicates current state.
|
|
|
|
### Color option unification
|
|
color_added, color_modified, color_removed options in diff & color_error,
|
|
color_warning, color_info, color_hint too only fg color that was different
|
|
from other color options that took fg ,bg & gui changes were made to make
|
|
them similar.
|
|
|
|
So instead of
|
|
```lua
|
|
color_added = '#rrbbgg',
|
|
```
|
|
You'll have
|
|
```lua
|
|
color_added = { fg = '#rrbbgg' }
|
|
```
|
|
for the same effect.
|
|
|
|
### Theme rename
|
|
Some themes were renamed so they are same as their `g:color_name`
|
|
- oceanicnext -> OceanicNext
|
|
- papercolor -> PaperColor
|
|
- tomorrow -> Tomorrow
|
|
- gruvbox_material -> gruvbox-material
|
|
- modus_vivendi -> modus-vivendi
|
|
|
|
### function components now receive some default parameters
|
|
Now function components receive the same args as `update_status`. So the function
|
|
signature is now:
|
|
```lua
|
|
function(self, is_active)
|
|
```
|
|
`self` is a table that represents the component in lualine & `is_active` is
|
|
a boolean value that indicates whether the function is being evaluated
|
|
for an active statusline or an inactive statusline. This means function components
|
|
can be more versatile. But it also means you can't use functions that take
|
|
optional arguments directly as function component. `lsp_status` is such
|
|
a case that takes an optional `winid` in its first argument.
|
|
You can wrap it with a function so the `self` & `is_active` don't
|
|
get passed to `lsp_status`
|
|
```lua
|
|
lualine_c = { function() return require'lsp-status'.status() end}
|
|
```
|
|
|
|
### Options simplification
|
|
See [#24](https://github.com/shadmansaleh/lualine.nvim/pull/24) for details
|
|
- `upper` & `lower` removed use `string.upper/lower` in `fmt` option.
|
|
- separators are specified by left & right instead of position
|
|
instead of `{'>', '<'}` you'll use `{left= '>', right='<'}`.
|
|
- `left_padding` & `right_padding` removed. You can specify left or right
|
|
padding with a padding option like padding = `{ left = 5 }`
|
|
- Option rename:
|
|
- condition -> cond
|
|
- format -> fmt
|
|
- disable_text -> icon_only
|
|
- color_added, color_modified, color_removed are now available as added,
|
|
modified, removed in diff_color table option
|
|
- color_error, color_warning, color_info, color_hint are now available
|
|
as error, warn, info, hint in diagnostics_color table option
|
|
|
|
### Component class refactor
|
|
***Applicable only ones responsible for custom components***
|
|
- Now call extend method on super class to create new type of component instead of calling new with empty args.
|
|
- Don't overrite new method for initialization. Overrite init instead.
|
|
- rename Component._parent -> Component.super
|
|
- Call methods from super class directly on classes super not through
|
|
objects super or self.super
|
|
So basically if you had something like
|
|
```lua
|
|
local my_comp = require'lualine.component':new()
|
|
function mycomp:new(options, child)
|
|
local obj = self._parent:new(options, child or my_comp)
|
|
obj.x = 1
|
|
obj.y = 2
|
|
return obj
|
|
end
|
|
```
|
|
change it to
|
|
```lua
|
|
local my_comp = require('lualine.component'):extend()
|
|
|
|
function my_comp:init(options)
|
|
-- Notice carefully it's not self.super.init nor my_comp.super:init
|
|
my_comp.super.init(self, options)
|
|
self.x = 1
|
|
self.y = 2
|
|
end
|
|
```
|
|
|