Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path_mapping not working when using local vimrc #197

Closed
epilgrim opened this issue Feb 1, 2015 · 11 comments

Comments

@epilgrim
Copy link

commented Feb 1, 2015

I've been using your plugin for a while already, without any issues. Thanks for that!!

But nowadays i'm trying to move all my development servers to a dockerized environmnent.
The problem that arises with this, is that each one of the projects will have different path_maps. For instance, one will have

let g:vdebug_options['path_maps'] = {"/var/www/": "/home/juan/sandbox/project1/"} 

while another might have

let g:vdebug_options['path_maps'] = {"/var/www/": "/home/juan/sandbox/project2/"} 

In order to make it work, I introduced the plugin https://github.com/embear/vim-localvimrc which allows me to configure those things in a by project basis, just adding a .lvimrc file with that content in the corresponding project.

Now, the problem I'm facing, is that the path_map is not taken into account the first time I run de debugger. If I open vim, run the debugger, stop it and then set the breakpoint and start the debugger again, it works as intended. But if I just open vim, set the breakpoint and run the debugger, it doesn't work

You can see the logs in this gist: https://gist.github.com/Epilgrim/28a7eb010b8135d4e781

Explanation of the files:
vdebug.no_lvimrc.log: log without anything to do with lvimrc. the options defined in the good old ~/.vimrc

vdebug.lvimrc.1.log: log using lvimrc. The breakpoint was not taken into account. Steps: open vim, set breakpoint, start vdebug (F5)

vdebug.lvimrc.2.log: log using lvimrc. The breakpoint was taken into account. Steps: open vim, start vdebug (F5), stop vdebug (ctrl+c), set breakpoint, start vdebug (F5)

Although basically everything works if I start and stop the debugger, it's a bit annoying sometimes. Do you have any clue what might be going on here?

@exussum12

This comment has been minimized.

Copy link

commented Mar 2, 2015

looks related to #152

@joonty

This comment has been minimized.

Copy link
Collaborator

commented Mar 4, 2015

Hi there, sorry for the delay. I think the issue is related to the options dictionary being loaded too late. Take a look at #113. There's a function that you can call in your vimrc/localrc that should load the options when vim starts.

Give that a go and see if it helps. Otherwise we'll try something else!

@epilgrim

This comment has been minimized.

Copy link
Author

commented Apr 19, 2015

Sorry for the delay!

Sadly, that does not work.
I tried:

call Vdebug_load_options({ 'path_maps' : {"/var/www": "/home/juan/Documents/sandbox/videos"} })

I can see that the global variable is correctly updated, :let g:vdebug_options shows:

g:vdebug_options      {'debug_file': '', 'debug_file_level': 0, 'watch_window_style': 'expanded', 'marker_default': '⬦', 'continuous_mode': 0, 'ide_key': '', 'break_on_open': 0, 'on_close':
 'detach', 'path_maps': {'/var/www': '/home/juan/Documents/sandbox/videos'}, 'marker_closed_tree': '▸', 'timeout': 40, 'port': 9000, 'marker_open_tree': '▾', 'debug_window_level': 0, 'serve
r': '0.0.0.0'}    

But still the debugger forces me to stop it and restarted before the mappings are recognized

@joonty

This comment has been minimized.

Copy link
Collaborator

commented May 5, 2015

@epilgrim so, just to clarify, are you running the Vdebug_load_options before you first start vdebug?

@epilgrim

This comment has been minimized.

Copy link
Author

commented May 11, 2015

yes, it's being called in the local vimrc.

This means that first vim will load .vimrc, and then .lvimrc. After this, i get into vim, and can run F5 to start the debugger

@joonty

This comment has been minimized.

Copy link
Collaborator

commented Jun 9, 2015

Just a quick update - this looks related to #200 - I don't know if you can find any information on there while I get myself together to look at this properly?

@joonty joonty added the bug label Jun 9, 2015

@joonty joonty added this to the Version 2.0.0 milestone Aug 18, 2015

@stephenplatz

This comment has been minimized.

Copy link

commented Oct 9, 2015

I'm having the same issue as @epilgrim, I'm glad at least to have the stop/start workaround, but it is annoying, I agree. I've just got my vdebug_options in my .vimrc.after file.

@chadrien

This comment has been minimized.

Copy link
Contributor

commented Jan 22, 2016

👍

@fenetikm

This comment has been minimized.

Copy link

commented Oct 30, 2016

My workaround is to have a function set the path_maps and run that before starting debug session. An additional benefit being that I can incorporate that with the vim-projectroot. e.g.

function! SetupDebug()
  let g:vdebug_options['ide_key']='PHPSTORM'
  let g:vdebug_options['port']=9001
  let g:vdebug_options['path_maps']={'/web': call('projectroot#get', a:000)}
endfunction
nmap <leader>xd :call SetupDebug()<cr>

@BlackIkeEagle BlackIkeEagle added this to TODO in v2.0 May 4, 2017

@jmarceli

This comment has been minimized.

Copy link

commented Jun 1, 2017

Provided that you have dbakker/vim-projectroot installed you may add following lines to the .vimrc (based on @fenetikm solution and #112 @dajmian hack).

" Define root making files. I've added docker-compose.yml to standard list
let g:rootmarkers = ['.projectroot', 'docker-compose.yml', '.git', '.hg', '.svn', '.bzr','_darcs','build.xml']

function! SetupDebug()
  let g:vdebug_options['path_maps']={'/app': call('projectroot#get', a:000)}
  " Hack to override vdebug options it should be the path of your vdebug.vim file
  source ~/.vim/bundle/vdebug/plugin/vdebug.vim
endfunction
" Automatically SetupDebug on each Vim enter
autocmd VimEnter * :call SetupDebug()

Does Vdebug generate some better events for autocmd? Ideally an event before starting the debugger. Another option would be mapping a key to run SetupDebug and then VdebugCommandRun.

EDIT: Probably the best available option would be SetupDebug() just before starting the debugger with f5. I was trying to achieve that with:

let g:vdebug_keymap = { 'run' : '<F1>' }
nnoremap <F5> :call SetupDebug() <bar> :VdebugStart <cr>

but it doesn't work and I don't know why.

@BlackIkeEagle

This comment has been minimized.

Copy link
Member

commented Feb 19, 2018

From my experience this issue no longer happens with v2-integration

@BlackIkeEagle BlackIkeEagle moved this from TODO to Done in v2.0 Feb 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
8 participants
You can’t perform that action at this time.