diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Doxyfile | 6 | ||||
-rw-r--r-- | src/nvim/lua/vim.lua | 83 |
2 files changed, 14 insertions, 75 deletions
diff --git a/src/Doxyfile b/src/Doxyfile index de31c8355f..461fafe99d 100644 --- a/src/Doxyfile +++ b/src/Doxyfile @@ -243,7 +243,7 @@ OPTIMIZE_OUTPUT_VHDL = NO # that for custom extensions you also need to set FILE_PATTERNS otherwise the # files are not read by doxygen. -EXTENSION_MAPPING = +EXTENSION_MAPPING = lua=C # If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all # comments according to the Markdown format, which allows for more readable @@ -672,7 +672,7 @@ INPUT_ENCODING = UTF-8 # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.for *.vhd *.vhdl -FILE_PATTERNS = *.h *.c +FILE_PATTERNS = *.h *.c *.lua # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. @@ -758,7 +758,7 @@ INPUT_FILTER = # info on how filters are used. If FILTER_PATTERNS is empty or if # non of the patterns match the file name, INPUT_FILTER is applied. -FILTER_PATTERNS = +FILTER_PATTERNS = *.lua=scripts/lua2dox_filter # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua index 1a7aec6cc6..38a8795680 100644 --- a/src/nvim/lua/vim.lua +++ b/src/nvim/lua/vim.lua @@ -1,10 +1,10 @@ -- Nvim-Lua stdlib: the `vim` module (:help lua-stdlib) -- -- Lua code lives in one of three places: --- 1. The runtime (`runtime/lua/vim/`). For "nice to have" features, e.g. --- the `inspect` and `lpeg` modules. --- 2. The `vim.shared` module: code shared between Nvim and its test-suite. --- 3. Compiled-into Nvim itself (`src/nvim/lua/`). +-- 1. runtime/lua/vim/ (the runtime): For "nice to have" features, e.g. the +-- `inspect` and `lpeg` modules. +-- 2. runtime/lua/vim/shared.lua: Code shared between Nvim and tests. +-- 3. src/nvim/lua/: Compiled-into Nvim itself. -- -- Guideline: "If in doubt, put it in the runtime". -- @@ -154,75 +154,17 @@ local function _update_package_paths() last_nvim_paths = cur_nvim_paths end -local function gsplit(s, sep, plain) - assert(type(s) == "string") - assert(type(sep) == "string") - assert(type(plain) == "boolean" or type(plain) == "nil") - - local start = 1 - local done = false - - local function pass(i, j, ...) - if i then - assert(j+1 > start, "Infinite loop detected") - local seg = s:sub(start, i - 1) - start = j + 1 - return seg, ... - else - done = true - return s:sub(start) - end - end - - return function() - if done then - return - end - if sep == '' then - if start == #s then - done = true - end - return pass(start+1, start) - end - return pass(s:find(sep, start, plain)) - end -end - -local function split(s,sep,plain) - local t={} for c in gsplit(s, sep, plain) do table.insert(t,c) end - return t -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") - local result = s:gsub("^%s+", ""):gsub("%s+$", "") + assert(type(s) == 'string', 'Only strings can be trimmed') + local result = s:gsub('^%s+', ''):gsub('%s+$', '') return result end -local deepcopy - -local function id(v) - return v -end - -local deepcopy_funcs = { - table = function(orig) - local copy = {} - for k, v in pairs(orig) do - copy[deepcopy(k)] = deepcopy(v) - end - return copy - end, - number = id, - string = id, - ['nil'] = id, - boolean = id, -} - -deepcopy = function(orig) - return deepcopy_funcs[type(orig)](orig) -end - local function __index(t, key) if key == 'inspect' then t.inspect = require('vim.inspect') @@ -240,9 +182,6 @@ local module = { _os_proc_info = _os_proc_info, _system = _system, trim = trim, - split = split, - gsplit = gsplit, - deepcopy = deepcopy, } setmetatable(module, { |