VonHeikemen / fine-cmdline.nvim

Enter ex-commands in a nice floating input.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fish-style autosuggestion.

VonHeikemen opened this issue · comments

I hate fish autosuggestion with a burning passion, so I will not implement them inside the plugin. That said, I will not be the reason you can't have it.

I believe this is entirely possible in userland space. What would you need?

1 - Access to command history. I got you, fam.

-- Code taken directly from telescope
local cmd_history = function()
  local history_string = vim.fn.execute('history cmd')
  local history_list = vim.split(history_string, '\n')

  local results = {}
  for i = #history_list, 3, -1 do
    local item = history_list[i]
    local _, finish = string.find(item, '%d+ +')
    table.insert(results, string.sub(item, finish + 1))
  end

  return results
end

2 - Knowledge about virtual text. I don't have that. But maybe this nice post can help.

3 - Execute a function right after the input is created. You already have it.

require('fine-cmdline').setup({
  hooks = {
    after_mount = function(input)
       -- make it happen
    end
  }
})

4 - Did someone said syntax highlight? Yeah buddy, you can have that too. Just set up a new filetype.

require('fine-cmdline').setup({
  buf_options = {
    filetype = 'FineCmdlinePrompt'
  }
})

Then create a syntax file. This step is bit complicated... not creating the file, the syntax. I don't know anything about it. You can figure it out, I believe in you.

If a brave soul can put all this pieces together, please share your solution with the world (or share it here).

Hm... Some auto completion plugins already supports the feature.

Even better. Still, wouldn't hurt to have a generic config documented somewhere.