danielfalk / smart-open.nvim

Neovim plugin for fast file-finding
MIT License
498 stars 25 forks source link

Can't alter mapping to open file from select_default to tab_drop or select_tab. #44

Closed ariel-frischer closed 5 months ago

ariel-frischer commented 1 year ago

I'd like the file to be opened with a tab drop because thats how I organize my files. This doesn't seem to support that event when trying to override default mappings in telescope config. Also show_scores is not working for me when set to true.

danielfalk commented 1 year ago

I'm not familiar with tab drop. Could you explain it or provide a link?

I'll look at show_scores, but I've been tempted to remove it for some time now. There's no good way of providing enough relevant scoring info for each entry anymore. There's not enough space. It's cryptic and apparently easy to break

megalithic commented 11 months ago

similarly, I'd love to be able to set the mappings for file opening to use vnew, etc, for <cr>; but the normal way of settings mappings for this extension doesn't seem to be working.

lougreenwood commented 7 months ago

Likewise I'd also like to use select_tab_drop.

@danielfalk :tab drop will open a file in either a new tab, or will use the existing window in a tab if the file is already open in that window.

That means that for those of us who use tabs to organise our buffers then we can ensure that the buffer is only open in a specific tab.

When I use the following config for telescope:

        defaults = {
          mappings = {
            i = {
              ["<CR>"] = "select_tab_drop",
              ["<C-b>"] = "select_default",
              ["<C-_>"] = "select_horizontal",
              ["<C-Bslash>"] = "select_vertical",
          },
        },

I get this error:

Error executing Lua callback: .../nvim/lazy/telescope.nvim/lua/telescope/actions/init.lua:74: Key does not exist for 'telescope.actions': select_tab_drop
stack traceback:
    [C]: in function 'error'
    .../nvim/lazy/telescope.nvim/lua/telescope/actions/init.lua:74: in function '__index'
    ...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:233: in function 'telescope_map'
    ...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:308: in function 'apply_keymap'
    ...share/nvim/lazy/telescope.nvim/lua/telescope/pickers.lua:569: in function 'find'
    ...pen.nvim/lua/telescope/_extensions/smart_open/picker.lua:95: in function 'start'
    ...smart-open.nvim/lua/telescope/_extensions/smart_open.lua:23: in function <...smart-open.nvim/lua/telescope/_extensions/smart_open.lua:10>
    ...share/nvim/lazy/telescope.nvim/lua/telescope/command.lua:193: in function 'run_command'
    ...share/nvim/lazy/telescope.nvim/lua/telescope/command.lua:259: in function 'load_command'
    ...ocal/share/nvim/lazy/telescope.nvim/plugin/telescope.lua:108: in function <...ocal/share/nvim/lazy/telescope.nvim/plugin/telescope.lua:107>

Here's an example of where that feature usage is mentioned: https://github.com/nvim-telescope/telescope.nvim/issues/2188#issuecomment-1516861881

This is the implementing PR: https://github.com/nvim-telescope/telescope.nvim/pull/2143 And a PR supporting it as a jump_type: https://github.com/nvim-telescope/telescope.nvim/pull/2751

danielfalk commented 5 months ago

Thanks for this @lougreenwood That really helps.

I think I've just pushed up some changes in the 0.2.x branch that should allow the mappings to be configured, but I'm not sure about the error message you pasted because that doesn't look like an issue with being able to set up a key mapping, but in being able to resolve that action with telescope. I could only see getting that error if there was no select_tab_drop in your version of telescope.nvim but maybe I'm missing something.

danielfalk commented 5 months ago

Update: I saw the issue with select_tab_drop as well, until I updated telescope to the latest master branch. I was on 0.1.x which didn't seem to have the implementing PR that was mentioned.

ariel-frischer commented 5 months ago

Sorry, you can close this out if you want I've stopped organizing by tabs now that I have this plugin: https://github.com/romgrk/barbar.nvim