1

I'm trying to write vim plugin for easier work with cmake. I want it to read some values from json file: build_dir, generator, cmake VARS and then give vim user few functions: configure, build, maybe run.

I decided to use python, because it's easy to run cmake from it and easy to parse json. But i have problem with understanding where i need to save values from json.

I decided to just save them to vim variables, g:cmake_configuration_name for example. But i didn't find way to do this. I read help python few times already and tried to google it, no luck.

Maybe that's just bad way to do this, so i need help with this too.

1 Answer 1

2

For a vim plugin with python, you may first import the vim module (see :h python-vim).

import vim

Then there is vim.command(cmd) to execute an Ex command, so in your case

vim.command('let g:cmake_configuration_name=' + python_variable)

should do the job.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.