Files
swift-mirror/utils/vim/ftplugin/swift.vim
Akshay Hegde 6c38a6b82a Conform to existing conventions for Vim ftplugin
This commit adds standard conventions for Vim filetype plugins:

- Allows users to opt out of using the provided ftplugin file, if they
  choose to install and use another set of runtime files for Swift
  (which offers its own version of ftplugin for Swift), It also prevents
  this ftplugin file from being sourced again if a ftplugin file for
  Swift was already sourced. Vim's documentation on this recommends
  offering users this option as well, under the "DISABLING" section
  of `:help write-filetype-plugin`).

- Adds the `b:undo_ftplugin` buffer local variable, which is used to
  undo the filetype settings when the `:setfiletype` command is used
  (See :help `undo_ftplugin`). Also prefer using the full names for Vim
  settings instead of short ones as they are more readable.

The above conventions are in place in many of the ftplugin files
shipped with Vim, so they can be used as a reference, as well.
2020-12-24 01:01:04 -08:00

22 lines
675 B
VimL

" This source file is part of the Swift.org open source project
"
" Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
" Licensed under Apache License v2.0 with Runtime Library Exception
"
" See https://swift.org/LICENSE.txt for license information
" See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1
let b:undo_ftplugin = "setlocal comments< expandtab< tabstop< shiftwidth< smartindent<"
setlocal comments=s1:/*,mb:*,ex:*/,:///,://
setlocal expandtab
setlocal tabstop=2
setlocal shiftwidth=2
setlocal smartindent