The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Write To A Neovim File Buffer With Lua

TODO: Pull subtitle into page object

TODO: Combine this with the other file that has the same basic deatils

Use `vim.api.nvim_buf_set_lines()` to write lines to a Neovim buffer. For example, this will append two lines to the end of a the

Code
local bufnr = 25
local start_line = -1
local end_line = -1
local strict_bounds = false
local lines = { "alfa" }

vim.api.nvim_buf_set_lines(
  bufnr, start_line, end_line, strict_bounds, lines
)

pre_start_default_section pre_end_default_section

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Write To A Neovim File Buffer With Lua 

-- note

TODO: Combine this with the other file that has the 
same basic deatils

-- p

Use `vim.api.nvim_buf_set_lines()` to write lines
to a Neovim buffer. For example, this will
append two lines to the end of a the 

-- code
-- lua

local bufnr = 25
local start_line = -1
local end_line = -1
local strict_bounds = false
local lines = { "alfa" }

vim.api.nvim_buf_set_lines(
  bufnr, start_line, end_line, strict_bounds, lines
)



-- pre/

From the docs:

nvim_buf_set_lines({buffer}, {start}, {end}, {strict_indexing}, {replacement})
                Sets (replaces) a line-range in the buffer.

                Indexing is zero-based, end-exclusive. Negative indices are
                interpreted as length+1+index: -1 refers to the index past the
                end. So to change or delete the last element use start=-2 and
                end=-1.

                To insert lines at a given index, set `start` and `end` to the
                same index. To delete a range of lines, set `replacement` to
                an empty array.

                Out-of-bounds indices are clamped to the nearest valid value,
                unless `strict_indexing` is set.

                Attributes: 
                    not allowed when |textlock| is active

                Parameters: 
                    {buffer}           Buffer handle, or 0 for current buffer
                    {start}            First line index
                    {end}              Last line index (exclusive)
                    {strict_indexing}  Whether out-of-bounds should be an
                                       error.
                    {replacement}      Array of lines to use as replacement




-- /pre

-- ref
-- url: https://neovim.io/doc/user/api.html


-- categories
-- Neovim 
-- Lua

-- metadata
-- date: 2021-06-20 19:41:39
-- id: 20eoc6qz
-- status: scratch
-- type: post
-- site: aws