Settings use special syntax. The values you set to them are not really expressions. This gives them the benefit that you don't need quotes or escaping, but they're less flexible when it comes to using with programmatic expressions.
One way to avoid this that's common for other kinds of Vim syntax is the execute
command (:help :execute
):
exe 'set backupdir = ' . g:base_data_folder . '/backup'
That said, for settings, there's a dedicated syntax (:help :let-&
) that I'd recommend instead:
let &backupdir = g:base_data_folder . '/backup'
Basically, this allows settings to be treated as "variables" of sorts. I recommend you read all the docs about "let" to get a better understanding of how this works, for other special cases as well.