Vim: a good way to configure makeprg = xcodebuild?

What is the best way to install makeprg=xcodebuildin vim?

I use the filetype line in files to indicate that the file is objective-c (unlike matlab or cpp), setting the first line of my file to:

/* vim: set filetype=objc : */

and having this in vimrc:

set modelines=1

I would probably want to use :makto run this command in the current directory:

xcodebuild -activetarget -activeconfiguration

I usually set manually xcodebuildhow makeprgso that I can do :makfor compilation.

I am always in the root directory of the project where I have the files .xcodeproj, so I donโ€™t have to worry about finding the project files.

What is the best way to customize makeprg? Ftplugin? Compilerplugin?

Any ideas appreciated.

+3
2

ftplugin, . .vim/ftplugin/objc.vim:

set makeprg=xcodebuild\ -activetarget\ -activeconfiguration

, Vim .m Objective-C, #include, #import /* . ftdetect, : .vim/ftdetect/objc.vim:

autocmd BufNewFile,BufReadPost *.m set filetype=objc
+1

.vimrc - :

if len(glob( getcwd() . '/*.xcodeproj' )) > 0
    let &makeprg = 'xcodebuild'
endif

, vim *.xcodeproj, makeprg xcodebuild.

+1

Source: https://habr.com/ru/post/1724739/


All Articles