Skip to content
Merged
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
20 changes: 6 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,23 @@ TEST_FILE?=$(realpath tests)
NVIM_PATH=deps/nvim_multiversion
# relative to ${NVIM_PATH} and relative to this makefile.
NVIM_MASTER_PATH_REL=worktree_master
NVIM_0.7_PATH_REL=worktree_0.7
NVIM_0.9_PATH_REL=worktree_0.9
NVIM_MASTER_PATH=${NVIM_PATH}/${NVIM_MASTER_PATH_REL}
NVIM_0.7_PATH=${NVIM_PATH}/${NVIM_0.7_PATH_REL}
NVIM_0.9_PATH=${NVIM_PATH}/${NVIM_0.9_PATH_REL}

# directory as target.
${NVIM_PATH}:
# fetch current master and 0.7.0 (the minimum version we support) and 0.9.0
# (the minimum version for treesitter-postfix to work).
# fetch current master and 0.9.0 (the minimum version for treesitter-postfix to
# work).
git clone --bare --depth 1 https://github.com/neovim/neovim ${NVIM_PATH};
git -C ${NVIM_PATH} fetch --depth 1 origin tag v0.7.0;
git -C ${NVIM_PATH} fetch --depth 1 origin tag v0.9.0;
# create one worktree for master, and one for 0.7.
# The rationale behind this is that switching from 0.7 to master (and
# create one worktree for master, and one for 0.9.
# The rationale behind this is that switching from 0.9 to master (and
# vice-versa) requires a `make distclean`, and full clean build, which takes
# a lot of time.
# The most straightforward solution seems to be too keep two worktrees, one
# for master, one for 0.7, and one for 0.9 which are used for the
# respective builds/tests.
# for master, and one for 0.9 which are used for the respective builds/tests.
git -C ${NVIM_PATH} worktree add ${NVIM_MASTER_PATH_REL} master;
git -C ${NVIM_PATH} worktree add ${NVIM_0.7_PATH_REL} v0.7.0;
git -C ${NVIM_PATH} worktree add ${NVIM_0.9_PATH_REL} v0.9.0;

# |: don't update `nvim` if `${NVIM_PATH}` is changed.
Expand Down Expand Up @@ -129,7 +124,6 @@ uninstall_jsregexp:
rm -f "$(PROJECT_ROOT)/deps/luasnip-jsregexp.so";
rm -f "$(PROJECT_ROOT)/lua/luasnip-jsregexp.lua";

TEST_07?=true
TEST_09?=true
TEST_MASTER?=true
PREVENT_LUA_PATH_LEAK?=true
Expand All @@ -148,13 +142,11 @@ test: nvim install_jsregexp
export BUSTED_ARGS=--lpath=$(PROJECT_ROOT)/tests/?.lua; \
export LUASNIP_OVERRIDE_LOGPATH=$(PROJECT_ROOT); \
set -e; \
if ${TEST_07}; then "$(MAKE)" -C ${NVIM_0.7_PATH} functionaltest DEPS_CMAKE_FLAGS=-DUSE_BUNDLED_GPERF=OFF -j; fi; \
if ${TEST_09}; then "$(MAKE)" -C ${NVIM_0.9_PATH} -j; "$(MAKE)" -C ${NVIM_0.9_PATH} functionaltest -j; fi; \
if ${TEST_MASTER}; then unset BUSTED_ARGS; "$(MAKE)" -C ${NVIM_MASTER_PATH} -j; ./tests/test_master.sh; fi;

test_nix: nvim install_jsregexp
set -e; \
if ${TEST_07}; then nix develop .#test_nvim_07 -c make test; fi; \
if ${TEST_09}; then nix develop .#test_nvim_09 -c make test; fi; \
if ${TEST_MASTER}; then nix develop .#test_nvim_master -c make test; fi;

