Giter Site home page Giter Site logo

Comments (6)

davidmh avatar davidmh commented on June 29, 2024 1

in terms of supporting command pass-through I haven't yet figured out a way to do that

This is such a great coincidence, I was about to post this in a discussion thread, but I think it's relevant enough to post it here.

I'm looking to solve a very similar problem, and I found a way to read all the arguments passed to the nested nvim instance.

I'm using the v:argv variable, which sounds the same as the argv function, exept that v:argv includes way more data.

For example, when open neovim in diff mode:

nvim -d file-a.txt file-b.txt

I get the following through vim.v.argv:

{ "<HOME>/.nix-profile/bin/nvim",
  "--cmd", "let g:loaded_node_provider=0 | let g:loaded_python_provider=0 | let g:python3_host_prog='/nix/store/2j5i0n338vrw9w1jwhmfgfxhnbncr27h-neovim-0.8.1/bin/nvim-python3' | let g:ruby_host_prog='/nix/store/2j5i0n338vrw9w1jwhmfgfxhnbncr27h-neovim-0.8.1/bin/nvim-ruby'",
  "--cmd", "set packpath^=/nix/store/vncf2y1mpg3m8iii6dngmjvsinb732sg-vim-pack-dir",
  "--cmd", "set rtp^=/nix/store/vncf2y1mpg3m8iii6dngmjvsinb732sg-vim-pack-dir",
  "-d", "file-a.txt", "file-b.txt" }

Which gets lets me know that -d was trying to start a diff mode for the passed files.

I haven't figured out how to get only the commands actually passed by the user. But for the time being, that does what I need.

See my fork: davidmh@311b4a2

And this is how I use it: https://github.com/davidmh/dot-files/blob/main/nvim/fnl/own/plugin/flatten.fnl#L20-L30

Some things I haven't worked through, which I like to address before sending a PR:

  • Get the actual commands passed by the user, not the extra commands shown in the output
  • Have options like -b automatically enable blocking, or just let the nested session run as usual.
    In my use case, the diff mode is meant to be used with the approvals.
    It could be an option like:
{
  ignore_for_options = {'-b'}
}

What do you think?

from flatten.nvim.

willothy avatar willothy commented on June 29, 2024 1

Thank you so much! That's super helpful, will look through your fork and get working on integrating v:argv tomorrow.

As far as a PR goes, that would be very welcome, but I would like to avoid adding argument flags that aren't already Neovim args, so that using flatten is as much like using default Neovim as possible. I would consider adding args for specific use cases such as blocking if enough people seem to prefer that to setting a global though, so if you submit a PR it would be ideal for the functionality to be enabled by a global or module-local var instead of an argument directly, so that I/we can decide on which direction to go in based on how the general user base responds to the idea.

Thanks!

from flatten.nvim.

willothy avatar willothy commented on June 29, 2024 1

Yes, sorry, I should've been more clear - I meant that I'd like to keep all arguments the same functionally as well as semantically, but it seems like including that but
allowing users to opt out through a config option would work very well. Thank you for contributing, I'll review the PR today!

from flatten.nvim.

willothy avatar willothy commented on June 29, 2024

This is something I've been looking into - definitely Manpage support is something I could hard code as an edge case, but in terms of supporting command pass-through I haven't yet figured out a way to do that. I am actively looking though and will absolutely implement that when I'm able.

I'll look for a solution for manpages in the short term though, thanks for reporting!

Until then, probably best to just use Man <topic> from the parent instance's command-line.

from flatten.nvim.

davidmh avatar davidmh commented on June 29, 2024

That makes sense, maybe a better way to enable blocking programmatically would be to introduce a callback function to determine the blocking before the files are sent from within the nested session.

from flatten.nvim.

davidmh avatar davidmh commented on June 29, 2024

As far as a PR goes, that would be very welcome, but I would like to avoid adding argument flags that aren't already Neovim args, so that using flatten is as much like using default Neovim as possible

I'm just re-reading this. The flag I mentioned (-b) already exists in neovim, what I was proposing was to opt out of flatten through a config option in the flatten config. The user would start neovim as they always do.

I'll tune up the fork to include a new callback: config.callbacks.should_block(vim.v.argv) to be used as a fallback to vim.g.flatten_wait.

I would be happy to also work on dispatching other commands, like the +Man something in this issue.

from flatten.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.