Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/luasnip.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*luasnip.txt* For NeoVim 0.7-0.11 Last change: 2026 April 05
*luasnip.txt* For NeoVim 0.7-0.11 Last change: 2026 May 14

==============================================================================
Table of Contents *luasnip-table-of-contents*
Expand Down
6 changes: 3 additions & 3 deletions lua/luasnip/extras/_treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local util = require("luasnip.util.util")
local tbl = require("luasnip.util.table")

local function get_lang(bufnr)
local ft = vim.api.nvim_buf_get_option(bufnr, "ft")
local ft = vim.api.nvim_get_option_value("ft", { buf = bufnr })
local lang = vim.treesitter.language.get_lang(ft) or ft
return lang
end
Expand Down Expand Up @@ -317,7 +317,7 @@ end
---@param pos { [1]: number, [2]: number }?
---@return TSNode?
function TSParser:get_node_at_pos(pos)
pos = vim.F.if_nil(pos, util.get_cursor_0ind())
pos = util.if_nil(pos, util.get_cursor_0ind())
local row, col = pos[1], pos[2]
assert(
row >= 0 and col >= 0,
Expand Down Expand Up @@ -436,7 +436,7 @@ local function find_topmost_parent(root, matcher)
if matcher == nil or matcher(node) then
current = node
end
return vim.F.if_nil(_impl(node:parent()), current)
return util.if_nil(_impl(node:parent()), current)
end

return _impl(root)
Expand Down
13 changes: 10 additions & 3 deletions lua/luasnip/extras/filetype_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ local function from_pos_or_filetype()
end

local function from_filetype_load(bufnr)
return vim.split(vim.api.nvim_buf_get_option(bufnr, "filetype"), ".", true)
return vim.split(
vim.api.nvim_get_option_value("filetype", { buf = bufnr }),
".",
true
)
end

local function extend_load_ft(extend_fts)
Expand All @@ -67,8 +71,11 @@ local function extend_load_ft(extend_fts)
end

return function(bufnr)
local fts =
vim.split(vim.api.nvim_buf_get_option(bufnr, "filetype"), ".", true)
local fts = vim.split(
vim.api.nvim_get_option_value("filetype", { buf = bufnr }),
".",
true
)
local res = {}

for _, ft in ipairs(fts) do
Expand Down
6 changes: 3 additions & 3 deletions lua/luasnip/extras/snippet_list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ local buf_opts = { filetype = "lua" }

local function set_win_opts(win, opts)
for opt, val in pairs(opts) do
vim.api.nvim_win_set_option(win, opt, val)
vim.api.nvim_set_option_value(opt, val, { win = win })
end
end

local function set_buf_opts(buf, opts)
for opt, val in pairs(opts) do
vim.api.nvim_buf_set_option(buf, opt, val)
vim.api.nvim_set_option_value(opt, val, { buf = buf })
end
end

Expand Down Expand Up @@ -73,7 +73,7 @@ local function display_split(opts)
vim.api.nvim_buf_set_lines(buf, 0, 0, false, replacement)

-- make it unmodifiable at this point
vim.api.nvim_buf_set_option(buf, "modifiable", false)
vim.api.nvim_set_option_value("modifiable", false, { buf = buf })
end
end

Expand Down
7 changes: 3 additions & 4 deletions lua/luasnip/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ local util = require("luasnip.util.util")
local lazy_table = require("luasnip.util.lazy_table")
local types = require("luasnip.util.types")
local node_util = require("luasnip.nodes.util")
local tbl_util = require("luasnip.util.table")
local feedkeys = require("luasnip.util.feedkeys")

local session = require("luasnip.session")
Expand Down Expand Up @@ -598,7 +597,7 @@ local function _snip_expand(snippet, opts)
-- override with current position if none given.
opts.pos = opts.pos or util.get_cursor_0ind()
opts.jump_into_func = opts.jump_into_func or _jump_into_default
opts.indent = vim.F.if_nil(opts.indent, true)
opts.indent = util.if_nil(opts.indent, true)

snip.trigger = opts.expand_params.trigger or snip.trigger
snip.captures = opts.expand_params.captures or {}
Expand Down Expand Up @@ -1309,8 +1308,8 @@ end
function API.activate_node(opts)
opts = opts or {}
local pos = opts.pos or util.get_cursor_0ind()
local strict = vim.F.if_nil(opts.strict, false)
local select = vim.F.if_nil(opts.select, true)
local strict = util.if_nil(opts.strict, false)
local select = util.if_nil(opts.select, true)

-- find tree-node the snippet should be inserted at (could be before another node).
local _, _, _, node = node_util.snippettree_find_undamaged_node(pos, {
Expand Down
4 changes: 2 additions & 2 deletions lua/luasnip/loaders/from_vscode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,10 @@ end
function M.load_standalone(opts)
opts = opts or {}

local lazy = vim.F.if_nil(opts.lazy, false)
local lazy = util.if_nil(opts.lazy, false)
local add_opts = loader_util.make_add_opts(opts)
local fs_event_providers =
vim.F.if_nil(opts.fs_event_providers, { autocmd = true, libuv = false })
util.if_nil(opts.fs_event_providers, { autocmd = true, libuv = false })

local path
if not lazy then
Expand Down
4 changes: 2 additions & 2 deletions lua/luasnip/loaders/fs_watchers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ local callback_mt = {

local function get_opts(opts)
opts = opts or {}
local lazy = vim.F.if_nil(opts.lazy, false)
local lazy = util.if_nil(opts.lazy, false)
local fs_event_providers =
vim.F.if_nil(opts.fs_event_providers, { autocmd = true, libuv = false })
util.if_nil(opts.fs_event_providers, { autocmd = true, libuv = false })

return lazy, fs_event_providers
end
Expand Down
2 changes: 1 addition & 1 deletion lua/luasnip/loaders/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ local function normalize_opts(opts)
end

local fs_event_providers =
vim.F.if_nil(opts.fs_event_providers, { autocmd = true, libuv = false })
util.if_nil(opts.fs_event_providers, { autocmd = true, libuv = false })

return {
paths = paths,
Expand Down
2 changes: 1 addition & 1 deletion lua/luasnip/nodes/snippet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ function Snippet:event(event, event_args)
modeline = false,
})

return vim.F.if_nil(cb_res, m1_cb_res, parent_cb_res)
return util.if_nil(cb_res, m1_cb_res, parent_cb_res)
end

local function nodes_from_pattern(pattern)
Expand Down
3 changes: 2 additions & 1 deletion lua/luasnip/util/auto_table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ end

local M = {}

local if_nil = vim.nonnil or vim.F.if_nil --todo(clason): remove when dropping Nvim 0.12 support
function M.autotable(max_depth, opts)
opts = opts or {}
local warn = vim.F.if_nil(opts.warn, false)
local warn = if_nil(opts.warn, false)

local auto_table_func = warn and auto_creating_tables_warn_depth
or auto_creating_tables
Expand Down
7 changes: 1 addition & 6 deletions lua/luasnip/util/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ return {
return function()
-- 'echo'd string is returned to lua.
return sn(nil, {
t(
vim.split(
vim.api.nvim_exec("echo " .. vimstring, true),
"\n"
)
),
t(vim.split(vim.cmd.echo(vimstring), "\n")),
})
end
end,
Expand Down
1 change: 1 addition & 0 deletions lua/luasnip/util/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -516,4 +516,5 @@ return {
pos_from_offset = pos_from_offset,
shallow_copy = shallow_copy,
copy3 = copy3,
if_nil = vim.nonnil or vim.F.if_nil, --todo(clason): remove when dropping Nvim 0.12 support
}
Loading