diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-07-22 23:57:15 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-07-22 23:57:15 +1200 |
commit | aa2d8d9c3a6b5009ababe42a0210fd5389a95d23 (patch) | |
tree | 4dbda1822b29d755bf45b24b650860bf308aa1ce /autoload | |
parent | Add plugin in current state (diff) | |
download | vim-alternate-filetypes-aa2d8d9c3a6b5009ababe42a0210fd5389a95d23.tar.gz vim-alternate-filetypes-aa2d8d9c3a6b5009ababe42a0210fd5389a95d23.zip |
Add spacing and comments
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/alternate_filetypes.vim | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/autoload/alternate_filetypes.vim b/autoload/alternate_filetypes.vim index 08ac88d..4bf16f5 100644 --- a/autoload/alternate_filetypes.vim +++ b/autoload/alternate_filetypes.vim @@ -1,7 +1,18 @@ +" Switch to next alternate filetype if specified function! alternate_filetypes#() abort + + " We only have anything to do if there's a list of filetypes ready for us if exists('b:alternate_filetypes') + + " Get the index of the current filetype in the list of filetypes let filetypes = b:alternate_filetypes let index = index(filetypes, &filetype) + + " If the current filetype is in the list of related filetypes, switch to + " the next filetype, or the first filetype if the current filetype is the + " last in the list; if it's not in there at all, clear the list, as + " something has gone wrong + " if index >= 0 let &filetype = filetypes[ \ (index + 1) % len(filetypes) @@ -10,4 +21,5 @@ function! alternate_filetypes#() abort unlet b:alternate_filetypes endif endif + endfunction |