Open AaronHutchinson opened 2 months ago
Hi, thanks for reporting this. At the moment I don't have access to a setup where I can test this, but it seems that indeed getenv
is not part of older Vim versions.
I think we can easily create a wrapper function that uses getenv
when available and otherwise emulates getenv
(see :help expr-env
and :help expr-env-expand
).
Would you be interested in creating a PR for this? The required changes should be pretty small (only autoload/libs/system.vim
uses getenv
). Otherwise I'll work on this in the next few days.
Thanks for your reply. After looking at :help expr-env
I was able to confirm that I can print environment variables with, e.g., :echo expand("$HOME")
even though getenv
doesn't exist in my Vim version.
Would you be interested in creating a PR for this?
I've been using Vim for about 2 weeks now and am not very familiar with Vim scripting yet. I'm not sure how to write the wrapper function you mention in a way that avoids the unknown function
error.
At the very least, I can definitely test any proposed solutions to confirm whether they work with Vim 8.0.
I've pushed a fix to the libs
submodule and updated this repository. Can you try pulling the latest version of Vim-CMake and checking if the plugin works for you?
It looks like your patch fixed the issue with getenv
. Thanks! Running :CMakeGenerate
got a little further, but I still encountered some fatal errors preventing it from completing:
bufnr
:
Error detected while processing function cmake#Generate[4]..546[32]..540[16]..535[17]..<SNR>70_CreateBuffer[3]..513[5]..505:
line 23:
E119: Not enough arguments for function: bufnr
E15 Invalid expression: bufnr()
It looks like the buffer id was previously a required argument. I got around this error by replacing all 4 occurrences of bufnr()
with bufnr('%')
in libs/system.vim
.
Error detected while processing function cmake#Generate[4]..546[32]..540[16]..535[17]..<SNR>70_CreateBuffer[13]..509:
line 5:
E521: Number required: &buflisted = 'v:false'
I tried searching the help regarding the buflisted
option but couldn't figure out what the issue was here. As a temporary hack in an attempt to proceed, I deleted this line and got around the error. I'm not sure what repercussions this had.
Error detected while processing function cmake#Generate[4]..546[32]..540[16]..535[17]..<SNR>70_CreateBuffer[14]..510[12]..<SNR>67_BufferExecute:
line 4:
E117: Unknown function: win_execute
The win_execute
function appears to have been added in Vim 8.1.1418. Another wrapper could probably be used to emulate win_execute
when it's not available similar to getenv
, but implementing this was beyond my knowledge. This is as far as I got.
Given the last error above, I went through all of the *.vim
files of vim-cmake
and vim-libs
looking at the various call
statements. I found that the following functions are used, but don't appear to exist in Vim 8.0: win_execute
, deletebufline
, appendbufline
. I think these latter two would need wrappers as well.
If at any point this seems like too much work to support an older version of Vim, I completely understand and won't feel offended.
Oh wow, that's more hurdles than expected :laughing:
Thanks a lot for the in-depth research and tests, these help a lot. I will need to see how to get around these limitations of old Vim, and perhaps install it myself to avoid going back and forth with you. Will keep you posted.
By the way, given you can't upgrade Vim, have you perhaps considered using a pre-compiled binary or an appimage from the Neovim release page?
Thanks for looking into it!
have you perhaps considered using a pre-compiled binary or an appimage
Thanks for the suggestions. I will look into these options and see how they work for my circumstances.
Bug description
The
libs
submodule usesgetenv
, which was not supported until Vim 8.1.1305: https://github.com/vim/vim/commit/691ddeefb545d8488e5a495af61caba2e57b3de9To Reproduce
Run
:CMakeGenerate
using a version of Vim earlier than 8.1.1305.Expected behavior
The
vim-cmake
plugin code should be parsed without errors.Behavior with minimal
.vimrc
I used the following
.vimrc
:Running
:CMakeGenerate
using Vim 8.0 gives the following errors:Additional context
It would be great if
vim-cmake
could support Vim 8.0. In my case, I don't have administrator privileges on the desired system in order to upgrade Vim, which means I can't usevim-cmake
.At the very least, I think the Requirements section of
README.md
should list a minimum required Vim version in order for the plugin to work.