Merge pull request #121 from puremourning/windows
Experimental Windows support
This commit is contained in:
commit
c8dcc47b1c
9 changed files with 65 additions and 27 deletions
14
README.md
14
README.md
|
|
@ -153,7 +153,8 @@ Vimspector requires:
|
||||||
* Vim version 8.1 with at least patch 1264, or Neovim 0.4.3
|
* Vim version 8.1 with at least patch 1264, or Neovim 0.4.3
|
||||||
* One of the following operating systems:
|
* One of the following operating systems:
|
||||||
* Linux
|
* Linux
|
||||||
* macOS Mojave or pater
|
* macOS Mojave or later
|
||||||
|
* Windows (experimental)
|
||||||
|
|
||||||
Why such a new vim ? Well 2 reasons:
|
Why such a new vim ? Well 2 reasons:
|
||||||
|
|
||||||
|
|
@ -161,8 +162,9 @@ Why such a new vim ? Well 2 reasons:
|
||||||
2. Because there are Vim bugs that vimspector triggers that will frustrate you
|
2. Because there are Vim bugs that vimspector triggers that will frustrate you
|
||||||
if you hit them.
|
if you hit them.
|
||||||
|
|
||||||
Why no Windows support? Because it's effort and it's not a priority for the
|
Why Windows support experimental? Because it's effort and it's not a priority
|
||||||
author. PRs are welcome.
|
for the author. PRs are welcome to fix bugs. Windows will not be regularly
|
||||||
|
tested.
|
||||||
|
|
||||||
Which Linux versions? I only test on Ubuntu 18.04 and later and RHEL 7.
|
Which Linux versions? I only test on Ubuntu 18.04 and later and RHEL 7.
|
||||||
|
|
||||||
|
|
@ -186,6 +188,12 @@ Workarounds are in place as follows:
|
||||||
There is no workaroud for the lack of balloons; you'll just have to use
|
There is no workaroud for the lack of balloons; you'll just have to use
|
||||||
`:VimspectorEval` or `:VimspectorWatch`, or switch to Vim.
|
`:VimspectorEval` or `:VimspectorWatch`, or switch to Vim.
|
||||||
|
|
||||||
|
## Windows differences
|
||||||
|
|
||||||
|
The following features are not implemented for Windows:
|
||||||
|
|
||||||
|
* Tailing the vimspector log in the Output Window.
|
||||||
|
|
||||||
## Language dependencies
|
## Language dependencies
|
||||||
|
|
||||||
The debug adapters themselves have certain runtime dependencies. They are
|
The debug adapters themselves have certain runtime dependencies. They are
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,9 @@ endfunction
|
||||||
function! s:_OnExit( channel, status ) abort
|
function! s:_OnExit( channel, status ) abort
|
||||||
echom 'Channel exit with status ' . a:status
|
echom 'Channel exit with status ' . a:status
|
||||||
redraw
|
redraw
|
||||||
unlet s:job
|
if exists( 's:job' )
|
||||||
|
unlet s:job
|
||||||
|
endif
|
||||||
py3 _vimspector_session.OnServerExit( vim.eval( 'a:status' ) )
|
py3 _vimspector_session.OnServerExit( vim.eval( 'a:status' ) )
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
@ -61,12 +63,17 @@ function! vimspector#internal#job#StartDebugSession( config ) abort
|
||||||
\ }
|
\ }
|
||||||
\ )
|
\ )
|
||||||
|
|
||||||
echom 'Started job, status is: ' . job_status( s:job )
|
if !exists( 's:job' )
|
||||||
|
" The job died immediately after starting and we cleaned up
|
||||||
|
return v:false
|
||||||
|
endif
|
||||||
|
|
||||||
|
let status = job_status( s:job )
|
||||||
|
|
||||||
|
echom 'Started job, status is: ' . status
|
||||||
redraw
|
redraw
|
||||||
|
|
||||||
if job_status( s:job ) !=# 'run'
|
if status !=# 'run'
|
||||||
echom 'Unable to start job, status is: ' . job_status( s:job )
|
|
||||||
redraw
|
|
||||||
return v:false
|
return v:false
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
@ -140,7 +147,7 @@ function! vimspector#internal#job#StartCommandWithLog( cmd, category ) abort
|
||||||
\ } ) )
|
\ } ) )
|
||||||
|
|
||||||
if job_status( s:commands[ a:category ][ index ] ) !=# 'run'
|
if job_status( s:commands[ a:category ][ index ] ) !=# 'run'
|
||||||
echom 'Unable to start job for ' . a:cmd
|
echom 'Unable to start job for ' . string( a:cmd )
|
||||||
redraw
|
redraw
|
||||||
return v:none
|
return v:none
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,9 @@ function! s:_OnEvent( chan_id, data, event ) abort
|
||||||
elseif a:event ==# 'exit'
|
elseif a:event ==# 'exit'
|
||||||
echom 'Channel exit with status ' . a:data
|
echom 'Channel exit with status ' . a:data
|
||||||
redraw
|
redraw
|
||||||
unlet s:job
|
if exists( 's:job' )
|
||||||
|
unlet s:job
|
||||||
|
endif
|
||||||
" This causes terminal spam in neovim due to
|
" This causes terminal spam in neovim due to
|
||||||
" https://github.com/neovim/neovim/issues/11725
|
" https://github.com/neovim/neovim/issues/11725
|
||||||
py3 _vimspector_session.OnServerExit( vim.eval( 'a:data' ) )
|
py3 _vimspector_session.OnServerExit( vim.eval( 'a:data' ) )
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,9 @@ let s:buffer_to_id = {}
|
||||||
function! vimspector#internal#neoterm#PrepareEnvironment( env ) abort
|
function! vimspector#internal#neoterm#PrepareEnvironment( env ) abort
|
||||||
let old_env = {}
|
let old_env = {}
|
||||||
|
|
||||||
let new_env = copy( environ() )
|
|
||||||
for key in keys( a:env )
|
for key in keys( a:env )
|
||||||
if has_key( new_env, key )
|
if exists( '$' . key )
|
||||||
let old_env[ key ] = new_env[ key ]
|
let old_env[ key ] = getenv( key )
|
||||||
endif
|
endif
|
||||||
call setenv( key, a:env[ key ] )
|
call setenv( key, a:env[ key ] )
|
||||||
endfor
|
endfor
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ GADGETS = {
|
||||||
'adapters': {
|
'adapters': {
|
||||||
'debugpy': {
|
'debugpy': {
|
||||||
"command": [
|
"command": [
|
||||||
"python3",
|
sys.executable,
|
||||||
"${gadgetDir}/debugpy/build/lib/debugpy/adapter"
|
"${gadgetDir}/debugpy/build/lib/debugpy/adapter"
|
||||||
],
|
],
|
||||||
"name": "debugpy",
|
"name": "debugpy",
|
||||||
|
|
|
||||||
|
|
@ -879,7 +879,11 @@ class DebugSession( object ):
|
||||||
status )
|
status )
|
||||||
self.Clear()
|
self.Clear()
|
||||||
|
|
||||||
self._connection.Reset()
|
if self._connection is not None:
|
||||||
|
# Can be None if the server dies _before_ StartDebugSession vim function
|
||||||
|
# returns
|
||||||
|
self._connection.Reset()
|
||||||
|
|
||||||
self._stackTraceView.ConnectionClosed()
|
self._stackTraceView.ConnectionClosed()
|
||||||
self._variablesView.ConnectionClosed()
|
self._variablesView.ConnectionClosed()
|
||||||
self._outputView.ConnectionClosed()
|
self._outputView.ConnectionClosed()
|
||||||
|
|
|
||||||
|
|
@ -201,9 +201,24 @@ def MakeSymlink( in_folder, link, pointing_to ):
|
||||||
RemoveIfExists( os.path.join( in_folder, link ) )
|
RemoveIfExists( os.path.join( in_folder, link ) )
|
||||||
|
|
||||||
in_folder = os.path.abspath( in_folder )
|
in_folder = os.path.abspath( in_folder )
|
||||||
pointing_to = os.path.relpath( os.path.abspath( pointing_to ),
|
pointing_to_relative = os.path.relpath( os.path.abspath( pointing_to ),
|
||||||
in_folder )
|
in_folder )
|
||||||
os.symlink( pointing_to, os.path.join( in_folder, link ) )
|
link_path = os.path.join( in_folder, link )
|
||||||
|
|
||||||
|
if install.GetOS() == 'windows':
|
||||||
|
# While symlinks do exist on Windows, they require elevated privileges, so
|
||||||
|
# let's use a directory junction which is all we need.
|
||||||
|
link_path = os.path.abspath( link_path )
|
||||||
|
if os.path.isdir( link_path ):
|
||||||
|
os.rmdir( link_path )
|
||||||
|
subprocess.check_call( [ 'cmd.exe',
|
||||||
|
'/c',
|
||||||
|
'mklink',
|
||||||
|
'/J',
|
||||||
|
link_path,
|
||||||
|
pointing_to ] )
|
||||||
|
else:
|
||||||
|
os.symlink( pointing_to_relative, link_path )
|
||||||
|
|
||||||
|
|
||||||
def CloneRepoTo( url, ref, destination ):
|
def CloneRepoTo( url, ref, destination ):
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from vimspector import utils
|
from vimspector import utils, install
|
||||||
|
|
||||||
import vim
|
import vim
|
||||||
import json
|
import json
|
||||||
|
|
@ -49,10 +49,7 @@ class OutputView( object ):
|
||||||
for b in set( BUFFER_MAP.values() ):
|
for b in set( BUFFER_MAP.values() ):
|
||||||
self._CreateBuffer( b )
|
self._CreateBuffer( b )
|
||||||
|
|
||||||
self._CreateBuffer(
|
self._CreateBuffer( 'Vimspector', file_name = utils.LOG_FILE )
|
||||||
'Vimspector',
|
|
||||||
file_name = vim.eval( 'expand( "~/.vimspector.log" )' ) )
|
|
||||||
|
|
||||||
self._ShowOutput( 'Console' )
|
self._ShowOutput( 'Console' )
|
||||||
|
|
||||||
def Print( self, categroy, text ):
|
def Print( self, categroy, text ):
|
||||||
|
|
@ -161,6 +158,10 @@ class OutputView( object ):
|
||||||
|
|
||||||
if file_name is not None:
|
if file_name is not None:
|
||||||
assert cmd is None
|
assert cmd is None
|
||||||
|
if install.GetOS() == "windows":
|
||||||
|
# FIXME: Can't display fiels in windows (yet?)
|
||||||
|
return
|
||||||
|
|
||||||
cmd = [ 'tail', '-F', '-n', '+1', '--', file_name ]
|
cmd = [ 'tail', '-F', '-n', '+1', '--', file_name ]
|
||||||
|
|
||||||
if cmd is not None:
|
if cmd is not None:
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,10 @@ import string
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
|
|
||||||
_log_handler = logging.FileHandler( os.path.expanduser( '~/.vimspector.log' ),
|
LOG_FILE = os.path.expanduser( os.path.join( '~', '.vimspector.log' ) )
|
||||||
mode = 'w' )
|
|
||||||
|
_log_handler = logging.FileHandler( LOG_FILE, mode = 'w' )
|
||||||
|
|
||||||
_log_handler.setFormatter(
|
_log_handler.setFormatter(
|
||||||
logging.Formatter( '%(asctime)s - %(levelname)s - %(message)s' ) )
|
logging.Formatter( '%(asctime)s - %(levelname)s - %(message)s' ) )
|
||||||
|
|
||||||
|
|
@ -40,7 +42,7 @@ SetUpLogging( _logger )
|
||||||
|
|
||||||
|
|
||||||
def BufferNumberForFile( file_name ):
|
def BufferNumberForFile( file_name ):
|
||||||
return int( vim.eval( 'bufnr( "{0}", 1 )'.format( file_name ) ) )
|
return int( vim.eval( "bufnr( '{0}', 1 )".format( Escape( file_name ) ) ) )
|
||||||
|
|
||||||
|
|
||||||
def BufferForFile( file_name ):
|
def BufferForFile( file_name ):
|
||||||
|
|
@ -50,7 +52,7 @@ def BufferForFile( file_name ):
|
||||||
def OpenFileInCurrentWindow( file_name ):
|
def OpenFileInCurrentWindow( file_name ):
|
||||||
buffer_number = BufferNumberForFile( file_name )
|
buffer_number = BufferNumberForFile( file_name )
|
||||||
try:
|
try:
|
||||||
vim.command( 'bu {0}'.format( buffer_number ) )
|
vim.current.buffer = vim.buffers[ buffer_number ]
|
||||||
except vim.error as e:
|
except vim.error as e:
|
||||||
if 'E325' not in str( e ):
|
if 'E325' not in str( e ):
|
||||||
raise
|
raise
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue