LucHermitte / local_vimrc

Per project/tree configuration plugins
GNU General Public License v3.0
125 stars 7 forks source link

No confirmation on macOS #17

Closed fuzhen011 closed 4 years ago

fuzhen011 commented 4 years ago

I have the plugin installed both on my work laptop which is running Ubuntu 18.04 and a Macbook which is running the macOS. I almost have the same setting for vim, but I found if I edit a project in Ubuntu, whenever I open a new buffer, it lets me to confirm if to load the local vimrc or not. However, on the Mac, I found there is no such confirmation, it automatically loads it. I just reviewed the readme file again to see if there is any configuration I missed on the Mac, but I couldn't find it.

LucHermitte commented 4 years ago

By default, $HOME shall be in the asklist (g:local_vimrc_options.asklist).

Could you tell me

Note that if you :call lh#local_vimrc#verbose(1), you should see what is tested exactly on your system. In case things behave differently on macOS, could you send me what it prints out?

Thanks.

fuzhen011 commented 4 years ago

I didn't explicitly modify the local_vimrc_options on both platforms, below is what I got when I echo it in my macbook. {'blacklist': [], 'asklist': [], '_action_name': 'recognize a local vimrc at', 'sandboxlist': [], 'whitelist': [], '_do _handle': function('166_source')}

$HOME is /Users/zhfu on mac.

When I entered :call lh#local_vimrc#verbose(1) in vim, it doesn't show up anything. Am I issue it correctly?

Additionally, I moved the __local_vimrc.vim to a subfolder of my working directory to avoid it being automatically load as a workaround now, but I just encountered below error message when I open any files in the project. However, if I close vim and vim the files again, the error doesn't show up again. I'm not sure what I did to cause this error, just for your information about it.


"~/work/projs/bt_mesh/src/element.c" 127L, 3324C


Let me know if you need more information. Thanks for your time on it, I really enjoy with this plugin and want to make it better.

LucHermitte commented 4 years ago

When I entered :call lh#local_vimrc#verbose(1) in vim, it doesn't show up anything. Am I issue it correctly?

Yes. This triggers debug mode in that particular plugin of mine.

Another possibility consists in forcing debug/verbose mode from the start by changing 0 into 1 in

" autoload/lh/local_vimrc.vim, line 26
let s:verbose = get(s:, 'verbose', 0)

Actually, this will give me more information. BTW, I've just committed a new version that should log calls to lh#local_vimrc#munge().

Then further actions are printed out as messages (that we can display again with :message). The logs can also be sent to the quickfix window with :LHLog qf -- but then you'll want to inhibit the logs (:call lh#local_vimrc#verbose(0)), or to redirect them elsewhere (see the related documentation -> :LHLogs echomsg)


There is something strange in the options.

I'll be interested in

" Should return ~/.vim
:echo lh#path#vimfiles()

" Should return -1 (x3)
:echo index(g:local_vimrc_options.whitelist,   $HOME)
:echo index(g:local_vimrc_options.blacklist,   $HOME)
:echo index(g:local_vimrc_options.sandboxlist, $HOME)

" Should return ['/Users/zhfu']
:echo lh#local_vimrc#munge('asklist', $HOME)

My idea is that this latter list has been either never filled, or cleared -- if your .vimrc is strictly identical on all systems, you should be in the first case, which should never happen, unless one of the previous call to index() returns something >= 0.


current buffer (1) hasn't changed since last time (1)

To trigger another message, that should be more interesting, you'll have to open another file that hasn't been opened yet, after the call to ....#verbose(1).

fuzhen011 commented 4 years ago

I got "/Users/zhfu/.vim" when I entered echo lh#path#vimfiles().

I got -1 for the following 3 commands as expected.

I got [] for the last command. It seems this one is abnormal?

LucHermitte commented 4 years ago

The last one is indeed the abnormal one. I guess that

:echo lh#path#munge([], $HOME)

will also return an empty list...

Other question (when I debug the previous command), what are the results of

:echo lh#path#readlink($HOME)
:echo executable('readlink')

" If the previous returns 1
:echo system('readlink -f '.shellescape($HOME))
" and
:echo lh#os#system('readlink -f '.shellescape($HOME))

" in any case:
:echo glob($HOME) " or `glob(result of previous command)`

Actually, if you used to debugging Vim function, I'll be interested in your observations of

: debug echo lh#path#munge([], $HOME)

to see when and where it goes wrong.

fuzhen011 commented 4 years ago

:echo lh#path#munge([], $HOME) returns empty list.

:echo lh#path#readlink($HOME) returns error: readlink: illegal option -- f usage: readlink [-n] [file ...]

:echo executable('readlink') returns 1

" If the previous returns 1 :echo system('readlink -f '.shellescape($HOME)) returns error: readlink: illegal option -- f usage: readlink [-n] [file ...]

" and :echo lh#os#system('readlink -f '.shellescape($HOME)) returns error: readlink: illegal option -- f usage: readlink [-n] [file ...]

" in any case: :echo glob($HOME) " or glob(result of previous command) returns /Users/zhfu

Sorry that I know nothing of debugging vim, so I can only pass the information to you without analyzing it. Many thanks to your time, this plugin really helps me a lot.

LucHermitte commented 4 years ago

It seems the problem comes from readlink. The version you have on MacOS doesn't support the -f as GNU version does.

If you already have greadlink (:echo executable('greadlink')), I can come up with a solution quite quickly. If this is not something all MacOS machines have by default, I'll have to find a workaround from https://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac

Does your version of vim supports Vim?

LucHermitte commented 4 years ago

realpath seems to do the job. Do you have it on your MacOS machine?

fuzhen011 commented 4 years ago

Yes, that's the problem, I just installed the coreutils with brew install coreutils and alias readlink to greadlink. It works fine now.

LucHermitte commented 4 years ago

BTW, I've also changed my dependency towards readlink. Vim's resolve() function helps me in what I'm looking for: making sure the same pathname will not be added twice in the list: through symbolic links or not.

LucHermitte commented 4 years ago

BTW, I've also changed my dependency towards readlink. Vim's resolve() function helps me in what I'm looking for: making sure the same pathname will not be added twice in the list: through symbolic links or not.