Giter VIP home page Giter VIP logo

Comments (7)

olimorris avatar olimorris commented on July 21, 2024

Hmmmm weird. Is it working now? I do feel that allowed_dirs is not the best name for the variable and may lead to confusion.

Secondly, the lua require("persisted").list() does return a table. I won't berate myself too much for this as it is in the readme 😉 . But...I have a custom function which launches a Telescope picker:

--- functions.lua file
function om.LoadSession()
  local ok, persisted = om.safe_require("persisted")
  if not ok then
    return
  end

  local sessions = persisted.list()
  local path_to_trim = Sessiondir .. "/"

  local sessions_short = {}
  for _, session in pairs(sessions) do
    sessions_short[#sessions_short + 1] = session:gsub(path_to_trim, "")
  end

  om.select("Session to load", sessions_short, function(choice)
    if choice == nil then
      return
    end
    vim.cmd("source " .. vim.fn.fnameescape(path_to_trim .. choice))
    vim.cmd('lua require("persisted").stop()')
  end)
end

--- globals.lua file
function om.select(prompt, choices, callback)
  vim.ui.select(choices, { prompt = prompt }, callback)
end

from persisted.nvim.

calebdw avatar calebdw commented on July 21, 2024

It is working, but I am not using the allowed_dirs option...maybe I should've appended a slash, /, to the end of the path?

And okay, my apologies---I thought I could create a mapping directly to lua require("persisted").list() and have it open in a Telescope window. Perhaps you would consider adding in a telescope extension? Then all that would be required for the user would be something along the lines of (note that I use the cartographer plugin for my mappings):

require('telescope').load_extension('persisted')
map.n.nore.silent['<leader>tp'] = ':Telescope persisted<cr>'

from persisted.nvim.

olimorris avatar olimorris commented on July 21, 2024

Love the idea of a telescope extension. I've raised this as a new issue.

Regarding allowed_dirs, the plugin compares your current working directory (from Neovim) with the directories listed in the allowed_dirs table. I suspect you need the full path. It should work with something like ~/Code/Projects/persisted.nvim.

from persisted.nvim.

olimorris avatar olimorris commented on July 21, 2024

I think this is highlighting that I need to do a full readme write up at some point. I tried to stay as close to Folke's as possible but it's starting to fail. Thanks for your great feedback.

from persisted.nvim.

olimorris avatar olimorris commented on July 21, 2024

Love the idea of a telescope extension. I've raised this as a new issue.

Regarding allowed_dirs, the plugin compares your current working directory (from Neovim) with the directories listed in the allowed_dirs table. I suspect you need the full path. It should work with something like ~/Code/Projects/persisted.nvim.

@calebdw I've initially added this via #7 . Let me know what you think. Also updated the readme, heavily!

from persisted.nvim.

calebdw avatar calebdw commented on July 21, 2024

Love the idea of a telescope extension. I've raised this as a new issue.
Regarding allowed_dirs, the plugin compares your current working directory (from Neovim) with the directories listed in the allowed_dirs table. I suspect you need the full path. It should work with something like ~/Code/Projects/persisted.nvim.

@calebdw I've initially added this via #7 . Let me know what you think. Also updated the readme, heavily!

Awesome! It looks pretty good but I noticed a couple of things:

  • There's a missing end-quote:
{
  allowed_dirs = {
    "~/Code/Neovim",
    "~/Code/Projects/Ruby"
  }
}
  • The Telescope window appear to clip the last column. There's also only two columns listed whereas 4 are listed in the README?
    image
  • The allowed_dirs and ignored_dirs needs a little clarification. If a directory is listed, does it include all children as well? For instance, if I want to ignore my home directory ('~'), would it also prevent autoloading in my projects directory ('~/projects')?

Thanks for the quick turnaround!

from persisted.nvim.

olimorris avatar olimorris commented on July 21, 2024

Great feedback, thank you! I have pushed updates to the readme and improved the way directories are pattern matched!

Regarding Telescope, can we move that to this thread?

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.