Skip to content

Is there a way to auto open a newly added file in buffer? #1268

Closed Answered by cseickel
jacobrreed asked this question in Q&A
Discussion options

You must be logged in to vote

You can update @pysan3's answer to use the utils.open_file method:

      {
        event = "file_added",
        handler = function(destination)
          local manager = require("neo-tree.sources.manager")
          local utils = require("neo-tree.utils")
          local uv = vim.loop
          local file_info = uv.fs_stat(destination)
          if file_info and file_info.type == "file" then
            vim.schedule(function()
              utils.open_file(manager.get_state_for_window(), destination)
            end)
          end
        end,
      },

This is untested but it will probably work...

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@jacobrreed
Comment options

@pysan3
Comment options

@jacobrreed
Comment options

@cseickel
Comment options

Answer selected by jacobrreed
@jacobrreed
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants