aboutsummaryrefslogtreecommitdiff
path: root/lua/simple-denote/api.lua
blob: 6a25f4ad4e4e10a05309cf784bb8f5c33fc070e8 (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
60
61
62
63
64
65
66
67
68
69
local M = {}

local internal = require("simple-denote.internal")

---@param options table
---@param title string|nil
---@param keywords table|nil
function M.note(options, title, keywords)
  if not title then
    vim.ui.input({ prompt = "Note title: " }, function(input)
      title = input
    end)
  end
  if not keywords then
    vim.ui.input({ prompt = "Keywords: " }, function(input)
      keywords = input
    end)
  end
  if not title or not keywords then return end
  internal.note(options, title, keywords)
end

---@param options table
---@param filename string|nil
---@param title string|nil
function M.title(options, filename, title)
  if not filename then
    filename = vim.fn.expand("%")
  end
  if not title then
    vim.ui.input({ prompt = "New title: " }, function(input)
      title = input
    end)
  end
  if not title then return end
  internal.title(options, filename, title)
end

---@param options table
---@param filename string|nil
---@param keywords table|nil
function M.keyword(options, filename, keywords)
  if not filename then
    filename = vim.fn.expand("%")
  end
  if not keywords then
    vim.ui.input({ prompt = "New keywords: " }, function(input)
      keywords = input
    end)
  end
  if not keywords then return end
  internal.keyword(options, filename, keywords)
end

---@param options table
---@param filename string|nil
---@param sig string
function M.signature(options, filename, sig)
  filename = filename or vim.fn.expand("%")
  if not sig then
    vim.ui.input({ prompt = "Signature: " }, function(input)
      sig = input
    end)
  end
  if not sig then return end
  internal.signature(options, filename, sig)
end

return M