Expand All @@ -180,7 +172,7 @@ doc:
# solution because indentation is identical for lists.
emmylua_doc_cli -f json -i lua/luasnip/ -o ./;
luals-mdgen data/DOC-template.md DOC.md --width 80 --mode vimdoc;
panvimdoc --project-name luasnip --input-file DOC.md --vim-version "NeoVim 0.7-0.11" --doc-mapping true;
panvimdoc --project-name luasnip --input-file DOC.md --vim-version "NeoVim 0.9-0.11" --doc-mapping true;
nvim --clean -es +"helptags doc | exit";
# again, this time without vimdoc, overwrite previous DOC.md.
luals-mdgen data/DOC-template.md DOC.md --width 100;
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ https://user-images.githubusercontent.com/41961280/122515860-5179fa00-d00e-11eb-
- Snippets that make use of the entire functionality of this plugin have to be defined in Lua (but 95% of snippets can be written in LSP-syntax).

# Requirements
Neovim >= 0.7 (extmarks)
Neovim >= 0.9
`jsregexp` for `lsp-snippet-transformations` (see [here](https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#transformations) for some tips on installing it).

# Setup
Expand Down
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 May 19
*luasnip.txt* For NeoVim 0.9-0.11 Last change: 2026 May 19

==============================================================================
Table of Contents *luasnip-table-of-contents*
Expand Down
64 changes: 5 additions & 59 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 0 additions & 31 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
# has tree-sitter 0.20.8, which is required for neovim 0.9.0.
inputs.nixpkgs-treesitter.url = "github:nixos/nixpkgs/7a339d87931bba829f68e94621536cad9132971a";

inputs.nvim_07.url = "github:neovim/neovim/v0.7.0?dir=contrib";

inputs.nvim_09.url = "github:neovim/neovim/v0.9.0?dir=contrib";

# this only has to be updated sporadically, basically whenever the source in
Expand All @@ -21,7 +19,6 @@
self,
nixpkgs,
nixpkgs-treesitter,
nvim_07,
nvim_09,
nvim_master,
luals-mdgen,
Expand All @@ -34,7 +31,6 @@
pkgs = import nixpkgs { inherit system; };
pkgs-treesitter = import nixpkgs-treesitter { inherit system; };
pkgs-nvim_09 = import nvim_09.inputs.nixpkgs { inherit system; };
pkgs-nvim_07 = import nvim_07.inputs.nixpkgs { inherit system; };
pkg-luals-mdgen = luals-mdgen.outputs.packages.${system}.default;
pkg-emmylua-doc = emmylua-analyzer-rust.outputs.packages.${system}.emmylua_doc_cli;
pkg-panvimdoc = panvimdoc.outputs.packages.${system}.default;
Expand All @@ -45,7 +41,6 @@
pkgs,
pkgs-treesitter,
pkgs-nvim_09,
pkgs-nvim_07,
pkg-luals-mdgen,
pkg-emmylua-doc,
pkg-panvimdoc
Expand All @@ -71,34 +66,9 @@
pkgs.neovim
];
};
# clang stdenv does not build, and it's used by de.
test_nvim_07 = (nvim_07.outputs.devShell.${pkgs.system}.override { stdenv = pkgs-nvim_07.gccStdenv; }).overrideAttrs(attrs: {
TEST_07=true_bin;
TEST_09=false_bin;
TEST_MASTER=false_bin;

# when using bundled dependencies, there are issues with luarocks :/
# don't need to build treesitter-parsers, so we can just set this.
USE_BUNDLED="OFF";

LUA_PATH="";
LUA_CPATH="";
PREVENT_LUA_PATH_LEAK=false_bin;
# ASAN does not work with gcc stdenv.
cmakeFlags = builtins.filter (x: x != "-DCLANG_ASAN_UBSAN=ON") attrs.cmakeFlags;

# adjust some paths.
# We're not running the devshell from the directory it expects.
shellHook = ''
cd ./deps/nvim_multiversion/worktree_0.7
cmakeConfigurePhase
cd ../../../../
'';
});

# override default tree-sitter, it has the wrong version (0.20.7 vs required 0.20.8).
test_nvim_09 = default_09_devshell.overrideAttrs(attrs: {
TEST_07=false_bin;
TEST_09=true_bin;
TEST_MASTER=false_bin;

Expand All @@ -124,7 +94,6 @@
});

test_nvim_master = nvim_master.outputs.devShells.${pkgs.system}.default.overrideAttrs(attrs: {
TEST_07=false_bin;
TEST_09=false_bin;
TEST_MASTER=true_bin;

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
Loading
Loading