-
-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(previewer): show unwritten buffer previewers for some pickers #2946
base: master
Are you sure you want to change the base?
Conversation
|
It includes it 😁
|
Maybe I need to verify it on minimal env first. |
with minimal local thisInitFile = debug.getinfo(1).source:match('@?(.*)')
local configDir = vim.fs.dirname(thisInitFile)
vim.env['XDG_CONFIG_HOME'] = configDir
vim.env['XDG_DATA_HOME'] = vim.fs.joinpath(configDir, '.xdg/data')
vim.env['XDG_STATE_HOME'] = vim.fs.joinpath(configDir, '.xdg/state')
vim.env['XDG_CACHE_HOME'] = vim.fs.joinpath(configDir, '.xdg/cache')
local stdPathConfig = vim.fn.stdpath('config')
vim.opt.runtimepath:prepend(stdPathConfig)
vim.opt.packpath:prepend(stdPathConfig)
local function gitClone(url, installPath, branch)
if vim.fn.isdirectory(installPath) ~= 0 then
return
end
local command = {'git', 'clone', '--', url, installPath}
if branch then
table.insert(command, 3, '--branch')
table.insert(command, 4, branch)
end
local sysObj = vim.system(command, {}):wait()
if sysObj.code ~= 0 then
error(sysObj.stderr)
end
vim.notify(sysObj.stdout)
vim.notify(sysObj.stderr, vim.log.levels.WARN)
end
local pluginsPath = 'plugins'
vim.fn.mkdir(pluginsPath, 'p')
pluginsPath = vim.uv.fs_realpath(pluginsPath)
local plugins = {
['plenary.nvim'] = {url = 'https://github.com/nvim-lua/plenary.nvim'},
['telescope.nvim'] = {url = 'https://github.com/nvim-telescope/telescope.nvim', branch = 'feat/unwritten-buffer-previewer'},
}
for name, repo in pairs(plugins) do
local installPath = vim.fs.joinpath(pluginsPath, name)
gitClone(repo.url, installPath, repo.branch)
vim.opt.runtimepath:append(installPath)
end
require('telescope').setup {
defaults = {
preview = {},
layout_strategy = 'horizontal',
layout_config = {
preview_cutoff = 1,
},
mappings = {
i = {
['<A-/>'] = function (promptBufnr)
return require 'telescope.actions.layout'.toggle_preview(promptBufnr)
end,
['<Esc>'] = 'close',
},
},
},
}
local function init()
vim.api.nvim_buf_set_lines(0, 0, 0, true, {'changed'})
vim.schedule(function ()
vim.cmd.Telescope 'buffers'
end)
end
vim.api.nvim_create_autocmd('UIEnter', {
once = true,
callback = init,
}) For comparison |
i'd like to review this in the next couple of days, dont think i can make it today |
Thanks for opening this PR anyway! I spent few hours for verify if it's possible at the user side before reporting an issue. I have updated the minimal repro to reduce typing. |
Ahh sorry it looks like it's an edge case with But in the mean time, I was able to verify this by modifying for minimal config here local function init()
vim.cmd("edit init.lua") -- edit this file so it's not a no name buffer
vim.api.nvim_buf_set_lines(0, -1, -1, true, {'changed'})
vim.schedule(function ()
vim.cmd.Telescope 'buffers'
end)
end |
I did not mention (but it's visible on the screenshot) that I run the minimal Notice that Indeed, for |
Now it works! |
@jamestrew could you update this branch, please? |
Use actual buffer contents for buffer previewers for some pickers (buffers, treesitter, current_buffer_fuzzy_find, for starters). Not to be confused with reusing buffers for preview buffers. This lets users view previews of buffers with unwritten changes. For treesitter and current_buffer_fuzzy_find, not showing actual buffer content is arguably a bug considering the finder operates over the buffer (written or not). So there are instances where you can search over unwritten content in the buffer only to see an outdated, written only content in the preview.
21ca3d9
to
2768d5e
Compare
Use actual buffer contents for buffer previewers for some pickers (buffers, treesitter, current_buffer_fuzzy_find, for starters). Not to be confused with reusing buffers for preview buffers.
This lets users view previews of buffers with unwritten changes. For treesitter and current_buffer_fuzzy_find, not showing actual buffer content is arguably a bug considering the finder operates over the buffer (written or not). So there are instances where you can search over unwritten content in the buffer only to see an outdated, written only content in the preview.
Closes #2481