diff options
| author | Josh Rahm <rahm@google.com> | 2022-09-12 10:57:30 -0600 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2022-09-12 10:57:30 -0600 |
| commit | fef78e339a10ac4bfcf973b8d14d6a759ec9d808 (patch) | |
| tree | 76c92e54f8d1e5333e0e071005e48c52150a1304 /runtime/lua/vim/inspect.lua | |
| parent | 24c75e4f7be4eb4052939e7d5db7721d88288604 (diff) | |
| parent | fd70e2bff2440181f63fe124738cf2a025d1e6a5 (diff) | |
| download | rneovim-fef78e339a10ac4bfcf973b8d14d6a759ec9d808.tar.gz rneovim-fef78e339a10ac4bfcf973b8d14d6a759ec9d808.tar.bz2 rneovim-fef78e339a10ac4bfcf973b8d14d6a759ec9d808.zip | |
Merge remote-tracking branch 'upstream/master' into userreg
Diffstat (limited to 'runtime/lua/vim/inspect.lua')
| -rw-r--r-- | runtime/lua/vim/inspect.lua | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/runtime/lua/vim/inspect.lua b/runtime/lua/vim/inspect.lua index 0a53fb203b..c232f69590 100644 --- a/runtime/lua/vim/inspect.lua +++ b/runtime/lua/vim/inspect.lua @@ -89,8 +89,38 @@ local function escape(str) ) end +-- List of lua keywords +local luaKeywords = { + ['and'] = true, + ['break'] = true, + ['do'] = true, + ['else'] = true, + ['elseif'] = true, + ['end'] = true, + ['false'] = true, + ['for'] = true, + ['function'] = true, + ['goto'] = true, + ['if'] = true, + ['in'] = true, + ['local'] = true, + ['nil'] = true, + ['not'] = true, + ['or'] = true, + ['repeat'] = true, + ['return'] = true, + ['then'] = true, + ['true'] = true, + ['until'] = true, + ['while'] = true, +} + local function isIdentifier(str) - return type(str) == 'string' and not not str:match('^[_%a][_%a%d]*$') + return type(str) == 'string' + -- identifier must start with a letter and underscore, and be followed by letters, numbers, and underscores + and not not str:match('^[_%a][_%a%d]*$') + -- lua keywords are not valid identifiers + and not luaKeywords[str] end local flr = math.floor |