perf: replace vim.endswith and vim.startswith with string.match
This commit is contained in:
parent
01b0b9d8ef
commit
4de30256c3
4 changed files with 8 additions and 4 deletions
|
|
@ -214,7 +214,8 @@ require("oil").setup({
|
||||||
show_hidden = false,
|
show_hidden = false,
|
||||||
-- This function defines what is considered a "hidden" file
|
-- This function defines what is considered a "hidden" file
|
||||||
is_hidden_file = function(name, bufnr)
|
is_hidden_file = function(name, bufnr)
|
||||||
return vim.startswith(name, ".")
|
local m = name:match("^%.")
|
||||||
|
return m ~= nil
|
||||||
end,
|
end,
|
||||||
-- This function defines what will never be shown, even when `show_hidden` is set
|
-- This function defines what will never be shown, even when `show_hidden` is set
|
||||||
is_always_hidden = function(name, bufnr)
|
is_always_hidden = function(name, bufnr)
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,8 @@ CONFIG *oil-confi
|
||||||
show_hidden = false,
|
show_hidden = false,
|
||||||
-- This function defines what is considered a "hidden" file
|
-- This function defines what is considered a "hidden" file
|
||||||
is_hidden_file = function(name, bufnr)
|
is_hidden_file = function(name, bufnr)
|
||||||
return vim.startswith(name, ".")
|
local m = name:match("^%.")
|
||||||
|
return m ~= nil
|
||||||
end,
|
end,
|
||||||
-- This function defines what will never be shown, even when `show_hidden` is set
|
-- This function defines what will never be shown, even when `show_hidden` is set
|
||||||
is_always_hidden = function(name, bufnr)
|
is_always_hidden = function(name, bufnr)
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,8 @@ local default_config = {
|
||||||
show_hidden = false,
|
show_hidden = false,
|
||||||
-- This function defines what is considered a "hidden" file
|
-- This function defines what is considered a "hidden" file
|
||||||
is_hidden_file = function(name, bufnr)
|
is_hidden_file = function(name, bufnr)
|
||||||
return vim.startswith(name, ".")
|
local m = name:match("^%.")
|
||||||
|
return m ~= nil
|
||||||
end,
|
end,
|
||||||
-- This function defines what will never be shown, even when `show_hidden` is set
|
-- This function defines what will never be shown, even when `show_hidden` is set
|
||||||
is_always_hidden = function(name, bufnr)
|
is_always_hidden = function(name, bufnr)
|
||||||
|
|
|
||||||
|
|
@ -347,7 +347,8 @@ M.addslash = function(path, os_slash)
|
||||||
slash = "\\"
|
slash = "\\"
|
||||||
end
|
end
|
||||||
|
|
||||||
if not vim.endswith(path, slash) then
|
local endslash = path:match(slash .. "$")
|
||||||
|
if not endslash then
|
||||||
return path .. slash
|
return path .. slash
|
||||||
else
|
else
|
||||||
return path
|
return path
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue