-
-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vimPlugins.codesnap-nvim: init at 2024-05-08 #321030
Conversation
Result of 1 package built:
|
Result of 1 package built:
|
Result of 1 package built:
|
Result of 1 package built:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from this, everything looks good to me.
Result of 1 package built:
Result of 1 package built:
Result of 1 package built:
Result of 1 package built:
|
|
||
# https://github.com/mistricky/codesnap.nvim/blob/main/scripts/build_generator.sh | ||
postInstall = let | ||
extension = if stdenv.isDarwin then "dylib" else "so"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use sthg like stdenv.hostPlatform.extensions.sharedLibrary
instead. in this case I guess it should be targetPlatform
? I dont know ^^' but I think hostPlatform is for the builder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the docs:
The "host platform" is the platform on which a package will be run.
So I think you're right, there.
Also, doesn't the library need to be copied to lua/generator${extension}
instead of lua/generator.so
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I thought, but looking at the script suggests that the destination should always be generator.so
...
But now that I have a look at it again, it feels like a mistake...
Could you please help us with this @mistricky ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @GaetanLepage, sorry to reply late, wow thank u for packing codesnap to nixpkgs.
The generator.so
is build from rust source, and called by Lua, both on Mac OS and Linux, the suffix should be .so
, so the script just rename the generator.[dylib | so]
to generator.so
, it's not a mistake.
But there is another situation, if the user on Windows, the suffix should be .dll
, but CodeSnap does not support Windows platform yet, so the filename of generator
should always belua/generator.so
for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, very good to know, thanks for coming in and helping !
I went and trust the script, so we have nothing to change.
''; | ||
|
||
doInstallCheck = true; | ||
nvimRequireCheck = "codesnap"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it rely on an external service or do you think you could try to generate a picture in the test ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any documentation for writing tests for Vim plugins?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No just the code. It's not hard: nvimRequireCheck starts nvim with :lua require'<nvimRequireCheck-value>'
while vimCommandHook starts nvim with :vimCommandHook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I was able to make the plugin work with just a single keymap:
vim.keymap.set(
'n',
'<leader>cs',
':lua require("codesnap").setup({save_path="/tmp/out.png"})<CR>:norm! ggVG<CR>:CodeSnapSave txt<CR>',
{ desc = 'Snap Code' }
)
Which is basically a combination of 3 commands:
:lua require("codesnap").setup({save_path="/tmp/out.png"})
: setup & set out path for the snapshot:norm! ggVG
: go to top, select all the code until the bottom:CodeSnapSave txt
: snap that with document typetxt
I'm having difficulties adding this to the vimCommandHook
, though, which I think only checks that the command exists.
My attempt is at eljamm@0a9aa3d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eljamm wow nice ! you are trying a more elaborate test than vimCommandHook or nvimRequireCheck in which case you will need to write your own checkPhase
.
The test you tried to write shouldn't live in nixpkgs IMO, it should be a basic test that codesnap upstream already has and we should just run it.
Now I can't find a testsuite in their repo (dont they have tests) ? If you are really motivated by this you can contribute to upstream, otherwise maybe just add nvimRequireCheck = "codesnap"
.
You can check what it does in pkgs/applications/editors/vim/plugins/neovim-require-check-hook.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are really motivated by this you can contribute to upstream, otherwise maybe just add
nvimRequireCheck = "codesnap"
.
This is what is already done in this PR. Do you want me to add anything else ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the help. I'll check and see what I can do upstream, but for now nvimRequireCheck
might be enough.
Description of changes
Add codesnap.nvim, a snapshot plugin with rich features that can make pretty code snapshots for Neovim.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.