diff --git a/doc/luasnip.txt b/doc/luasnip.txt index fc0239ff1..8b3fcc189 100644 --- a/doc/luasnip.txt +++ b/doc/luasnip.txt @@ -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* diff --git a/flake.lock b/flake.lock index f76ab055a..8ee5b0f6c 100644 --- a/flake.lock +++ b/flake.lock @@ -40,38 +40,6 @@ "type": "github" } }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1733328505, - "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_2": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -80,11 +48,11 @@ ] }, "locked": { - "lastModified": 1743550720, - "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "lastModified": 1782949081, + "narHash": "sha256-vp6Y/Grm98ESt6ceOkWiHWyZRDV3J1RID4w+6NWK9yA=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "rev": "17c9d6cdfc60c64f4ee8d306f9bc0b4ccb51481e", "type": "github" }, "original": { @@ -93,27 +61,6 @@ "type": "github" } }, - "flake-parts_2": { - "inputs": { - "nixpkgs-lib": [ - "nvim_master", - "hercules-ci-effects", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1743550720, - "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "c621e8422220273271f52058f618c94e405bb0f5", - "type": "github" - }, - "original": { - "id": "flake-parts", - "type": "indirect" - } - }, "flake-utils": { "inputs": { "systems": "systems" @@ -200,73 +147,6 @@ "type": "github" } }, - "git-hooks": { - "inputs": { - "flake-compat": "flake-compat_2", - "gitignore": "gitignore", - "nixpkgs": [ - "nvim_master", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1742649964, - "narHash": "sha256-DwOTp7nvfi8mRfuL1escHDXabVXFGT1VlPD1JHrtrco=", - "owner": "cachix", - "repo": "git-hooks.nix", - "rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "git-hooks.nix", - "type": "github" - } - }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "nvim_master", - "git-hooks", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1709087332, - "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, - "hercules-ci-effects": { - "inputs": { - "flake-parts": "flake-parts_2", - "nixpkgs": [ - "nvim_master", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1744693102, - "narHash": "sha256-1Z4WPGVky4w3lrhrgs89OKsLzPdtkbi1bPLNFWsoLfY=", - "owner": "hercules-ci", - "repo": "hercules-ci-effects", - "rev": "5b6cec51c9ec095a0d3fd4c8eeb53eb5c59ae33e", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "hercules-ci-effects", - "type": "github" - } - }, "luals-mdgen": { "inputs": { "emmylua-analyzer-rust": "emmylua-analyzer-rust_2", @@ -291,11 +171,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1745795730, - "narHash": "sha256-7sPk1jScMqsTwXYYFKYILrE9xLk7CK+yCBqcK46HTv8=", + "lastModified": 1783199847, + "narHash": "sha256-TiDFXEa4zEPMX8TvsrbMunQYJPGWQhXBTngi23lAY6g=", "owner": "neovim", "repo": "neovim", - "rev": "ce097c5091eab3550e1534fd111752577b5813ea", + "rev": "3b8c19ea460b4abb5b74f91e05a14c0fcf9cc6a6", "type": "github" }, "original": { @@ -418,11 +298,11 @@ }, "nixpkgs_6": { "locked": { - "lastModified": 1745377448, - "narHash": "sha256-jhZDfXVKdD7TSEGgzFJQvEEZ2K65UMiqW5YJ2aIqxMA=", + "lastModified": 1782978903, + "narHash": "sha256-bG1LAS3YehMzp4RSXw99o3yMEO/Ktb0Tx29RCtEU0Tk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "507b63021ada5fee621b6ca371c4fca9ca46f52c", + "rev": "d33369954a67ae3322177dc9a3d564092912120c", "type": "github" }, "original": { @@ -468,20 +348,16 @@ }, "nvim_master": { "inputs": { - "flake-compat": "flake-compat", "flake-parts": "flake-parts", - "git-hooks": "git-hooks", - "hercules-ci-effects": "hercules-ci-effects", "neovim-src": "neovim-src", - "nixpkgs": "nixpkgs_6", - "treefmt-nix": "treefmt-nix" + "nixpkgs": "nixpkgs_6" }, "locked": { - "lastModified": 1745798752, - "narHash": "sha256-0jiImtQNvlDqf0eWqWFGugNjhazNmaXMi2fM7/B/cd8=", + "lastModified": 1783209806, + "narHash": "sha256-YKUtOu/HmaL8hD2FgAWZ/ZnXti6dau7kvq7BQ/oDdOU=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "31a7206bdf9e0c01db2165e20a6082690c60b9c9", + "rev": "a4af0dcfd0788d45088dfed9d7fa50ce16070c97", "type": "github" }, "original": { @@ -622,27 +498,6 @@ "repo": "default", "type": "github" } - }, - "treefmt-nix": { - "inputs": { - "nixpkgs": [ - "nvim_master", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1745780832, - "narHash": "sha256-jGzkZoJWx+nJnPe0Z2xQBUOqMKuR1slVFQrMjFTKgeM=", - "owner": "numtide", - "repo": "treefmt-nix", - "rev": "b2b6c027d708fbf4b01c9c11f6e80f2800b5a624", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "treefmt-nix", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 2393cb321..db8573a5d 100644 --- a/flake.nix +++ b/flake.nix @@ -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}; + ''; }); }); }; diff --git a/lua/luasnip/util/parser/neovim_parser.lua b/lua/luasnip/util/parser/neovim_parser.lua index 5848c83fd..a02c9921e 100644 --- a/lua/luasnip/util/parser/neovim_parser.lua +++ b/lua/luasnip/util/parser/neovim_parser.lua @@ -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 ), diff --git a/lua/luasnip/util/str.lua b/lua/luasnip/util/str.lua index 8f8a29ec8..05814ebcb 100644 --- a/lua/luasnip/util/str.lua +++ b/lua/luasnip/util/str.lua @@ -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, @@ -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 diff --git a/tests/integration/parser_spec.lua b/tests/integration/parser_spec.lua index e72fe5b19..7cf6da402 100644 --- a/tests/integration/parser_spec.lua +++ b/tests/integration/parser_spec.lua @@ -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 @@ -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()