feat(Popup): allow override of default config

Before we did not allow the default config to be overridden, but now we
do.
This commit is contained in:
Iron-E 2020-12-13 18:44:05 -05:00
parent 0f9b51cb0c
commit 81abfff50c
No known key found for this signature in database
GPG Key ID: 19B71B7B7B021D22
2 changed files with 10 additions and 3 deletions

View File

@ -386,13 +386,20 @@ FUNCTIONS *libmodal-lua-Popup-functions*
{keepBuffer} A `boolean` that (when `true`) indicates the underlying {keepBuffer} A `boolean` that (when `true`) indicates the underlying
              |scratch-buffer| should be kept               |scratch-buffer| should be kept
`self`:open() *libmodal-lua-Popup.open()* `self`:open({config}) *libmodal-lua-Popup.open()*
Open the |Popup.window|. Open the |Popup.window|.
Note: if the |Popup.window| is already open, then it will be reopened in Note: if the |Popup.window| is already open, then it will be reopened in
      case the |current_tabpage| has changed.       case the |current_tabpage| has changed.
      In this case, it will also override the default options with the
      options in the window so there is no need to pass in {config} a
      second time.
Parameters: ~
{config} Same as |nvim_open_win| {config}.
`self`:refresh({inputBytes}) *libmodal-lua-Popup.refresh()* `self`:refresh({inputBytes}) *libmodal-lua-Popup.refresh()*
Update the content of the `Popup` using an array-like `table` of Update the content of the `Popup` using an array-like `table` of

View File

@ -81,8 +81,8 @@ end
* If the popup was already open, close it and re-open it. * If the popup was already open, close it and re-open it.
]] ]]
-------------------------- --------------------------
function _metaPopup:open() function _metaPopup:open(config)
local config = Popup.config if not config then config = Popup.config end
if valid(self.window) then if valid(self.window) then
config = vim.tbl_extend('force', config, api.nvim_win_get_config(self.window)) config = vim.tbl_extend('force', config, api.nvim_win_get_config(self.window))