Merge pull request #294 from eduardomezencio/lua-support
Add lua support through local-lua-debugger-vscode
This commit is contained in:
commit
888c558aa4
14 changed files with 319 additions and 7 deletions
2
.github/workflows/build.yaml
vendored
2
.github/workflows/build.yaml
vendored
|
|
@ -86,7 +86,7 @@ jobs:
|
||||||
- run: |
|
- run: |
|
||||||
brew update-reset
|
brew update-reset
|
||||||
brew doctor || true
|
brew doctor || true
|
||||||
for p in macvim tcl-tk llvm; do
|
for p in macvim tcl-tk llvm lua luajit love; do
|
||||||
brew install $p
|
brew install $p
|
||||||
brew outdated $p || brew upgrade $p
|
brew outdated $p || brew upgrade $p
|
||||||
done
|
done
|
||||||
|
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -6,6 +6,7 @@ tests/*.res
|
||||||
tests/messages
|
tests/messages
|
||||||
tests/debuglog
|
tests/debuglog
|
||||||
test.log
|
test.log
|
||||||
|
*.testlog
|
||||||
gadgets/
|
gadgets/
|
||||||
package/
|
package/
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|
|
||||||
56
README.md
56
README.md
|
|
@ -64,6 +64,7 @@ For a tutorial and usage overview, take a look at the
|
||||||
* [Java](#java)
|
* [Java](#java)
|
||||||
* [Usage with YouCompleteMe](#usage-with-youcompleteme)
|
* [Usage with YouCompleteMe](#usage-with-youcompleteme)
|
||||||
* [Other LSP clients](#other-lsp-clients)
|
* [Other LSP clients](#other-lsp-clients)
|
||||||
|
* [Lua](#lua)
|
||||||
* [Rust](#rust)
|
* [Rust](#rust)
|
||||||
* [Other servers](#other-servers)
|
* [Other servers](#other-servers)
|
||||||
* [Customisation](#customisation)
|
* [Customisation](#customisation)
|
||||||
|
|
@ -140,6 +141,7 @@ runtime dependencies). They are categorised by their level of support:
|
||||||
| Go | Tested | `--enable-go` | vscode-go | Go, [Delve][] |
|
| Go | Tested | `--enable-go` | vscode-go | Go, [Delve][] |
|
||||||
| TCL | Supported | `--all` or `--enable-tcl` | tclpro | TCL 8.5 |
|
| TCL | Supported | `--all` or `--enable-tcl` | tclpro | TCL 8.5 |
|
||||||
| Bourne Shell | Supported | `--all` or `--enable-bash` | vscode-bash-debug | Bash v?? |
|
| Bourne Shell | Supported | `--all` or `--enable-bash` | vscode-bash-debug | Bash v?? |
|
||||||
|
| Lua | Supported | `--all` or `--enable-lua` | local-lua-debugger-vscode | Node >=12.13.0, Npm, Lua interpreter |
|
||||||
| Node.js | Supported | `--force-enable-node` | vscode-node-debug2 | 6 < Node < 12, Npm |
|
| Node.js | Supported | `--force-enable-node` | vscode-node-debug2 | 6 < Node < 12, Npm |
|
||||||
| Javascript | Supported | `--force-enable-chrome` | debugger-for-chrome | Chrome |
|
| Javascript | Supported | `--force-enable-chrome` | debugger-for-chrome | Chrome |
|
||||||
| Java | Supported | `--force-enable-java ` | vscode-java-debug | Compatible LSP plugin (see [later](#java)) |
|
| Java | Supported | `--force-enable-java ` | vscode-java-debug | Compatible LSP plugin (see [later](#java)) |
|
||||||
|
|
@ -1410,6 +1412,60 @@ For the launch arguments, see the
|
||||||
See [this issue](https://github.com/puremourning/vimspector/issues/3) for more
|
See [this issue](https://github.com/puremourning/vimspector/issues/3) for more
|
||||||
background.
|
background.
|
||||||
|
|
||||||
|
## Lua
|
||||||
|
|
||||||
|
Lua is supported through
|
||||||
|
[local-lua-debugger-vscode](https://github.com/tomblind/local-lua-debugger-vscode).
|
||||||
|
This debugger uses stdio to communicate with the running process, so calls to
|
||||||
|
`io.read` will cause problems.
|
||||||
|
|
||||||
|
* `./install_gadget.py --enable-lua` or `:VimspectorInstall local-lua-debugger-vscode`
|
||||||
|
* Examples: `support/test/lua/simple` and `support/test/lua/love`
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"$schema": "https://puremourning.github.io/vimspector/schema/vimspector.schema.json#",
|
||||||
|
"configurations": {
|
||||||
|
"lua": {
|
||||||
|
"adapter": "lua-local",
|
||||||
|
"configuration": {
|
||||||
|
"request": "launch",
|
||||||
|
"type": "lua-local",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"program": {
|
||||||
|
"lua": "lua",
|
||||||
|
"file": "${file}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"luajit": {
|
||||||
|
"adapter": "lua-local",
|
||||||
|
"configuration": {
|
||||||
|
"request": "launch",
|
||||||
|
"type": "lua-local",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"program": {
|
||||||
|
"lua": "luajit",
|
||||||
|
"file": "${file}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"love": {
|
||||||
|
"adapter": "lua-local",
|
||||||
|
"configuration": {
|
||||||
|
"request": "launch",
|
||||||
|
"type": "lua-local",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"program": {
|
||||||
|
"command": "love"
|
||||||
|
},
|
||||||
|
"args": ["${workspaceFolder}"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Other servers
|
## Other servers
|
||||||
|
|
||||||
* Java - vscode-javac. This works, but is not as functional as Java Debug
|
* Java - vscode-javac. This works, but is not as functional as Java Debug
|
||||||
|
|
|
||||||
|
|
@ -495,4 +495,31 @@ GADGETS = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'local-lua-debugger-vscode': {
|
||||||
|
'language': 'lua',
|
||||||
|
'enabled': True,
|
||||||
|
'repo': {
|
||||||
|
'url': 'https://github.com/tomblind/local-lua-debugger-vscode.git',
|
||||||
|
'ref': 'release-${version}'
|
||||||
|
},
|
||||||
|
'all': {
|
||||||
|
'version': '0.2.0',
|
||||||
|
},
|
||||||
|
'do': lambda name, root, gadget: installer.InstallLuaLocal( name,
|
||||||
|
root,
|
||||||
|
gadget ),
|
||||||
|
'adapters': {
|
||||||
|
'lua-local': {
|
||||||
|
'command': [
|
||||||
|
'node',
|
||||||
|
'${gadgetDir}/local-lua-debugger-vscode/extension/debugAdapter.js'
|
||||||
|
],
|
||||||
|
'name': 'lua-local',
|
||||||
|
'configuration': {
|
||||||
|
'interpreter': 'lua',
|
||||||
|
'extensionPath': '${gadgetDir}/local-lua-debugger-vscode'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -425,6 +425,13 @@ def InstallNodeDebug( name, root, gadget ):
|
||||||
MakeSymlink( name, root )
|
MakeSymlink( name, root )
|
||||||
|
|
||||||
|
|
||||||
|
def InstallLuaLocal( name, root, gadget ):
|
||||||
|
with CurrentWorkingDir( root ):
|
||||||
|
CheckCall( [ 'npm', 'install' ] )
|
||||||
|
CheckCall( [ 'npm', 'run', 'build' ] )
|
||||||
|
MakeSymlink( name, root )
|
||||||
|
|
||||||
|
|
||||||
def InstallGagdet( name: str,
|
def InstallGagdet( name: str,
|
||||||
gadget: dict,
|
gadget: dict,
|
||||||
manifest: Manifest,
|
manifest: Manifest,
|
||||||
|
|
|
||||||
17
support/test/lua/love-headless/.vimspector.json
Normal file
17
support/test/lua/love-headless/.vimspector.json
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://puremourning.github.io/vimspector/schema/vimspector.schema.json#",
|
||||||
|
"configurations": {
|
||||||
|
"love": {
|
||||||
|
"adapter": "lua-local",
|
||||||
|
"configuration": {
|
||||||
|
"request": "launch",
|
||||||
|
"type": "lua-local",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"program": {
|
||||||
|
"command": "love"
|
||||||
|
},
|
||||||
|
"args": ["${workspaceFolder}"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
support/test/lua/love-headless/conf.lua
Normal file
12
support/test/lua/love-headless/conf.lua
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
function love.conf(t)
|
||||||
|
t.modules.audio = false
|
||||||
|
t.modules.font = false
|
||||||
|
t.modules.graphics = false
|
||||||
|
t.modules.image = false
|
||||||
|
t.modules.mouse = false
|
||||||
|
t.modules.physics = false
|
||||||
|
t.modules.sound = false
|
||||||
|
t.modules.touch = false
|
||||||
|
t.modules.video = false
|
||||||
|
t.modules.window = false
|
||||||
|
end
|
||||||
10
support/test/lua/love-headless/main.lua
Normal file
10
support/test/lua/love-headless/main.lua
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
if pcall(require, 'lldebugger') then
|
||||||
|
require('lldebugger').start()
|
||||||
|
end
|
||||||
|
|
||||||
|
local time = 0
|
||||||
|
|
||||||
|
function love.update(dt)
|
||||||
|
time = time + dt
|
||||||
|
love.event.quit()
|
||||||
|
end
|
||||||
17
support/test/lua/love/.vimspector.json
Normal file
17
support/test/lua/love/.vimspector.json
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://puremourning.github.io/vimspector/schema/vimspector.schema.json#",
|
||||||
|
"configurations": {
|
||||||
|
"love": {
|
||||||
|
"adapter": "lua-local",
|
||||||
|
"configuration": {
|
||||||
|
"request": "launch",
|
||||||
|
"type": "lua-local",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"program": {
|
||||||
|
"command": "love"
|
||||||
|
},
|
||||||
|
"args": ["${workspaceFolder}"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
support/test/lua/love/main.lua
Normal file
21
support/test/lua/love/main.lua
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
if pcall(require, 'lldebugger') then
|
||||||
|
require('lldebugger').start()
|
||||||
|
end
|
||||||
|
|
||||||
|
local rect = {0, 0, 64, 64}
|
||||||
|
|
||||||
|
|
||||||
|
function love.update(dt)
|
||||||
|
rect[1] = rect[1] + 10 * dt
|
||||||
|
rect[2] = rect[2] + 10 * dt
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function love.draw()
|
||||||
|
love.graphics.rectangle('fill', rect[1], rect[2], rect[3], rect[4])
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function love.keypressed()
|
||||||
|
love.event.quit()
|
||||||
|
end
|
||||||
29
support/test/lua/simple/.vimspector.json
Normal file
29
support/test/lua/simple/.vimspector.json
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://puremourning.github.io/vimspector/schema/vimspector.schema.json#",
|
||||||
|
"configurations": {
|
||||||
|
"lua": {
|
||||||
|
"adapter": "lua-local",
|
||||||
|
"configuration": {
|
||||||
|
"request": "launch",
|
||||||
|
"type": "lua-local",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"program": {
|
||||||
|
"lua": "lua",
|
||||||
|
"file": "simple.lua"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"luajit": {
|
||||||
|
"adapter": "lua-local",
|
||||||
|
"configuration": {
|
||||||
|
"request": "launch",
|
||||||
|
"type": "lua-local",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"program": {
|
||||||
|
"lua": "luajit",
|
||||||
|
"file": "simple.lua"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
support/test/lua/simple/simple.lua
Normal file
25
support/test/lua/simple/simple.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
if pcall(require, 'lldebugger') then
|
||||||
|
require('lldebugger').start()
|
||||||
|
end
|
||||||
|
|
||||||
|
local separator = ' '
|
||||||
|
|
||||||
|
|
||||||
|
local function createMessage()
|
||||||
|
local words = {}
|
||||||
|
table.insert(words, 'Hello')
|
||||||
|
table.insert(words, 'world')
|
||||||
|
return table.concat(words, separator)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function withEmphasis(func)
|
||||||
|
return function()
|
||||||
|
return func() .. '!'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
createMessage = withEmphasis(createMessage)
|
||||||
|
|
||||||
|
print(createMessage())
|
||||||
|
|
@ -4,6 +4,11 @@ ENV DEBIAN_FRONTEND=noninteractive
|
||||||
ENV LC_ALL C.UTF-8
|
ENV LC_ALL C.UTF-8
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
|
apt install -y curl dirmngr apt-transport-https lsb-release ca-certificates \
|
||||||
|
software-properties-common && \
|
||||||
|
curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
|
||||||
|
add-apt-repository ppa:bartbes/love-stable -y && \
|
||||||
|
apt-get update && \
|
||||||
apt-get -y dist-upgrade && \
|
apt-get -y dist-upgrade && \
|
||||||
apt-get -y install python3-dev \
|
apt-get -y install python3-dev \
|
||||||
python3-pip \
|
python3-pip \
|
||||||
|
|
@ -17,9 +22,10 @@ RUN apt-get update && \
|
||||||
tcllib \
|
tcllib \
|
||||||
gdb \
|
gdb \
|
||||||
lldb \
|
lldb \
|
||||||
curl \
|
|
||||||
nodejs \
|
nodejs \
|
||||||
npm && \
|
lua5.1 \
|
||||||
|
luajit \
|
||||||
|
love && \
|
||||||
apt-get -y autoremove
|
apt-get -y autoremove
|
||||||
|
|
||||||
RUN ln -fs /usr/share/zoneinfo/Europe/London /etc/localtime && \
|
RUN ln -fs /usr/share/zoneinfo/Europe/London /etc/localtime && \
|
||||||
|
|
|
||||||
84
tests/language_lua.test.vim
Normal file
84
tests/language_lua.test.vim
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
function! SetUp()
|
||||||
|
let g:vimspector_enable_mappings = 'HUMAN'
|
||||||
|
call vimspector#test#setup#SetUpWithMappings( v:none )
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ClearDown()
|
||||||
|
call vimspector#test#setup#ClearDown()
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! BaseTest( configuration )
|
||||||
|
let fn='simple.lua'
|
||||||
|
lcd ../support/test/lua/simple
|
||||||
|
exe 'edit ' . fn
|
||||||
|
|
||||||
|
call vimspector#SetLineBreakpoint( fn, 9 )
|
||||||
|
call vimspector#LaunchWithSettings( { 'configuration': a:configuration } )
|
||||||
|
|
||||||
|
" This debugger is ignoring stopOnEntry when not running a custom executable
|
||||||
|
" and always stopping on the first line after setting the hook. This first
|
||||||
|
" check assumes that behavior.
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 5, 1 )
|
||||||
|
call WaitForAssert( {->
|
||||||
|
\ vimspector#test#signs#AssertPCIsAtLineInBuffer( fn, 5 )
|
||||||
|
\ } )
|
||||||
|
" Continue
|
||||||
|
call feedkeys( "\<F5>", 'xt' )
|
||||||
|
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 9, 1 )
|
||||||
|
call WaitForAssert( {->
|
||||||
|
\ vimspector#test#signs#AssertPCIsAtLineInBuffer( fn, 9 )
|
||||||
|
\ } )
|
||||||
|
|
||||||
|
" Step
|
||||||
|
call feedkeys( "\<F10>", 'xt' )
|
||||||
|
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 10, 1 )
|
||||||
|
call WaitForAssert( {->
|
||||||
|
\ vimspector#test#signs#AssertPCIsAtLineInBuffer( fn, 10 )
|
||||||
|
\ } )
|
||||||
|
|
||||||
|
call vimspector#test#setup#Reset()
|
||||||
|
|
||||||
|
lcd -
|
||||||
|
%bwipeout!
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! Test_Lua_Simple()
|
||||||
|
call BaseTest( 'lua' )
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! Test_Lua_Luajit()
|
||||||
|
call BaseTest( 'luajit' )
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! Test_Lua_Love()
|
||||||
|
let fn='main.lua'
|
||||||
|
lcd ../support/test/lua/love-headless
|
||||||
|
exe 'edit ' . fn
|
||||||
|
|
||||||
|
call vimspector#SetLineBreakpoint( fn, 8 )
|
||||||
|
call vimspector#LaunchWithSettings( { 'configuration': 'love' } )
|
||||||
|
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 8, 1 )
|
||||||
|
call WaitForAssert( {->
|
||||||
|
\ vimspector#test#signs#AssertPCIsAtLineInBuffer( fn, 8 )
|
||||||
|
\ } )
|
||||||
|
|
||||||
|
" Step
|
||||||
|
call feedkeys( "\<F10>", 'xt' )
|
||||||
|
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 9, 1 )
|
||||||
|
call WaitForAssert( {->
|
||||||
|
\ vimspector#test#signs#AssertPCIsAtLineInBuffer( fn, 9 )
|
||||||
|
\ } )
|
||||||
|
|
||||||
|
call vimspector#test#setup#Reset()
|
||||||
|
|
||||||
|
lcd -
|
||||||
|
%bwipeout!
|
||||||
|
endfunction
|
||||||
Loading…
Add table
Add a link
Reference in a new issue