2

I want vim to highlight Swift syntax. The following is what I did. Firstly, I downloaded the Swift Language Repo:

git clone https://github.com/keith/swift.vim

to

~/.vim/bundle/

Then I added the following line to my .vimrc file:

set rtp+=~/.vim/bundle/swift.vim

I tried to add path to swift.vim like this in .vimrc

Plugin '~/.vim/bundle/swift.vim'

But it does not work. So, question:

How to make vim highlight Swift code properly?

NOTE: I also use YouCompleteMe plugin.

0

That 'runtimepath' modification looks right to me. If you have :filetype on in your ~/.vimrc, it should load the filetype detection from ~/.vim/bundle/swift.vim/ftdetect/swift.vim. You can check :scriptnames output for it.

To manually enable Swift syntax, :setfiletype swift should do it.

The Plugin command requires the corresponding plugin manager. As you've manually cloned the Git repository already, this is not necessary. It basically performs the same 'runtimepath' manipulations, and often also checks for plugin updates for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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