Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
zztrieuzz committed Sep 8, 2023
1 parent d80a75c commit defad64
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
7 changes: 5 additions & 2 deletions lua/nvim-autopairs/rules/basic.lua
Expand Up @@ -5,7 +5,9 @@ local utils = require('nvim-autopairs.utils')
local function quote_creator(opt)
local quote = function(...)
local move_func = opt.enable_moveright and cond.move_right or cond.none
local rule = Rule(...):with_move(move_func()):with_pair(cond.not_add_quote_inside_quote())
local rule = Rule(...)
:with_move(move_func())
:with_pair(cond.not_add_quote_inside_quote())

if #opt.ignored_next_char > 1 then
rule:with_pair(cond.not_after_regex(opt.ignored_next_char))
Expand All @@ -21,7 +23,8 @@ local function bracket_creator(opt)
local bracket = function(...)
local rule = quote(...)
if opt.enable_check_bracket_line == true then
rule:with_pair(cond.is_bracket_line()):with_move(cond.is_bracket_line_move())
rule:with_pair(cond.is_bracket_line())
:with_move(cond.is_bracket_line_move())
end
if opt.enable_bracket_in_quote then
-- still add bracket if text is quote "|" and next_char have "
Expand Down
36 changes: 18 additions & 18 deletions lua/nvim-autopairs/utils.lua
@@ -1,4 +1,4 @@
local M={}
local M = {}
local api = vim.api
local log = require('nvim-autopairs._log')

Expand All @@ -21,20 +21,20 @@ M.set_vchar = function(text)
end


M.is_quote = function (char)
M.is_quote = function(char)
return char == "'" or char == '"' or char == '`'
end

M.is_bracket = function (char)
M.is_bracket = function(char)
return char == "(" or char == '[' or char == '{' or char == '<'
end


M.is_close_bracket = function (char)
M.is_close_bracket = function(char)
return char == ")" or char == ']' or char == '}' or char == '>'
end

M.compare = function (value, text, is_regex)
M.compare = function(value, text, is_regex)
if is_regex and string.match(text, value) then
return true
elseif text == value then
Expand Down Expand Up @@ -89,14 +89,14 @@ M.is_attached = function(bufnr)
end


M.set_attach = function(bufnr,value)
M.set_attach = function(bufnr, value)
api.nvim_buf_set_var(bufnr or 0, "nvim-autopairs", value)
end

M.is_in_table = function(tbl, val)
if tbl == nil then return false end
for _, value in pairs(tbl) do
if val== value then return true end
if val == value then return true end
end
return false
end
Expand All @@ -112,7 +112,7 @@ M.check_not_filetype = function(tbl, filetype)
end

M.is_in_range = function(row, col, range)
local start_row, start_col, end_row, end_col = unpack(range)
local start_row, start_col, end_row, end_col = unpack(range)

return (row > start_row or (start_row == row and col >= start_col))
and (row < end_row or (row == end_row and col <= end_col))
Expand All @@ -132,9 +132,9 @@ M.text_get_current_line = function(bufnr)
end

M.repeat_key = function(key, num)
local text=''
local text = ''
for _ = 1, num, 1 do
text=text..key
text = text .. key
end
return text
end
Expand All @@ -149,7 +149,7 @@ M.text_cusor_line = function(line, col, prev_count, next_count, is_regex)
prev_count = col
next_count = #line - col
end
local prev = M.text_sub_char(line, col, - prev_count)
local prev = M.text_sub_char(line, col, -prev_count)
local next = M.text_sub_char(line, col + 1, next_count)
return prev, next
end
Expand All @@ -159,14 +159,14 @@ M.text_sub_char = function(line, start, num)
if num < 0 then
start = start + num + 1
else
finish = start + num -1
finish = start + num - 1
end
return string.sub(line, start, finish)
end

-- P(M.text_sub_char("aa'' aaa", 3, -1))
M.insert_char = function(text)
api.nvim_put({text}, "c", false, true)
api.nvim_put({ text }, "c", false, true)
end

M.feed = function(text, num)
Expand All @@ -178,21 +178,21 @@ M.feed = function(text, num)
end
log.debug("result" .. result)
api.nvim_feedkeys(api.nvim_replace_termcodes(
result, true, false, true),
"n", true)
result, true, false, true),
"n", true)
end

M.esc = function(cmd)
return vim.api.nvim_replace_termcodes(cmd, true, false, true)
end

M.is_block_wise_mode = function ()
return vim.fn.visualmode() == ''
M.is_block_wise_mode = function()
return vim.fn.visualmode() == ''
end

--- get prev_char with out key_map
M.get_prev_char = function(opt)
return opt.line:sub(opt.col -1, opt.col + #opt.rule.start_pair -2)
return opt.line:sub(opt.col - 1, opt.col + #opt.rule.start_pair - 2)
end

return M

0 comments on commit defad64

Please sign in to comment.