summaryrefslogtreecommitdiff
path: root/dot_config/nvim/ftplugin/markdown_quote.lua
blob: 4bcfc335fcddefb75155c889c5523086a88e3d35 (plain) (blame)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
-- [nfnl] Compiled from ftplugin/markdown_quote.fnl by https://github.com/Olical/nfnl, do not edit.
local buf = 0
local function location(opts)
  local sl
  local _2_
  do
    local t_1_ = opts
    if (nil ~= t_1_) then
      t_1_ = t_1_.line1
    else
    end
    _2_ = t_1_
  end
  sl = (_2_ or vim.fn.line("v"))
  local el
  local _5_
  do
    local t_4_ = opts
    if (nil ~= t_4_) then
      t_4_ = t_4_.line2
    else
    end
    _5_ = t_4_
  end
  el = (_5_ or vim.fn.line("."))
  local swap = (sl > el)
  local dec
  local function _7_(_241)
    return (_241 - 1)
  end
  dec = _7_
  if swap then
    return {line1 = dec(el), line2 = sl}
  else
    return {line1 = dec(sl), line2 = el}
  end
end
local function maplines(f)
  local function _9_(opts)
    local opts0 = location(opts)
    local argp
    local function _10_(_241)
      local _11_ = opts0.line1
      local _12_ = opts0.line2
      local function _13_(...)
        return _241(buf, _11_, _12_, true, ...)
      end
      return _13_
    end
    argp = _10_
    local setl = argp(vim.api.nvim_buf_set_lines)
    local getl = argp(vim.api.nvim_buf_get_lines)
    local function _14_()
      local tbl_21_auto = {}
      local i_22_auto = 0
      for _, v in ipairs(getl()) do
        local val_23_auto = f(v)
        if (nil ~= val_23_auto) then
          i_22_auto = (i_22_auto + 1)
          tbl_21_auto[i_22_auto] = val_23_auto
        else
        end
      end
      return tbl_21_auto
    end
    return setl(_14_())
  end
  return _9_
end
local _2bqf
local function _16_(_241)
  if (_241 == "") then
    return _241
  else
    local and_17_ = (nil ~= _241)
    if and_17_ then
      local s = _241
      and_17_ = s:match("^[%s>]")
    end
    if and_17_ then
      local s = _241
      return (">" .. s)
    elseif (nil ~= _241) then
      local s = _241
      return ("> " .. s)
    else
      return nil
    end
  end
end
_2bqf = _16_
local _qf
local function _20_(_241)
  local and_21_ = (nil ~= _241)
  if and_21_ then
    local s = _241
    and_21_ = s:match("^> ")
  end
  if and_21_ then
    local s = _241
    return s:sub(3)
  else
    local and_23_ = (nil ~= _241)
    if and_23_ then
      local s = _241
      and_23_ = s:match("^>")
    end
    if and_23_ then
      local s = _241
      return s:sub(2)
    else
      local _ = _241
      return _241
    end
  end
end
_qf = _20_
local _2bquote = maplines(_2bqf)
local _quote = maplines(_qf)
vim.api.nvim_buf_create_user_command(buf, "MdQuote", _2bquote, {range = true})
vim.api.nvim_buf_create_user_command(buf, "MdDeQuote", _quote, {range = true})
vim.keymap.set({"n", "x"}, ">", _2bquote, {buffer = true, desc = "increase quote level of selection"})
return vim.keymap.set({"n", "x"}, "<", _quote, {buffer = true, desc = "decrease quote level of selection"})