Skip to content
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

feat(utility): adding snacks.nvim #1264

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

feat(utility): adding snacks.nvim #1264

wants to merge 5 commits into from

Conversation

luxus
Copy link
Member

@luxus luxus commented Nov 8, 2024

adding snacks from our friend folke. i just copied the install instruction and modified it a little to make them fit into astrocommunity, i'm sure im missing something and collide with some keybindings

Copy link

github-actions bot commented Nov 8, 2024

Review Checklist

Does this PR follow the [Contribution Guidelines](development guidelines)? Following is a partial checklist:

Proper conventional commit scoping:

  • If you are adding a new plugin, the scope would be the name of the category it is being added into. ex. feat(utility): added noice.nvim plugin

  • If you are modifying a pre-existing plugin or pack, the scope would be the name of the plugin folder. ex. fix(noice-nvim): fix LSP handler error

  • Pull request title has the appropriate conventional commit type and scope where the scope is the name of the pre-existing directory in the project as described above

  • README is properly formatted and uses fenced in links with <url> unless they are inside a [title](url)

  • Entry returns a single plugin spec with the new plugin as the only top level spec (not applicable for recipes or packs).

  • Proper usage of opts table rather than setting things up with the config function.

  • Proper usage of specs table for all specs that are not dependencies of a given plugin (not applicable for recipes or packs).

maps.n["<c-_>"] = { function() Snacks.terminal() end, desc = "which_key_ignore" }
maps.n["]]"] = { function() Snacks.words.jump(vim.v.count1) end, desc = "Next Reference" }
maps.n["[["] = { function() Snacks.words.jump(-vim.v.count1) end, desc = "Prev Reference" }
maps.n["<leader>N"] = {
Copy link
Member

@Uzaaft Uzaaft Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesnt this override an existing binding.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i need some time to convert the toggleterm stuff to snacks
https://github.com/AstroNvim/AstroNvim/blob/main/lua/astronvim/plugins/toggleterm.lua

@luxus luxus marked this pull request as ready for review November 11, 2024 17:37
@luxus
Copy link
Member Author

luxus commented Nov 11, 2024

i think this News <Leader>N is just a PoC and not really useful? :D

@Uzaaft
Copy link
Member

Uzaaft commented Nov 11, 2024

i think this News <Leader>N is just a PoC and not really useful? :D

Agreed.

Co-authored-by: Uzair Aftab <[email protected]>
@luxus
Copy link
Member Author

luxus commented Nov 11, 2024

should not toggleterm be fully replaced with that? @mehalter

@mehalter
Copy link
Member

Yeah I think it should, I think you mentioned above you were gonna do it 😂

@mehalter
Copy link
Member

It should probably be default override toggleterm but if the user manually re-enables it then it should go back to the defaults in AstroNvim

@luxus
Copy link
Member Author

luxus commented Nov 11, 2024

if i wait long enough, hopefully it will fix by itself :-D

@Uzaaft
Copy link
Member

Uzaaft commented Nov 16, 2024

Ready for review?

@mehalter
Copy link
Member

There still needs to be work done to replace toggleterm stuff

@Uzaaft Uzaaft marked this pull request as draft November 17, 2024 09:54
@luxus
Copy link
Member Author

luxus commented Nov 17, 2024

i checked snacks, dunno how to do a float without a cmd
not sure how to emulate <Leader>tf

@RayJameson
Copy link
Contributor

RayJameson commented Dec 1, 2024

i checked snacks, dunno how to do a float without a cmd not sure how to emulate <Leader>tf

I peeked into source code, this snippet works for me

        maps.n["<Leader>tf"] = {
          function() Snacks.terminal(nil, { win = { position = "float" } }) end,
          desc = "Toggle Terminal Float",
        }

maps.n["<Leader>cR"] = { function() Snacks.rename() end, desc = "Rename File" }
maps.n["<Leader>th"] = { function() Snacks.terminal() end, desc = "Toggle Terminal" }
maps.n["<Leader>tf"] = { function() Snacks.terminal() end, desc = "Toggle Terminal Float" }
maps.n["<Leader>to"] = { function() Snacks.terminal "<Cmd>execute v:count ." end, desc = "Toggle Terminal" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems incorrect

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why/How?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm using it wrong, but if I press the keymap, then I get error, and if I understand the Snacks.terminal api correctly, use supposed to provide shell command, not vim command

---@param opts snacks.Config
opts = function(_, opts)
local astrocore = require "astrocore"
return astrocore.extend_tbl(opts, {
Copy link
Contributor

@RayJameson RayJameson Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think those options would make snacks fall in line with astronvim float windows style

Suggested change
return astrocore.extend_tbl(opts, {
return astrocore.extend_tbl(opts, {
win = {
border = "rounded",
backdrop = false,
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants