-
Notifications
You must be signed in to change notification settings - Fork 58
Developer documentation
Mostly for extending plugin functionalities.
Plugin states are stored in require("markview").states
.
--- Table containing various plugin states.
---@class mkv.state
---
--- List of attached buffers.
---@field attached_buffers integer[]
---
--- Buffer local states.
---@field buffer_states { [integer]: { enable: boolean, hybrid_mode: boolean? } }
---
--- Source buffer for hybrid mode.
---@field splitview_source? integer
--- Preview buffer for hybrid mode.
---@field splitview_buffer? integer
--- Preview window for hybrid mode.
---@field splitview_window? integer
markview.state = {
attached_buffers = {},
buffer_states = {},
splitview_buffer = nil,
splitview_source = nil,
splitview_window = nil
};
Warning
splitview_buffer
might not be nil
even after closing splitview as there's no point in creating a new buffer every time.
Tip
The sub-command implementation can be found in require("markview").commands
.
Commonly used functions can be found inside require("markview").actions
. These are,
-
__exec_callback
, Safely executes a given callback.Usage:
markview.actions.__exec_callback(callback, ...)
-
callback
, callback name. -
...
arguments.
-
-
__is_attached
, Checks ifmarkview
is attached to a buffer or not.Usage:
markview.actions.__is_attached(buffer)
-
buffer
, buffer ID(defaults to current buffer).
Return:
boolean
-
-
__is_enabled
, Checks ifmarkview
is enabled on a buffer or not.Usage:
markview.actions.__is_enabled(buffer)
-
buffer
, buffer ID(defaults to current buffer).
Return:
boolean
-
-
__splitview_setup
Sets up the buffer & window forsplitview
.Usage:
markview.actions.__splitview_setup()
Warning
Anti-pattern: Prevents users from forcefully closing the splitview window.
-
attach
Attachesmarkview
to a buffer.Usage:
markview.actions.attach(buffer)
-
buffer
, buffer ID(defaults to current buffer).
-
-
detach
Detachesmarkview
to a buffer.Usage:
markview.actions.detach(buffer)
-
buffer
, buffer ID(defaults to current buffer).
-
-
enable
Enables previews for the given buffer.Usage:
markview.actions.enable(buffer)
-
buffer
, buffer ID(defaults to current buffer).
-
-
disable
Disables previews for the given buffer.Usage:
markview.actions.disable(buffer)
-
buffer
, buffer ID(defaults to current buffer).
-
-
hybridEnable
Enables hybrid mode for the given buffer.Usage:
markview.actions.hybridEnable(buffer)
-
buffer
, buffer ID(defaults to current buffer).
-
-
hybridDisable
Disables hybrid mode for the given buffer.Usage:
markview.actions.hybridDisable(buffer)
-
buffer
, buffer ID(defaults to current buffer).
-
-
splitOpen
Opens splitview for the given buffer.Usage:
markview.actions.splitOpen(buffer)
-
buffer
, buffer ID(defaults to current buffer).
-
-
splitClose
Closes any open splitview window.
You can manually show previews via these functions,
-
markview.render(buffer)
Renders preview onbuffer
(defaults to current buffer). -
markview.clear(buffer)
Clears previews ofbuffer
(defaults to current buffer).
-
markview.clean()
Detachesmarkview
from any invalid buffer.
Also available in vimdoc, :h markview.nvim-dev
.