From ceae0136635aa2a6bfb6626c72b80504af358808 Mon Sep 17 00:00:00 2001 From: Subhaditya Nath Date: Thu, 9 Mar 2023 00:56:28 +0530 Subject: [PATCH] Improve plugin startup time Instead of running nvim-ghost-binary --version (which takes a long time) to get the version of the installed binary, we distribute a .version file along with the binary, and read from that. --- .github/workflows/build_release_binaries.yaml | 12 +++++++++--- .gitignore | 2 ++ autoload/nvim_ghost.vim | 5 ++--- binary.py | 2 +- binary_version | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_release_binaries.yaml b/.github/workflows/build_release_binaries.yaml index d615bb0..be6f757 100644 --- a/.github/workflows/build_release_binaries.yaml +++ b/.github/workflows/build_release_binaries.yaml @@ -19,7 +19,9 @@ jobs: asset_name: nvim-ghost-macos.tar.gz asset_path: binary.tar.gz asset_type: application/gzip - packaging_command: tar -czf binary.tar.gz nvim-ghost-binary + packaging_command: | + cp binary_version nvim-ghost-binary.version + tar -czf binary.tar.gz nvim-ghost-binary nvim-ghost-binary.version upload_command: | curl -L \ -X POST \ @@ -34,7 +36,9 @@ jobs: asset_name: nvim-ghost-linux.tar.gz asset_path: binary.tar.gz asset_type: application/gzip - packaging_command: tar -czf binary.tar.gz nvim-ghost-binary + packaging_command: | + cp binary_version nvim-ghost-binary.version + tar -czf binary.tar.gz nvim-ghost-binary nvim-ghost-binary.version upload_command: | curl -L \ -X POST \ @@ -49,7 +53,9 @@ jobs: asset_name: nvim-ghost-win64.zip asset_path: binary.zip asset_type: application/zip - packaging_command: 7z a -tzip binary.zip nvim-ghost-binary.exe + packaging_command: | + Copy-Item binary_version nvim-ghost-binary.exe.version + 7z a -tzip binary.zip nvim-ghost-binary.exe nvim-ghost-binary.exe.version upload_command: | Invoke-WebRequest ` -Method POST ` diff --git a/.gitignore b/.gitignore index baeaf3c..8f648e9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ __pycache__ build nvim-ghost-binary nvim-ghost-binary.exe +nvim-ghost-binary.version +nvim-ghost-binary.exe.version nvim-ghost-macos.tar.gz nvim-ghost-linux.tar.gz nvim-ghost-win64.zip diff --git a/autoload/nvim_ghost.vim b/autoload/nvim_ghost.vim index 64d116c..8f6d7c3 100644 --- a/autoload/nvim_ghost.vim +++ b/autoload/nvim_ghost.vim @@ -3,10 +3,9 @@ if !has('nvim') endif function! nvim_ghost#init() - " We need trim() because Windows may introduce trailing CR or LF characters if !g:nvim_ghost_use_script && (!filereadable(g:nvim_ghost_binary_path) || - \ trim(readfile(g:nvim_ghost_installation_dir .. 'binary_version')[0]) - \ != trim(systemlist([g:nvim_ghost_binary_path, "--version"])[0]) + \ readfile(g:nvim_ghost_installation_dir .. 'binary_version')[0] != + \ readfile(g:nvim_ghost_binary_path .. ".version")[0] \) call nvim_ghost#installer#install(function("nvim_ghost#enable")) else diff --git a/binary.py b/binary.py index a846c8f..2102780 100644 --- a/binary.py +++ b/binary.py @@ -18,7 +18,7 @@ from simple_websocket_server import WebSocket from simple_websocket_server import WebSocketServer -BUILD_VERSION: str = "v0.2.0" +BUILD_VERSION: str = "v0.2.1" WINDOWS: bool = os.name == "nt" LOCALHOST: str = "127.0.0.1" if WINDOWS else "localhost" diff --git a/binary_version b/binary_version index 1474d00..22c08f7 100644 --- a/binary_version +++ b/binary_version @@ -1 +1 @@ -v0.2.0 +v0.2.1