Giter Site home page Giter Site logo

Moving files about nvim-tree.lua HOT 7 CLOSED

aneshodza avatar aneshodza commented on May 12, 2024
Moving files

from nvim-tree.lua.

Comments (7)

joelpeapen avatar joelpeapen commented on May 12, 2024 1

It's on the wiki: https://github.com/nvim-tree/nvim-tree.lua/wiki/Recipes#nerdtree-style-copy-file-to

local function on_attach(bufnr)
...
    local function move_file_to()
        local node = api.tree.get_node_under_cursor()
        local file_src = node['absolute_path']
        local file_out = vim.fn.input("MOVE TO: ", file_src, "file")
        local dir = vim.fn.fnamemodify(file_out, ":h")
        vim.fn.system { 'mkdir', '-p', dir }
        vim.fn.system { 'mv',  file_src, file_out }
    end
    vim.keymap.set('n', 'X', move_file_to, opts('Move File To'))
end

from nvim-tree.lua.

aneshodza avatar aneshodza commented on May 12, 2024

But this is still a copy (it doesn't remove the old location). This function does a cp, instead of an mv
Now:

vim.fn.system { 'cp', '-R', file_src, file_out }

To move:

vim.fn.system { 'mv', '-R', file_src, file_out }

But the message I'm getting from this, is that the lack of a move is a design choice?

from nvim-tree.lua.

joelpeapen avatar joelpeapen commented on May 12, 2024

removing the '-R' flag works

from nvim-tree.lua.

aneshodza avatar aneshodza commented on May 12, 2024

But cp is still a copy. I'm talking about having a built in move_file_to. Maybe by just copying and slightly changing copy_file_to.

from nvim-tree.lua.

joelpeapen avatar joelpeapen commented on May 12, 2024

yes you can rename the function. I've updated the snippet.

from nvim-tree.lua.

aneshodza avatar aneshodza commented on May 12, 2024

Alright, thanks! Im wondering why this isn't in per default.

from nvim-tree.lua.

alex-courtis avatar alex-courtis commented on May 12, 2024

Many thanks @joelpeapen

from nvim-tree.lua.

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.