hadronized / mind.nvim

The power of trees at your fingertips.
Other
688 stars 42 forks source link

[New Feature] Node cloning #85

Open pr-313 opened 1 year ago

pr-313 commented 1 year ago

Absolutely loved the simplicity of this plugin, and the ease at which I can traverse complex todos

I wanted to start using this to record our teams daily stand-up meetings. Since they have roughly a set format, with regards to the topics that are discussed; week over week I mind myself having to keep re-creating the whole template I use.

Is there any plan to implement node cloning or copying? That would just be the last and final thing I need to switch to this plugin fulltime

pr-313 commented 1 year ago

Currently my solution is to hand edit the .json state file. But this isnt really a great solution as the data file linkages get messed up

hadronized commented 1 year ago

For daily, I have my own thing using the Mind API:

        key = '<leader>j',
        lua = function()
          require'mind'.wrap_main_tree_fn(function(args)
            local tree = args.get_tree()
            local path = vim.fn.strftime('/Journal/%Y/%b/%d')
            local _, node = require'mind.node'.get_node_by_path(tree, path, true)

            if node == nil then
              vim.notify('cannot open journal 🙁', vim.log.levels.WARN)
              return
            end

            require'mind.commands'.open_data(tree, node, args.data_dir, args.save_tree, args.opts)
            args.save_tree()
          end)
        end
      },

You can probably edit that snippet to change the content of the path and put your template there as well. There should be something the API to pass the default text used when creating data (if not, maybe I should add it, :h mind-lua-api should have something about it).

As for node cloning… yeah, adding a command doing that should be quite easy. It just needs to support both link and data nodes, but that should be fairly simple.