Skip to content

Commit 0bf9775

Browse files
committed
Support for Lua 5.2 (updated to latest version of LuaInspect)
Requested in issue #2 on GitHub: #2
1 parent 77f9da1 commit 0bf9775

37 files changed

+3277
-1938
lines changed

addon-info.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"vim_script_nr": 3169, "dependencies": {"vim-misc": {}}, "homepage": "http://peterodding.com/code/vim/lua-inspect", "name": "vim-lua-inspect"}

autoload/xolox/luainspect.vim

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
" Vim script.
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: May 27, 2013
3+
" Last Change: July 18, 2013
44
" URL: http://peterodding.com/code/vim/lua-inspect/
55

6-
let g:xolox#luainspect#version = '0.4.27'
6+
let g:xolox#luainspect#version = '0.5'
77

88
function! xolox#luainspect#toggle_cmd() " {{{1
99
if !(exists('b:luainspect_disabled') && b:luainspect_disabled)
@@ -126,8 +126,16 @@ endfunction
126126
function! s:prepare_search_path() " {{{1
127127
let code = ''
128128
if !(has('lua') && g:lua_inspect_internal && exists('s:changed_path'))
129-
let template = 'package.path = ''%s/?.lua;'' .. package.path'
130-
let code = printf(template, escape(expand(g:lua_inspect_path), '"\'''))
129+
let root = xolox#misc#path#absolute(g:lua_inspect_path)
130+
let directories = [root]
131+
call add(directories, xolox#misc#path#merge(root, 'metalualib'))
132+
call add(directories, xolox#misc#path#merge(root, 'luainspect'))
133+
let template = "package.path = package.path .. ';%s/?.lua'"
134+
let lines = []
135+
for directory in directories
136+
call add(lines, printf(template, escape(directory, '"\''')))
137+
endfor
138+
let code = join(lines, '; ')
131139
if has('lua') && g:lua_inspect_internal
132140
execute 'lua' code
133141
let s:changed_path = 1

doc/luainspect.txt

Lines changed: 82 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
*luainspect.txt* Semantic highlighting for Lua in Vim
22

33
===============================================================================
4-
*luainspect-contents*
54
Contents ~
65

7-
1. Introduction |luainspect-introduction|
8-
2. Installation |luainspect-installation|
9-
3. Usage |luainspect-usage|
6+
1. Introduction |luainspect-introduction|
7+
2. Installation |luainspect-installation|
8+
3. Usage |luainspect-usage|
109
1. The |:LuaInspect| command
1110
2. The |:LuaInspectToggle| command
1211
3. The |g:loaded_luainspect| option
1312
4. The |g:lua_inspect_warnings| option
1413
5. The |g:lua_inspect_events| option
1514
6. The |g:lua_inspect_internal| option
16-
4. Contact |luainspect-contact|
17-
5. License |luainspect-license|
15+
4. Contact |luainspect-contact|
16+
5. License |luainspect-license|
17+
6. References |luainspect-references|
1818

1919
===============================================================================
20-
*luainspect-introduction*
20+
*luainspect-introduction*
2121
Introduction ~
2222

2323
The Vim plug-in 'luainspect.vim' uses the LuaInspect [1] tool to
@@ -26,38 +26,39 @@ It was inspired by lua2-mode [2] (for Emacs [3]) and the SciTE [4] plug-in
2626
included with LuaInspect. In addition to the semantic highlighting the
2727
following features are currently supported:
2828

29-
- Press '<F2>' with the text cursor on a variable and the plug-in will prompt
30-
you to rename the variable.
29+
- Press '<F2>' with the text cursor on a variable and the plug-in will prompt
30+
you to rename the variable.
3131

32-
- Press 'gd' (in normal mode) with the text cursor on a variable and you'll
33-
jump to its declaration / first occurrence.
32+
- Press 'gd' (in normal mode) with the text cursor on a variable and you'll
33+
jump to its declaration / first occurrence.
3434

35-
- When you hover over a variable with the mouse cursor in graphical Vim,
36-
information about the variable is displayed in a tooltip.
35+
- When you hover over a variable with the mouse cursor in graphical Vim,
36+
information about the variable is displayed in a tooltip.
3737

38-
- If the text cursor is on a variable while the highlighting is refreshed then
39-
all occurrences of the variable will be marked in the style of Vim's
40-
cursorline option (see |'cursorline'|).
38+
- If the text cursor is on a variable while the highlighting is refreshed
39+
then all occurrences of the variable will be marked in the style of Vim's
40+
cursorline option (see |'cursorline'|).
4141

42-
- When luainspect reports a wrong argument count for a function call the text
43-
will be highlighted with a green underline. When you hover over the
44-
highlighted text a tooltip shows the associated warning message.
42+
- When luainspect reports a wrong argument count for a function call the text
43+
will be highlighted with a green underline. When you hover over the
44+
highlighted text a tooltip shows the associated warning message.
4545

46-
- When LuaInspect reports warnings about unused variables, wrong argument
47-
counts, etc. they are shown in a location list window (see |location-list|).
46+
- When LuaInspect reports warnings about unused variables, wrong argument
47+
counts, etc. they are shown in a location list window (see |location-
48+
list|).
4849

49-
- When a syntax error is found (during highlighting or using the rename
50-
functionality) the lines where the error is reported will be marked like a
51-
spelling error.
50+
- When a syntax error is found (during highlighting or using the rename
51+
functionality) the lines where the error is reported will be marked like a
52+
spelling error.
5253

53-
Screenshot of semantic highlighting, see reference [5]
54+
Image: Screenshot of semantic highlighting (see reference [5])
5455

5556
===============================================================================
56-
*luainspect-installation*
57+
*luainspect-installation*
5758
Installation ~
5859

59-
Please note that the vim-lua-inspect plug-in requires my vim-misc plug-in
60-
which is separately distributed.
60+
_Please note that the vim-lua-inspect plug-in requires my vim-misc plug-in
61+
which is separately distributed._
6162

6263
Unzip the most recent ZIP archives of the vim-lua-inspect [6] and vim-misc [7]
6364
plug-ins inside your Vim profile directory (usually this is '~/.vim' on UNIX
@@ -71,13 +72,13 @@ local clone of the git repository.
7172
Now try it out: Edit a Lua file and within a few seconds semantic highlighting
7273
should be enabled automatically!
7374

74-
Note that on Windows a command prompt window pops up whenever LuaInspect is
75-
run as an external process. If this bothers you then you can install my
76-
shell.vim [12] plug-in which includes a DLL [13] that works around this issue.
77-
Once you've installed both plug-ins it should work out of the box!
75+
Note that on Windows a command prompt window pops up whenever LuaInspect is run
76+
as an external process. If this bothers you then you can install my shell.vim
77+
[12] plug-in which includes a DLL [13] that works around this issue. Once
78+
you've installed both plug-ins it should work out of the box!
7879

7980
===============================================================================
80-
*luainspect-usage*
81+
*luainspect-usage*
8182
Usage ~
8283

8384
When you open any Lua file the semantic highlighting should be enabled
@@ -92,29 +93,18 @@ highlighting using |g:lua_inspect_events|. When you execute this command the
9293
plug-in runs the LuaInspect tool and then highlights all variables in the
9394
current buffer using one of the following highlighting groups:
9495

95-
- luaInspectGlobalDefined
96-
97-
- luaInspectGlobalUndefined
98-
99-
- luaInspectLocalUnused
100-
101-
- luaInspectLocalMutated
102-
103-
- luaInspectUpValue
104-
105-
- luaInspectParam
106-
107-
- luaInspectLocal
108-
109-
- luaInspectFieldDefined
110-
111-
- luaInspectFieldUndefined
112-
113-
- luaInspectSelectedVariable
114-
115-
- luaInspectWrongArgCount
116-
117-
- luaInspectSyntaxError
96+
- luaInspectGlobalDefined
97+
- luaInspectGlobalUndefined
98+
- luaInspectLocalUnused
99+
- luaInspectLocalMutated
100+
- luaInspectUpValue
101+
- luaInspectParam
102+
- luaInspectLocal
103+
- luaInspectFieldDefined
104+
- luaInspectFieldUndefined
105+
- luaInspectSelectedVariable
106+
- luaInspectWrongArgCount
107+
- luaInspectSyntaxError
118108

119109
If you don't like one or more of the default styles the Vim documentation
120110
describes how to change them (see |:hi-default|). If you want to disable the
@@ -127,52 +117,52 @@ The *:LuaInspectToggle* command
127117

128118
By default the semantic highlighting and the warning messages in the location
129119
list window are automatically applied to Lua buffers and updated every once in
130-
a while, but this can be disabled by setting |g:lua_inspect_events| to an
131-
empty string in your |vimrc| script. If the plug-in is not automatically enabled
132-
then it may be useful to enable/disable it using a key mapping. That's what
133-
the |:LuaInspectToggle| command is for. You still have to define your key
134-
mapping of choice in your |vimrc| script though. For example:
120+
a while, but this can be disabled by setting |g:lua_inspect_events| to an empty
121+
string in your |vimrc| script. If the plug-in is not automatically enabled then
122+
it may be useful to enable/disable it using a key mapping. That's what the
123+
|:LuaInspectToggle| command is for. You still have to define your key mapping
124+
of choice in your |vimrc| script though. For example:
135125
>
136-
" Don't enable the lua-inspect plug-in automatically in Lua buffers.
137-
let g:lua_inspect_events = ''
138-
139-
" Enable/disable the lua-inspect plug-in manually using <F6>.
140-
imap <F6> <C-o>:LuaInspectToggle<CR>
141-
nmap <F6> :LuaInspectToggle<CR>
142-
126+
" Don't enable the lua-inspect plug-in automatically in Lua buffers.
127+
let g:lua_inspect_events = ''
128+
129+
" Enable/disable the lua-inspect plug-in manually using <F6>.
130+
imap <F6> <C-o>:LuaInspectToggle<CR>
131+
nmap <F6> :LuaInspectToggle<CR>
132+
<
143133
-------------------------------------------------------------------------------
144134
The *g:loaded_luainspect* option
145135

146136
This variable isn't really an option but if you want to avoid loading the
147137
'luainspect.vim' plug-in you can set this variable to any value in your |vimrc|
148138
script:
149139
>
150-
:let g:loaded_luainspect = 1
151-
140+
:let g:loaded_luainspect = 1
141+
<
152142
-------------------------------------------------------------------------------
153143
The *g:lua_inspect_warnings* option
154144

155-
When LuaInspect reports warnings about unused variables, wrong argument
156-
counts, etc. they are automatically shown in a location list window (see
157-
|location-list|). If you don't like this add the following to your |vimrc| script:
145+
When LuaInspect reports warnings about unused variables, wrong argument counts,
146+
etc. they are automatically shown in a location list window (see |location-
147+
list|). If you don't like this add the following to your |vimrc| script:
158148
>
159-
:let g:lua_inspect_warnings = 0
160-
149+
:let g:lua_inspect_warnings = 0
150+
<
161151
-------------------------------------------------------------------------------
162152
The *g:lua_inspect_events* option
163153

164-
By default semantic highlighting is automatically enabled after a short
165-
timeout and when you save a buffer. If you want to disable automatic
166-
highlighting altogether add the following to your |vimrc| script:
154+
By default semantic highlighting is automatically enabled after a short timeout
155+
and when you save a buffer. If you want to disable automatic highlighting
156+
altogether add the following to your |vimrc| script:
167157
>
168-
:let g:lua_inspect_events = ''
169-
158+
:let g:lua_inspect_events = ''
159+
<
170160
You can also add events, for example if you also want to run |:LuaInspect| the
171161
moment you edit a Lua file then try this:
172162
>
173-
:let g:lua_inspect_events = 'CursorHold,CursorHoldI,BufReadPost,BufWritePost'
174-
175-
Note that this only works when the plug-in is loaded (or reloaded) after
163+
:let g:lua_inspect_events = 'CursorHold,CursorHoldI,BufReadPost,BufWritePost'
164+
<
165+
Note that this only works when the plug-in is loaded (or reloaded) _after_
176166
setting the |g:lua_inspect_events| option.
177167

178168
-------------------------------------------------------------------------------
@@ -183,26 +173,26 @@ have to run LuaInspect as an external program (which can slow things down). If
183173
you insist on running LuaInspect as an external program you can set this
184174
variable to false (0) in your |vimrc| script:
185175
>
186-
:let g:lua_inspect_internal = 0
187-
176+
:let g:lua_inspect_internal = 0
177+
<
188178
===============================================================================
189-
*luainspect-contact*
179+
*luainspect-contact*
190180
Contact ~
191181

192182
If you have questions, bug reports, suggestions, etc. the author can be
193183
contacted at peter@peterodding.com. The latest version is available at
194-
http://peterodding.com/code/vim/lua-inspect/ and http://github.com/xolox/vim-lua-inspect.
195-
If you like this plug-in please vote for it on Vim Online [14].
184+
http://peterodding.com/code/vim/lua-inspect/ and http://github.com/xolox/vim-
185+
lua-inspect. If you like this plug-in please vote for it on Vim Online [14].
196186

197187
===============================================================================
198-
*luainspect-license*
188+
*luainspect-license*
199189
License ~
200190

201-
This software is licensed under the MIT license [15]. Copyright 2013 Peter
202-
Odding <peter@peterodding.com>.
191+
This software is licensed under the MIT license [15]. © 2013 Peter Odding
192+
<peter@peterodding.com>.
203193

204194
===============================================================================
205-
*luainspect-references*
195+
*luainspect-references*
206196
References ~
207197

208198
[1] http://lua-users.org/wiki/LuaInspect

0 commit comments

Comments
 (0)