Comments (10)
The additional defaults are in now, I also added some general clarifications on configuring, mapping, and so on. Hope it helps, thanks for your feedback 🥇
from telescope-undo.nvim.
Hi, yes indeed <c-cr>
and <s-cr>
are kinda known to cause problems in various terminal emulators, especially with a multiplexer in the mix. Tbh, I mostly use normal mode with the undo telescope... I think I'll adopt yours as an additional default for insert mode in a future version 👍🏻
from telescope-undo.nvim.
FWIW: I changed the default mappings to:
i = {
['<cr>'] = function(...) return require('telescope-undo.actions').yank_additions(...) end,
['<c-y>'] = function(...) return require('telescope-undo.actions').yank_deletions(...) end,
['<c-r>'] = function(...) return require('telescope-undo.actions').restore(...) end,
},
n = {
['y'] = function(...) return require('telescope-undo.actions').yank_additions(...) end,
['Y'] = function(...) return require('telescope-undo.actions').yank_deletions(...) end,
['r'] = function(...) return require('telescope-undo.actions').restore(...) end,
},
Now things are are working as expected. It seems the Ctrl+Enter and Shift+Enter keymaps aren't working for me.
from telescope-undo.nvim.
Attaching my Telescope config in lazy.nvim for convenience:
return {
{
'nvim-telescope/telescope.nvim',
dependencies = { { 'nvim-lua/plenary.nvim' }, { 'EdenEast/nightfox.nvim' } },
init = function()
local hl = vim.api.nvim_set_hl
local p = require('nightfox.palette').load('carbonfox')
hl(0, 'TelescopePreviewBorder', { fg = p.blue.dim })
hl(0, 'TelescopePreviewTitle', { fg = p.blue.base })
hl(0, 'TelescopePromptBorder', { fg = p.cyan.dim })
hl(0, 'TelescopePromptTitle', { fg = p.cyan.bright })
hl(0, 'TelescopeResultsBorder', { fg = p.orange.dim })
hl(0, 'TelescopeResultsTitle', { fg = p.orange.bright })
end,
keys = {
-- f
{
'<leader>ff',
function() require('telescope.builtin').find_files() end,
desc = 'Find files',
},
{
'<leader>fF',
function() require('telescope.builtin').find_files({ hidden = true, no_ignore = true }) end,
desc = 'Find files (hidden)',
},
{
'<leader>fb',
function() require('telescope.builtin').buffers({ ignore_current_buffer = true, sort_mru = true }) end,
desc = 'Find buffers',
},
-- s
{
'<leader>sb',
function() require('telescope.builtin').current_buffer_fuzzy_find() end,
desc = 'Search buffer',
},
{
'<leader>sg',
function() require('telescope.builtin').live_grep() end,
desc = 'Grep files',
},
{
'<leader>sG',
function() require('telescope.builtin').live_grep({ grep_open_files = true }) end,
desc = 'Grep files (Open files)',
},
{
'<leader>sh',
function() require('telescope.builtin').help_tags() end,
desc = 'Search help tags',
},
{
'<leader>sH',
function() require('telescope.builtin').highlights() end,
desc = 'Search highlights',
},
{
'<leader>sw',
function() require('telescope.builtin').grep_string({ word_match = '-w' }) end,
desc = 'Search word',
},
{
'<leader>sw',
function() require('telescope.builtin').grep_string({ word_match = '-w' }) end,
mode = 'v',
desc = 'Search selection',
},
{
'<leader>R',
function() require('telescope.builtin').resume() end,
desc = 'Resume',
},
},
opts = {
defaults = {
-- use square corners
borderchars = { '─', '│', '─', '│', '┌', '┐', '┘', '└' },
},
},
},
-- native fuzzy search for telescope
{
'nvim-telescope/telescope-fzf-native.nvim',
build = 'make',
dependencies = {
'nvim-telescope/telescope.nvim',
opts = { extensions = { fzf = {} } },
},
init = function() require('telescope').load_extension('fzf') end,
},
-- telescope undo extension
{
'debugloop/telescope-undo.nvim',
dependencies = {
'nvim-telescope/telescope.nvim',
opts = {
extensions = {
undo = {
use_delta = false,
layout_config = {
preview_width = 0.75,
},
mappings = {
i = {
['<cr>'] = function(...) return require('telescope-undo.actions').yank_additions(...) end,
['<c-y>'] = function(...) return require('telescope-undo.actions').yank_deletions(...) end,
['<c-r>'] = function(...) return require('telescope-undo.actions').restore(...) end,
},
n = {
['y'] = function(...) return require('telescope-undo.actions').yank_additions(...) end,
['Y'] = function(...) return require('telescope-undo.actions').yank_deletions(...) end,
['r'] = function(...) return require('telescope-undo.actions').restore(...) end,
},
},
},
},
},
},
init = function() require('telescope').load_extension('undo') end,
keys = {
{ '<leader>su', function() require('telescope').extensions.undo.undo() end, desc = 'Search undo history' },
},
},
}
from telescope-undo.nvim.
Hitting this issue as well - out of the default mappings only <cr>
is working. Somehow @freddiehaddad's workaround doesn't work for me.
My config is here (loading via NvChad): https://github.com/zarmory/NvChad/blob/v2.0/lua/custom/plugins.lua#L51
The plugin is still useful (thank you!), just not as useful as it could've been.
from telescope-undo.nvim.
@haizaar Can you post your config with the key map changes as well? I'm curious as to why my suggested modifications aren't working. It's either not being configured correctly or conflicting key maps.
If you notice in my example, I'm setting telescope as a dependency of the undo extension. This way I configured the key maps in telescope prior to loading the extension which I'm fairly sure is necessary.
from telescope-undo.nvim.
@freddiehaddad is right, the way Telescope works you'll always have to set telescope as a dependency. The other trick is to realize that you can call Telescope's setup as often as you'd like, it will merge configs (including additional keymaps) from consecutive calls. The second thing is, you wont be able to set keymaps in Lazy's opts
field, as the require
is likely not available yet due to lazy loading of some form (you could get that right, but...), so you best do that from config
.
Looking at your config, you're never calling load_extension
which telescope requires you to do.
I suggest doing this in addition to whatever you use as a standalone telescope plugin spec:
{
"debugloop/telescope-undo.nvim",
dependencies = {
{
"nvim-telescope/telescope.nvim",
dependencies = {
{ "nvim-lua/plenary.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)
opts.defaults.mappings = {
i = {
['<c-y>'] = require('telescope-undo.actions').yank_deletions,
['<c-r>'] = require('telescope-undo.actions').restore,
},
}
require("telescope").setup(opts)
require("telescope").load_extension("undo")
end,
}
I'll put the two keymaps in asap, I should have never assumed proper handling of keycodes in people's terminals 🙃
from telescope-undo.nvim.
Thanks for the quick response. Looks like the opts
table doesn't have defaults
member:
Failed to run `config` for telescope-undo.nvim
/home/.../.config/nvim/lua/custom/plugins.lua:96: attempt to index field 'defaults' (a nil value)
# stacktrace:
- lua/custom/plugins.lua:96 _in_ **config**
- /telescope.nvim/lua/telescope/_extensions/init.lua:8 _in_ **load_extension**
- /telescope.nvim/lua/telescope/_extensions/init.lua:62
- /telescope.nvim/lua/telescope/command.lua:197 _in_ **run_command**
- /telescope.nvim/lua/telescope/command.lua:259 _in_ **load_command**
- /telescope.nvim/plugin/telescope.lua:108
My config is here: zarmory/NvChad@fa9bb4a
from telescope-undo.nvim.
After removing the mapping definitions, it all works fine (since they are now defaults - thank you for adding those).
P.S. Telescope itself is initialized by NvChad here, in case it's related.
from telescope-undo.nvim.
Yup, makes sense, I've actually had a small error in above snippet (the assignment should not have been to default). If you keep to the readme it should work alright 👍
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
- 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.