Git Product home page Git Product logo

Comments (14)

dtormoen avatar dtormoen commented on July 22, 2024 1

Switching to FZF will probably address this issue. This is the exact case I requested fzf support for

from smart-open.nvim.

danielfalk avatar danielfalk commented on July 22, 2024 1

No, my setup is to use this plugin for all file switching. I still use regular telescope for a few other things live grep, but they're different row types. The code to do this is in format_filepath.lua. If it's the highlighting you're after, I think that's doable through standard telescope customization, but there are a couple things like splitting the filename and shortening via ellipsis only when necessary that this plugin does in formatting that I'm pretty sure isn't pluggable on that level. But maybe the code can be adapted to your use case so have at it :-)

from smart-open.nvim.

danielfalk avatar danielfalk commented on July 22, 2024

It uses fzy (or optionally fzf) to do the matching. It's outside of the scope of this plugin to implement our own algorithm here, but if there's something I'm doing wrong with respect to plugging in the prompt text, then that's something we could change.

On the other hand if fzy/fzf just work differently in this regard, then we could see if we could add the algorithm that telescope uses as an additional option?

I'd appreciate any input or contributions from others on this one.

from smart-open.nvim.

lougreenwood avatar lougreenwood commented on July 22, 2024

@dtormoen Is the FZF support merged, I don't see anything in the README for how to configure it in the way you imply. All I see is that smart open can use FZF optionally?

As a side note, I'm using the Astronvim distro and that ships with fzf-native, so I would assume smart open would already be using FZF if it's an optional, automatic opt in?

https://astronvim.github.io/acknowledgements#-plugins-used-in-astronvim

Thanks to both of you for the help & advice here! 😄

from smart-open.nvim.

danielfalk avatar danielfalk commented on July 22, 2024

Yeah you configure match_algorithm = 'fzf'. If you don't specify anything, it's treated as match_algorithm = 'fzy'

It's in the docs here: https://github.com/danielfalk/smart-open.nvim#configuration

from smart-open.nvim.

lougreenwood avatar lougreenwood commented on July 22, 2024

Cool, thanks @danielfalk, I must have missed that - all working as expected now, spaces are handled as I expect 👍.


Side question, is it possible to configure using the following format rather than directly in the main telescope setup - I'm not sure it's working?

require("smart_open").setup {
  match_algorithm = "fzf",
}

require("telescope").load_extension "smart_open"

I recently saw this issue for another telescope extension which was also missing the above style of config.

from smart-open.nvim.

danielfalk avatar danielfalk commented on July 22, 2024

I'm not sure if there's an example of a plugin that woks that way. The one cited in the issue doesn't work that way as far as I can tell. Instead, telescope extensions are directed to provide a setup function that telescope is responsible for calling. I provide that here.

I just pushed a change however that should allow you to put it as part of your key mapping if you want to override what's configured in setup.

Example:

vim.api.nvim_set_keymap("n", "<leader><leader>", "", {
   callback = function ()
      require('telescope').extensions.smart_open.smart_open({ match_algorithm = "fzy" })
   end, 
   noremap = true,
   silent = true
})

from smart-open.nvim.

lougreenwood avatar lougreenwood commented on July 22, 2024

@danielfalk Thanks for your reply - I can't find any other addons which use this setup method, but I have a strong feeling that I've seen and used other plugins which allow this before.

However, telescope-alternate certainly does allow that particular method - I'm using it in my config right now, for reference, here's both my telescope & telescope alternate configs.

(The nice thing about this setup method is it decouples telescope config from any addon setup & makes splitting up and managing config for telescope much cleaner).

actions = require "telescope.actions"
return {
  defaults = {
    mappings = {
      i = {
        ["<CR>"] = actions.select_tab,
        ["<C-b>"] = actions.select_default,
        ["<C-_>"] = actions.select_horizontal,
        ["<C-Bslash>"] = actions.select_vertical,
      },
    },
  },
  extensions = {
    smart_open = {
      match_algorithm = "fzf",
    },
  },
}
require("telescope-alternate").setup {
  layout_strategy = "vertical",
  layout_config = {
    vetical = {},
  },
  mappings = {
    -- .... loads of stuff here
  },
}

require("telescope").load_extension "telescope-alternate"

I just pushed a change however that should allow you to put it as part of your key mapping if you want to override what's configured in setup.

Thanks!

from smart-open.nvim.

danielfalk avatar danielfalk commented on July 22, 2024

OK yeah that helps. I see what they're doing and should be able to make this change

from smart-open.nvim.

danielfalk avatar danielfalk commented on July 22, 2024

I've got a new branch for this if you want to try it. It seems to work for me, but if you want to give it a shot and let me know, the branch is called alternate-setup

from smart-open.nvim.

lougreenwood avatar lougreenwood commented on July 22, 2024

Thanks @danielfalk, I've switched to that branch and it seems to work well!

The only weirdness is the inconsistency with the setup & telescope names (kebab vs snake casing of smart-open), but not sure if that's a real problem or not...

return {
    "danielfalk/smart-open.nvim",
    dependencies = { "kkharji/sqlite.lua" },
    event = "BufRead",
    branch = "alternate-setup",
    config = function()
        require("smart-open").setup {
            match_algorithm = "fzf",
        }
        require("telescope").load_extension "smart_open"
    end,
}

See require("smart-open") vs require("telescope").load_extension "smart_open"

from smart-open.nvim.

lougreenwood avatar lougreenwood commented on July 22, 2024

I'm also interested in trying out the other fixes in the 0.2 branch. Do you have plans to merge this alternate-setup to master and back port to 0.2?

from smart-open.nvim.

danielfalk avatar danielfalk commented on July 22, 2024

OK, it's backported now.

from smart-open.nvim.

lougreenwood avatar lougreenwood commented on July 22, 2024

Thanks @danielfalk - love the new results in 0.2.x - the file_name path colouring is so much better.

I don't suppose you have a snippet to use this same highlighting by default in telescope file pickers? (figured you might have configured your setup to use this everywhere?)

from smart-open.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.