Skip to content

Commit

Permalink
Improve plugin startup time
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
subnut committed Mar 8, 2023
1 parent 2f18b0f commit ceae013
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/build_release_binaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand All @@ -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 `
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions autoload/nvim_ghost.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion binary_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.2.0
v0.2.1

0 comments on commit ceae013

Please sign in to comment.