-
-
Notifications
You must be signed in to change notification settings - Fork 856
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: set defaults for each picker in telescope setup #883
feat: set defaults for each picker in telescope setup #883
Conversation
THANKS SO MUCH CONNI. I'm really disappointed 😢 that I haven't gotten around and implemented this. but awesome work, I wouldn't have done it better for mapping I suggest we simplify it a bit
I already implemented this in some other projects, so I can share a code snippet here This better because it save a lot of space. what do u think |
I would not do that for a number of reasons
|
Wow, looking forward to configuring in this way! Maybe we could provide a field to define the keymap for opening the picker? The user can also provide the default keymap options to pass. This would simplify defining the dozen key bindings for all the pickers ;) require("telescope").setup {
pickers = {
buffers = {
open_with = "<C-b>",
...
}
}
}
} Or, instead of mapping each picker individually, a table specifically for mapping all the pickers, similar to that of gitsigns: require("telescope").setup {
picker_keymaps = {
noremap = true,
silent = true,
buffers = "<C-b>",
-- or ["<C-b>"] = "buffers",
-- or ["<C-b>"] = require('telescope.builtin').buffers,
-- or ["<C-b>"] = "<cmd>lua require('telescope.builtin').buffers()<cr>",
}
}
} |
95e2b6f
to
01be067
Compare
Oh, this gave me an idea. What if we also added the ability for mappings right hand side to just be the key from actions as a shorthand, for very simple setup for people not used to Lua. So instead of Thoughts? |
f27b453
to
dfa967d
Compare
lua/telescope/mappings.lua
Outdated
@@ -191,7 +191,11 @@ mappings.apply_keymap = function(prompt_bufnr, attach_mappings, buffer_keymap) | |||
local key_bind_internal = a.nvim_replace_termcodes(key_bind, true, true, true) | |||
if not applied_mappings[mode][key_bind_internal] then | |||
applied_mappings[mode][key_bind_internal] = true | |||
telescope_map(prompt_bufnr, mode, key_bind, key_func) | |||
if type(key_func) == "string" then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should just actually do this check above at the top of the function, inside of the map function we create on line 104 -- that way any time someone uses a string, it defaults to searching actions
.
216dc89
to
169342c
Compare
67da7b6
to
2e69c39
Compare
I have a question: I know that concatenating actions works because of mappings = {
i = {
-- This works
["<c-q>"] = actions.send_to_qflist + actions.open_qflist,
-- But this won't work
-- E5108: Error executing lua [string ":lua"]:1: attempt to perform arithmetic on a string value
["<c-q>"] = "send_to_qflist" + "open_qflist",
}
} Maybe for multiple actions, we can ask for a table of strings like so: |
Okay the current interface that is implemented is: mappings = {
i = {
-- current
["<c-d>"] = actions.smart_send_to_qflist + ....,
-- same as
["<c-d>"] = { actions.smart_send_to_qflist + ...., type = "action" },
-- future opts = { nowait = true } in table for all tables. See #890
-- To make user configuration more simple for people not familiar with lua
["<c-d>"] = "smart_send_to_qflist",
-- is basicall this:
["<c-d>"] = { "smart_send_to_qflist", type = "action_key" },
-- for viml
["<c-d>"] = { '<cmd>:echo "Hello"<CR>', type = "command" },
}
} Plus for actions should still work. But i am not sure if we should do |
I think we could do something like this, but it's out of scope for this PR. In fact, what I'd prefer to do is probably wait til I get a little farther on something like https://github.com/tjdevries/vimterface.nvim and consider hooking up to that plugin rather than re-creating it all here. |
2267fc1
to
13d5efe
Compare
skip-checks: true
@Conni2461, thank you very much, I really missed this feature. Can we add the ability to specify a default After this PR we can do the following: require("telescope").setup {
pickers = {
buffers = {
theme = "dropdown",
}
}
} But it would be nice to be able to also specify a theme for each buffer: require("telescope").setup {
defaults = {
theme = "dropdown",
}
} |
Close #582
Its so long that i wrote telescope code. LUL
I don't like the idea of custom pickers, the one that @tami5 proposed. I think for that people should just continue to go with own wrapper functions. But this helps clean up other things. Like this e.g.
I am not sure if this is the best way to implement this feature