diff options
author | Josh Rahm <rahm@google.com> | 2022-09-12 10:57:59 -0600 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2022-09-12 10:57:59 -0600 |
commit | 040b05d7d01defe16e4b31a6fd9c863fd2443091 (patch) | |
tree | 5e4a295fe310c73dfc2fe196708c49b4c0b41396 /runtime/lua/vim/inspect.lua | |
parent | 52ce04a002a882da19bb2c78d1fd8eb4825d669d (diff) | |
parent | fd70e2bff2440181f63fe124738cf2a025d1e6a5 (diff) | |
download | rneovim-040b05d7d01defe16e4b31a6fd9c863fd2443091.tar.gz rneovim-040b05d7d01defe16e4b31a6fd9c863fd2443091.tar.bz2 rneovim-040b05d7d01defe16e4b31a6fd9c863fd2443091.zip |
Merge remote-tracking branch 'upstream/master' into floattitle
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 |