kevinhwang91 / rnvimr

Make Ranger running in a floating window to communicate with Neovim via RPC
BSD 3-Clause "New" or "Revised" License
812 stars 17 forks source link

cwd enhancement #29

Closed monkoose closed 4 years ago

monkoose commented 4 years ago

Hello. It's me again. Have tested your plugin a little. For sure ranger is more powerful than some other vim fm(tree) plugins like NerdTree, but one thing that bothers me that it's hard to say (after you have changed few directories) which directory is cwd in neovim. Can it be improved somehow? Like receiving string from getcwd() and

kevinhwang91 commented 4 years ago

Sorry for my inability to understand what you mean. Please explain clearly to me.

There's some feature in rnvimr about cwd.

Pressing q in Ranger just hides the floating window. Ranger will attach the file of the current buffer in the next toggle event.

If you want to make ranger stay the ordinary directory, you can use :RnvimrToggle instead of pressing q. Or you press 'H' after the window of ranger popup.

monkoose commented 4 years ago

English isn't my native too, sorry.

What do i mean is that you have some cwd in neovim that you can get with :pwd or :echo getcwd() (and more often it is your projects root directory), when you first time toggle rnvimr it shows this directory. But lets say you jump around in ranger and completely change it. How you can fast return to the root of this cwd or at least visually distinguish it from other directories?

So in ranger by default we have gh - command that jumps to your home directory, and some other like gu etc. So i was asking is it possible to implement something like this with rnvimr? So it get cwd from neovim and set some shortcut something like maybe gg (do not mapped in ranger by default). So with this shortcut you can easily jump to this directory. Or maybe with marks?

And another not so useful (and maybe for someone bad default) is to restrict h hotkey only in this cwd, so you can't go to parent directory beyond cwd from neovim.

kevinhwang91 commented 4 years ago

I get your point now, you want to change the directory inside ranger into pwd In neovim?

monkoose commented 4 years ago

More like ability to easily distinguish it from others in ranger and ability to fast jump to the root of it.

kevinhwang91 commented 4 years ago

I think this is a good idea. For now, I use this script wrote by myself to jump git root.

class GitRoot(Command):
    """
    :GitRoot

    """

    def execute(self):
        git_root = subprocess.Popen(
            'git rev-parse --show-toplevel', universal_newlines=True, shell=True,
            stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
        stdout = git_root.communicate()[0]
        if git_root.returncode == 0:
            git_root_path = os.path.abspath(stdout.rstrip('\n'))
            self.fm.cd(git_root_path)

and z.lua combine to ranger jump everywhere.

It's very easy to implement your demand. I am doing it now.

monkoose commented 4 years ago

Waiting for implementation. Thank you again.

kevinhwang91 commented 4 years ago
g:rnvimr_action
    Default: {dict}

            { 
                '<C-t>': 'Edit tabedit',
                '<C-x>': 'Edit split',
                '<C-v>': 'Edit vsplit',
                'gw': 'JumpNvimCwd',
                'yw': 'EmitRangerCwd'
            }

    Edit : Use Neovim's command to edit the selected file in Ranger.
    JumpNvimCwd : Change Ranger's cwd to Neovim's.
    EmitRangerCwd : Change Neovim's cwd to Ranger's.

    Disable it by using empty dict. The keymap should follow Ranger's format.

gw is what you want.

monkoose commented 4 years ago

Seems working. Thank You.

kevinhwang91 commented 4 years ago

I'm sorry for refactoring the name of Edit to NvimEdit. Because Edit Not sure if it's Neovim's or Ranger's. I hope it doesn't affect you.

https://github.com/kevinhwang91/rnvimr/commits/master