Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
118 lines
2.4 KiB
Lua
118 lines
2.4 KiB
Lua
local _
|
|
|
|
local alpha = {}
|
|
_ = string.gsub('abcdefghijklmnopqrstuvwxyz', '.', function(char)
|
|
alpha[string.byte(char)] = true
|
|
end)
|
|
|
|
local ALPHA = {}
|
|
_ = string.gsub('ABCDEFGHIJKLMNOPQRSTUVWXYZ', '.', function(char)
|
|
ALPHA[string.byte(char)] = true
|
|
end)
|
|
|
|
local digit = {}
|
|
_ = string.gsub('1234567890', '.', function(char)
|
|
digit[string.byte(char)] = true
|
|
end)
|
|
|
|
local white = {}
|
|
_ = string.gsub(' \t\n', '.', function(char)
|
|
white[string.byte(char)] = true
|
|
end)
|
|
|
|
local char = {}
|
|
|
|
---@param byte integer
|
|
---@return boolean
|
|
char.is_upper = function(byte)
|
|
return ALPHA[byte]
|
|
end
|
|
|
|
---@param byte integer
|
|
---@return boolean
|
|
char.is_alpha = function(byte)
|
|
return alpha[byte] or ALPHA[byte]
|
|
end
|
|
|
|
---@param byte integer
|
|
---@return boolean
|
|
char.is_digit = function(byte)
|
|
return digit[byte]
|
|
end
|
|
|
|
---@param byte integer
|
|
---@return boolean
|
|
char.is_white = function(byte)
|
|
return white[byte]
|
|
end
|
|
|
|
---@param byte integer
|
|
---@return boolean
|
|
char.is_symbol = function(byte)
|
|
return not (char.is_alnum(byte) or char.is_white(byte))
|
|
end
|
|
|
|
---@param byte integer
|
|
---@return boolean
|
|
char.is_printable = function(byte)
|
|
return string.match(string.char(byte), '^%c$') == nil
|
|
end
|
|
|
|
---@param byte integer
|
|
---@return boolean
|
|
char.is_alnum = function(byte)
|
|
return char.is_alpha(byte) or char.is_digit(byte)
|
|
end
|
|
|
|
---@param text string
|
|
---@param index integer
|
|
---@return boolean
|
|
char.is_semantic_index = function(text, index)
|
|
if index <= 1 then
|
|
return true
|
|
end
|
|
|
|
local prev = string.byte(text, index - 1)
|
|
local curr = string.byte(text, index)
|
|
|
|
if not char.is_upper(prev) and char.is_upper(curr) then
|
|
return true
|
|
end
|
|
if char.is_symbol(curr) or char.is_white(curr) then
|
|
return true
|
|
end
|
|
if not char.is_alpha(prev) and char.is_alpha(curr) then
|
|
return true
|
|
end
|
|
if not char.is_digit(prev) and char.is_digit(curr) then
|
|
return true
|
|
end
|
|
return false
|
|
end
|
|
|
|
---@param text string
|
|
---@param current_index integer
|
|
---@return integer
|
|
char.get_next_semantic_index = function(text, current_index)
|
|
for i = current_index + 1, #text do
|
|
if char.is_semantic_index(text, i) then
|
|
return i
|
|
end
|
|
end
|
|
return #text + 1
|
|
end
|
|
|
|
---Ignore case match
|
|
---@param byte1 integer
|
|
---@param byte2 integer
|
|
---@return boolean
|
|
char.match = function(byte1, byte2)
|
|
if not char.is_alpha(byte1) or not char.is_alpha(byte2) then
|
|
return byte1 == byte2
|
|
end
|
|
local diff = byte1 - byte2
|
|
return diff == 0 or diff == 32 or diff == -32
|
|
end
|
|
|
|
return char
|