Mercurial > vim
annotate runtime/ftplugin/abaqus.vim @ 34134:8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Commit: https://github.com/vim/vim/commit/93197fde0f1db09b1e495cf3eb14a8f42c318b80
Author: Doug Kearns <dougkearns@gmail.com>
Date: Sun Jan 14 20:59:02 2024 +0100
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Problem: The "*.*" browsefilter pattern only matches all files on
Windows (Daryl Lee)
Solution: Use "*" to filter on all platforms but keep "*.*" as the label
text on Windows. (Fixes #12685, Doug Kearns)
The *.* browsefilter pattern used to match "All Files" on Windows is a
legacy of the DOS 8.3 filename wildcard matching algorithm. For reasons
of backward compatibility this still works on Windows to match all
files, even those without an extension.
However, this pattern only matches filenames containing a dot on other
platforms. This often makes files without an extension difficult to
access from the file dialog, e.g., "Makefile"
On Windows it is still standard practice to use "*.*" for the filter
label so ftplugins should use "All Files (*.*)" on Windows and "All
Files (*)" on other platforms. This matches Vim's default browsefilter
values.
This commit also normalises the browsefilter conditional test to check
for the Win32 and GTK GUI features and an unset b:browsefilter.
closes: #12759
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 14 Jan 2024 21:15:03 +0100 |
parents | 3295247d97a5 |
children | 7c7432a53a6c |
rev | line source |
---|---|
7 | 1 " Vim filetype plugin file |
2 " Language: Abaqus finite element input file (www.abaqus.com) | |
29659 | 3 " Maintainer: Carl Osterwisch <costerwi@gmail.com> |
30875 | 4 " Last Change: 2022 Oct 08 |
34134
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
30875
diff
changeset
|
5 " 2024 Jan 14 by Vim Project (browsefilter) |
7 | 6 |
7 " Only do this when not done yet for this buffer | |
8 if exists("b:did_ftplugin") | finish | endif | |
9 | |
10 " Don't load another plugin for this buffer | |
11 let b:did_ftplugin = 1 | |
12 | |
13 " Save the compatibility options and temporarily switch to vim defaults | |
14 let s:cpo_save = &cpoptions | |
15 set cpoptions&vim | |
16 | |
17 " Set the format of the include file specification for Abaqus | |
18 " Used in :check gf ^wf [i and other commands | |
19 setlocal include=\\<\\cINPUT\\s*= | |
20 | |
21 " Remove characters up to the first = when evaluating filenames | |
22 setlocal includeexpr=substitute(v:fname,'.\\{-}=','','') | |
23 | |
15 | 24 " Remove comma from valid filename characters since it is used to |
25 " separate keyword parameters | |
26 setlocal isfname-=, | |
27 | |
7 | 28 " Define format of comment lines (see 'formatoptions' for uses) |
29 setlocal comments=:** | |
30 setlocal commentstring=**%s | |
31 | |
32 " Definitions start with a * and assign a NAME, NSET, or ELSET | |
33 " Used in [d ^wd and other commands | |
34 setlocal define=^\\*\\a.*\\c\\(NAME\\\|NSET\\\|ELSET\\)\\s*= | |
35 | |
36 " Abaqus keywords and identifiers may include a - character | |
37 setlocal iskeyword+=- | |
38 | |
2034 | 39 let b:undo_ftplugin = "setlocal include< includeexpr< isfname<" |
40 \ . " comments< commentstring< define< iskeyword<" | |
41 | |
42 if has("folding") | |
43 " Fold all lines that do not begin with * | |
44 setlocal foldexpr=getline(v:lnum)[0]!=\"\*\" | |
45 setlocal foldmethod=expr | |
46 let b:undo_ftplugin .= " foldexpr< foldmethod<" | |
47 endif | |
48 | |
7 | 49 " Set the file browse filter (currently only supported under Win32 gui) |
29659 | 50 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") |
7 | 51 let b:browsefilter = "Abaqus Input Files (*.inp *.inc)\t*.inp;*.inc\n" . |
52 \ "Abaqus Results (*.dat)\t*.dat\n" . | |
34134
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
30875
diff
changeset
|
53 \ "Abaqus Messages (*.pre, *.msg, *.sta)\t*.pre;*.msg;*.sta\n" |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
30875
diff
changeset
|
54 if has("win32") |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
30875
diff
changeset
|
55 let b:browsefilter .= "All Files (*.*)\t*\n" |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
30875
diff
changeset
|
56 else |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
30875
diff
changeset
|
57 let b:browsefilter .= "All Files (*)\t*\n" |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
30875
diff
changeset
|
58 endif |
3496
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
3410
diff
changeset
|
59 let b:undo_ftplugin .= "|unlet! b:browsefilter" |
7 | 60 endif |
61 | |
2034 | 62 " Define patterns for the matchit plugin |
63 if exists("loaded_matchit") && !exists("b:match_words") | |
64 let b:match_ignorecase = 1 | |
29659 | 65 let b:match_words = |
2034 | 66 \ '\*part:\*end\s*part,' . |
67 \ '\*assembly:\*end\s*assembly,' . | |
68 \ '\*instance:\*end\s*instance,' . | |
69 \ '\*step:\*end\s*step' | |
3496
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
3410
diff
changeset
|
70 let b:undo_ftplugin .= "|unlet! b:match_ignorecase b:match_words" |
2034 | 71 endif |
72 | |
29659 | 73 if !exists("no_plugin_maps") && !exists("no_abaqus_maps") |
30875 | 74 " Map [[ and ]] keys to move [count] keywords backward or forward |
75 nnoremap <silent><buffer> ]] :call <SID>Abaqus_NextKeyword(1)<CR> | |
76 nnoremap <silent><buffer> [[ :call <SID>Abaqus_NextKeyword(-1)<CR> | |
77 function! <SID>Abaqus_NextKeyword(direction) | |
78 .mark ' | |
79 if a:direction < 0 | |
80 let flags = 'b' | |
81 else | |
82 let flags = '' | |
83 endif | |
84 let l:count = abs(a:direction) * v:count1 | |
85 while l:count > 0 && search("^\\*\\a", flags) | |
86 let l:count -= 1 | |
87 endwhile | |
88 endfunction | |
7 | 89 |
30875 | 90 " Map \\ to toggle commenting of the current line or range |
29659 | 91 noremap <silent><buffer> <LocalLeader><LocalLeader> |
92 \ :call <SID>Abaqus_ToggleComment()<CR>j | |
93 function! <SID>Abaqus_ToggleComment() range | |
30875 | 94 if strpart(getline(a:firstline), 0, 2) == "**" |
95 " Un-comment all lines in range | |
96 silent execute a:firstline . ',' . a:lastline . 's/^\*\*//' | |
97 else | |
98 " Comment all lines in range | |
99 silent execute a:firstline . ',' . a:lastline . 's/^/**/' | |
100 endif | |
101 endfunction | |
102 | |
103 " Map \s to swap first two comma separated fields | |
104 noremap <silent><buffer> <LocalLeader>s :call <SID>Abaqus_Swap()<CR> | |
105 function! <SID>Abaqus_Swap() range | |
106 silent execute a:firstline . ',' . a:lastline . 's/\([^*,]*\),\([^,]*\)/\2,\1/' | |
29659 | 107 endfunction |
7 | 108 |
29659 | 109 let b:undo_ftplugin .= "|unmap <buffer> [[|unmap <buffer> ]]" |
110 \ . "|unmap <buffer> <LocalLeader><LocalLeader>" | |
30875 | 111 \ . "|unmap <buffer> <LocalLeader>s" |
29659 | 112 endif |
2034 | 113 |
3496
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
3410
diff
changeset
|
114 " Undo must be done in nocompatible mode for <LocalLeader>. |
28808
0f0fed554cdc
Update runtime files, translations
Bram Moolenaar <Bram@vim.org>
parents:
3496
diff
changeset
|
115 let b:undo_ftplugin = "let b:cpo_save = &cpoptions|" |
3496
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
3410
diff
changeset
|
116 \ . "set cpoptions&vim|" |
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
3410
diff
changeset
|
117 \ . b:undo_ftplugin |
28808
0f0fed554cdc
Update runtime files, translations
Bram Moolenaar <Bram@vim.org>
parents:
3496
diff
changeset
|
118 \ . "|let &cpoptions = b:cpo_save" |
0f0fed554cdc
Update runtime files, translations
Bram Moolenaar <Bram@vim.org>
parents:
3496
diff
changeset
|
119 \ . "|unlet b:cpo_save" |
3496
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
3410
diff
changeset
|
120 |
7 | 121 " Restore saved compatibility options |
122 let &cpoptions = s:cpo_save | |
3410
94601b379f38
Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
123 unlet s:cpo_save |