diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-05-21 01:06:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-21 01:06:31 +0200 |
commit | ca1ce590257c35426aeeaac349317d2cb163cd2e (patch) | |
tree | 04f75eccd24174f4723274a7505874d822363b9a /runtime | |
parent | b9ba1295b466a440600b36a717c701bfcea53dbc (diff) | |
parent | 5b04a4fa09e0ee09678aec23b1d0233e7c25e3e6 (diff) | |
download | rneovim-ca1ce590257c35426aeeaac349317d2cb163cd2e.tar.gz rneovim-ca1ce590257c35426aeeaac349317d2cb163cd2e.tar.bz2 rneovim-ca1ce590257c35426aeeaac349317d2cb163cd2e.zip |
Merge #9709 'fileio: use os_copy to create backups'
ref #8288
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/if_lua.txt | 31 | ||||
-rw-r--r-- | runtime/lua/vim/shared.lua | 11 |
2 files changed, 27 insertions, 15 deletions
diff --git a/runtime/doc/if_lua.txt b/runtime/doc/if_lua.txt index 7f90074ff0..e2d1f0f675 100644 --- a/runtime/doc/if_lua.txt +++ b/runtime/doc/if_lua.txt @@ -374,11 +374,6 @@ For example, to use the "nvim_get_current_line()" API function, call ------------------------------------------------------------------------------ VIM *lua-util* -vim.inspect({object}, {options}) *vim.inspect* - Return a human-readable representation of the passed object. See - https://github.com/kikito/inspect.lua - for details and possible options. - vim.stricmp(a, b) *lua-vim.stricmp* Function used for case-insensitive string comparison. Takes two string arguments and returns 0, 1 or -1 if strings are equal, a is @@ -422,18 +417,11 @@ vim.types *lua-vim.types* ============================================================================== Lua module: vim *lua-vim* -trim({s}) *vim.trim()* - Trim whitespace (Lua pattern "%%s") from both sides of a - string. - - Parameters: ~ - {s} String to trim - - Return: ~ - String with whitespace removed from its beginning and end +inspect({object}, {options}) *vim.inspect()* + Return a human-readable representation of the given object. See also: ~ - https://www.lua.org/pil/20.2.html + https://github.com/kikito/inspect.lua @@ -521,4 +509,17 @@ tbl_flatten({t}) *vim.tbl_flatten()* Return: ~ Flattened copy of the given list-like table. +trim({s}) *vim.trim()* + Trim whitespace (Lua pattern "%%s") from both sides of a + string. + + Parameters: ~ + {s} String to trim + + Return: ~ + String with whitespace removed from its beginning and end + + See also: ~ + https://www.lua.org/pil/20.2.html + vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 07145c6e3f..1038a95dd3 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -168,6 +168,16 @@ local function tbl_flatten(t) return result end +--- Trim whitespace (Lua pattern "%%s") from both sides of a string. +--- +--@see https://www.lua.org/pil/20.2.html +--@param s String to trim +--@returns String with whitespace removed from its beginning and end +local function trim(s) + assert(type(s) == 'string', 'Only strings can be trimmed') + return s:match('^%s*(.*%S)') or '' +end + local module = { deepcopy = deepcopy, gsplit = gsplit, @@ -175,5 +185,6 @@ local module = { tbl_contains = tbl_contains, tbl_extend = tbl_extend, tbl_flatten = tbl_flatten, + trim = trim, } return module |