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 Answers1

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.

perelo
  • 461
  • 4
  • 8
  • This I imagine would be very inefficient for large list like objects. Is there a better way? Edit: Yes, there is. See https://vi.stackexchange.com/a/20404/33130 – tejasvi88 Feb 06 '21 at 13:02