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.9-0.11 Last change: 2026 May 19
*luasnip.txt* For NeoVim 0.9-0.11 Last change: 2026 July 05

==============================================================================
Table of Contents *luasnip-table-of-contents*
Expand Down
171 changes: 13 additions & 158 deletions flake.lock

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

78 changes: 46 additions & 32 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -94,42 +94,56 @@
shellHook = "";
});

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

# same reasoning as in nvim_09
DEPS_CMAKE_FLAGS="-D USE_BUNDLED=OFF -D USE_BUNDLED_TS_PARSERS=ON";

# unset lua-path here, to make sure the global env does not leak, and
# prevent unset later, s.t. the lua env imported by this flake
# exists.
LUA_PATH="";
LUA_CPATH="";
PREVENT_LUA_PATH_LEAK=false_bin;
# the package is used here instead of the dev shell that neovim-nightly-overlay provides
# since, for some reason, it uses an older version of fetch-cargo-vendor-util which
# makes crates.io return a 403 error (https://github.com/rust-lang/crates.io/issues/13482)
test_nvim_012 = nvim_master.packages.${pkgs.system}.neovim-developer.overrideAttrs(attrs: {
nativeBuildInputs = attrs.nativeBuildInputs ++ [
pkgs.stylua
pkgs.include-what-you-use
pkgs.clang-tools
];

# clear shellHook, it doesn't do anything we really need.
shellHook = "";
# a shell hook must be used when setting env variables when using a package derivation
# as a dev shell
shellHook = /* sh */ ''
export TEST_09=${false_bin};
export TEST_012=${true_bin};
export TEST_MASTER=${false_bin};

# unset lua-path here, to make sure the global env does not leak, and
# prevent unset later, s.t. the lua env imported by this flake
# exists.
export LUA_PATH="";
export LUA_CPATH="";
export PREVENT_LUA_PATH_LEAK=${false_bin};
'';
});

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

# same reasoning as in nvim_09
DEPS_CMAKE_FLAGS="-D USE_BUNDLED=OFF -D USE_BUNDLED_TS_PARSERS=ON";

# unset lua-path here, to make sure the global env does not leak, and
# prevent unset later, s.t. the lua env imported by this flake
# exists.
LUA_PATH="";
LUA_CPATH="";
PREVENT_LUA_PATH_LEAK=false_bin;
# the package is used here instead of the dev shell that neovim-nightly-overlay provides
# since, for some reason, it uses an older version of fetch-cargo-vendor-util which
# makes crates.io return a 403 error (https://github.com/rust-lang/crates.io/issues/13482)
test_nvim_master = nvim_master.packages.${pkgs.system}.neovim-developer.overrideAttrs(attrs: {
nativeBuildInputs = attrs.nativeBuildInputs ++ [
pkgs.stylua
pkgs.include-what-you-use
pkgs.clang-tools
];

# clear shellHook, it doesn't do anything we really need.
shellHook = "";
# a shell hook must be used when setting env variables when using a package derivation
# as a dev shell
shellHook = /* sh */ ''
export TEST_09=${false_bin};
export TEST_012=${false_bin};
export TEST_MASTER=${true_bin};

# unset lua-path here, to make sure the global env does not leak, and
# prevent unset later, s.t. the lua env imported by this flake
# exists.
export LUA_PATH="";
export LUA_CPATH="";
export PREVENT_LUA_PATH_LEAK=${false_bin};
'';
});
});
};
Expand Down
4 changes: 3 additions & 1 deletion lua/luasnip/util/parser/neovim_parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ S.format = P.any(
P.token("downcase"),
P.token("capitalize"),
P.token("camelcase"),
P.token("pascalcase")
P.token("pascalcase"),
P.token("snakecase"),
P.token("kebabcase")
),
S.close
),
Expand Down
10 changes: 10 additions & 0 deletions lua/luasnip/util/str.lua
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ local function pascalcase(str)
end
return pascalcased
end
local function snakecase(str)
return string
.lower(str:gsub("(%l)(%u)", "%1_%2"))
:gsub("(%l)%s(%l)", "%1_%2")
:gsub("-", "_")
end

M.vscode_string_modifiers = {
upcase = string.upper,
Expand All @@ -277,6 +283,10 @@ M.vscode_string_modifiers = {
-- same as pascalcase, but first character lowercased.
return pascalcase(str):gsub("^.", string.lower)
end,
snakecase = snakecase,
kebabcase = function(str)
return snakecase(str):gsub("_", "-")
end,
}

return M
4 changes: 4 additions & 0 deletions tests/integration/parser_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ describe("Parser", function()
capitalize = true,
camelcase = true,
pascalcase = true,
snakecase = true,
kebabcase = true,
}

for modifier, modified_expected in pairs(expected_map) do
Expand Down Expand Up @@ -335,6 +337,8 @@ describe("Parser", function()
capitalize = "Test text Text",
camelcase = "testTextText",
pascalcase = "TestTextText",
snakecase = "test_text_text",
kebabcase = "test-text-text",
})

it("modifies invalid $0 with choice.", function()
Expand Down
Loading