Giter VIP home page Giter VIP logo

Comments (5)

latipun7 avatar latipun7 commented on July 21, 2024 1

This really solved my issue. Thank you @olimorris for your guidance.
If you don't mind, I'll create PR to update docs on telescope callback.
Thank you very much 🎉

from persisted.nvim.

latipun7 avatar latipun7 commented on July 21, 2024

With this config:

require("persisted").setup({
  after_source = function()
    vim.notify("Loaded session")
    print("Loaded session")
  end,
  telescope = {
    before_source = function()
      vim.api.nvim_input("<Esc><Cmd>%bd<CR>")
    end,
    after_source = function()
      -- vim.notify(
      --   "Loaded session " .. session.name,
      --   vim.log.levels.INFO,
      --   { title = title }
      -- )
      print("Loaded session")
    end,
  },
})

Loading session and last session normally printed "Loaded session" and notify window is appeared.
But if I load session thru telescope, even print didn't printed.
WindowsTerminal_cCQg8Ozlj3

from persisted.nvim.

olimorris avatar olimorris commented on July 21, 2024

Very strange. Both callbacks use the same function so I would expect both patterns to be the same. Do you know if notify plays nicely with Telescope? Could you try using the after_source telescope callback to delay sending the notification?

from persisted.nvim.

latipun7 avatar latipun7 commented on July 21, 2024

I don't know how to delay sending the notification, but I changed to this config:

require("persisted").setup({
    after_source = function(session)
      local async = require("plenary.async")
      local notify = require("notify").async

      async.run(function()
        notify(
          "Loaded session " .. session.name,
          vim.log.levels.INFO,
          { title = title }
        )
        print("Loaded session")
      end)
    end,
  },
})

Now, the notification window is always showed if there's already notify window. But, print statement still didn't get printed. Then, if I wait until notify window all is gone, that code is still didn't send the notify window.
I hope this recording is clear for what I describe:
WindowsTerminal_QrNOdxUF7l

I don't know much about lua callback / async code, so I can't figured out why.

from persisted.nvim.

olimorris avatar olimorris commented on July 21, 2024

Have you looked at vim.defer_fn? Not one to link to Reddit but this post and subsequent comments explain things nicely. I wonder if this may solve the problem.

from persisted.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.