nvim_runtime_lua

vim._watch

Methods3

function M.watch(path: string, opts: vim._watch.watch.Opts | nil, callback: vim._watch.Callback) -> cancel fun() -> nil

Initializes and starts a |uvfsevent_t|

Parameters
pathstring

The path to watch

optsvim._watch.watch.Opts | nil

Additional options:

  • uvflags (table|nil)
  • Same flags as accepted by |uv.fseventstart()|

callbackvim._watch.Callback

Callback for new events

Returns
cancelfun() -> nil

Stops the watcher

function M.watchdirs(path: string, opts: vim._watch.Opts | nil, callback: vim._watch.Callback) -> cancel fun() -> nil

Initializes and starts a |uvfsevent_t| recursively watching every directory underneath the directory at path.

Parameters
pathstring

The path to watch. Must refer to a directory.

optsvim._watch.Opts | nil

Additional options

callbackvim._watch.Callback

Callback for new events

Returns
cancelfun() -> nil

Stops the watcher

function M.inotify(path: string, opts: vim._watch.Opts | nil, callback: vim._watch.Callback) -> cancel fun() -> nil
Parameters
pathstring

The path to watch. Must refer to a directory.

optsvim._watch.Opts | nil
callbackvim._watch.Callback

Callback for new events

Returns
cancelfun() -> nil

Stops the watcher

Fields2

M.FileChangeType : vim._watch.FileChangeType
M.active: table

Count of currently-active watchers. Each "watcher" here is one call to vim._watch.watch(), vim.watch.watchdirs(), or vim.watch.inotify() that hasn't been cancelled yet.