From e871094d2766673ddcdad349c4eeb782302cd2af Mon Sep 17 00:00:00 2001 From: xudyang1 <61672396+xudyang1@users.noreply.github.com> Date: Tue, 7 Jan 2025 18:30:10 -0500 Subject: [PATCH 1/8] feat(Makefile): enable auto detect compiler --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 02364c17..c775075e 100644 --- a/Makefile +++ b/Makefile @@ -84,14 +84,15 @@ ifeq ($(LUASNIP_DETECTED_OS),Windows) LUA_LDLIBS?=$(if $(strip $(NEOVIM_BIN_PATH)),-L$(NEOVIM_BIN_PATH) -llua51,) endif +CC_ENV:=$(or $(shell which $(CC) 2>/dev/null), $(shell which gcc 2>/dev/null), $(shell which clang 2>/dev/null)) PROJECT_ROOT:=$(shell pwd 2>/dev/null) JSREGEXP_PATH=$(PROJECT_ROOT)/deps/jsregexp JSREGEXP005_PATH=$(PROJECT_ROOT)/deps/jsregexp005 jsregexp: git submodule init git submodule update - "$(MAKE)" "CC=$(CC)" "INCLUDE_DIR=-I$(PROJECT_ROOT)/deps/lua51_include/" LDLIBS='$(LUA_LDLIBS)' -C "$(JSREGEXP_PATH)" - "$(MAKE)" "CC=$(CC)" "INCLUDE_DIR=-I$(PROJECT_ROOT)/deps/lua51_include/" LDLIBS='$(LUA_LDLIBS)' -C "$(JSREGEXP005_PATH)" + "$(MAKE)" "CC=$(CC_ENV)" "INCLUDE_DIR=-I$(PROJECT_ROOT)/deps/lua51_include/" LDLIBS='$(LUA_LDLIBS)' -C "$(JSREGEXP_PATH)" + "$(MAKE)" "CC=$(CC_ENV)" "INCLUDE_DIR=-I$(PROJECT_ROOT)/deps/lua51_include/" LDLIBS='$(LUA_LDLIBS)' -C "$(JSREGEXP005_PATH)" install_jsregexp: jsregexp # remove old binary. From e33fc6cee077ffe4420c9139325cbf563b567f2e Mon Sep 17 00:00:00 2001 From: xudyang1 <61672396+xudyang1@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:22:05 -0500 Subject: [PATCH 2/8] refactor(Makefile): always double quote path --- Makefile | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index c775075e..40a588ab 100644 --- a/Makefile +++ b/Makefile @@ -55,15 +55,9 @@ ifneq (,$(findstring Msys,$(UNAME_ALL))) LUASNIP_DETECTED_OS:=Windows endif -# On Windows, you may need to set: -# SHELL=C:/path/to/Git/usr/bin/sh.exe -# .SHELLFLAGS=-c -# CC=gcc -# NEOVIM_BIN_PATH=C:/path/to/Neovim/bin # contains lua51.dll, or use your own LUA_LDLIBS ifeq ($(LUASNIP_DETECTED_OS),Windows) # If neovim is installed by scoop, only scoop/shims is exposed. We need to find original nvim/bin that contains lua51.dll # If neovim is installed by winget or other methods, nvim/bin is already included in PATH. - # Double quotes the absolute path if it contains spaces # `scoop prefix neovim` outputs either # 1. C:\Users\MyUsername\scoop\apps\neovim\current @@ -73,26 +67,27 @@ ifeq ($(LUASNIP_DETECTED_OS),Windows) # The following code will also work if future scoop returns 1 for unknown `package` # # On Git Bash, `which nvim` returns a Unix style path: `/c/Program Files/Git/bin/nvim` - # Convertion to `"C:/Program Files/Git/bin/nvim"` may be needed if neovim is running in powershell or pwsh + # Always convert to `C:/Program Files/Git/bin/nvim` for powershell and pwsh users NEOVIM_BIN_PATH?=$(shell \ if (scoop prefix neovim | grep '^[A-Z]:[/\\]') >/dev/null 2>&1; then \ - echo "$$(scoop prefix neovim)/bin" | sed 's/\\\\/\\//g' | sed 's/\\(.*\\) \\(.*\\)/"\\1 \\2"/'; \ + echo "$$(scoop prefix neovim)/bin" | sed 's/\\\\/\\//g'; \ elif which nvim >/dev/null 2>&1; then \ - dirname "$$(which nvim)" | sed 's/^\\/\\(.\\)\\//\\U\\1:\\//' | sed 's/\\(.*\\) \\(.*\\)/"\\1 \\2"/'; \ + dirname "$$(which nvim)" | sed 's/^\\/\\(.\\)\\//\\U\\1:\\//'; \ fi) - LUA_LDLIBS?=$(if $(strip $(NEOVIM_BIN_PATH)),-L$(NEOVIM_BIN_PATH) -llua51,) + # Always double quote the absolute path as it may contain spaces + LUA_LDLIBS?=$(if $(strip $(NEOVIM_BIN_PATH)),-L"$(NEOVIM_BIN_PATH)" -llua51,) endif CC_ENV:=$(or $(shell which $(CC) 2>/dev/null), $(shell which gcc 2>/dev/null), $(shell which clang 2>/dev/null)) -PROJECT_ROOT:=$(shell pwd 2>/dev/null) +PROJECT_ROOT:=$(CURDIR) JSREGEXP_PATH=$(PROJECT_ROOT)/deps/jsregexp JSREGEXP005_PATH=$(PROJECT_ROOT)/deps/jsregexp005 jsregexp: git submodule init git submodule update - "$(MAKE)" "CC=$(CC_ENV)" "INCLUDE_DIR=-I$(PROJECT_ROOT)/deps/lua51_include/" LDLIBS='$(LUA_LDLIBS)' -C "$(JSREGEXP_PATH)" - "$(MAKE)" "CC=$(CC_ENV)" "INCLUDE_DIR=-I$(PROJECT_ROOT)/deps/lua51_include/" LDLIBS='$(LUA_LDLIBS)' -C "$(JSREGEXP005_PATH)" + "$(MAKE)" "CC=$(CC_ENV)" "INCLUDE_DIR=-I$(PROJECT_ROOT)/deps/lua51_include/" 'LDLIBS=$(LUA_LDLIBS)' -C "$(JSREGEXP_PATH)" + "$(MAKE)" "CC=$(CC_ENV)" "INCLUDE_DIR=-I$(PROJECT_ROOT)/deps/lua51_include/" 'LDLIBS=$(LUA_LDLIBS)' -C "$(JSREGEXP005_PATH)" install_jsregexp: jsregexp # remove old binary. From 08255c229cff7da06d234ea49e28d416c4701836 Mon Sep 17 00:00:00 2001 From: xudyang1 <61672396+xudyang1@users.noreply.github.com> Date: Sat, 11 Jan 2025 20:39:36 -0500 Subject: [PATCH 3/8] refactor(Makefile): use semicolon instead of error redirect --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 40a588ab..46b0fb0e 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ nvim: | ${NVIM_PATH} git -C ${NVIM_MASTER_PATH} fetch origin master --depth 1 git -C ${NVIM_MASTER_PATH} checkout FETCH_HEAD -LUASNIP_DETECTED_OS?=$(shell uname 2>/dev/null) +LUASNIP_DETECTED_OS?=$(shell uname;) ifeq ($(LUASNIP_DETECTED_OS),Darwin) # flags for dynamic linking on macos, from luarocks # (https://github.com/luarocks/luarocks/blob/9a3c5a879849f4f411a96cf1bdc0c4c7e26ade42/src/luarocks/core/cfg.lua#LL468C37-L468C80) @@ -47,7 +47,7 @@ ifeq ($(OS_ENV),Windows_NT) LUASNIP_DETECTED_OS:=Windows endif # Example output on Windows: MINGW64_NT-10.0-19045 DESKTOP-ABCDE 3.4.10-1234567.x86_64 2024-02-14 20:17 UTC x86_64 Msys -UNAME_ALL:=$(shell uname -a 2>/dev/null) +UNAME_ALL:=$(shell uname -a;) ifneq (,$(findstring MINGW,$(UNAME_ALL))) LUASNIP_DETECTED_OS:=Windows endif @@ -79,7 +79,7 @@ ifeq ($(LUASNIP_DETECTED_OS),Windows) LUA_LDLIBS?=$(if $(strip $(NEOVIM_BIN_PATH)),-L"$(NEOVIM_BIN_PATH)" -llua51,) endif -CC_ENV:=$(or $(shell which $(CC) 2>/dev/null), $(shell which gcc 2>/dev/null), $(shell which clang 2>/dev/null)) +CC_ENV:=$(shell (which $(CC) || which clang || which gcc || which cl || which zig) 2>/dev/null;) PROJECT_ROOT:=$(CURDIR) JSREGEXP_PATH=$(PROJECT_ROOT)/deps/jsregexp JSREGEXP005_PATH=$(PROJECT_ROOT)/deps/jsregexp005 @@ -91,7 +91,7 @@ jsregexp: install_jsregexp: jsregexp # remove old binary. - rm "$(PROJECT_ROOT)/lua/luasnip-jsregexp.so" || true + rm -f "$(PROJECT_ROOT)/lua/luasnip-jsregexp.so" # there is some additional trickery to make this work with jsregexp-0.0.6 in # util/jsregexp.lua. cp "$(JSREGEXP_PATH)/jsregexp.lua" "$(PROJECT_ROOT)/lua/luasnip-jsregexp.lua" From b65825efa9d58e52ea63bc42f47b630266119bbc Mon Sep 17 00:00:00 2001 From: xudyang1 <61672396+xudyang1@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:22:59 -0500 Subject: [PATCH 4/8] fix(Makefile): escape backslash in grep --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 46b0fb0e..308c2042 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ ifeq ($(LUASNIP_DETECTED_OS),Windows) # On Git Bash, `which nvim` returns a Unix style path: `/c/Program Files/Git/bin/nvim` # Always convert to `C:/Program Files/Git/bin/nvim` for powershell and pwsh users NEOVIM_BIN_PATH?=$(shell \ - if (scoop prefix neovim | grep '^[A-Z]:[/\\]') >/dev/null 2>&1; then \ + if (scoop prefix neovim | grep '^[A-Z]:[/\\\\]') >/dev/null 2>&1; then \ echo "$$(scoop prefix neovim)/bin" | sed 's/\\\\/\\//g'; \ elif which nvim >/dev/null 2>&1; then \ dirname "$$(which nvim)" | sed 's/^\\/\\(.\\)\\//\\U\\1:\\//'; \ From 446f536a9d3896a9e547229185abffb5f8611188 Mon Sep 17 00:00:00 2001 From: xudyang1 <61672396+xudyang1@users.noreply.github.com> Date: Tue, 7 Jan 2025 21:24:34 -0500 Subject: [PATCH 5/8] doc(README): remove unnecessary flags and instructions --- README.md | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 61342df7..f74b0250 100644 --- a/README.md +++ b/README.md @@ -61,17 +61,11 @@ Neovim >= 0.7 (extmarks) Consider watching the repository's releases so you're notified when a new version becomes available. > [!NOTE] -> On Windows, you need to use a shell that can run Unix commands (MinGW,MSYS2,etc). -> Luckily, Git offers a `sh.exe`, so you don't need to install a heavy MSYS2 environment. -> Other than Git, you also need a C compiler and `make` to install `jsregexp`. -> You may also need to change the build command: `make install_jsregexp CC=gcc.exe SHELL=C:/path/to/sh.exe .SHELLFLAGS=-c`: - -```text -SHELL=C:/path/to/Git/usr/bin/sh.exe # if Git/MinGW/MSYS2 `sh.exe` is not in PATH -.SHELLFLAGS=-c # if Git/MinGW/MSYS2 `sh.exe` is not in PATH -CC=gcc.exe # if CC's default value cc is not set (when `which cc` fails to find the compiler command) -NEOVIM_BIN_PATH=C:/path/to/Neovim/bin # if the Makefile fails to automatically detect the Neovim/bin path -``` +> On Windows, you need a C compiler and `make` to install `jsregexp`. If the +> compiler is not `gcc` or `clang`, you need to explicitly specify the `CC` +> flag in the build command: `make install_jsregexp CC=your_compiler_program`. +> Also, make sure `%GIT%/bin` directory is added in the `$PATH` so that +> `make` can use `%GIT%/bin/sh.exe`. ## Keymaps In Vim script, with `` for jumping forward/expanding a snippet, `` for From 11433f4510e69be4b99206ada0693d4ba0f20763 Mon Sep 17 00:00:00 2001 From: xudyang1 <61672396+xudyang1@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:57:52 -0500 Subject: [PATCH 6/8] fix(README): fix invalid syntax --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f74b0250..785e588d 100644 --- a/README.md +++ b/README.md @@ -121,9 +121,9 @@ loaders and their benefits. The following list serves only as a short overview. ```lua -- load snippets from path/of/your/nvim/config/my-cool-snippets require("luasnip.loaders.from_vscode").lazy_load({ paths = { "./my-cool-snippets" } }) - - (Note: It's mandatory to have a 'package.json' file in the snippet directory. For examples, see documentation.) ``` + > NOTE: + > It's mandatory to have a `package.json` file in the snippet directory. For examples, see [friendly-snippets](https://github.com/rafamadriz/friendly-snippets/blob/main/package.json). For more info on the VS Code loader, check the [examples](https://github.com/L3MON4D3/LuaSnip/blob/b5a72f1fbde545be101fcd10b70bcd51ea4367de/Examples/snippets.lua#L501) or [documentation](https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#loaders). - **SnipMate-like**: Very similar to VS Code packages; install a plugin that provides snippets and call the `load`-function: @@ -133,7 +133,7 @@ loaders and their benefits. The following list serves only as a short overview. The SnipMate format is very simple, so adding **custom snippets** only requires a few steps: - add a directory beside your `init.vim` (or any other place that is in your `runtimepath`) named `snippets`. - inside that directory, create files named `.snippets` and add snippets for the given filetype in it (for inspiration, check [honza/vim-snippets](https://github.com/honza/vim-snippets/tree/master/snippets)). - ``` snipmate + ```snipmate # comment snippet From f348aabc41ca0828ca3bca8d85547c273ed57081 Mon Sep 17 00:00:00 2001 From: xudyang1 <61672396+xudyang1@users.noreply.github.com> Date: Sun, 26 Jan 2025 22:00:30 -0500 Subject: [PATCH 7/8] chore(dictionary): clean words --- .github/data/project-dictionary.txt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/data/project-dictionary.txt b/.github/data/project-dictionary.txt index 9c0849ad..343666ee 100644 --- a/.github/data/project-dictionary.txt +++ b/.github/data/project-dictionary.txt @@ -105,11 +105,3 @@ there'd truthy varargs vsnip -Unix -MinGW -CC's -usr -gcc -exe -MSYS -SHELLFLAGS From f647d5e9dab6792954ab3356384b190def190732 Mon Sep 17 00:00:00 2001 From: xudyang1 Date: Mon, 27 Jan 2025 03:01:55 +0000 Subject: [PATCH 8/8] Auto generate docs --- doc/luasnip.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/luasnip.txt b/doc/luasnip.txt index 38216b72..22ea4636 100644 --- a/doc/luasnip.txt +++ b/doc/luasnip.txt @@ -1,4 +1,4 @@ -*luasnip.txt* For NVIM v0.8.0 Last change: 2025 January 04 +*luasnip.txt* For NVIM v0.8.0 Last change: 2025 January 27 ============================================================================== Table of Contents *luasnip-table-of-contents*