Home Explore Blog CI



neovim

29th chunk of `runtime/doc/api.txt`
3341495d9f9939eb4735920b2675bd3c49ee822af8d18ac40000000100000fc4
 provided, the last set information applies to the
    local value in the current buffer or window if it is available, otherwise
    the global value information is returned. This behavior can be disabled by
    explicitly specifying {scope} in the {opts} table.

    Attributes: ~
        Since: 0.9.0

    Parameters: ~
      • {name}  Option name
      • {opts}  Optional parameters
                • scope: One of "global" or "local". Analogous to |:setglobal|
                  and |:setlocal|, respectively.
                • win: |window-ID|. Used for getting window local options.
                • buf: Buffer number. Used for getting buffer local options.
                  Implies {scope} is "local".

    Return: ~
        Option Information

nvim_get_option_value({name}, {opts})                *nvim_get_option_value()*
    Gets the value of an option. The behavior of this function matches that of
    |:set|: the local value of an option is returned if it exists; otherwise,
    the global value is returned. Local values always correspond to the
    current buffer or window, unless "buf" or "win" is set in {opts}.

    Attributes: ~
        Since: 0.7.0

    Parameters: ~
      • {name}  Option name
      • {opts}  Optional parameters
                • scope: One of "global" or "local". Analogous to |:setglobal|
                  and |:setlocal|, respectively.
                • win: |window-ID|. Used for getting window local options.
                • buf: Buffer number. Used for getting buffer local options.
                  Implies {scope} is "local".
                • filetype: |filetype|. Used to get the default option for a
                  specific filetype. Cannot be used with any other option.
                  Note: this will trigger |ftplugin| and all |FileType|
                  autocommands for the corresponding filetype.

    Return: ~
        Option value

                                                     *nvim_set_option_value()*
nvim_set_option_value({name}, {value}, {opts})
    Sets the value of an option. The behavior of this function matches that of
    |:set|: for global-local options, both the global and local value are set
    unless otherwise specified with {scope}.

    Note the options {win} and {buf} cannot be used together.

    Attributes: ~
        Since: 0.7.0

    Parameters: ~
      • {name}   Option name
      • {value}  New option value
      • {opts}   Optional parameters
                 • scope: One of "global" or "local". Analogous to
                   |:setglobal| and |:setlocal|, respectively.
                 • win: |window-ID|. Used for setting window local option.
                 • buf: Buffer number. Used for setting buffer local option.


==============================================================================
Buffer Functions                                                  *api-buffer*


For more information on buffers, see |buffers|.

Unloaded Buffers: ~

Buffers may be unloaded by the |:bunload| command or the buffer's
|'bufhidden'| option. When a buffer is unloaded its file contents are freed
from memory and vim cannot operate on the buffer lines until it is reloaded
(usually by opening the buffer again in a new window). API methods such as
|nvim_buf_get_lines()| and |nvim_buf_line_count()| will be affected.

You can use |nvim_buf_is_loaded()| or |nvim_buf_line_count()| to check
whether a buffer is loaded.


nvim_buf_attach({buffer}, {send_buffer}, {opts})           *nvim_buf_attach()*
    Activates buffer-update events on a channel, or as Lua callbacks.

    Example (Lua): capture buffer updates in a global `events` variable (use
    "vim.print(events)" to see its contents): >lua
        events = {}
        vim.api.nvim_buf_attach(0, false, {
          on_lines = function(...)
            table.insert(events, {...})
          end,
        })
<

    Attributes: ~
        Since: 0.3.0

    Parameters: ~
      • {buffer}       Buffer id, or 0 for current buffer
    

Title: API Options and Buffer Functions
Summary
This section details functions for getting and setting option values in Neovim. `nvim_get_option_value` retrieves the value of an option, prioritizing local values unless specified otherwise in the options. `nvim_set_option_value` sets the value of an option, allowing specification of scope (global or local), window, or buffer. The documentation then transitions to buffer functions, including information on unloaded buffers and `nvim_buf_attach`, which activates buffer-update events.