Skip to content

Neat-looking code action menu #133

Answered by Andrew15-5
Andrew15-5 asked this question in Q&A
Discussion options

You must be logged in to vote

Niice. Thanks. I added it to the end of a custom.configs.crates module. So it only appears for Cargo.toml.

snippet
local M = {}

local namespace = vim.api.nvim_create_namespace "user.util.select"

local calculate_popup_width = function(entries)
  local result = 0

  for _, entry in ipairs(entries) do
    local width = vim.fn.strdisplaywidth(entry)
    if width > result then
      result = #entry
    end
  end

  result = result + 2

  local num_entries = #entries
  while num_entries >= 10 do
    num_entries = num_entries / 10
    result = result + 1
  end

  return result
end

local format_entries = function(entries, formatter)
  local format_item = formatter or tostring

  local results =

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Andrew15-5
Comment options

@Andrew15-5
Comment options

Answer selected by Andrew15-5
@saecki
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants