diff options
Diffstat (limited to 'runtime/ftplugin')
-rw-r--r-- | runtime/ftplugin/abaqus.vim | 48 | ||||
-rw-r--r-- | runtime/ftplugin/elixir.vim | 20 | ||||
-rw-r--r-- | runtime/ftplugin/php.vim | 151 | ||||
-rw-r--r-- | runtime/ftplugin/vim.vim | 4 |
4 files changed, 155 insertions, 68 deletions
diff --git a/runtime/ftplugin/abaqus.vim b/runtime/ftplugin/abaqus.vim index 5ce565ef3f..3faeff621a 100644 --- a/runtime/ftplugin/abaqus.vim +++ b/runtime/ftplugin/abaqus.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: Abaqus finite element input file (www.abaqus.com) -" Maintainer: Carl Osterwisch <osterwischc@asme.org> -" Last Change: 2022 May 09 +" Maintainer: Carl Osterwisch <costerwi@gmail.com> +" Last Change: 2022 Aug 03 " Only do this when not done yet for this buffer if exists("b:did_ftplugin") | finish | endif @@ -46,7 +46,7 @@ if has("folding") endif " Set the file browse filter (currently only supported under Win32 gui) -if has("gui_win32") && !exists("b:browsefilter") +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") let b:browsefilter = "Abaqus Input Files (*.inp *.inc)\t*.inp;*.inc\n" . \ "Abaqus Results (*.dat)\t*.dat\n" . \ "Abaqus Messages (*.pre *.msg *.sta)\t*.pre;*.msg;*.sta\n" . @@ -57,7 +57,7 @@ endif " Define patterns for the matchit plugin if exists("loaded_matchit") && !exists("b:match_words") let b:match_ignorecase = 1 - let b:match_words = + let b:match_words = \ '\*part:\*end\s*part,' . \ '\*assembly:\*end\s*assembly,' . \ '\*instance:\*end\s*instance,' . @@ -65,25 +65,27 @@ if exists("loaded_matchit") && !exists("b:match_words") let b:undo_ftplugin .= "|unlet! b:match_ignorecase b:match_words" endif -" Define keys used to move [count] keywords backward or forward. -noremap <silent><buffer> [[ ?^\*\a<CR>:nohlsearch<CR> -noremap <silent><buffer> ]] /^\*\a<CR>:nohlsearch<CR> - -" Define key to toggle commenting of the current line or range -noremap <silent><buffer> <LocalLeader><LocalLeader> - \ :call <SID>Abaqus_ToggleComment()<CR>j -function! <SID>Abaqus_ToggleComment() range - if strpart(getline(a:firstline), 0, 2) == "**" - " Un-comment all lines in range - silent execute a:firstline . ',' . a:lastline . 's/^\*\*//' - else - " Comment all lines in range - silent execute a:firstline . ',' . a:lastline . 's/^/**/' - endif -endfunction - -let b:undo_ftplugin .= "|unmap <buffer> [[|unmap <buffer> ]]" - \ . "|unmap <buffer> <LocalLeader><LocalLeader>" +if !exists("no_plugin_maps") && !exists("no_abaqus_maps") + " Define keys used to move [count] keywords backward or forward. + noremap <silent><buffer> [[ ?^\*\a<CR>:nohlsearch<CR> + noremap <silent><buffer> ]] /^\*\a<CR>:nohlsearch<CR> + + " Define key to toggle commenting of the current line or range + noremap <silent><buffer> <LocalLeader><LocalLeader> + \ :call <SID>Abaqus_ToggleComment()<CR>j + function! <SID>Abaqus_ToggleComment() range + if strpart(getline(a:firstline), 0, 2) == "**" + " Un-comment all lines in range + silent execute a:firstline . ',' . a:lastline . 's/^\*\*//' + else + " Comment all lines in range + silent execute a:firstline . ',' . a:lastline . 's/^/**/' + endif + endfunction + + let b:undo_ftplugin .= "|unmap <buffer> [[|unmap <buffer> ]]" + \ . "|unmap <buffer> <LocalLeader><LocalLeader>" +endif " Undo must be done in nocompatible mode for <LocalLeader>. let b:undo_ftplugin = "let b:cpo_save = &cpoptions|" diff --git a/runtime/ftplugin/elixir.vim b/runtime/ftplugin/elixir.vim index 3b38051d08..c423c2acb7 100644 --- a/runtime/ftplugin/elixir.vim +++ b/runtime/ftplugin/elixir.vim @@ -1,11 +1,29 @@ " Elixir filetype plugin " Language: Elixir " Maintainer: Mitchell Hanberg <vimNOSPAM@mitchellhanberg.com> -" Last Change: 2022 Apr 20 +" Last Change: 2022 August 10 if exists("b:did_ftplugin") finish endif let b:did_ftplugin = 1 +let s:save_cpo = &cpo +set cpo&vim + +" Matchit support +if exists('loaded_matchit') && !exists('b:match_words') + let b:match_ignorecase = 0 + + let b:match_words = '\:\@<!\<\%(do\|fn\)\:\@!\>' . + \ ':' . + \ '\<\%(else\|catch\|after\|rescue\)\:\@!\>' . + \ ':' . + \ '\:\@<!\<end\>' . + \ ',{:},\[:\],(:)' +endif + setlocal commentstring=#\ %s + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/runtime/ftplugin/php.vim b/runtime/ftplugin/php.vim index 2824a5853b..540653e030 100644 --- a/runtime/ftplugin/php.vim +++ b/runtime/ftplugin/php.vim @@ -1,12 +1,12 @@ " Vim filetype plugin file -" Language: php -" -" This runtime file is looking for a new maintainer. -" -" Former maintainer: Dan Sharp -" Last Changed: 20 Jan 2009 +" Language: PHP +" Maintainer: Doug Kearns <dougkearns@gmail.com> +" Previous Maintainer: Dan Sharp +" Last Changed: 2022 Jul 20 -if exists("b:did_ftplugin") | finish | endif +if exists("b:did_ftplugin") + finish +endif " Make sure the continuation lines below do not cause problems in " compatibility mode. @@ -15,8 +15,8 @@ set cpo&vim " Define some defaults in case the included ftplugins don't set them. let s:undo_ftplugin = "" -let s:browsefilter = "HTML Files (*.html, *.htm)\t*.html;*.htm\n" . - \ "All Files (*.*)\t*.*\n" +let s:browsefilter = "HTML Files (*.html, *.htm)\t*.html;*.htm\n" .. + \ "All Files (*.*)\t*.*\n" let s:match_words = "" runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim @@ -24,63 +24,130 @@ let b:did_ftplugin = 1 " Override our defaults if these were set by an included ftplugin. if exists("b:undo_ftplugin") - let s:undo_ftplugin = b:undo_ftplugin +" let b:undo_ftplugin = "setlocal comments< commentstring< formatoptions< omnifunc<" + let s:undo_ftplugin = b:undo_ftplugin endif if exists("b:browsefilter") - let s:browsefilter = b:browsefilter +" let b:undo_ftplugin ..= " | unlet! b:browsefilter b:html_set_browsefilter" + let s:browsefilter = b:browsefilter endif if exists("b:match_words") - let s:match_words = b:match_words +" let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words b:html_set_match_words" + let s:match_words = b:match_words endif if exists("b:match_skip") - unlet b:match_skip + unlet b:match_skip endif -" Change the :browse e filter to primarily show PHP-related files. -if has("gui_win32") - let b:browsefilter="PHP Files (*.php)\t*.php\n" . s:browsefilter +setlocal comments=s1:/*,mb:*,ex:*/,://,:# +setlocal commentstring=/*%s*/ +setlocal formatoptions+=l formatoptions-=t + +if get(g:, "php_autocomment", 1) + setlocal formatoptions+=croq + " NOTE: set g:PHP_autoformatcomment = 0 to prevent the indent plugin from + " overriding this 'comments' value + setlocal comments-=:# + " space after # comments to exclude attributes + setlocal comments+=b:# endif +if exists('&omnifunc') + setlocal omnifunc=phpcomplete#CompletePHP +endif + +setlocal suffixesadd=.php + " ### " Provided by Mikolaj Machowski <mikmach at wp dot pl> setlocal include=\\\(require\\\|include\\\)\\\(_once\\\)\\\? " Disabled changing 'iskeyword', it breaks a command such as "*" " setlocal iskeyword+=$ -if exists("loaded_matchit") - let b:match_words = '<?php:?>,\<switch\>:\<endswitch\>,' . - \ '\<if\>:\<elseif\>:\<else\>:\<endif\>,' . - \ '\<while\>:\<endwhile\>,' . - \ '\<do\>:\<while\>,' . - \ '\<for\>:\<endfor\>,' . - \ '\<foreach\>:\<endforeach\>,' . - \ '(:),[:],{:},' . - \ s:match_words +let b:undo_ftplugin = "setlocal include< suffixesadd<" + +if exists("loaded_matchit") && exists("b:html_set_match_words") + let b:match_ignorecase = 1 + let b:match_words = 'PhpMatchWords()' + + if !exists("*PhpMatchWords") + function! PhpMatchWords() + " The PHP syntax file uses the Delimiter syntax group for the phpRegion + " matchgroups, without a "php" prefix, so use the stack to test for the + " outer phpRegion group. This also means the closing ?> tag which is + " outside of the matched region just uses the Delimiter group for the + " end match. + let stack = synstack(line('.'), col('.')) + let php_region = !empty(stack) && synIDattr(stack[0], "name") =~# '\<php' + if php_region || getline(".") =~ '.\=\%.c\&?>' + let b:match_skip = "PhpMatchSkip('html')" + return '<?php\|<?=\=:?>,' .. + \ '\<if\>:\<elseif\>:\<else\>:\<endif\>,' .. + \ '\<switch\>:\<case\>:\<break\>:\<continue\>:\<endswitch\>,' .. + \ '\<while\>.\{-})\s*\::\<break\>:\<continue\>:\<endwhile\>,' .. + \ '\<do\>:\<break\>:\<continue\>:\<while\>,' .. + \ '\<for\>:\<break\>:\<continue\>:\<endfor\>,' .. + \ '\<foreach\>:\<break\>:\<continue\>:\<endforeach\>,' .. + \ '\%(<<<\s*\)\@<=''\=\(\h\w*\)''\=:^\s*\1\>' + + " TODO: these probably aren't worth adding and really need syntax support + " '<\_s*script\_s*language\_s*=\_s*[''"]\=\_s*php\_s*[''"]\=\_s*>:<\_s*\_s*/\_s*script\_s*>,' .. + " '<%:%>,' .. + else + let b:match_skip = "PhpMatchSkip('php')" + return s:match_words + endif + endfunction + endif + if !exists("*PhpMatchSkip") + function! PhpMatchSkip(skip) + let name = synIDattr(synID(line('.'), col('.'), 1), 'name') + if a:skip == "html" + " ?> in line comments will also be correctly matched as Delimiter + return name =~? 'comment\|string' || name !~? 'php\|delimiter' + else " php + return name =~? 'comment\|string\|php' + endif + endfunction + endif + let b:undo_ftplugin ..= " | unlet! b:match_skip" endif " ### -if exists('&omnifunc') - setlocal omnifunc=phpcomplete#CompletePHP +" Change the :browse e filter to primarily show PHP-related files. +if (has("gui_win32") || has("gui_gtk")) && exists("b:html_set_browsefilter") + let b:browsefilter = "PHP Files (*.php)\t*.php\n" .. + \ "PHP Test Files (*.phpt)\t*.phpt\n" .. + \ s:browsefilter endif -" Section jumping: [[ and ]] provided by Antony Scriven <adscriven at gmail dot com> -let s:function = '\(abstract\s\+\|final\s\+\|private\s\+\|protected\s\+\|public\s\+\|static\s\+\)*function' -let s:class = '\(abstract\s\+\|final\s\+\)*class' -let s:interface = 'interface' -let s:section = '\(.*\%#\)\@!\_^\s*\zs\('.s:function.'\|'.s:class.'\|'.s:interface.'\)' -exe 'nno <buffer> <silent> [[ ?' . escape(s:section, '|') . '?<CR>:nohls<CR>' -exe 'nno <buffer> <silent> ]] /' . escape(s:section, '|') . '/<CR>:nohls<CR>' -exe 'ono <buffer> <silent> [[ ?' . escape(s:section, '|') . '?<CR>:nohls<CR>' -exe 'ono <buffer> <silent> ]] /' . escape(s:section, '|') . '/<CR>:nohls<CR>' +if !exists("no_plugin_maps") && !exists("no_php_maps") + " Section jumping: [[ and ]] provided by Antony Scriven <adscriven at gmail dot com> + let s:function = '\%(abstract\s\+\|final\s\+\|private\s\+\|protected\s\+\|public\s\+\|static\s\+\)*function' + let s:class = '\%(abstract\s\+\|final\s\+\)*class' + let s:section = escape('^\s*\zs\%(' .. s:function .. '\|' .. s:class .. '\|interface\|trait\|enum\)\>', "|") -setlocal suffixesadd=.php -setlocal commentstring=/*%s*/ + function! s:Jump(pattern, count, flags) + normal! m' + for i in range(a:count) + if !search(a:pattern, a:flags) + break + endif + endfor + endfunction -" Undo the stuff we changed. -let b:undo_ftplugin = "setlocal suffixesadd< commentstring< include< omnifunc<" . - \ " | unlet! b:browsefilter b:match_words | " . - \ s:undo_ftplugin + for mode in ["n", "o", "x"] + exe mode .. "noremap <buffer> <silent> ]] <Cmd>call <SID>Jump('" .. s:section .. "', v:count1, 'W')<CR>" + exe mode .. "noremap <buffer> <silent> [[ <Cmd>call <SID>Jump('" .. s:section .. "', v:count1, 'bW')<CR>" + let b:undo_ftplugin ..= " | sil! exe '" .. mode .. "unmap <buffer> ]]'" .. + \ " | sil! exe '" .. mode .. "unmap <buffer> [['" + endfor +endif + +let b:undo_ftplugin ..= " | " .. s:undo_ftplugin " Restore the saved compatibility options. let &cpo = s:keepcpo unlet s:keepcpo + +" vim: nowrap sw=2 sts=2 ts=8 noet: diff --git a/runtime/ftplugin/vim.vim b/runtime/ftplugin/vim.vim index 64b64b45e3..772899cb42 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: 2021 Apr 11 +" Last Change: 2022 Aug 4 " Only do this when not done yet for this buffer if exists("b:did_ftplugin") @@ -109,7 +109,7 @@ if exists("loaded_matchit") " - set spl=de,en " - au! FileType javascript syntax region foldBraces start=/{/ end=/}/ … let b:match_skip = 'synIDattr(synID(line("."),col("."),1),"name") - \ =~? "comment\\|string\\|vimSynReg\\|vimSet"' + \ =~? "comment\\|string\\|vimLetHereDoc\\|vimSynReg\\|vimSet"' endif let &cpo = s:cpo_save |