mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
refactor(vim.opt): optimize append/prepend/remove
This commit is contained in:
parent
b364bc2c34
commit
ad972990ad
@ -502,8 +502,6 @@ local create_option_accessor = function(scope)
|
|||||||
_set = function(self)
|
_set = function(self)
|
||||||
local value = convert_value_to_vim(self._name, self._info, self._value)
|
local value = convert_value_to_vim(self._name, self._info, self._value)
|
||||||
a.nvim_set_option_value(self._name, value, { scope = scope })
|
a.nvim_set_option_value(self._name, value, { scope = scope })
|
||||||
|
|
||||||
return self
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
get = function(self)
|
get = function(self)
|
||||||
@ -511,7 +509,8 @@ local create_option_accessor = function(scope)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
append = function(self, right)
|
append = function(self, right)
|
||||||
return self:__add(right):_set()
|
self._value = add_value(self._info, self._value, right)
|
||||||
|
self:_set()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
__add = function(self, right)
|
__add = function(self, right)
|
||||||
@ -519,7 +518,8 @@ local create_option_accessor = function(scope)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
prepend = function(self, right)
|
prepend = function(self, right)
|
||||||
return self:__pow(right):_set()
|
self._value = prepend_value(self._info, self._value, right)
|
||||||
|
self:_set()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
__pow = function(self, right)
|
__pow = function(self, right)
|
||||||
@ -527,7 +527,8 @@ local create_option_accessor = function(scope)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
remove = function(self, right)
|
remove = function(self, right)
|
||||||
return self:__sub(right):_set()
|
self._value = remove_value(self._info, self._value, right)
|
||||||
|
self:_set()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
__sub = function(self, right)
|
__sub = function(self, right)
|
||||||
|
Loading…
Reference in New Issue
Block a user