summaryrefslogtreecommitdiff
path: root/lua/telescope/deprecated.lua
blob: 0d98c1d34946837a6353b0dde0ce038a7235fab6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
local log = require "telescope.log"

local deprecated = {}

deprecated.picker_window_options = function(opts)
  local messages = {}

  -- Deprecated: PR:922, 2021/06/25
  -- Can be removed in a few weeks.

  if opts.width then
    table.insert(messages, "'opts.width' is no longer valid. Please use 'layout_config.width' instead")
  end

  if opts.height then
    table.insert(messages, "'opts.height' is no longer valid. Please use 'layout_config.height' instead")
  end

  if opts.results_height then
    table.insert(messages, "'opts.results_height' is no longer valid. Please see ':help telescope.changelog-922'")
  end

  if opts.results_width then
    table.insert(messages,
      "'opts.results_width' actually didn't do anything. Please see ':help telescope.changelog-922'"
    )
  end

  if opts.prompt_position then
    table.insert(messages,
      "'opts.prompt_position' is no longer valid. Please use 'layout_config.prompt_position' instead."
    )
  end

  if opts.preview_cutoff then
    table.insert(messages,
      "'opts.preview_cutoff' is no longer valid. Please use 'layout_config.preview_cutoff' instead."
    )
  end

  if #messages > 0 then
    table.insert(messages, 1, "Deprecated window options. Please see ':help telescope.changelog'")
    vim.api.nvim_err_write(table.concat(messages, "\n \n   ") .. "\n \nPress <Enter> to continue\n")
  end
end

deprecated.layout_configuration = function(user_defaults)
  if user_defaults.layout_defaults then
    if user_defaults.layout_config == nil then
      log.warn "Using 'layout_defaults' in setup() is deprecated. Use 'layout_config' instead."
      user_defaults.layout_config = user_defaults.layout_defaults
    else
      error "Using 'layout_defaults' in setup() is deprecated. Remove this key and use 'layout_config' instead."
    end
  end
  return user_defaults
end

return deprecated