nvim-telescope / telescope-frecency.nvim

A telescope.nvim extension that offers intelligent prioritization when selecting files from your editing history.
MIT License
777 stars 37 forks source link

Feature request: Use the git root as CWD #158

Closed arnevm123 closed 9 months ago

arnevm123 commented 9 months ago

Hi, Most of my Telescope mappings are wrapped in something like this: Use the git root if it exists, else use cwd. This did not work with this plugin, as I think the workspace can't be a full path.

local root = string.gsub(vim.fn.system("git rev-parse --show-toplevel"), "\n", "")
if vim.v.shell_error == 0 then
    require("telescope").extensions.frecency.frecency({ workspace = root })
else
    require("telescope").extensions.frecency.frecency({ workspace = "CWD" })
end

I can make a MR that would resolve this in a similar way as the lsp one. Is this something you'd want in this project?

arnevm123 commented 9 months ago

Ahaa, nevermind it seems like I can set the cwd as well I could only find this in the code though.

function()
    local root = string.gsub(vim.fn.system("git rev-parse --show-toplevel"), "\n", "")
    if vim.v.shell_error == 0 then
        require("telescope").extensions.frecency.frecency({ cwd = root, workspace = "CWD" })
    else
        require("telescope").extensions.frecency.frecency({ workspace = "CWD" })
    end
end,