nvim-neorg / neorg-telescope

Telescope.nvim integration for Neorg
GNU General Public License v3.0
187 stars 24 forks source link

Updated the use of relative to absolute paths. #31

Closed AlphabetsAlphabets closed 1 year ago

AlphabetsAlphabets commented 1 year ago

This is to fix #30. My not be the best solution given that you can use :Telescope find_norg_files from anywhere and you'll be able to view your norg files. This works similarly to setting vim.opt.autochdir = true in an ftplugin or your configs

image

One minor edit is that it will always show the absolute file path. Of course this has no issue with function. I'm just really hung up on the appearance lmao.

AlphabetsAlphabets commented 1 year ago

To add onto the "it has no effect on function" after using it for a while unsurprisingly, the fuzzy searching also matches the /home/yjh/neorg part and will occasionally make things difficult when it matches that instead of the actual file name.

max397574 commented 1 year ago

imo it makes no sense to try to fix things like this I should just overwrite the select action to make it work

because as far as I understand opening the files is the only issue

AlphabetsAlphabets commented 1 year ago

because as far as I understand opening the files is the only issue

It's not just opening the files. The preview is completely empty as well. #30

Nekketsu commented 1 year ago

I fixed it locally by creating the picker like this:

pickers
        .new(opts, {
            prompt_title = opts.prompt_title or "Find Norg Files",
            cwd = files[1],
            finder = finders.new_table({
                results = files[2],
                entry_maker = function(entry)
                    return {
                        value = entry,
                        display = entry,
                        ordinal = entry,
                        path = files[1] .. neorg.configuration.pathsep .. entry
                    }
                end,
            }),
            previewer = conf.file_previewer(opts),
            sorter = conf.file_sorter(opts),
        })
        :find()

The get_neorg_files doesn't need to be modified. It can be reverted their changes.

Nekketsu commented 1 year ago

And even easier:


return function(opts)
    opts = opts or {}

    local files = get_norg_files()

    if not (files and files[2]) then
        return
    end

    pickers
        .new(opts, {
            prompt_title = opts.prompt_title or "Find Norg Files",
            finder = finders.new_table({
                results = files[2],
                entry_maker = make_entry.gen_from_file({ cwd = files[1] })
            }),
            previewer = conf.file_previewer(opts),
            sorter = conf.file_sorter(opts),
        })
        :find()
end

It seems that the original code was well defined, but some variables where used in an invalid place.

AlphabetsAlphabets commented 1 year ago

Your solution works @Nekketsu, I'll update my PR to include your code. Or would you like to submit your own PR? If that's the case, you can close the PR with your next comment.

max397574 commented 1 year ago

because as far as I understand opening the files is the only issue

It's not just opening the files. The preview is completely empty as well. #30

there must be a better way of fixing this anyway I can look into it later today

something similar to what @Nekketsu did should work @Nekketsu do you want to open a pr or should I just push a fix?