summaryrefslogtreecommitdiffstats
path: root/runtime/ftplugin
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-01-11 19:40:15 +0100
committerBram Moolenaar <Bram@vim.org>2021-01-11 19:40:15 +0100
commit82be4849eed0b8fbee45bc8da99b685ec89af59a (patch)
tree23edae21e79564327a052e2a6204f569cb602f30 /runtime/ftplugin
parent48e11c10548782f573411b6302f77adb69c40401 (diff)
Update runtime files.
Diffstat (limited to 'runtime/ftplugin')
-rw-r--r--runtime/ftplugin/erlang.vim112
-rw-r--r--runtime/ftplugin/fstab.vim4
-rw-r--r--runtime/ftplugin/swift.vim11
-rw-r--r--runtime/ftplugin/vim.vim19
4 files changed, 78 insertions, 68 deletions
diff --git a/runtime/ftplugin/erlang.vim b/runtime/ftplugin/erlang.vim
index ece11d7249..c775247f51 100644
--- a/runtime/ftplugin/erlang.vim
+++ b/runtime/ftplugin/erlang.vim
@@ -1,87 +1,83 @@
" Vim ftplugin file
-" Language: Erlang
+" Language: Erlang (http://www.erlang.org)
+" Maintainer: Csaba Hoch <csaba.hoch@gmail.com>
" Author: Oscar Hellström <oscar@oscarh.net>
" Contributors: Ricardo Catalinas Jiménez <jimenezrick@gmail.com>
" Eduardo Lopez (http://github.com/tapichu)
+" Arvid Bjurklint (http://github.com/slarwise)
+" Last Update: 2021-Jan-08
" License: Vim license
-" Version: 2012/01/25
+" URL: https://github.com/vim-erlang/vim-erlang-runtime
if exists('b:did_ftplugin')
- finish
-else
- let b:did_ftplugin = 1
-endif
-
-if exists('s:did_function_definitions')
- call s:SetErlangOptions()
- finish
-else
- let s:did_function_definitions = 1
+ finish
endif
+let b:did_ftplugin = 1
let s:cpo_save = &cpo
set cpo&vim
-if !exists('g:erlang_keywordprg')
- let g:erlang_keywordprg = 'erl -man'
-endif
+let &l:keywordprg = get(g:, 'erlang_keywordprg', 'erl -man')
-if !exists('g:erlang_folding')
- let g:erlang_folding = 0
+if get(g:, 'erlang_folding', 0)
+ setlocal foldmethod=expr
+ setlocal foldexpr=GetErlangFold(v:lnum)
+ setlocal foldtext=ErlangFoldText()
endif
-let s:erlang_fun_begin = '^\a\w*(.*$'
-let s:erlang_fun_end = '^[^%]*\.\s*\(%.*\)\?$'
-
-function s:SetErlangOptions()
- if g:erlang_folding
- setlocal foldmethod=expr
- setlocal foldexpr=GetErlangFold(v:lnum)
- setlocal foldtext=ErlangFoldText()
- endif
+setlocal comments=:%%%,:%%,:%
+setlocal commentstring=%%s
- setlocal comments=:%%%,:%%,:%
- setlocal commentstring=%%s
+setlocal formatoptions+=ro
- setlocal formatoptions+=ro
- let &l:keywordprg = g:erlang_keywordprg
-endfunction
+setlocal suffixesadd=.erl,.hrl
-function GetErlangFold(lnum)
- let lnum = a:lnum
- let line = getline(lnum)
+let &l:include = '^\s*-\%(include\|include_lib\)\s*("\zs\f*\ze")'
+let &l:define = '^\s*-\%(define\|record\|type\|opaque\)'
- if line =~ s:erlang_fun_end
- return '<1'
- endif
+let s:erlang_fun_begin = '^\a\w*(.*$'
+let s:erlang_fun_end = '^[^%]*\.\s*\(%.*\)\?$'
- if line =~ s:erlang_fun_begin && foldlevel(lnum - 1) == 1
- return '1'
- endif
+if !exists('*GetErlangFold')
+ function GetErlangFold(lnum)
+ let lnum = a:lnum
+ let line = getline(lnum)
- if line =~ s:erlang_fun_begin
- return '>1'
- endif
+ if line =~ s:erlang_fun_end
+ return '<1'
+ endif
- return '='
-endfunction
+ if line =~ s:erlang_fun_begin && foldlevel(lnum - 1) == 1
+ return '1'
+ endif
-function ErlangFoldText()
- let line = getline(v:foldstart)
- let foldlen = v:foldend - v:foldstart + 1
- let lines = ' ' . foldlen . ' lines: ' . substitute(line, "[\ \t]*", '', '')
- if foldlen < 10
- let lines = ' ' . lines
- endif
- let retval = '+' . v:folddashes . lines
+ if line =~ s:erlang_fun_begin
+ return '>1'
+ endif
- return retval
-endfunction
+ return '='
+ endfunction
+endif
-call s:SetErlangOptions()
+if !exists('*ErlangFoldText')
+ function ErlangFoldText()
+ let line = getline(v:foldstart)
+ let foldlen = v:foldend - v:foldstart + 1
+ let lines = ' ' . foldlen . ' lines: ' . substitute(line, "[\ \t]*", '', '')
+ if foldlen < 10
+ let lines = ' ' . lines
+ endif
+ let retval = '+' . v:folddashes . lines
+
+ return retval
+ endfunction
+endif
-let b:undo_ftplugin = "setlocal foldmethod< foldexpr< foldtext<"
- \ . " comments< commentstring< formatoptions<"
+let b:undo_ftplugin = "setlocal keywordprg< foldmethod< foldexpr< foldtext<"
+ \ . " comments< commentstring< formatoptions< suffixesadd< include<"
+ \ . " define<"
let &cpo = s:cpo_save
unlet s:cpo_save
+
+" vim: sw=2 et
diff --git a/runtime/ftplugin/fstab.vim b/runtime/ftplugin/fstab.vim
index 3e7af9fb30..99805322cd 100644
--- a/runtime/ftplugin/fstab.vim
+++ b/runtime/ftplugin/fstab.vim
@@ -2,7 +2,7 @@
" Language: fstab file
" Maintainer: Radu Dineiu <radu.dineiu@gmail.com>
" URL: https://raw.github.com/rid9/vim-fstab/master/ftplugin/fstab.vim
-" Last Change: 2020 Dec 29
+" Last Change: 2021 Jan 02
" Version: 1.0
"
" Credits:
@@ -16,4 +16,4 @@ let b:did_ftplugin = 1
setlocal commentstring=#%s
let b:undo_ftplugin = "setlocal commentstring<"
-" vim: ts=8 ft=vim \ No newline at end of file
+" vim: ts=8 ft=vim
diff --git a/runtime/ftplugin/swift.vim b/runtime/ftplugin/swift.vim
index 55678f8bfc..a86b782c22 100644
--- a/runtime/ftplugin/swift.vim
+++ b/runtime/ftplugin/swift.vim
@@ -6,7 +6,16 @@
" See https://swift.org/LICENSE.txt for license information
" See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
"
-" Vim maintainer: Emir SARI <bitigchi@me.com>
+" Vim maintainer: Emir SARI <bitigchi@me.com>
+" Last Change: 2021 Jan 08
+
+" 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
diff --git a/runtime/ftplugin/vim.vim b/runtime/ftplugin/vim.vim
index b87e144220..3307de5410 100644
--- a/runtime/ftplugin/vim.vim
+++ b/runtime/ftplugin/vim.vim
@@ -1,7 +1,7 @@
" Vim filetype plugin
" Language: Vim
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2020 Aug 14
+" Last Change: 2021 Jan 05
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
@@ -48,18 +48,23 @@ setlocal isk+=#
" Use :help to lookup the keyword under the cursor with K.
setlocal keywordprg=:help
-" Set 'comments' to format dashed lists in comments
-" Avoid that #{} starts a comment.
-setlocal com=sO:\"\ -,mO:\"\ \ ,sO:#\ -,mO:#\ \ ,eO:##,:\",b:#
+if "\n" .. getline(1, 10)->join("\n") =~# '\n\s*vim9\%[script]\>'
+ " Set 'comments' to format dashed lists in comments
+ setlocal com=sO:#\ -,mO:#\ \ ,eO:##,:#
+ " Comments start with a double quote in a legacy script;
+ " with # in a Vim9 script
+ setlocal commentstring=\"%s
+else
+ setlocal com=sO:\"\ -,mO:\"\ \ ,:\"
+ setlocal commentstring=#%s
+endif
+
" Format comments to be up to 78 characters long
if &tw == 0
setlocal tw=78
endif
-" Comments start with a double quote; in Vim9 script # would also work
-setlocal commentstring=\"%s
-
if !exists("no_plugin_maps") && !exists("no_vim_maps")
let b:did_add_maps = 1