Comments (18)
This is my final config working correctly: Please note that for all plugins except telescope undo, we are defining them as separated plugins, and the the only part that touches Telescope, is when we add a Telescope extension.
telescope-undo.nvim
is special in this sense, it needs to be 100% defined inside Telescope (not only its extension, but its config too). I insist we shouldn't be doing this unless it's 100% unavoidable, as it bloats the Telescope settings considerably.
telescope-undo.nvim
settings should be defined in the plugin, NOT in the extension. Therefore I'm leaving the issue opened.
-- Telescope [search] + [search backend] dependency
-- https://github.com/nvim-telescope/telescope.nvim
-- https://github.com/nvim-telescope/telescope-fzf-native.nvim
-- https://github.com/debugloop/telescope-undo.nvim
-- NOTE: Normally, plugins that depend on Telescope are defined separately.
-- But its Telescope extension is added in the Telescope 'config' section.
{
"nvim-telescope/telescope.nvim",
dependencies = {
"debugloop/telescope-undo.nvim",
{
"nvim-telescope/telescope-fzf-native.nvim",
enabled = vim.fn.executable "make" == 1,
build = "make",
},
},
cmd = "Telescope",
opts = function()
local actions = require "telescope.actions"
local get_icon = require("base.utils").get_icon
local mappings = {
i = {
["<C-n>"] = actions.cycle_history_next,
["<C-p>"] = actions.cycle_history_prev,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<ESC>"] = actions.close,
["<C-c>"] = false,
},
n = { ["q"] = actions.close },
}
return {
defaults = {
prompt_prefix = get_icon("Selected", 1),
selection_caret = get_icon("Selected", 1),
path_display = { "truncate" },
sorting_strategy = "ascending",
layout_config = {
horizontal = {
prompt_position = "top",
preview_width = 0.50,
},
vertical = {
mirror = false,
},
width = 0.87,
height = 0.80,
preview_cutoff = 120,
},
mappings = mappings,
},
extensions = {
undo = {
use_delta = true,
side_by_side = true,
diff_context_lines = 0,
entry_format = " #$ID, $STAT, $TIME",
layout_strategy = "horizontal",
mappings = {
i = {
["<cr>"] = require("telescope-undo.actions").yank_additions,
["<S-cr>"] = require("telescope-undo.actions").yank_deletions,
["<C-cr>"] = require("telescope-undo.actions").restore,
},
n = {
["y"] = require("telescope-undo.actions").yank_additions,
["Y"] = require("telescope-undo.actions").yank_deletions,
["u"] = require("telescope-undo.actions").restore,
},
},
},
},
}
end,
config = function(_, opts)
local telescope = require "telescope"
telescope.setup(opts)
-- Here we define the Telescope extension for all plugins.
-- If you delete a plugin, you can also delete its Telescope extension.
utils.conditional_func(
telescope.load_extension,
utils.is_available "nvim-notify",
"notify"
)
utils.conditional_func(
telescope.load_extension,
utils.is_available "telescope-fzf-native.nvim",
"fzf"
)
utils.conditional_func(
telescope.load_extension,
utils.is_available "telescope-undo.nvim",
"undo"
)
utils.conditional_func(
telescope.load_extension,
utils.is_available "nvim-neoclip.lua",
"neoclip"
)
utils.conditional_func(
telescope.load_extension,
utils.is_available "nvim-neoclip.lua",
"macroscope"
)
utils.conditional_func(
telescope.load_extension,
utils.is_available "project.nvim",
"projects"
)
utils.conditional_func(
telescope.load_extension,
utils.is_available "LuaSnip",
"luasnip"
)
utils.conditional_func(
telescope.load_extension,
utils.is_available "aerial.nvim",
"aerial"
)
end,
},
from telescope-undo.nvim.
It's what telescope itself recommends though, so I am tempted to close it anyways ;)
Do you have an example of a telescope plugin that behaves as you expect it too regarding config? I'll take a peek on what to do different some time 👍🏻 As I said, also not a fan of the integrated config, but I don't do telescope extensively anyhow.
from telescope-undo.nvim.
@debugloop several:
https://github.com/stevearc/aerial.nvim/tree/master/lua
https://github.com/AckslD/nvim-neoclip.lua/tree/main/lua
https://github.com/ahmedkhalf/project.nvim/tree/main/lua
You see none of these plugins define their options on the Telescope extension. They do it on the plugin.
IDK if there would be some limiting particularity on this approach for telescope-undo.
from telescope-undo.nvim.
I've tested around a bit and I'm not entirely clear anymore what your precise issue is. You can configure it just fine in a standalone manner:
{
"debugloop/telescope-undo.nvim",
dependencies = {
{ "nvim-telescope/telescope.nvim" },
},
keys = {
{
"<leader>u",
"<cmd>Telescope undo<cr>",
desc = "undo history"
},
},
opts = {
extensions = {
undo = {
side_by_side = true,
layout_strategy = "vertical",
layout_config = {
preview_height = 0.8,
},
},
},
},
config = function(_, opts)
require("telescope").setup(opts)
require("telescope").load_extension('undo')
end,
}
from telescope-undo.nvim.
i spent some time this weekend ripping apart my config. i had an element in the wrong part of the table that was causing me issues. for anyone interested i have this config working as expected:
return {
"nvim-telescope/telescope.nvim",
event = "VeryLazy",
dependencies = {
"nvim-lua/plenary.nvim",
"debugloop/telescope-undo.nvim",
},
config = function()
local telescope = require("telescope")
local tele_actions = require("telescope.actions")
local undo_actions = require("telescope-undo.actions")
telescope.setup({
defaults = {
layout_config = {
anchor = "center",
height = 0.8,
width = 0.9,
preview_width = 0.6,
prompt_position = "bottom",
},
mappings = {
i = {
["<esc>"] = tele_actions.close,
},
},
},
extensions = {
undo = {
use_delta = true,
side_by_side = true,
entry_format = " #$ID, $STAT, $TIME",
layout_strategy = "flex",
mappings = {
i = {
["<cr>"] = undo_actions.yank_additions,
["<S-cr>"] = undo_actions.yank_deletions,
["<C-\\>"] = undo_actions.restore,
},
},
},
},
})
telescope.load_extension("undo")
end,
}
![Screenshot 2023-07-11 at 7 53 40 AM](https://private-user-images.githubusercontent.com/227907/252655265-dff66784-24dc-4ef2-936f-f1147c4ff970.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg3NjQyMDYsIm5iZiI6MTcxODc2MzkwNiwicGF0aCI6Ii8yMjc5MDcvMjUyNjU1MjY1LWRmZjY2Nzg0LTI0ZGMtNGVmMi05MzZmLWYxMTQ3YzRmZjk3MC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjE5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYxOVQwMjI1MDZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03MmU1NTE5M2MyY2VjNmJkZGQxYWZjNTUyZDExMzZiMTY3YWE5ODA0NGMxYTYyYjI2N2Q5MmUzY2Y1YTIzOTM1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.8clWgiVQSIWHRkMeq1Qiibg4vEfg_C61HvYQU6v5rh8)
from telescope-undo.nvim.
I can confirm @xero config works as expected. Thank you so much for sharing it!!!
from telescope-undo.nvim.
np. for completion and search results sake, it took me a while to figure out the highlight groups for the diffs. these are what i’m using in the screenshot:
hi DiffAdded guifg=#5f875f guibg=#1c1c1c guisp=NONE blend=NONE gui=NONE
hi DiffRemoved guifg=#b36d43 guibg=#1c1c1c guisp=NONE blend=NONE gui=NONE
hi WarningMsg guifg=#b36d43 guibg=NONE guisp=NONE blend=NONE gui=NONE
from telescope-undo.nvim.
@debugloop That one indeed take correctly the options passed by the user. Thank you so much for taking the time to review it.
Adding to the readme might benefit other users.
from telescope-undo.nvim.
I don't think this would work for remapping the defaults, would it? I actually only use telescope for this plugin, and I've adhered to what telescope itself recommends here. Do you know why they're recommending that way?
I however agree that your way of doing it is much nicer and more self-contained, as stated elsewhere, I dislike the extensions
key in telescope config as well... I'll test it out soon to figure out if there are any drawbacks.
from telescope-undo.nvim.
The options seem to be ignored. Could you try this and check if it diff_context_lines
is applied correctly?
-- telescope-undo.nvim
-- https://github.com/debugloop/telescope-undo.nvim
{
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"debugloop/telescope-undo.nvim",
},
config = function()
require("telescope").setup({
extensions = {
undo = {
diff_context_lines = 0,
},
},
})
require("telescope").load_extension("undo")
-- optional: vim.keymap.set("n", "<leader>u", "<cmd>Telescope undo<cr>")
end,
},
In order to keep testing, I've created a fork and changed the options in the source code so I can use it in the meantime.
from telescope-undo.nvim.
My options are also being ignored. My conifg looks like
local M = {
"nvim-telescope/telescope.nvim",
tag = "0.1.1",
cmd = { "Telescope" },
dependencies = {
"nvim-telescope/telescope-media-files.nvim", -- display preview of media files in telescope
"nvim-lua/plenary.nvim",
"debugloop/telescope-undo.nvim",
"nvim-treesitter/nvim-treesitter",
}
}
function M.config()
local actions = require("telescope.actions")
local telescope = require("telescope")
vim.keymap.set("n", "<leader>u", "<cmd>Telescope undo<cr>",
{ silent = true, noremap = true, desc = "Telescope: Open undotree" }
)
telescope.setup({
...
extensions = {
...
undo = {
-- defaults
use_delta = true,
use_custom_command = nil, -- setting this implies `use_delta = false`. Accepted format is: { "bash", "-c", "echo '$DIFF' | delta" }
side_by_side = true,
diff_context_lines = vim.o.scrolloff,
entry_format = "state #$ID, $STAT, $TIME",
time_format = "",
-- layout_strategy = "vertical",
-- layout_config = {
-- preview_height = 0.8,
-- },
mappings = {
i = {
-- IMPORTANT: Note that telescope-undo must be available when telescope is configured if
-- you want to replicate these defaults and use the following actions. This means
-- installing as a dependency of telescope in it's `requirements` and loading this
-- extension from there instead of having the separate plugin definition as outlined
-- above.
["<C-cr>"] = require("telescope-undo.actions").yank_additions,
["<S-cr>"] = require("telescope-undo.actions").yank_deletions,
["<cr>"] = require("telescope-undo.actions").restore,
},
n = {
["y"] = require("telescope-undo.actions").yank_additions,
["Y"] = require("telescope-undo.actions").yank_deletions,
["<cr>"] = require("telescope-undo.actions").restore,
},
},
},
},
})
telescope.load_extension("undo")
...
end
return M
It also isn't using delta even though I have it installed. I don't know if I should open a separate issue for that. I get other strange issues too like I noticed my bracket colorizer (ts-rainbow2) stops working. Really strange.
from telescope-undo.nvim.
@TSoli I can’t tell if that is just a copy-and-paste error or if that is the actual content of your telescope config. If the latter, I'm not surprised it’s not working, you’re duplicating your undo config inside the mappings section of an existing undo config.
telescope.setup({
...
extensions: {
...
undo = {
-- defaults
use_delta = true,
...
mappings = {
...
n = {
undo = {
-- defaults
use_delta = true,
This is my telescope config which also loads another extension,, telescope-file-browser:
return {
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope-file-browser.nvim",
"debugloop/telescope-undo.nvim",
},
keys = {
{
"<leader>sB",
":Telescope file_browser path=%:p:h select_buffer=true<cr>",
desc = "Browse Files",
},
{
"<leader>su",
":Telescope undo<cr>",
desc = "Undo history",
},
},
config = function()
local ts = require("telescope")
local tsu = require("telescope-undo.actions")
ts.setup({
extensions = {
undo = {
use_delta = true,
side_by_side = true,
layout_strategy = "vertical",
layout_config = {
preview_height = 0.8,
},
mappings = {
i = {
["<cr>"] = tsu.yank_additions,
["<S-cr>"] = tsu.yank_deletions,
["<C-cr>"] = tsu.restore,
},
},
},
},
})
ts.load_extension("file_browser")
ts.load_extension("undo")
end,
}
from telescope-undo.nvim.
@TSoli I can’t tell if that is just a copy-and-paste error or if that is the actual content of your telescope config. If the latter, I'm not surprised it’s not working, you’re duplicating your undo config inside the mappings section of an existing undo config.
That was definitely a copy paste error hahahaha oops. Fixed my post now. Same issues as I said earlier.
from telescope-undo.nvim.
i can confirm that options are being ignored as well.
testing: setting the layout strategy has no effect:
extensions = { undo = { layout_strategy = "vertical" }}
this appears to be a breaking change from telescope, if i roll back to telescope.nvim@6074847b6ee4b725747c8fc540d9b6b128ac8a12
config options work again.
from telescope-undo.nvim.
i can confirm that options are being ignored as well.
testing: setting the layout strategy has no effect:
extensions = { undo = { layout_strategy = "vertical" }}
this appears to be a breaking change from telescope, if i roll back to telescope.nvim@6074847b6ee4b725747c8fc540d9b6b128ac8a12 config options work again.
Still not working for me if I try this. I added "commit = "6074847b6ee4b725747c8fc540d9b6b128ac8a12"
to the table and removed the old version and it still is not working. I am using neovim 0.9.1.
from telescope-undo.nvim.
I can't reproduce this, sorry. The options seem to work for most people, so I'll ask you to do some additional debugging. Can you check changing the layout as @xero is doing in his comment? This option is not read by telescope-undo but by telescope itself (although configured per-plugin), and if this one is ignored it's an indicator of some issue with telescope itself and/or your config around it.
If you get telescope per-plugin options working but telescope-undo is still ignoring its very own settings, then we'll have to think about next steps. I myself run telescope 3dec002
right now which has the configuration from the telescope-undo README working flawlessly. Let me once again state that I also think this extension config system in telescope is not very elegant...
As for further debugging: If you don't mind getting your hands dirty, you could clone the repo, point lazy to dir = "your/checkout/location",
and add some print statements here to further narrow it down (vim.print(vim.inspect(...))
), specifically to find out if:
extension_config
contains your custom settings (if not, telescope and/or your config is at fault)config
is correctly extended using your custom settingstelescope_config
also might warrant a glance to see whats going on/if it's got familiar contents.
Let me know when you can tell me more. Alternatively, I'd also be fine with a minimal nvim config including the specific nvim version your using, but its probably easier to check out these points rather than creating the minimal config and me replicating it.
from telescope-undo.nvim.
Can you check changing the layout as @xero is doing in his comment?
So it does change the layout to this. If I have my terminal smaller you cannot see the preview window.
Before I change the settings it has the default look (and retains it for other options like below). So it is setting telescope settings at least it seems.
I might have a go at cloning the repo like you said. I know this isn's a minimal config but to at least give an idea of the plugins I am using e.t.c here is my dotfiles. I have been updating them a fair bit recently and switched over to undotree since I couldn't get this working so when I am testing this it is not installed. Again this is just for a rough idea. Anyways thanks for the suggestions.
It seems the mappings e.t.c. work however I still can't get delta and I still get the weird bracket colors disappearing.
from telescope-undo.nvim.
btw I found my mistake:
Trying to make all plugins self-contained, I defined the telescope plugin multiple times.
Telescope doesns't allow extensions to be self-contained, all must be defined into a single Telescope plugin definition. Which is not super user friendly, but it is how it is.
from telescope-undo.nvim.
Related Issues (20)
- Bug: Instead of re-using scrolloff, let's have an specific option HOT 1
- Bug: Preview show "[Process exited 0]" when delta is used HOT 1
- Add support for telescope theme HOT 4
- Add an option to merge yank_addition and yank_deletion HOT 2
- Incompatibility with Zellij HOT 1
- Does not work with page and neovim remote HOT 2
- [Feature request]: Show which version is currently saved HOT 1
- Expected behavior of key mappings seems like they are not working. HOT 10
- Restore does not seem to be working HOT 1
- Diff Preview Against Current File HOT 8
- Error : after the second argument: expected table, got nil HOT 5
- u_undo: line numbers wrong HOT 1
- delta in wsl not working HOT 3
- [Bug / Question] Undo preview only showing difference HOT 2
- Toggle between diff preview and the actual state preview HOT 4
- Unable to disable default key mappings HOT 3
- Not showing all undolevels HOT 7
- Diff View output is wrong HOT 7
- Clear undo history HOT 1
- Global function timeago HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telescope-undo.nvim.