zizhongyan / vim-stata

Vim Plugin for Running Selected Do-File in Stata
https://github.com/zizhongyan/vim-stata
9 stars 7 forks source link

Works on m1 chip MacOS, and then... doesn't? #6

Open greglum opened 3 years ago

greglum commented 3 years ago

Using the plug-in on an m1 MacOS (Big Sur 11.4) machine with NVIM v0.4.4

on Stata v16.1

And the system changes have been made per the documentation:

I'm using vim-plug to install and it works fine initially + after multiple reboots, but it randomly stops working.

After selecting all lines and doing the hotkey to run the code, the function:call RunDoLines() does appear to be called successfully, but the lines of code are not being run + Stata will not automatically open (and even if I add in alet g:vimforstata_pathbin_sh" in the init.vim akin to the Linux setup, Stata launches but the do-file lines are not run). To my knowledge, no changes were made in my init.vim nor system settings that would have caused this and it has occurred twice now off of two separate fresh MacOS installs where the plugin works fine initially and then the function no longer runs the code.

Is this an issue, or am I unaware to some system changes I may be implementing that cause this change?

Edit: also unsure if this is related, but before this issue arose, when I imported my init.vim from my Linux system over to my Mac, I first had commented out my let g:vimforstata_pathbin* lines, however, I would get the errors

E121: Undefined variable: g:vimforstata_pathbin_sh
E15: Invalid expression: (g:vimforstata_pathbin_sh != ' ')

To resolve this issue, I had to uncomment that relevant line in my init.vim and even though the line still was just calling a script to a non-existent stata binary on my MacOS system. This WOULD run my do-lines, until seemingly randomly the posted issue arose (I'm sure I did something, but can't identify what).

greglum commented 3 years ago

Well I discovered at least the cause of the issue, which was within the plugin .vim script.

In order to resolve it, I had to comment out/delete the lines:

" elseif (has("unix") && executable("xdg-open")) || s:haskdeinit " " For KDE-based or Various Other Linux Desktop Environments " if (g:vimforstata_pathbin_sh != '') " exe "silent !xdg-open | bash ".g:vimforstata_pathbin_sh." do ".args " elseif (g:vimforstata_pathbin != '') " exe "silent !xdg-open ".g:vimforstata_pathbin." do ".args " else " exe "silent !xdg-open ".g:vimforstata_pathbin_ifnotset_linux." do ".args " endif " let ret= v:shell_error " elseif has("unix") && executable("gtk-launch") " " For Linux Desktop Environments without the above, which would usually at least have gtk-launch " if (g:vimforstata_pathbin_sh != '') " exe "silent !gtk-launch | bash ".g:vimforstata_pathbin_sh." do ".args " elseif (g:vimforstata_pathbin != '') " exe "silent !gtk-launch ".g:vimforstata_pathbin." do ".args " else " exe "silent !gtk-launch ".g:vimforstata_pathbin_ifnotset_linux." do ".args " endif " let ret= v:shell_error

I'm not sure what on my system was making the script mistakenly identify the OS, but that was the issue. Appears to be working fine now.

jmillanq commented 1 year ago

I use the same solution above. However, I hope this is something you guys can fix for future versions. Thanks gerglum

greglum commented 1 year ago

No problem - glad I could provide a workaround!