Merge remote-tracking branch 'vim/master'

This commit is contained in:
Yee Cheng Chin
2023-09-29 15:31:29 -07:00
65 changed files with 6190 additions and 2960 deletions
+1 -1
View File
@@ -55,6 +55,6 @@ runtime:
termdebug: runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
netrw:
plugin-netrw:
- any: ['runtime/plugin/netrwPlugin.vim']
- any: ['runtime/autoload/netrw*']
+13 -13
View File
@@ -6832,55 +6832,55 @@ printf({fmt}, {expr1} ...) *printf()*
echo printf("%1$*2$.*3$f", 1.4142135, 6, 2)
< 1.41
*E1400*
*E1500*
You cannot mix positional and non-positional arguments: >
echo printf("%s%1$s", "One", "Two")
< E1400: Cannot mix positional and non-positional
< E1500: Cannot mix positional and non-positional
arguments: %s%1$s
*E1401*
*E1501*
You cannot skip a positional argument in a format string: >
echo printf("%3$s%1$s", "One", "Two", "Three")
< E1401: format argument 2 unused in $-style
< E1501: format argument 2 unused in $-style
format: %3$s%1$s
*E1402*
*E1502*
You can re-use a [field-width] (or [precision]) argument: >
echo printf("%1$d at width %2$d is: %01$*2$d", 1, 2)
< 1 at width 2 is: 01
However, you can't use it as a different type: >
echo printf("%1$d at width %2$ld is: %01$*2$d", 1, 2)
< E1402: Positional argument 2 used as field
< E1502: Positional argument 2 used as field
width reused as different type: long int/int
*E1403*
*E1503*
When a positional argument is used, but not the correct number
or arguments is given, an error is raised: >
echo printf("%1$d at width %2$d is: %01$*2$.*3$d", 1, 2)
< E1403: Positional argument 3 out of bounds:
< E1503: Positional argument 3 out of bounds:
%1$d at width %2$d is: %01$*2$.*3$d
Only the first error is reported: >
echo printf("%01$*2$.*3$d %4$d", 1, 2)
< E1403: Positional argument 3 out of bounds:
< E1503: Positional argument 3 out of bounds:
%01$*2$.*3$d %4$d
*E1404*
*E1504*
A positional argument can be used more than once: >
echo printf("%1$s %2$s %1$s", "One", "Two")
< One Two One
However, you can't use a different type the second time: >
echo printf("%1$s %2$s %1$d", "One", "Two")
< E1404: Positional argument 1 type used
< E1504: Positional argument 1 type used
inconsistently: int/string
*E1405*
*E1505*
Various other errors that lead to a format string being
wrongly formatted lead to: >
echo printf("%1$d at width %2$d is: %01$*2$.3$d", 1, 2)
< E1405: Invalid format specifier:
< E1505: Invalid format specifier:
%1$d at width %2$d is: %01$*2$.3$d
prompt_getprompt({buf}) *prompt_getprompt()*
+15 -5
View File
@@ -517,16 +517,26 @@ example, to match only files that end in ".c": >
:e *.c$
This will not match a file ending in ".cpp". Without the "$" it does match.
The old value of an option can be obtained by hitting 'wildchar' just after
the '='. For example, typing 'wildchar' after ":set dir=" will insert the
current value of 'dir'. This overrules file name completion for the options
that take a file name.
If you would like using <S-Tab> for CTRL-P in an xterm, put this command in
your .cshrc: >
xmodmap -e "keysym Tab = Tab Find"
And this in your .vimrc: >
:cmap <Esc>[1~ <C-P>
< *complete-set-option*
When setting an option using |:set=|, the old value of an option can be
obtained by hitting 'wildchar' just after the '='. For example, typing
'wildchar' after ":set dir=" will insert the current value of 'dir'. This
overrules file name completion for the options that take a file name.
When using |:set=|, |:set+=|, or |:set^=|, string options that have
pre-defined names or syntax (e.g. 'diffopt', 'listchars') or are a list of
single-character flags (e.g. 'shortmess') will also present a list of possible
values for completion when using 'wildchar'.
When using |:set-=|, comma-separated options like 'diffopt' or 'backupdir'
will show each item separately. Flag list options like 'shortmess' will show
both the entire old value and the individual flags. Otherwise completion will
just fill in with the entire old value.
==============================================================================
3. Ex command-lines *cmdline-lines*
+4 -2
View File
@@ -1,4 +1,4 @@
*editing.txt* For Vim version 9.0. Last change: 2023 Apr 23
*editing.txt* For Vim version 9.0. Last change: 2023 Sep 22
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -385,7 +385,9 @@ as a wildcard when "[" is in the 'isfname' option. A simple way to avoid this
is to use "path\[[]abc]", this matches the file "path\[abc]".
*starstar-wildcard*
Expanding "**" is possible on Unix, Win32, macOS and a few other systems.
Expanding "**" is possible on Unix, Win32, macOS and a few other systems (but
it may depend on your 'shell' setting. It's known to work correctly for zsh; for
bash this requires at least bash version >= 4.X).
This allows searching a directory tree. This goes up to 100 directories deep.
Note there are some commands where this works slightly differently, see
|file-searching|.
+17 -9
View File
@@ -1,4 +1,4 @@
*motion.txt* For Vim version 9.0. Last change: 2023 Sep 18
*motion.txt* For Vim version 9.0. Last change: 2023 Sep 28
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -592,14 +592,16 @@ a] *v_a]* *v_a[* *a]* *a[*
a[ "a [] block", select [count] '[' ']' blocks. This
goes backwards to the [count] unclosed '[', and finds
the matching ']'. The enclosed text is selected,
including the '[' and ']'.
including the '[' and ']'. The |cpo-M| option flag
is used to handle escaped brackets.
When used in Visual mode it is made characterwise.
i] *v_i]* *v_i[* *i]* *i[*
i[ "inner [] block", select [count] '[' ']' blocks. This
goes backwards to the [count] unclosed '[', and finds
the matching ']'. The enclosed text is selected,
excluding the '[' and ']'.
excluding the '[' and ']'. The |cpo-M| option flag
is used to handle escaped brackets.
When used in Visual mode it is made characterwise.
a) *v_a)* *a)* *a(*
@@ -607,7 +609,8 @@ a( *vab* *v_ab* *v_a(* *ab*
ab "a block", select [count] blocks, from "[count] [(" to
the matching ')', including the '(' and ')' (see
|[(|). Does not include white space outside of the
parenthesis.
parenthesis. The |cpo-M| option flag is used to
handle escaped parenthesis.
When used in Visual mode it is made characterwise.
i) *v_i)* *i)* *i(*
@@ -615,19 +618,22 @@ i( *vib* *v_ib* *v_i(* *ib*
ib "inner block", select [count] blocks, from "[count] [("
to the matching ')', excluding the '(' and ')' (see
|[(|). If the cursor is not inside a () block, then
find the next "(".
find the next "(". The |cpo-M| option flag
is used to handle escaped parenthesis.
When used in Visual mode it is made characterwise.
a> *v_a>* *v_a<* *a>* *a<*
a< "a <> block", select [count] <> blocks, from the
[count]'th unmatched '<' backwards to the matching
'>', including the '<' and '>'.
'>', including the '<' and '>'. The |cpo-M| option flag
is used to handle escaped '<' and '>'.
When used in Visual mode it is made characterwise.
i> *v_i>* *v_i<* *i>* *i<*
i< "inner <> block", select [count] <> blocks, from
the [count]'th unmatched '<' backwards to the matching
'>', excluding the '<' and '>'.
'>', excluding the '<' and '>'. The |cpo-M| option flag
is used to handle escaped '<' and '>'.
When used in Visual mode it is made characterwise.
*v_at* *at*
@@ -649,14 +655,16 @@ a} *v_a}* *a}* *a{*
a{ *v_aB* *v_a{* *aB*
aB "a Block", select [count] Blocks, from "[count] [{" to
the matching '}', including the '{' and '}' (see
|[{|).
|[{|). The |cpo-M| option flag is used to handle
escaped braces.
When used in Visual mode it is made characterwise.
i} *v_i}* *i}* *i{*
i{ *v_iB* *v_i{* *iB*
iB "inner Block", select [count] Blocks, from "[count] [{"
to the matching '}', excluding the '{' and '}' (see
|[{|).
|[{|). The |cpo-M| option flag is used to handle
escaped braces.
When used in Visual mode it is made characterwise.
a" *v_aquote* *aquote*
+10 -5
View File
@@ -71,7 +71,7 @@ achieve special effects. These options come in three forms:
'ttytype'
Warning: This may have a lot of side effects.
*:set-args* *E487* *E521*
*:set-args* *:set=* *E487* *E521*
:se[t] {option}={value} or
:se[t] {option}:{value}
Set string or number option to {value}.
@@ -79,7 +79,9 @@ achieve special effects. These options come in three forms:
hex (preceded with 0x) or octal (preceded with '0').
The old value can be inserted by typing 'wildchar' (by
default this is a <Tab> or CTRL-E if 'compatible' is
set). See |cmdline-completion|.
set). Many string options with fixed syntax and names
also support completing known values. See
|cmdline-completion| and |complete-set-option|.
White space between {option} and '=' is allowed and
will be ignored. White space between '=' and {value}
is not allowed.
@@ -113,6 +115,9 @@ achieve special effects. These options come in three forms:
When the option is a list of flags, {value} must be
exactly as they appear in the option. Remove flags
one by one to avoid problems.
The individual values from a comma separated list or
list of flags can be inserted by typing 'wildchar'.
See |complete-set-option|.
Also see |:set-args| above.
The {option} arguments to ":set" may be repeated. For example: >
@@ -6886,9 +6891,9 @@ A jump table for the options with a short description can be found at |Q_op|.
*'scrollbind'* *'scb'* *'noscrollbind'* *'noscb'*
'scrollbind' 'scb' boolean (default off)
local to window
See also |scroll-binding|. When this option is set, the current
window scrolls as other scrollbind windows (windows that also have
this option set) scroll. This option is useful for viewing the
See also |scroll-binding|. When this option is set, scrolling the
current window also scrolls other scrollbind windows (windows that
also have this option set). This option is useful for viewing the
differences between two versions of a file, see 'diff'.
See |'scrollopt'| for options that determine how this option should be
interpreted.
+8 -7
View File
@@ -191,16 +191,16 @@ windows can be given this behavior by setting the (window-specific)
other 'scrollbind' windows are scrolled the same amount, if possible. The
behavior of 'scrollbind' can be modified by the 'scrollopt' option.
When using the scrollbars, the binding only happens when scrolling the window
with focus (where the cursor is). You can use this to avoid scroll-binding
for a moment without resetting options.
When using the scrollbars or the mouse wheel, the binding only happens when
scrolling the window with focus (where the cursor is). You can use this to
avoid scroll-binding for a moment without resetting options.
When a window also has the 'diff' option set, the scroll-binding uses the
differences between the two buffers to synchronize the position precisely.
Otherwise the following method is used.
*scrollbind-relative*
Each 'scrollbind' window keeps track of its "relative offset," which can be
Each 'scrollbind' window keeps track of its "relative offset", which can be
thought of as the difference between the current window's vertical scroll
position and the other window's vertical scroll position. When one of the
'scrollbind' windows is asked to vertically scroll past the beginning or end
@@ -224,9 +224,10 @@ option.
*scrollbind-quickadj*
The 'scrollbind' flag is meaningful when using keyboard commands to vertically
scroll a window, and also meaningful when using the vertical scrollbar of the
window which has the cursor focus. However, when using the vertical scrollbar
of a window which doesn't have the cursor focus, 'scrollbind' is ignored.
scroll a window, and is also meaningful when using the vertical scrollbar or
the mouse wheel in the window which has the cursor focus. However, when using
the vertical scrollbar or the mouse wheel in a window which doesn't have the
cursor focus, 'scrollbind' is ignored.
This allows quick adjustment of the relative offset of 'scrollbind' windows.
==============================================================================
+20 -6
View File
@@ -3235,6 +3235,7 @@ $quote eval.txt /*$quote*
:set-inv options.txt /*:set-inv*
:set-termcap options.txt /*:set-termcap*
:set-verbose options.txt /*:set-verbose*
:set= options.txt /*:set=*
:set^= options.txt /*:set^=*
:set_env options.txt /*:set_env*
:setf options.txt /*:setf*
@@ -4533,14 +4534,15 @@ E1380 vim9class.txt /*E1380*
E1381 vim9class.txt /*E1381*
E1382 vim9class.txt /*E1382*
E1383 vim9class.txt /*E1383*
E1384 vim9class.txt /*E1384*
E1385 vim9class.txt /*E1385*
E1386 vim9class.txt /*E1386*
E1387 vim9class.txt /*E1387*
E1388 vim9class.txt /*E1388*
E1389 vim9class.txt /*E1389*
E139 message.txt /*E139*
E1390 vim9class.txt /*E1390*
E140 message.txt /*E140*
E1400 builtin.txt /*E1400*
E1401 builtin.txt /*E1401*
E1402 builtin.txt /*E1402*
E1403 builtin.txt /*E1403*
E1404 builtin.txt /*E1404*
E1405 builtin.txt /*E1405*
E141 message.txt /*E141*
E142 message.txt /*E142*
E143 autocmd.txt /*E143*
@@ -4552,6 +4554,12 @@ E148 repeat.txt /*E148*
E149 helphelp.txt /*E149*
E15 eval.txt /*E15*
E150 helphelp.txt /*E150*
E1500 builtin.txt /*E1500*
E1501 builtin.txt /*E1501*
E1502 builtin.txt /*E1502*
E1503 builtin.txt /*E1503*
E1504 builtin.txt /*E1504*
E1505 builtin.txt /*E1505*
E151 helphelp.txt /*E151*
E152 helphelp.txt /*E152*
E153 helphelp.txt /*E153*
@@ -6575,6 +6583,7 @@ complete-items insert.txt /*complete-items*
complete-popup insert.txt /*complete-popup*
complete-popuphidden insert.txt /*complete-popuphidden*
complete-script-local-functions cmdline.txt /*complete-script-local-functions*
complete-set-option cmdline.txt /*complete-set-option*
complete_CTRL-E insert.txt /*complete_CTRL-E*
complete_CTRL-Y insert.txt /*complete_CTRL-Y*
complete_add() builtin.txt /*complete_add()*
@@ -6590,6 +6599,7 @@ conceal syntax.txt /*conceal*
confirm() builtin.txt /*confirm()*
connection-refused message.txt /*connection-refused*
console-menus gui.txt /*console-menus*
constructor vim9class.txt /*constructor*
context.vim ft_context.txt /*context.vim*
control intro.txt /*control*
conversion-server mbyte.txt /*conversion-server*
@@ -6763,6 +6773,7 @@ debugger.txt debugger.txt /*debugger.txt*
dec-mouse options.txt /*dec-mouse*
decada_members ft_ada.txt /*decada_members*
deepcopy() builtin.txt /*deepcopy()*
default-constructor vim9class.txt /*default-constructor*
defaults.vim starting.txt /*defaults.vim*
defaults.vim-explained usr_05.txt /*defaults.vim-explained*
define-function userfunc.txt /*define-function*
@@ -9078,6 +9089,7 @@ netrw.vim pi_netrw.txt /*netrw.vim*
netrw_filehandler pi_netrw.txt /*netrw_filehandler*
netterm-mouse options.txt /*netterm-mouse*
network pi_netrw.txt /*network*
new() vim9class.txt /*new()*
new-5 version5.txt /*new-5*
new-6 version6.txt /*new-6*
new-7 version7.txt /*new-7*
@@ -9471,6 +9483,8 @@ printf-s builtin.txt /*printf-s*
printf-x builtin.txt /*printf-x*
printing print.txt /*printing*
printing-formfeed print.txt /*printing-formfeed*
private-method vim9class.txt /*private-method*
private-variable vim9class.txt /*private-variable*
profile repeat.txt /*profile*
profiling repeat.txt /*profiling*
profiling-variable eval.txt /*profiling-variable*
+28 -16
View File
@@ -150,7 +150,7 @@ If you try to set an object variable that doesn't exist you get an error: >
A object variable cannot be accessed using the class name.
Private variables ~
*E1332* *E1333*
*private-variable* *E1332* *E1333*
On the other hand, if you do not want the object variables to be read directly,
you can make them private. This is done by prefixing an underscore to the
name: >
@@ -182,7 +182,7 @@ number to the total number of lines: >
enddef
<
Private methods ~
*E1366*
*private-method* *E1366*
If you want object methods to be accessible only from other methods of the
same class and not used from outside the class, then you can make them
private. This is done by prefixing the method name with an underscore: >
@@ -203,7 +203,7 @@ the above class): >
a._Foo()
<
Simplifying the new() method ~
*new()* *constructor*
Many constructors take values for the object variables. Thus you very often
see this pattern: >
@@ -216,7 +216,8 @@ see this pattern: >
this.col = col
enddef
endclass
<
*E1390*
Not only is this text you need to write, it also has the type of each
variables twice. Since this is so common a shorter way to write new() is
provided: >
@@ -257,10 +258,15 @@ If the class extends a parent class, the same thing happens. In the second
step the object variables of the parent class are initialized first. There is
no need to call "super()" or "new()" on the parent.
*E1365*
*E1365*
When defining the new() method the return type should not be specified. It
always returns an object of the class.
*E1386*
When invoking an object method, the method name should be preceded by the
object variable name. A object method cannot be invoked using the class
name.
==============================================================================
3. Class Variables and Methods *Vim9-class-member*
@@ -281,7 +287,7 @@ prefix in the class where they are defined: >
Since the name is used as-is, shadowing the name by a method argument name
or local variable name is not allowed.
*E1374* *E1375*
*E1374* *E1375* *E1384* *E1385*
To access a class member outside of the class where it is defined, the class
name prefix must be used. A class member cannot be accessed using an object.
@@ -464,10 +470,10 @@ The interface name can be used as a type: >
echo $'the surface is {shape.Surface()}'
endfor
<
*E1378* *E1379* *E1380*
An interface can have only instance variables (read-only and read-write
access) and methods. An interface cannot contain private variables, private
methods, class variables and class methods.
*E1378* *E1379* *E1380* *E1387*
An interface can contain only object methods and read-only object variables.
An interface cannot contain read-write and private object variables, private
object methods, class variables and class methods.
An interface can extend another interface using "extends". The sub-interface
inherits all the instance variables and methods from the super interface.
@@ -524,6 +530,10 @@ If the type of a variable is not explicitly specified in a class, then it is
set to "any" during class definition. When an object is instantiated from the
class, then the type of the variable is set.
The following reserved keyword names cannot be used as an object or class
variable name: "super", "this", "true", "false", "null", "null_blob",
"null_dict", "null_function", "null_list", "null_partial", "null_string",
"null_channel" and "null_job".
Extending a class ~
*extends*
@@ -537,9 +547,11 @@ Object variables from the base class are all taken over by the child class. It
is not possible to override them (unlike some other languages).
*E1356* *E1357* *E1358*
Object methods of the base class can be overruled. The signature (arguments,
argument types and return type) must be exactly the same. The method of the
base class can be called by prefixing "super.".
Object methods of the base class can be overruled. The number of arguments
must be exactly the same. The method argument type can be a contra-variant
type of the base class method argument type. The method return value type can
be a covariant type of the base class method return value type. The method of
the base class can be called by prefixing "super.".
*E1377*
The access level of a method (public or private) in a child class should be
@@ -563,7 +575,7 @@ will be added automatically.
A class implementing an interface ~
*implements* *E1346* *E1347*
*implements* *E1346* *E1347* *E1389*
A class can implement one or more interfaces. The "implements" keyword can
only appear once *E1350* . Multiple interfaces can be specified, separated by
commas. Each interface name can appear only once. *E1351*
@@ -577,7 +589,7 @@ interface, which is often done in many languages, especially Java.
Items in a class ~
*E1318* *E1325*
*E1318* *E1325* *E1388*
Inside a class, in between `:class` and `:endclass`, these items can appear:
- An object variable declaration: >
this._privateVariableName: memberType
@@ -650,7 +662,7 @@ even when the variable name is invalid. *E1360* *E1362* *E1363*
Default constructor ~
*default-constructor*
In case you define a class without a new() method, one will be automatically
defined. This default constructor will have arguments for all the object
variables, in the order they were specified. Thus if your class looks like: >
+64 -58
View File
@@ -3,7 +3,7 @@ XXD(1) General Commands Manual XXD(1)
NAME
xxd - make a hexdump or do the reverse.
xxd - make a hex dump or do the reverse.
SYNOPSIS
xxd -h[elp]
@@ -30,19 +30,19 @@ OPTIONS
notation. Thus -c8, -c 8, -c 010 and -cols 8 are all equivalent.
-a | -autoskip
Toggle autoskip: A single '*' replaces nul-lines. Default off.
Toggle autoskip: A single '*' replaces NUL-lines. Default off.
-b | -bits
Switch to bits (binary digits) dump, rather than hexdump. This
Switch to bits (binary digits) dump, rather than hex dump. This
option writes octets as eight digits "1"s and "0"s instead of a
normal hexadecimal dump. Each line is preceded by a line number
in hexadecimal and followed by an ascii (or ebcdic) representa
in hexadecimal and followed by an ASCII (or EBCDIC) representa
tion. The command line switches -r, -p, -i do not work with this
mode.
-c cols | -cols cols
Format <cols> octets per line. Default 16 (-i: 12, -ps: 30, -b:
6). Max 256. No maxmimum for -ps. With -ps, 0 results in one
6). Max 256. No maximum for -ps. With -ps, 0 results in one
long line of output.
-C | -capitalize
@@ -54,53 +54,60 @@ OPTIONS
to EBCDIC. This does not change the hexadecimal representation.
The option is meaningless in combinations with -r, -p or -i.
-e Switch to little-endian hexdump. This option treats byte groups
as words in little-endian byte order. The default grouping of 4
bytes may be changed using -g. This option only applies to hex
dump, leaving the ASCII (or EBCDIC) representation unchanged.
The command line switches -r, -p, -i do not work with this mode.
-e Switch to little-endian hex dump. This option treats byte
groups as words in little-endian byte order. The default group
ing of 4 bytes may be changed using -g. This option only ap
plies to the hex dump, leaving the ASCII (or EBCDIC) representa
tion unchanged. The command line switches -r, -p, -i do not
work with this mode.
-g bytes | -groupsize bytes
Separate the output of every <bytes> bytes (two hex characters
or eight bit-digits each) by a whitespace. Specify -g 0 to sup
Separate the output of every <bytes> bytes (two hex characters
or eight bit digits each) by a whitespace. Specify -g 0 to sup
press grouping. <Bytes> defaults to 2 in normal mode, 4 in lit
tle-endian mode and 1 in bits mode. Grouping does not apply to
postscript or include style.
tle-endian mode and 1 in bits mode. Grouping does not apply to
PostScript or include style.
-h | -help
Print a summary of available commands and exit. No hex dumping
Print a summary of available commands and exit. No hex dumping
is performed.
-i | -include
Output in C include file style. A complete static array defini
tion is written (named after the input file), unless xxd reads
Output in C include file style. A complete static array defini
tion is written (named after the input file), unless xxd reads
from stdin.
-l len | -len len
Stop after writing <len> octets.
-n name | -name name
Override the variable name output when -i is used. The array is
Override the variable name output when -i is used. The array is
named name and the length is named name_len.
-o offset
Add <offset> to the displayed file position.
-p | -ps | -postscript | -plain
Output in postscript continuous hexdump style. Also known as
plain hexdump style.
Output in PostScript continuous hex dump style. Also known as
plain hex dump style.
-r | -revert
Reverse operation: convert (or patch) hexdump into binary. If
not writing to stdout, xxd writes into its output file without
Reverse operation: convert (or patch) hex dump into binary. If
not writing to stdout, xxd writes into its output file without
truncating it. Use the combination -r -p to read plain hexadeci
mal dumps without line number information and without a particu
lar column layout. Additional Whitespace and line-breaks are al
lar column layout. Additional whitespace and line breaks are al
lowed anywhere.
-R when
In output the hex-value and the value are both colored with the
same color depending on the hex-value. Mostly helping to differ
entiate printable and non-printable characters. when is never,
always, or auto.
-seek offset
When used after -r: revert with <offset> added to file positions
found in hexdump.
found in hex dump.
-s [+][-]seek
Start at <seek> bytes abs. (or rel.) infile offset. + indicates
@@ -110,56 +117,55 @@ OPTIONS
(or if combined with +: before the current stdin file position).
Without -s option, xxd starts at the current file position.
-u Use upper case hex letters. Default is lower case.
-u Use upper-case hex letters. Default is lower-case.
-v | -version
Show version string.
CAVEATS
xxd -r has some builtin magic while evaluating line number information.
If the output file is seekable, then the linenumbers at the start of
each hexdump line may be out of order, lines may be missing, or over
lapping. In these cases xxd will lseek(2) to the next position. If the
output file is not seekable, only gaps are allowed, which will be
filled by null-bytes.
xxd -r has some built-in magic while evaluating line number informa
tion. If the output file is seekable, then the line numbers at the
start of each hex dump line may be out of order, lines may be missing,
or overlapping. In these cases xxd will lseek(2) to the next position.
If the output file is not seekable, only gaps are allowed, which will
be filled by null-bytes.
xxd -r never generates parse errors. Garbage is silently skipped.
When editing hexdumps, please note that xxd -r skips everything on the
When editing hex dumps, please note that xxd -r skips everything on the
input line after reading enough columns of hexadecimal data (see option
-c). This also means, that changes to the printable ascii (or ebcdic)
columns are always ignored. Reverting a plain (or postscript) style
hexdump with xxd -r -p does not depend on the correct number of col
umns. Here anything that looks like a pair of hex-digits is inter
preted.
-c). This also means that changes to the printable ASCII (or EBCDIC)
columns are always ignored. Reverting a plain (or PostScript) style hex
dump with xxd -r -p does not depend on the correct number of columns.
Here, anything that looks like a pair of hex digits is interpreted.
Note the difference between
% xxd -i file
and
% xxd -i < file
xxd -s +seek may be different from xxd -s seek, as lseek(2) is used to
xxd -s +seek may be different from xxd -s seek, as lseek(2) is used to
"rewind" input. A '+' makes a difference if the input source is stdin,
and if stdin's file position is not at the start of the file by the
time xxd is started and given its input. The following examples may
help to clarify (or further confuse!)...
and if stdin's file position is not at the start of the file by the
time xxd is started and given its input. The following examples may
help to clarify (or further confuse!):
Rewind stdin before reading; needed because the `cat' has already read
Rewind stdin before reading; needed because the `cat' has already read
to the end of stdin.
% sh -c "cat > plain_copy; xxd -s 0 > hex_copy" < file
Hexdump from file position 0x480 (=1024+128) onwards. The `+' sign
Hex dump from file position 0x480 (=1024+128) onwards. The `+' sign
means "relative to the current position", thus the `128' adds to the 1k
where dd left off.
% sh -c "dd of=plain_snippet bs=1k count=1; xxd -s +128 > hex_snippet"
% sh -c "dd of=plain_snippet bs=1k count=1; xxd -s +128 > hex_snippet"
< file
Hexdump from file position 0x100 ( = 1024-768) on.
Hex dump from file position 0x100 (=1024-768) onwards.
% sh -c "dd of=plain_snippet bs=1k count=1; xxd -s +-768 > hex_snippet"
< file
However, this is a rare situation and the use of `+' is rarely needed.
The author prefers to monitor the effect of xxd with strace(1) or
However, this is a rare situation and the use of `+' is rarely needed.
The author prefers to monitor the effect of xxd with strace(1) or
truss(1), whenever -s is used.
EXAMPLES
@@ -169,7 +175,7 @@ EXAMPLES
Print 3 lines (hex 0x30 bytes) from the end of file.
% xxd -s -0x30 file
Print 120 bytes as continuous hexdump with 20 octets per line.
Print 120 bytes as a continuous hex dump with 20 octets per line.
% xxd -l 120 -ps -c 20 xxd.1
2e54482058584420312022417567757374203139
39362220224d616e75616c207061676520666f72
@@ -178,7 +184,7 @@ EXAMPLES
20617574686f723a0a2e5c2220202020546f6e79
204e7567656e74203c746f6e79407363746e7567
Hexdump the first 120 bytes of this man page with 12 octets per line.
Hex dump the first 120 bytes of this man page with 12 octets per line.
% xxd -l 120 -c 12 xxd.1
0000000: 2e54 4820 5858 4420 3120 2241 .TH XXD 1 "A
000000c: 7567 7573 7420 3139 3936 2220 ugust 1996"
@@ -203,31 +209,31 @@ EXAMPLES
% xxd -s 0x36 -l 13 -c 13 xxd.1
0000036: 3235 7468 204d 6179 2031 3939 36 25th May 1996
Create a 65537 byte file with all bytes 0x00, except for the last one
Create a 65537 byte file with all bytes 0x00, except for the last one
which is 'A' (hex 0x41).
% echo "010000: 41" | xxd -r > file
Hexdump this file with autoskip.
Hex dump this file with autoskip.
% xxd -a -c 12 file
0000000: 0000 0000 0000 0000 0000 0000 ............
*
000fffc: 0000 0000 40 ....A
Create a 1 byte file containing a single 'A' character. The number af
ter '-r -s' adds to the linenumbers found in the file; in effect, the
ter '-r -s' adds to the line numbers found in the file; in effect, the
leading bytes are suppressed.
% echo "010000: 41" | xxd -r -s -0x10000 > file
Use xxd as a filter within an editor such as vim(1) to hexdump a region
marked between `a' and `z'.
Use xxd as a filter within an editor such as vim(1) to hex dump a re
gion marked between `a' and `z'.
:'a,'z!xxd
Use xxd as a filter within an editor such as vim(1) to recover a binary
hexdump marked between `a' and `z'.
hex dump marked between `a' and `z'.
:'a,'z!xxd -r
Use xxd as a filter within an editor such as vim(1) to recover one line
of a hexdump. Move the cursor over the line and type:
of a hex dump. Move the cursor over the line and type:
!!xxd -r
Read single characters from a serial line
@@ -240,7 +246,7 @@ RETURN VALUES
0 no errors encountered.
-1 operation not supported ( xxd -r -i still impossible).
-1 operation not supported (xxd -r -i still impossible).
1 error while parsing options.
@@ -254,7 +260,7 @@ SEE ALSO
uuencode(1), uudecode(1), patch(1)
WARNINGS
The tools weirdness matches its creators brain. Use entirely at your
The tool's weirdness matches its creator's brain. Use entirely at your
own risk. Copy files. Trace it. Become a wizard.
VERSION
+12 -6
View File
@@ -2,7 +2,7 @@
" Language: R Markdown file
" Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com>
" Homepage: https://github.com/jalvesaq/R-Vim-runtime
" Last Change: Mon Feb 27, 2023 07:15PM
" Last Change: Mon May 29, 2023 06:31AM
" Original work by Alex Zvoleff (adjusted from R help for rmd by Michel Kuhlmann)
" Only do this when not yet done for this buffer
@@ -32,12 +32,18 @@ function FormatRmd()
return 1
endfunction
let s:last_line = 0
function SetRmdCommentStr()
if (search("^[ \t]*```[ ]*{r", "bncW") > search("^[ \t]*```$", "bncW")) || ((search('^---$', 'Wn') || search('^\.\.\.$', 'Wn')) && search('^---$', 'bnW'))
set commentstring=#\ %s
else
set commentstring=<!--\ %s\ -->
endif
if line('.') == s:last_line
return
endif
let s:last_line = line('.')
if (search("^[ \t]*```[ ]*{r", "bncW") > search("^[ \t]*```$", "bncW")) || ((search('^---$', 'Wn') || search('^\.\.\.$', 'Wn')) && search('^---$', 'bnW'))
set commentstring=#\ %s
else
set commentstring=<!--\ %s\ -->
endif
endfunction
" If you do not want both 'comments' and 'commentstring' dynamically defined,
+1 -2
View File
@@ -39,8 +39,7 @@ if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
let b:undo_ftplugin ..= " | unlet! b:browsefilter"
endif
if (exists("b:is_bash") && (b:is_bash == 1)) ||
\ (exists("b:is_sh") && (b:is_sh == 1))
if (exists("b:is_bash") && (b:is_bash == 1))
if !has("gui_running") && executable("less")
command! -buffer -nargs=1 Help silent exe '!bash -c "{ help "<args>" 2>/dev/null || man "<args>"; } | LESS= less"' | redraw!
elseif has('terminal')
+78 -88
View File
@@ -1,10 +1,9 @@
" Vim syntax file
" Language: i3 config file
" Original Author: Mohamed Boughaba <mohamed dot bgb at gmail dot com>
" Original Author: Josef Litos (JosefLitos/i3config.vim)
" Maintainer: Quentin Hibon (github user hiqua)
" Version: 0.4.22
" Reference version (JosefLitos/i3config.vim): 4.22
" Last Change: 2023-09-12
" Version: 1.0.0
" Last Change: 2023-09-14
" References:
" http://i3wm.org/docs/userguide.html#configuring
@@ -25,18 +24,18 @@ syn match i3ConfigError /.\+/
syn keyword i3ConfigTodo TODO FIXME XXX contained
" Helper type definitions
syn match i3ConfigSeparator /[,;]/ contained
syn match i3ConfigSeparator /[,;\\]/ contained
syn match i3ConfigParen /[{}]/ contained
syn keyword i3ConfigBoolean yes no enabled disabled on off true false contained
syn region i3ConfigString start=/\W\@<="/ skip=/\\"/ end=/"/ contained contains=i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigVariable,i3ConfigExecAction keepend extend
syn region i3ConfigString start=/\W\@<='/ end=/'/ contained contains=i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigVariable,i3ConfigExecAction keepend extend
syn match i3ConfigColor /#\w\{3,8}/ contained
syn match i3ConfigNumber /[a-zA-Z_$-]\@<!-\?\d\+\w\@!/ contained
syn region i3ConfigString start=/\W\@<="/ skip=/\\\("\|$\)/ end=/"\|$/ contained contains=i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigVariable,i3ConfigExecAction keepend extend
syn region i3ConfigString start=/\W\@<='/ skip=/\\$/ end=/'\|$/ contained contains=i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigVariable,i3ConfigExecAction keepend extend
syn match i3ConfigColor /#[0-9A-Fa-f]\{3,8}/ contained
syn match i3ConfigNumber /[0-9A-Za-z_$-]\@<!-\?\d\+\w\@!/ contained
" 4.1 Include directive
syn keyword i3ConfigIncludeKeyword include contained
syn match i3ConfigIncludeCommand /`[^`]*`/ contained contains=i3ConfigShDelim,i3ConfigShParam,i3ConfigShOper,i3ConfigShCommand
syn match i3ConfigInclude /^include .*$/ contains=i3ConfigIncludeKeyword,i3ConfigString,i3ConfigVariable,i3ConfigIncludeCommand
syn match i3ConfigIncludeCommand /`[^`]*`/ contained contains=i3ConfigShDelim,i3ConfigShParam,i3ConfigShOper,i3ConfigShCommand,i3ConfigString
syn match i3ConfigParamLine /^include .*$/ contains=i3ConfigIncludeKeyword,i3ConfigString,i3ConfigVariable,i3ConfigIncludeCommand,i3ConfigShOper
" 4.2 Comments
syn match i3ConfigComment /^\s*#.*$/ contains=i3ConfigTodo
@@ -45,23 +44,23 @@ syn match i3ConfigComment /^\s*#.*$/ contains=i3ConfigTodo
syn keyword i3ConfigFontKeyword font contained
syn match i3ConfigColonOperator /:/ contained
syn match i3ConfigFontNamespace /\w\+:/ contained contains=i3ConfigColonOperator
syn match i3ConfigFontSize /\s\=\d\+\(px\)\?\s\?$/ contained
syn match i3ConfigFontSize / \d\+\(px\)\?\s\?$/ contained
syn region i3ConfigFont start=/^\s*font / skip=/\\$/ end=/$/ contains=i3ConfigFontKeyword,i3ConfigFontNamespace,i3ConfigFontSize,i3ConfigSeparator keepend
" 4.4-4.5 Keyboard/Mouse bindings
syn keyword i3ConfigBindKeyword bindsym bindcode contained
syn match i3ConfigBindArgument /--\(release\|border\|whole-window\|exclude-titlebar\)/ contained
syn match i3ConfigBindModifier /+/ contained
syn match i3ConfigBindModkey /Ctrl\|Shift\|Mod[1-5]/ contained
syn match i3ConfigBindCombo /[$a-zA-Z0-9_+]\+ / contained contains=i3ConfigBindModifier,i3ConfigVariable,i3ConfigBindModkey
syn match i3ConfigBindComboLine /bind\(sym\|code\)\( --[a-z-]\+\)* [$a-zA-Z0-9_+]\+ / contained contains=i3ConfigBindKeyword,i3ConfigBindArgument,i3ConfigBindCombo
syn keyword i3ConfigBindModkey Ctrl Shift Mod1 Mod2 Mod3 Mod4 Mod5 contained
syn match i3ConfigBindCombo /[$0-9A-Za-z_+]\+ / contained contains=i3ConfigBindModifier,i3ConfigVariable,i3ConfigBindModkey
syn match i3ConfigBindComboLine /bind\(sym\|code\)\( --[a-z-]\+\)* [$0-9A-Za-z_+]\+ / contained contains=i3ConfigBindKeyword,i3ConfigBindArgument,i3ConfigBindCombo
syn region i3ConfigBind start=/^\s*bind\(sym\|code\) / skip=/\\$/ end=/$/ contains=i3ConfigBindComboLine,i3ConfigCriteria,i3ConfigAction,i3ConfigSeparator,i3ConfigActionKeyword,i3ConfigOption,i3ConfigString,i3ConfigNumber,i3ConfigVariable,i3ConfigBoolean keepend
" 4.6 Binding modes
syn region i3ConfigKeyword start=/^mode\( --pango_markup\)\? \([^'" {]\+\|'[^']\+'\|".\+"\)\s\+{$/ end=/^\s*}$/ contains=i3ConfigShParam,i3ConfigString,i3ConfigBind,i3ConfigComment,i3ConfigNumber,i3ConfigParen,i3ConfigVariable fold keepend extend
" 4.7 Floating modifier
syn match i3ConfigKeyword /^floating_modifier [$a-zA-Z0-9+]\+$/ contains=i3ConfigVariable,i3ConfigBindModkey
syn match i3ConfigKeyword /^floating_modifier [$0-9A-Za-z]*$/ contains=i3ConfigVariable,i3ConfigBindModkey
" 4.8 Floating window size
syn keyword i3ConfigSizeSpecial x contained
@@ -86,47 +85,46 @@ syn match i3ConfigKeyword /^default\(_floating\)\?_border .*$/ contains=i3Config
" 4.13 Hide edge borders
syn keyword i3ConfigEdgeOpts none vertical horizontal both smart smart_no_gaps contained
syn match i3ConfigKeyword /^hide_edge_borders \w\+$/ contains=i3ConfigEdgeOpts
syn match i3ConfigKeyword /^hide_edge_borders \w*$/ contains=i3ConfigEdgeOpts
" 4.14 Smart Borders
syn keyword i3ConfigSmartBorderOpts no_gaps contained
syn match i3ConfigKeyword /^smart_borders \(on\|off\|no_gaps\)$/ contains=i3ConfigSmartBorderOpts,i3ConfigBoolean
" 4.15 Arbitrary commands
syn keyword i3ConfigForWindowKeyword for_window contained
syn region i3ConfigForWindow start=/^for_window / end=/$/ contains=i3ConfigForWindowKeyword,i3ConfigCriteria keepend
syn region i3ConfigKeyword start=/^for_window / end=/$/ contains=i3ConfigForWindowKeyword,i3ConfigCriteria keepend
" 4.16 No opening focus
syn match i3ConfigKeyword /^no_focus .*$/ contains=i3ConfigCondition
" 4.17 Variables
syn match i3ConfigVariable /\$[A-Z0-9a-z_:|[\]-]\+/
syn match i3ConfigVariable /\$[0-9A-Za-z_:|[\]-]\+/
syn keyword i3ConfigSetKeyword set contained
syn match i3ConfigSet /^set \$.*$/ contains=i3ConfigVariable,i3ConfigSetKeyword,i3ConfigColor,i3ConfigString,i3ConfigNoStartupId,i3ConfigNumber,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShParam,i3ConfigShOper
syn match i3ConfigSet /^set \$.*$/ contains=i3ConfigSetKeyword,i3ConfigVariable,i3ConfigColor,i3ConfigString,i3ConfigNumber,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShParam,i3ConfigShOper,i3ConfigBindModkey
" 4.18 X resources
syn keyword i3ConfigResourceKeyword set_from_resource contained
syn match i3ConfigResource /^set_from_resource\s\+.*$/ contains=i3ConfigResourceKeyword,i3ConfigCondition,i3ConfigColor,i3ConfigVariable,i3ConfigString,i3ConfigNumber
syn match i3ConfigParamLine /^set_from_resource\s\+.*$/ contains=i3ConfigResourceKeyword,i3ConfigCondition,i3ConfigColor,i3ConfigVariable,i3ConfigString,i3ConfigNumber
" 4.19 Assign clients to workspaces
syn keyword i3ConfigAssignKeyword assign contained
syn match i3ConfigAssignSpecial /→/ contained
syn match i3ConfigAssignSpecial /→\|number/ contained
syn match i3ConfigAssign /^assign .*$/ contains=i3ConfigAssignKeyword,i3ConfigAssignSpecial,i3ConfigCondition,i3ConfigVariable,i3ConfigString,i3ConfigNumber
" 4.20 Executing shell commands
syn keyword i3ConfigExecKeyword exec contained
syn keyword i3ConfigExecAlwaysKeyword exec_always contained
syn match i3ConfigShCmdDelim /\$(/ contained
syn region i3ConfigShCommand start=/\$(/ end=/)/ contained contains=i3ConfigShCmdDelim,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigString,i3ConfigNumber,i3ConfigVariable keepend extend
syn region i3ConfigShCommand start=/\$(/ end=/)/ contained contains=i3ConfigShCmdDelim,i3ConfigExecAction,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigString,i3ConfigNumber,i3ConfigVariable keepend extend
syn match i3ConfigShDelim /[[\]{}();`]\+/ contained
syn match i3ConfigShOper /[<>&|+=~^*!.?]\+/ contained
syn match i3ConfigShParam /\<-[a-zA-Z0-9_-]\+\>/ contained containedin=i3ConfigVar
syn match i3ConfigShParam /\<-[0-9A-Za-z_-]\+\>/ contained containedin=i3ConfigVar
syn region i3ConfigExec start=/^\s*exec\(_always\)\?\( --no-startup-id\)\? [^{]/ skip=/\\$/ end=/$/ contains=i3ConfigExecKeyword,i3ConfigExecAlwaysKeyword,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigString,i3ConfigVariable,i3ConfigExecAction keepend
" 4.21 Workspaces per output
syn keyword i3ConfigWorkspaceKeyword workspace contained
syn keyword i3ConfigWorkspaceOutput output contained
syn keyword i3ConfigWorkspaceDir prev next back_and_forth contained
syn keyword i3ConfigWorkspaceDir prev next back_and_forth number contained
syn region i3ConfigWorkspaceLine start=/^workspace / skip=/\\$/ end=/$/ contains=i3ConfigWorkspaceKeyword,i3ConfigNumber,i3ConfigString,i3ConfigGaps,i3ConfigWorkspaceOutput,i3ConfigVariable,i3ConfigBoolean,i3ConfigSeparator keepend
" 4.22 Changing colors
@@ -136,121 +134,126 @@ syn match i3ConfigKeyword /^client\..*$/ contains=i3ConfigDotOperator,i3ConfigCl
" 4.23 Interprocess communication
syn match i3ConfigIpcKeyword /ipc-socket/ contained
syn match i3ConfigIpc /^ipc-socket .*$/ contains=i3ConfigIpcKeyword
syn match i3ConfigParamLine /^ipc-socket .*$/ contains=i3ConfigIpcKeyword
" 4.24 Focus follows mouse
syn keyword i3ConfigFocusFollowsMouseOpts always contained
syn match i3ConfigFocusFollowsMouse /^focus_follows_mouse \(yes\|no\|always\)$/ contains=i3ConfigBoolean,i3ConfigFocusFollowsMouseOpts
syn match i3ConfigKeyword /^focus_follows_mouse \(yes\|no\|always\)$/ contains=i3ConfigBoolean,i3ConfigFocusFollowsMouseOpts
" 4.25 Mouse warping
syn keyword i3ConfigMouseWarpingOpts output container none contained
syn match i3ConfigMouseWarping /^mouse_warping \w*$/ contains=i3ConfigMouseWarpingOpts
syn match i3ConfigKeyword /^mouse_warping \w*$/ contains=i3ConfigMouseWarpingOpts
" 4.26 Popups while fullscreen
syn keyword i3ConfigPopupFullscreenOpts smart ignore leave_fullscreen contained
syn match i3ConfigPopupFullscreen /^popup_during_fullscreen \w*$/ contains=i3ConfigPopupFullscreenOpts
syn match i3ConfigKeyword /^popup_during_fullscreen \w*$/ contains=i3ConfigPopupFullscreenOpts
" 4.27 Focus wrapping
syn keyword i3ConfigFocusWrappingOpts force workspace contained
syn match i3ConfigFocusWrapping /^focus_wrapping \(yes\|no\|force\|workspace\)$/ contains=i3ConfigBoolean,i3ConfigFocusWrappingOpts
syn match i3ConfigKeyword /^focus_wrapping \(yes\|no\|force\|workspace\)$/ contains=i3ConfigBoolean,i3ConfigFocusWrappingOpts
" 4.28 Forcing Xinerama
syn match i3ConfigForceXinerama /^force_xinerama \(yes\|no\)$/ contains=i3ConfigBoolean
syn match i3ConfigKeyword /^force_xinerama \(yes\|no\)$/ contains=i3ConfigBoolean
" 4.29 Automatic workspace back-and-forth
syn match i3ConfigAutomaticSwitch /^workspace_auto_back_and_forth \(yes\|no\)$/ contains=i3ConfigBoolean
syn match i3ConfigKeyword /^workspace_auto_back_and_forth \(yes\|no\)$/ contains=i3ConfigBoolean
" 4.30 Delay urgency hint
syn keyword i3ConfigTimeUnit ms contained
syn match i3ConfigDelayUrgency /^force_display_urgency_hint \d\+ ms$/ contains=i3ConfigBoolean,i3ConfigNumber,i3ConfigTimeUnit
syn match i3ConfigKeyword /^force_display_urgency_hint \d\+\( ms\)\?$/ contains=i3ConfigNumber,i3ConfigTimeUnit
" 4.31 Focus on window activation
syn keyword i3ConfigFocusOnActivationOpts smart urgent focus none contained
syn match i3ConfigFocusOnActivation /^focus_on_window_activation .*$/ contains=i3ConfigFocusOnActivationKeyword
syn match i3ConfigKeyword /^focus_on_window_activation \w*$/ contains=i3ConfigFocusOnActivationOpts
" 4.32 Show marks in title
syn match i3ConfigShowMarks /^show_marks \(yes\|no\)$/ contains=i3ConfigBoolean
" 4.34 Tiling drag
syn keyword i3ConfigTilingDragOpts modifier titlebar contained
syn match i3ConfigTilingDrag /^tiling_drag\( off\|\( modifier\| titlebar\)\{1,2\}\)$/ contains=i3ConfigTilingOpts,i3ConfigBoolean
syn match i3ConfigKeyword /^tiling_drag\( off\|\( modifier\| titlebar\)\{1,2\}\)$/ contains=i3ConfigTilingDragOpts,i3ConfigBoolean
" 4.35 Gaps
syn keyword i3ConfigGapsOpts inner outer horizontal vertical left right top bottom current all set plus minus toggle contained
syn region i3ConfigGaps start=/gaps/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigGapsOpts,i3ConfigNumber,i3ConfigVariable,i3ConfigSeparator keepend
syn match i3ConfigGapStyleLine /^gaps .*$/ contains=i3ConfigGaps
syn region i3ConfigGaps start=/gaps/ skip=/\\$/ end=/[,;]\|$/ contained contains=i3ConfigGapsOpts,i3ConfigNumber,i3ConfigVariable,i3ConfigSeparator keepend
syn match i3ConfigGapsLine /^gaps .*$/ contains=i3ConfigGaps
syn keyword i3ConfigSmartGapOpts inverse_outer contained
syn match i3ConfigSmartGap /^smart_gaps \(on\|off\|inverse_outer\)$/ contains=i3ConfigSmartGapOpts,i3ConfigBoolean
syn match i3ConfigKeyword /^smart_gaps \(on\|off\|inverse_outer\)$/ contains=i3ConfigSmartGapOpts,i3ConfigBoolean
" 5 Configuring bar
syn match i3ConfigBarModifier /^\s\+modifier [^ ]\+$/ contained contains=i3ConfigBindModifier,i3ConfigVariable,i3ConfigBindModkey
syn keyword i3ConfigBarOpts bar i3bar_command status_command mode hidden_state id position output tray_output tray_padding font separator_symbol workspace_buttons workspace_min_width strip_workspace_numbers strip_workspace_name binding_mode_indicator padding contained
syn region i3ConfigBarBlock start=/^bar {$/ end=/^}$/ contains=i3ConfigBarOpts,i3ConfigBarModifier,i3ConfigBind,i3ConfigString,i3ConfigComment,i3ConfigFont,i3ConfigBoolean,i3ConfigNumber,i3ConfigParen,i3ConfigColor,i3ConfigVariable,i3ConfigColorsBlock fold keepend extend
syn match i3ConfigBarModifier /^\s\+modifier \S\+$/ contained contains=i3ConfigBindModifier,i3ConfigVariable,i3ConfigBindModkey,i3ConfigBarOptVals
syn keyword i3ConfigBarOpts bar i3bar_command status_command mode hidden_state id position output tray_output tray_padding separator_symbol workspace_buttons workspace_min_width strip_workspace_numbers strip_workspace_name binding_mode_indicator padding contained
syn keyword i3ConfigBarOptVals dock hide invisible show none top bottom primary nonprimary contained
syn region i3ConfigBarBlock start=/^bar {$/ end=/^}$/ contains=i3ConfigBarOpts,i3ConfigBarOptVals,i3ConfigBarModifier,i3ConfigBind,i3ConfigString,i3ConfigComment,i3ConfigFont,i3ConfigBoolean,i3ConfigNumber,i3ConfigParen,i3ConfigColor,i3ConfigVariable,i3ConfigColorsBlock,i3ConfigShOper,i3ConfigShCommand fold keepend extend
" 5.16 Color block
syn keyword i3ConfigColorsKeyword colors contained
syn match i3ConfigColorsOpts /\(focused_\)\?\(background\|statusline\|separator\)\|\(focused\|active\|inactive\|urgent\)_workspace\|binding_mode/ contained
syn region i3ConfigColorsBlock start=/^\s\+colors {$/ end=/^\s\+}$/ contained contains=i3ConfigColorsOpts,i3ConfigColor,i3ConfigVariable,i3ConfigComment,i3ConfigParen fold keepend extend
syn region i3ConfigColorsBlock start=/^\s\+colors {$/ end=/^\s\+}$/ contained contains=i3ConfigColorsKeyword,i3ConfigColorsOpts,i3ConfigColor,i3ConfigVariable,i3ConfigComment,i3ConfigParen fold keepend extend
" 6.0 Criteria-based commands
syn match i3ConfigConditionProp /\w\+\(-\w\+\)*/ contained
syn match i3ConfigConditionText /[^[ ]\+=/ contained contains=i3ConfigConditionProp,i3ConfigShOper
syn keyword i3ConfigConditionFocused __focused__ contained
syn region i3ConfigCondition start=/\[/ end=/\]/ contained contains=i3ConfigConditionText,i3ConfigShDelim,i3ConfigNumber,i3ConfigString,i3ConfigConditionFocused keepend extend
syn region i3ConfigCriteria start=/\[/ skip=/\\$/ end=/\(;\|$\)/ contained contains=i3ConfigCondition,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigBoolean,i3ConfigNumber,i3ConfigVariable,i3ConfigSeparator keepend
" 6.0 Command criteria
syn keyword i3ConfigConditionProp class instance window_role window_type machine id title urgent workspace con_mark con_id floating_from tiling_from contained
syn keyword i3ConfigConditionSpecial __focused__ all floating tiling contained
syn region i3ConfigCondition start=/\[/ end=/\]/ contained contains=i3ConfigShDelim,i3ConfigConditionProp,i3ConfigShOper,i3ConfigConditionSpecial,i3ConfigNumber,i3ConfigString keepend extend
syn region i3ConfigCriteria start=/\[/ skip=/\\$/ end=/\(;\|$\)/ contained contains=i3ConfigCondition,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigBoolean,i3ConfigNumber,i3ConfigVariable,i3ConfigSeparator keepend transparent
" 6.1 Actions through shell
syn match i3ConfigExecActionKeyword /i3-msg/ contained
syn region i3ConfigExecAction start=/[a-z3-]\+msg '/ skip=/\\$\| '/ end=/'/ contained contains=i3ConfigExecActionKeyword,i3ConfigShCommand,i3ConfigNumber,i3ConfigShOper,i3ConfigCriteria,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigVariable keepend extend
syn region i3ConfigExecAction start=/[a-z3-]\+msg "/ skip=/\\$\| "/ end=/"/ contained contains=i3ConfigExecActionKeyword,i3ConfigShCommand,i3ConfigNumber,i3ConfigShOper,i3ConfigCriteria,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigVariable keepend extend
syn region i3ConfigExecAction start=/[a-z3-]\+msg\( ['"-]\)\@!/ skip=/\\$/ end=/\([&|;})'"]\|$\)/ contained contains=i3ConfigExecActionKeyword,i3ConfigShCommand,i3ConfigNumber,i3ConfigShOper,i3ConfigCriteria,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigVariable keepend
syn region i3ConfigExecAction start=/[a-z3-]\+msg "/ skip=/ "\|\\$/ end=/"\|$/ contained contains=i3ConfigExecActionKeyword,i3ConfigShCommand,i3ConfigNumber,i3ConfigShOper,i3ConfigCriteria,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigVariable keepend extend
syn region i3ConfigExecAction start=/[a-z3-]\+msg '/ skip=/ '\|\\$/ end=/'\|$/ contained contains=i3ConfigExecActionKeyword,i3ConfigShCommand,i3ConfigNumber,i3ConfigShOper,i3ConfigCriteria,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigVariable keepend extend
syn region i3ConfigExecAction start=/[a-z3-]\+msg ['"-]\@!/ skip=/\\$/ end=/[&|;})'"]\@=\|$/ contained contains=i3ConfigExecActionKeyword,i3ConfigShCommand,i3ConfigNumber,i3ConfigShOper,i3ConfigCriteria,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigVariable keepend extend
" 6.1 Executing applications (4.20)
syn region i3ConfigAction start=/exec/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigExecKeyword,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigString,i3ConfigVariable,i3ConfigSeparator keepend
syn region i3ConfigAction start=/exec/ skip=/\\$/ end=/[,;]\|$/ contained contains=i3ConfigExecKeyword,i3ConfigExecAction,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigString,i3ConfigVariable,i3ConfigSeparator keepend
" 6.3 Manipulating layout
syn keyword i3ConfigLayoutKeyword layout contained
syn keyword i3ConfigLayoutOpts default tabbed stacking splitv splith toggle split all contained
syn region i3ConfigAction start=/layout/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigLayoutKeyword,i3ConfigLayoutOpts,i3ConfigSeparator keepend
syn region i3ConfigAction start=/layout/ skip=/\\$/ end=/[,;]\|$/ contained contains=i3ConfigLayoutKeyword,i3ConfigLayoutOpts,i3ConfigSeparator keepend transparent
" 6.4 Focusing containers
syn keyword i3ConfigFocusKeyword focus contained
syn keyword i3ConfigFocusOpts left right up down parent child next prev sibling floating tiling mode_toggle contained
syn keyword i3ConfigFocusOutputOpts left right down up current primary nonprimary next prev contained
syn region i3ConfigFocusOutput start=/ output / skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigMoveType,i3ConfigWorkspaceOutput,i3ConfigFocusOutputOpts,i3ConfigString,i3ConfigNumber,i3ConfigSeparator keepend
syn region i3ConfigFocusOutput start=/ output / skip=/\\$/ end=/[,;]\|$/ contained contains=i3ConfigWorkspaceOutput,i3ConfigFocusOutputOpts,i3ConfigString,i3ConfigNumber,i3ConfigSeparator keepend
syn match i3ConfigFocusOutputLine /^focus output .*$/ contains=i3ConfigFocusKeyword,i3ConfigFocusOutput
syn region i3ConfigAction start=/focus/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigFocusKeyword,i3ConfigFocusOpts,i3ConfigFocusOutput,i3ConfigString,i3ConfigSeparator keepend
syn region i3ConfigAction start=/focus/ skip=/\\$/ end=/[,;]\|$/ contained contains=i3ConfigFocusKeyword,i3ConfigFocusOpts,i3ConfigFocusOutput,i3ConfigString,i3ConfigSeparator keepend transparent
" 6.8 Focusing workspaces (4.21)
syn region i3ConfigAction start=/workspace / skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigWorkspaceKeyword,i3ConfigWorkspaceDir,i3ConfigNumber,i3ConfigString,i3ConfigGaps,i3ConfigWorkspaceOutput,i3ConfigVariable,i3ConfigBoolean,i3ConfigSeparator keepend
syn region i3ConfigAction start=/workspace / skip=/\\$/ end=/[,;]\|$/ contained contains=i3ConfigWorkspaceKeyword,i3ConfigWorkspaceDir,i3ConfigNumber,i3ConfigString,i3ConfigGaps,i3ConfigWorkspaceOutput,i3ConfigVariable,i3ConfigBoolean,i3ConfigSeparator keepend transparent
" 6.9-6.11 Moving containers
" 6.8.2 Renaming workspaces
syn keyword i3ConfigRenameKeyword rename contained
syn region i3ConfigAction start=/rename workspace/ end=/[,;]\|$/ contained contains=i3ConfigRenameKeyword,i3ConfigMoveDir,i3ConfigMoveType,i3ConfigNumber,i3ConfigVariable,i3ConfigString keepend transparent
" 6.5,6.9-6.11 Moving containers
syn keyword i3ConfigMoveKeyword move contained
syn keyword i3ConfigMoveDir left right down up position absolute center to contained
syn keyword i3ConfigMoveDir left right down up position absolute center to current contained
syn keyword i3ConfigMoveType window container workspace output mark mouse scratchpad contained
syn match i3ConfigUnit / px\| ppt/ contained
syn region i3ConfigAction start=/move/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigMoveKeyword,i3ConfigMoveDir,i3ConfigMoveType,i3ConfigWorkspaceDir,i3ConfigUnit,i3ConfigNumber,i3ConfigVariable,i3ConfigSeparator keepend
syn region i3ConfigAction start=/move/ skip=/\\$/ end=/[,;]\|$/ contained contains=i3ConfigMoveKeyword,i3ConfigMoveDir,i3ConfigMoveType,i3ConfigWorkspaceDir,i3ConfigUnit,i3ConfigNumber,i3ConfigVariable,i3ConfigString,i3ConfigSeparator,i3ConfigShParam keepend transparent
" 6.12 Resizing containers/windows
syn keyword i3ConfigResizeKeyword resize contained
syn keyword i3ConfigResizeOpts grow shrink up down left right set width height or contained
syn region i3ConfigAction start=/resize/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigResizeKeyword,i3ConfigResizeOpts,i3ConfigNumber,i3ConfigUnit,i3ConfigSeparator keepend
syn region i3ConfigAction start=/resize/ skip=/\\$/ end=/[,;]\|$/ contained contains=i3ConfigResizeKeyword,i3ConfigResizeOpts,i3ConfigNumber,i3ConfigUnit,i3ConfigSeparator keepend transparent
" 6.14 VIM-like marks
syn keyword i3ConfigMarkKeyword mark contained
syn match i3ConfigMark /mark\( --\(add\|replace\)\( --toggle\)\?\)\?/ contained contains=i3ConfigMarkKeyword
syn region i3ConfigAction start=/\<mark/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigMark,i3ConfigNumber,i3ConfigString,i3ConfigSeparator keepend
syn match i3ConfigMark /mark\( --\(add\|replace\)\( --toggle\)\?\)\?/ contained contains=i3ConfigShParam
syn region i3ConfigAction start=/\<mark/ skip=/\\$/ end=/[,;]\|$/ contained contains=i3ConfigMark,i3ConfigNumber,i3ConfigString,i3ConfigSeparator keepend transparent
" 6.24 Changing gaps (4.35)
syn region i3ConfigAction start=/gaps/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigGaps keepend
syn region i3ConfigAction start=/gaps/ skip=/\\$/ end=/[,;]\|$/ contained contains=i3ConfigGaps keepend transparent
" Commands useable in keybinds
syn keyword i3ConfigActionKeyword mode append_layout kill open fullscreen sticky split floating swap rename unmark show_marks title_window_icon title_format border restart reload exit scratchpad nop bar contained
syn keyword i3ConfigOption enable disable toggle key restore current horizontal vertical auto none normal pixel show container with id con_id contained
syn keyword i3ConfigActionKeyword mode append_layout kill open fullscreen sticky split floating swap unmark show_marks title_window_icon title_format border restart reload exit scratchpad nop bar contained
syn keyword i3ConfigOption default enable disable toggle key restore current horizontal vertical auto none normal pixel show container with id con_id padding hidden_state hide dock invisible contained
" Define the highlighting.
hi def link i3ConfigError Error
hi def link i3ConfigTodo Todo
hi def link i3ConfigKeyword Keyword
hi def link i3ConfigCommand Statement
hi def link i3ConfigParamLine i3ConfigString
hi def link i3ConfigOperator Operator
hi def link i3ConfigSeparator i3ConfigOperator
hi def link i3ConfigParen Delimiter
@@ -259,7 +262,6 @@ hi def link i3ConfigString String
hi def link i3ConfigColor Constant
hi def link i3ConfigNumber Number
hi def link i3ConfigIncludeKeyword i3ConfigKeyword
hi def link i3ConfigInclude i3ConfigString
hi def link i3ConfigComment Comment
hi def link i3ConfigFontKeyword i3ConfigKeyword
hi def link i3ConfigColonOperator i3ConfigOperator
@@ -278,11 +280,9 @@ hi def link i3ConfigTitleAlignOpts i3ConfigOption
hi def link i3ConfigBorderOpts i3ConfigOption
hi def link i3ConfigEdgeOpts i3ConfigOption
hi def link i3ConfigSmartBorderOpts i3ConfigOption
hi def link i3ConfigForWindowKeyword i3ConfigKeyword
hi def link i3ConfigVariable Variable
hi def link i3ConfigSetKeyword i3ConfigKeyword
hi def link i3ConfigResourceKeyword i3ConfigKeyword
hi def link i3ConfigResource i3ConfigString
hi def link i3ConfigAssignKeyword i3ConfigKeyword
hi def link i3ConfigAssignSpecial i3ConfigOption
hi def link i3ConfigExecKeyword i3ConfigCommand
@@ -293,39 +293,29 @@ hi def link i3ConfigShOper Operator
hi def link i3ConfigShCmdDelim i3ConfigShDelim
hi def link i3ConfigShCommand Normal
hi def link i3ConfigWorkspaceKeyword i3ConfigCommand
hi def link i3ConfigWorkspaceOutput i3ConfigOption
hi def link i3ConfigWorkspaceOutput i3ConfigMoveType
hi def link i3ConfigWorkspaceDir i3ConfigOption
hi def link i3ConfigDotOperator i3ConfigOperator
hi def link i3ConfigClientOpts i3ConfigOption
hi def link i3ConfigIpcKeyword i3ConfigKeyword
hi def link i3ConfigIpc i3ConfigString
hi def link i3ConfigFocusFollowsMouseOpts i3ConfigOption
hi def link i3ConfigFocusFollowsMouse i3ConfigKeyword
hi def link i3ConfigMouseWarpingOpts i3ConfigOption
hi def link i3ConfigMouseWarping i3ConfigKeyword
hi def link i3ConfigPopupFullscreenOpts i3ConfigOption
hi def link i3ConfigPopupFullscreen i3ConfigKeyword
hi def link i3ConfigFocusWrappingOpts i3ConfigOption
hi def link i3ConfigFocusWrapping i3ConfigKeyword
hi def link i3ConfigForceXinerama i3ConfigKeyword
hi def link i3ConfigAutomaticSwitch i3ConfigKeyword
hi def link i3ConfigTimeUnit i3ConfigNumber
hi def link i3ConfigDelayUrgency i3ConfigKeyword
hi def link i3ConfigFocusOnActivationOpts i3ConfigOption
hi def link i3ConfigFocusOnActivation i3ConfigKeyword
hi def link i3ConfigShowMarks i3ConfigCommand
hi def link i3ConfigTilingDragOpts i3ConfigOption
hi def link i3ConfigTilingDrag i3ConfigKeyword
hi def link i3ConfigGapsOpts i3ConfigOption
hi def link i3ConfigGaps i3ConfigCommand
hi def link i3ConfigSmartGapOpts i3ConfigOption
hi def link i3ConfigSmartGap i3ConfigKeyword
hi def link i3ConfigBarModifier i3ConfigKeyword
hi def link i3ConfigBarOpts i3ConfigKeyword
hi def link i3ConfigBarOptVals i3ConfigOption
hi def link i3ConfigColorsKeyword i3ConfigKeyword
hi def link i3ConfigColorsOpts i3ConfigOption
hi def link i3ConfigColors i3ConfigKeyword
hi def link i3ConfigConditionProp i3ConfigShParam
hi def link i3ConfigConditionFocused Constant
hi def link i3ConfigConditionSpecial Constant
hi def link i3ConfigExecActionKeyword i3ConfigShCommand
hi def link i3ConfigExecAction i3ConfigString
hi def link i3ConfigLayoutKeyword i3ConfigCommand
@@ -333,15 +323,15 @@ hi def link i3ConfigLayoutOpts i3ConfigOption
hi def link i3ConfigFocusKeyword i3ConfigCommand
hi def link i3ConfigFocusOpts i3ConfigOption
hi def link i3ConfigFocusOutputOpts i3ConfigOption
hi def link i3ConfigRenameKeyword i3ConfigCommand
hi def link i3ConfigMoveKeyword i3ConfigCommand
hi def link i3ConfigMoveDir i3ConfigOption
hi def link i3ConfigMoveType i3ConfigOption
hi def link i3ConfigMoveType Constant
hi def link i3ConfigUnit i3ConfigNumber
hi def link i3ConfigResizeKeyword i3ConfigCommand
hi def link i3ConfigResizeOpts i3ConfigOption
hi def link i3ConfigMarkKeyword i3ConfigCommand
hi def link i3ConfigMark i3ConfigShParam
hi def link i3ConfigMark i3ConfigCommand
hi def link i3ConfigActionKeyword i3ConfigCommand
hi def link i3ConfigOption Type
let b:current_syntax = "i3config"
let b:current_syntax = "i3config"
+74 -21
View File
@@ -1,7 +1,7 @@
" Language: Markdown with chunks of R, Python and other languages
" Maintainer: Jakson Aquino <jalvesaq@gmail.com>
" Homepage: https://github.com/jalvesaq/R-Vim-runtime
" Last Change: Fri Feb 24, 2023 08:28AM
" Last Change: Wed May 17, 2023 06:34AM
"
" For highlighting pandoc extensions to markdown like citations and TeX and
" many other advanced features like folding of markdown sections, it is
@@ -26,6 +26,8 @@ let g:rmd_syn_hl_chunk = get(g:, 'rmd_syn_hl_chunk', 0)
let s:save_pandoc_lngs = get(g:, 'pandoc#syntax#codeblocks#embeds#langs', [])
let g:pandoc#syntax#codeblocks#embeds#langs = []
let g:rmd_dynamic_fenced_languages = get(g:, 'rmd_dynamic_fenced_languages', v:true)
" Step_1: Source pandoc.vim if it is installed:
runtime syntax/pandoc.vim
if exists("b:current_syntax")
@@ -95,6 +97,11 @@ else
hi def link yamlColonError Error
endif
" Conceal char for manual line break
if &encoding ==# 'utf-8'
syn match rmdNewLine ' $' conceal cchar=
endif
" You don't need this if either your markdown/syntax.vim already highlights
" citations or you are writing standard markdown
if g:rmd_syn_hl_citations
@@ -127,32 +134,78 @@ syn match knitrBodyValue ': \zs.*\ze$' keepend contained containedin=knitrBodyOp
syn match knitrBodyVar '| \zs\S\{-}\ze:' contained containedin=knitrBodyOptions
let g:rmd_fenced_languages = get(g:, 'rmd_fenced_languages', ['r'])
for s:type in g:rmd_fenced_languages
if s:type =~ '='
let s:ft = substitute(s:type, '.*=', '', '')
let s:nm = substitute(s:type, '=.*', '', '')
else
let s:ft = s:type
let s:nm = s:type
endif
unlet! b:current_syntax
exe 'syn include @Rmd'.s:nm.' syntax/'.s:ft.'.vim'
if g:rmd_syn_hl_chunk
exe 'syn match knitrChunkDelim /```\s*{\s*'.s:nm.'/ contained containedin=knitrChunkBrace contains=knitrChunkLabel'
exe 'syn match knitrChunkLabelDelim /```\s*{\s*'.s:nm.',\=\s*[-[:alnum:]]\{-1,}[,}]/ contained containedin=knitrChunkBrace'
syn match knitrChunkDelim /}\s*$/ contained containedin=knitrChunkBrace
exe 'syn match knitrChunkBrace /```\s*{\s*'.s:nm.'.*$/ contained containedin=rmd'.s:nm.'Chunk contains=knitrChunkDelim,knitrChunkLabelDelim,@Rmd'.s:nm
exe 'syn region rmd'.s:nm.'Chunk start="^\s*```\s*{\s*=\?'.s:nm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=knitrChunkBrace,@Rmd'.s:nm
hi link knitrChunkLabel Identifier
hi link knitrChunkDelim rmdCodeDelim
hi link knitrChunkLabelDelim rmdCodeDelim
let s:no_syntax_vim = []
function IncludeLanguage(lng)
if a:lng =~ '='
let ftpy = substitute(a:lng, '.*=', '', '')
let lnm = substitute(a:lng, '=.*', '', '')
else
exe 'syn region rmd'.s:nm.'Chunk matchgroup=rmdCodeDelim start="^\s*```\s*{\s*=\?'.s:nm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=@Rmd'.s:nm
let ftpy = a:lng
let lnm = a:lng
endif
if index(s:no_syntax_vim, ftpy) >= 0
return
endif
if len(globpath(&rtp, "syntax/" . ftpy . ".vim"))
unlet! b:current_syntax
exe 'syn include @Rmd'.lnm.' syntax/'.ftpy.'.vim'
let b:current_syntax = "rmd"
if g:rmd_syn_hl_chunk
exe 'syn match knitrChunkDelim /```\s*{\s*'.lnm.'/ contained containedin=knitrChunkBrace contains=knitrChunkLabel'
exe 'syn match knitrChunkLabelDelim /```\s*{\s*'.lnm.',\=\s*[-[:alnum:]]\{-1,}[,}]/ contained containedin=knitrChunkBrace'
syn match knitrChunkDelim /}\s*$/ contained containedin=knitrChunkBrace
exe 'syn match knitrChunkBrace /```\s*{\s*'.lnm.'.*$/ contained containedin=rmd'.lnm.'Chunk contains=knitrChunkDelim,knitrChunkLabelDelim,@Rmd'.lnm
exe 'syn region rmd'.lnm.'Chunk start="^\s*```\s*{\s*=\?'.lnm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=knitrChunkBrace,@Rmd'.lnm
hi link knitrChunkLabel Identifier
hi link knitrChunkDelim rmdCodeDelim
hi link knitrChunkLabelDelim rmdCodeDelim
else
exe 'syn region rmd'.lnm.'Chunk matchgroup=rmdCodeDelim start="^\s*```\s*{\s*=\?'.lnm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=@Rmd'.lnm
endif
else
" Avoid the cost of running globpath() whenever the buffer is saved
let s:no_syntax_vim += [ftpy]
endif
endfunction
for s:type in g:rmd_fenced_languages
call IncludeLanguage(s:type)
endfor
unlet! s:type
function CheckRmdFencedLanguages()
let alines = getline(1, '$')
call filter(alines, "v:val =~ '^```{'")
call map(alines, "substitute(v:val, '^```{', '', '')")
call map(alines, "substitute(v:val, '\\W.*', '', '')")
for tpy in alines
if len(tpy) == 0
continue
endif
let has_lng = 0
for lng in g:rmd_fenced_languages
if tpy == lng
let has_lng = 1
continue
endif
endfor
if has_lng == 0
let g:rmd_fenced_languages += [tpy]
call IncludeLanguage(tpy)
endif
endfor
endfunction
if g:rmd_dynamic_fenced_languages
call CheckRmdFencedLanguages()
augroup RmdSyntax
autocmd!
autocmd BufWritePost <buffer> call CheckRmdFencedLanguages()
augroup END
endif
" Step_4: Highlight code recognized by pandoc but not defined in pandoc.vim yet:
syn match pandocDivBegin '^:::\+ {.\{-}}' contains=pandocHeaderAttr
syn match pandocDivEnd '^:::\+$'
+75 -53
View File
@@ -1,10 +1,9 @@
" Vim syntax file
" Language: sway window manager config
" Original Author: Josef Litos
" Language: sway config file
" Original Author: Josef Litos (JosefLitos/i3config.vim)
" Maintainer: James Eapen <james.eapen@vai.org>
" Version: 0.2.2
" Reference version (JosefLitos/i3config.vim): 1.8.1
" Last Change: 2023-09-12
" Version: 1.0.0
" Last Change: 2023-09-14
" References:
" http://i3wm.org/docs/userguide.html#configuring
@@ -20,9 +19,12 @@ endif
runtime! syntax/i3config.vim
" i3 extensions
syn match i3ConfigSet /^\s*set \$\w\+ .*$/ contains=i3ConfigVariable,i3ConfigSetKeyword,i3ConfigColor,i3ConfigString,i3ConfigNoStartupId,i3ConfigNumber,swayConfigOutputCommand,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShParam,i3ConfigShOper
syn keyword i3ConfigActionKeyword opacity urgent shortcuts_inhibitor splitv splith splitt contained
syn keyword i3ConfigOption set plus minus allow deny csd v h t contained
syn keyword i3ConfigActionKeyword opacity contained
syn keyword i3ConfigConditionProp app_id pid shell contained
syn keyword i3ConfigWorkspaceDir prev_on_output next_on_output contained
syn keyword swayConfigBindKeyword bindswitch bindgesture contained
syn match i3ConfigBindArgument /--\(locked\|to-code\|no-repeat\|input-device=[:0-9a-zA-Z_/-]\+\|no-warn\)/ contained
@@ -31,6 +33,8 @@ syn region i3ConfigBind start=/^\s*bind\(switch\|gesture\) / skip=/\\$/ end=/$/
syn match swayConfigBindBlockHeader /^\s*bind\(sym\|code\) .*{$/ contained contains=i3ConfigBindKeyword,i3ConfigBindArgument,i3ConfigParen
syn match swayConfigBindBlockCombo /^\s\+\(--[a-z-]\+ \)*[$a-zA-Z0-9_+]\+ [a-z[]\@=/ contained contains=i3ConfigBindArgument,i3ConfigBindCombo
syn region i3ConfigBind start=/^\s*bind\(sym\|code\) .*{$/ end=/^\s*}$/ contains=swayConfigBindBlockHeader,swayConfigBindBlockCombo,i3ConfigCriteria,i3ConfigAction,i3ConfigSeparator,i3ConfigActionKeyword,i3ConfigOption,i3ConfigString,i3ConfigNumber,i3ConfigVariable,i3ConfigBoolean,i3ConfigComment,i3ConfigParen fold keepend extend
" fix for extra long bindsym blocks that would be parsed incorrectly when scrolling up
syn region i3ConfigBlockOrphan start=/^\s\+\S/ skip=/^\s\|^$/ end=/^}\?/ contains=swayConfigBindBlockCombo,i3ConfigCriteria,i3ConfigAction,i3ConfigSeparator,i3ConfigActionKeyword,i3ConfigOption,i3ConfigString,i3ConfigNumber,i3ConfigVariable,i3ConfigBoolean,i3ConfigComment,i3ConfigParen keepend extend
syn keyword i3ConfigClientOpts focused_tab_title contained
@@ -39,16 +43,22 @@ syn region swayConfigExecBlock start=/exec\(_always\)\? {/ end=/^}$/ contains=i3
syn keyword swayConfigFloatingModifierOpts normal inverse contained
syn match i3ConfigKeyword /^floating_modifier [$a-zA-Z0-9+]\+ \(normal\|inverse\)$/ contains=i3ConfigVariable,i3ConfigBindModkey,swayConfigFloatingModifierOpts
syn match i3ConfigEdge /^hide_edge_borders\( --i3\)\? \(none\|vertical\|horizontal\|both\|smart\|smart_no_gaps\)\s\?$/ contains=i3ConfigEdgeKeyword,i3ConfigShParam
syn match i3ConfigKeyword /^hide_edge_borders --i3 \w*$/ contains=i3ConfigEdgeKeyword,i3ConfigShParam
syn keyword i3ConfigBarBlockKeyword swaybar_command gaps height pango_markup status_edge_padding status_padding wrap_scroll tray_bindcode tray_bindsym icon_theme contained
syn keyword i3ConfigBarOpts swaybar_command gaps height pango_markup status_edge_padding status_padding wrap_scroll tray_bindcode tray_bindsym icon_theme contained
syn keyword i3ConfigBarOptVals overlay contained
syn keyword i3ConfigExecActionKeyword swaymsg contained
" Sway-only options
" Xwayland
syn keyword swayConfigXOpt enable disable force contained
syn match i3ConfigKeyword /^xwayland .*$/ contains=swayConfigXOpt
syn match i3ConfigKeyword /^xwayland \w*$/ contains=swayConfigXOpt
" Inhibit idle
syn keyword swayConfigInhibitKeyword inhibit_idle contained
syn keyword swayConfigInhibitOpts focus fullscreen open none visible contained
syn match i3ConfigAction /inhibit_idle \w*/ contained contains=swayConfigInhibitKeyword,swayConfigInhibitOpts
" Bindswitch
syn match swayConfigBindswitchArgument /--\(locked\|no-warn\|reload\)/ contained
@@ -64,65 +74,77 @@ syn keyword swayConfigBindgestureDir up down left right inward outward clockwise
syn match swayConfigBindgesture /\(hold\(:[1-5]\)\?\|swipe\(:[3-5]\)\?\(:up\|:down\|:left\|:right\)\?\|pinch\(:[2-5]\)\?:\(+\?\(inward\|outward\|clockwise\|counterclockwise\|up\|down\|left\|right\)\)\+\) / contained contains=i3ConfigNumber,swayConfigBindgestureType,i3ConfigColonOperator,swayConfigBindgestureDir,i3ConfigBindModifier
syn region i3ConfigBind start=/^\s*bindgesture\s\+.*{$/ end=/^\s*}$/ contains=swayConfigBindKeyword,swayConfigBindgesture,swayConfigBindgestureArgument,i3ConfigCriteria,i3ConfigAction,i3ConfigSeparator,i3ConfigActionKeyword,i3ConfigOption,i3ConfigString,i3ConfigNumber,i3ConfigVariable,i3ConfigBoolean,i3ConfigParen fold keepend extend
" Tiling drag threshold
syn match i3ConfigKeyword /^tiling_drag_threshold \d\+$/ contains=i3ConfigNumber
" Titlebar commands
syn match i3ConfigKeyword /^titlebar_border_thickness \(\d\+\|\$\S\+\)$/ contains=i3ConfigNumber,i3ConfigVariable
syn match i3ConfigKeyword /^titlebar_padding \(\d\+\|\$\S\+\)\( \d\+\)\?$/ contains=i3ConfigNumber,i3ConfigVariable
syn match swayConfigDeviceOps /[*,:;]/ contained
" Output monitors
syn keyword swayConfigOutputKeyword output contained
syn keyword swayConfigOutputOpts mode resolution res modeline position pos scale scale_filter subpixel background bg transform disable enable power dpms max_render_time adaptive_sync render_bit_depth contained
syn keyword swayConfigOutputOptVals linear nearest smart rgb bgr vrgb vbgr none normal flipped fill stretch fit center tile solid_color clockwise anticlockwise toggle contained
syn match swayConfigOutputFPS /@[0-9.]\+Hz/ contained
syn match swayConfigOutputMode / [0-9]\+x[0-9]\+\(@[0-9.]\+Hz\)\?/ contained contains=swayConfigOutputFPS,i3ConfigNumber
syn region i3ConfigAction start=/output/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=swayConfigOutputKeyword,swayConfigOutputMode,swayConfigOutputOpts,swayConfigOutputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigString,i3ConfigColor,i3ConfigBoolean,swayConfigDeviceOps keepend
syn region swayConfigOutput start=/^output/ skip=/\\$/ end=/$/ contains=swayConfigOutputKeyword,swayConfigOutputMode,swayConfigOutputOpts,swayConfigOutputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigString,i3ConfigColor,i3ConfigBoolean,swayConfigDeviceOps keepend
syn region swayConfigOutput start=/^output .* {$/ end=/}$/ contains=swayConfigOutputKeyword,swayConfigOutputMode,swayConfigOutputOpts,swayConfigOutputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigString,i3ConfigColor,i3ConfigBoolean,swayConfigDeviceOps,i3ConfigParen keepend extend
" Input devices
syn keyword swayConfigInputKeyword input contained
syn keyword swayConfigInputType touchpad pointer keyboard touch tablet_tool tablet_pad switch contained
syn match swayConfigInputTypePair /\<type:\w\+\>/ contained contains=i3ConfigColonOperator,swayConfigInputType
syn region swayConfigInputStart start=/^input / end=/\s/ contained contains=swayConfigInputKeyword,swayConfigInputTypePair,i3ConfigString keepend extend
syn keyword swayConfigInputOpts xkb_layout xkb_variant xkb_rules xkb_switch_layout xkb_numlock xkb_file xkb_capslock xkb_model repeat_delay repeat_rate map_to_output map_to_region map_from_region tool_mode accel_profile dwt dwtp drag_lock drag click_method middle_emulation tap events calibration_matrix natural_scroll left_handed pointer_accel scroll_button scroll_factor scroll_method tap_button_map contained
syn keyword swayConfigInputOptVals absolute relative adaptive flat none button_areas clickfinger toggle two_finger edge on_button_down lrm lmr contained
syn match swayConfigColonPairVal /:[0-9a-z_-]\+/ contained contains=i3ConfigColonOperator
syn match swayConfigColonPair /[a-z]\+:[0-9a-z_-]\+/ contained contains=swayConfigColonPairVal
syn match swayConfigInputXkbOpts /xkb_options \([a-z]\+:[0-9a-z_-]\+,\?\)\+/ contained contains=swayConfigColonPair,swayConfigDeviceOps
syn region i3ConfigAction start=/input/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=swayConfigInputKeyword,swayConfigColonPair,swayConfigInputXkbOpts,swayConfigInputOpts,swayConfigInputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigString,i3ConfigBoolean,swayConfigDeviceOps keepend
syn region i3ConfigInput start=/^input/ skip=/\\$/ end=/$/ contains=swayConfigInputKeyword,swayConfigColonPair,swayConfigInputXkbOpts,swayConfigInputOpts,swayConfigInputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigString,i3ConfigBoolean,swayConfigDeviceOps keepend
syn region i3ConfigInput start=/^input .* {/ end=/}$/ contains=swayConfigInputKeyword,swayConfigColonPair,swayConfigInputXkbOpts,swayConfigInputOpts,swayConfigInputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigString,i3ConfigBoolean,swayConfigDeviceOps,i3ConfigParen keepend extend
syn keyword swayConfigInputOptVals absolute relative adaptive flat none button_areas clickfinger toggle two_finger edge on_button_down lrm lmr next prev pen eraser brush pencil airbrush disabled_on_external_mouse disable contained
syn match swayConfigXkbOptsPairVal /:[0-9a-z_-]\+/ contained contains=i3ConfigColonOperator
syn match swayConfigXkbOptsPair /[a-z]\+:[0-9a-z_-]\+/ contained contains=swayConfigXkbOptsPairVal
syn match swayConfigInputXkbOpts /xkb_options \([a-z]\+:[0-9a-z_-]\+,\?\)\+/ contained contains=swayConfigXkbOptsPair,swayConfigDeviceOps
syn region i3ConfigAction start=/input/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=swayConfigInputStart,swayConfigInputXkbOpts,swayConfigInputOpts,swayConfigInputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigBoolean,swayConfigDeviceOps keepend transparent
syn region i3ConfigInput start=/^input/ skip=/\\$/ end=/$/ contains=swayConfigInputStart,swayConfigInputXkbOpts,swayConfigInputOpts,swayConfigInputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigBoolean,swayConfigDeviceOps keepend
syn region i3ConfigInput start=/^input .* {/ end=/}$/ contains=swayConfigInputStart,swayConfigInputXkbOpts,swayConfigInputOpts,swayConfigInputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigBoolean,swayConfigDeviceOps,i3ConfigParen keepend extend
" Seat
syn keyword swayConfigSeatKeyword seat contained
syn keyword swayConfigSeatOpts attach cursor fallback hide_cursor idle_inhibit idle_wake keyboard_grouping shortcuts_inhibitor pointer_constraint xcursor_theme contained
syn match swayConfigSeatOptVals /when-typing/ contained
syn keyword swayConfigSeatOptVals move set press release none smart activate deactivate toggle escape enable disable contained
syn region i3ConfigAction start=/seat/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=swayConfigSeatKeyword,i3ConfigString,i3ConfigNumber,i3ConfigBoolean,swayConfigSeatOptVals,swayConfigSeatOpts,swayConfigDeviceOps keepend
syn region swayConfigSeat start=/seat/ skip=/\\$/ end=/$/ contains=swayConfigSeatKeyword,i3ConfigString,i3ConfigNumber,i3ConfigBoolean,swayConfigSeatOptVals,swayConfigSeatOpts,swayConfigDeviceOps keepend
syn region swayConfigSeat start=/seat .* {$/ end=/}$/ contains=swayConfigSeatKeyword,i3ConfigString,i3ConfigNumber,i3ConfigBoolean,swayConfigSeatOptVals,swayConfigSeatOpts,swayConfigDeviceOps,i3ConfigParen keepend extend
syn region i3ConfigAction start=/seat/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=swayConfigSeatKeyword,i3ConfigString,i3ConfigNumber,i3ConfigBoolean,swayConfigSeatOptVals,swayConfigSeatOpts,swayConfigDeviceOps,swayConfigInputType keepend transparent
syn region swayConfigSeat start=/seat/ skip=/\\$/ end=/$/ contains=swayConfigSeatKeyword,i3ConfigString,i3ConfigNumber,i3ConfigBoolean,swayConfigSeatOptVals,swayConfigSeatOpts,swayConfigDeviceOps,swayConfigInputType keepend
syn region swayConfigSeat start=/seat .* {$/ end=/}$/ contains=swayConfigSeatKeyword,i3ConfigString,i3ConfigNumber,i3ConfigBoolean,swayConfigSeatOptVals,swayConfigSeatOpts,swayConfigDeviceOps,i3ConfigParen,swayConfigInputType keepend extend
" Output monitors
syn keyword swayConfigOutputKeyword output contained
syn keyword swayConfigOutputOpts mode resolution res modeline position pos scale scale_filter subpixel background bg transform disable enable power dpms max_render_time adaptive_sync render_bit_depth contained
syn keyword swayConfigOutputOptVals linear nearest smart rgb bgr vrgb vbgr none normal flipped fill stretch fit center tile solid_color clockwise anticlockwise toggle contained
syn match swayConfigOutputOptVals /--custom\|flipped-\(90\|180\|270\)/ contained
syn match swayConfigOutputFPS /@[0-9.]\+Hz/ contained
syn match swayConfigOutputMode / [0-9]\+x[0-9]\+\(@[0-9.]\+Hz\)\?/ contained contains=swayConfigOutputFPS
syn region i3ConfigAction start=/output/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=swayConfigOutputKeyword,swayConfigOutputMode,swayConfigOutputOpts,swayConfigOutputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigString,i3ConfigColor,i3ConfigBoolean,swayConfigDeviceOps keepend transparent
syn region swayConfigOutput start=/^output/ skip=/\\$/ end=/$/ contains=swayConfigOutputKeyword,swayConfigOutputMode,swayConfigOutputOpts,swayConfigOutputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigString,i3ConfigColor,i3ConfigBoolean,swayConfigDeviceOps keepend
syn region swayConfigOutput start=/^output .* {$/ end=/}$/ contains=swayConfigOutputKeyword,swayConfigOutputMode,swayConfigOutputOpts,swayConfigOutputOptVals,i3ConfigVariable,i3ConfigNumber,i3ConfigString,i3ConfigColor,i3ConfigBoolean,swayConfigDeviceOps,i3ConfigParen keepend extend
" Define the highlighting.
hi def link swayConfigFloatingModifierOpts i3ConfigOption
hi def link swayConfigBindKeyword i3ConfigBindKeyword
hi def link swayConfigXOpt i3ConfigOption
hi def link swayConfigBindswitchArgument i3ConfigBindArgument
hi def link swayConfigBindswitchType i3ConfigMoveType
hi def link swayConfigBindswitchState i3ConfigMoveDir
hi def link swayConfigBindgestureArgument i3ConfigBindArgument
hi def link swayConfigBindgestureType i3ConfigMoveType
hi def link swayConfigBindgestureDir i3ConfigMoveDir
hi def link swayConfigDeviceOps i3ConfigOperator
hi def link swayConfigOutputKeyword i3ConfigCommand
hi def link swayConfigOutputOptVals i3ConfigOption
hi def link swayConfigOutputOpts i3ConfigOption
hi def link swayConfigOutputFPS Constant
hi def link swayConfigInputKeyword i3ConfigCommand
hi def link swayConfigInputOptVals i3ConfigShParam
hi def link swayConfigInputOpts i3ConfigOption
hi def link swayConfigInputXkbOpts i3ConfigOption
hi def link swayConfigColonPairVal i3ConfigString
hi def link swayConfigColonPair i3ConfigShParam
hi def link swayConfigSeatKeyword i3ConfigCommand
hi def link swayConfigSeatOptVals i3ConfigOption
hi def link swayConfigSeatOpts i3ConfigOption
hi def link swayConfigFloatingModifierOpts i3ConfigOption
hi def link swayConfigBindKeyword i3ConfigBindKeyword
hi def link swayConfigXOpt i3ConfigOption
hi def link swayConfigInhibitKeyword i3ConfigCommand
hi def link swayConfigInhibitOpts i3ConfigOption
hi def link swayConfigBindswitchArgument i3ConfigBindArgument
hi def link swayConfigBindswitchType i3ConfigMoveType
hi def link swayConfigBindswitchState i3ConfigMoveDir
hi def link swayConfigBindgestureArgument i3ConfigBindArgument
hi def link swayConfigBindgestureType i3ConfigMoveType
hi def link swayConfigBindgestureDir i3ConfigMoveDir
hi def link swayConfigDeviceOps i3ConfigOperator
hi def link swayConfigInputKeyword i3ConfigCommand
hi def link swayConfigInputType i3ConfigMoveType
hi def link swayConfigInputTypePair i3ConfigMoveDir
hi def link swayConfigInputOptVals i3ConfigShParam
hi def link swayConfigInputOpts i3ConfigOption
hi def link swayConfigXkbOptsPairVal i3ConfigString
hi def link swayConfigXkbOptsPair i3ConfigShParam
hi def link swayConfigInputXkbOpts i3ConfigOption
hi def link swayConfigSeatKeyword i3ConfigCommand
hi def link swayConfigSeatOptVals swayConfigInputOptVals
hi def link swayConfigSeatOpts swayConfigInputOpts
hi def link swayConfigOutputKeyword i3ConfigCommand
hi def link swayConfigOutputOptVals swayConfigInputOptVals
hi def link swayConfigOutputOpts swayConfigInputOpts
hi def link swayConfigOutputFPS Constant
hi def link swayConfigOutputMode i3ConfigNumber
let b:current_syntax = "swayconfig"
+10
View File
@@ -2738,6 +2738,16 @@ get_event_name(expand_T *xp UNUSED, int idx)
return (char_u *)event_names[idx - augroups.ga_len].name;
}
/*
* Function given to ExpandGeneric() to obtain the list of event names. Don't
* include groups.
*/
char_u *
get_event_name_no_group(expand_T *xp UNUSED, int idx)
{
return (char_u *)event_names[idx].name;
}
#if defined(FEAT_EVAL) || defined(PROTO)
/*
+1
View File
@@ -1270,6 +1270,7 @@ did_set_clipboard(optset_T *args UNUSED)
for (p = p_cb; *p != NUL; )
{
// Note: Keep this in sync with p_cb_values.
if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
{
new_unnamed |= CLIP_UNNAMED;
+22 -19
View File
@@ -15,9 +15,6 @@
static int cmd_showtail; // Only show path tail in lists ?
static int ExpandGeneric(char_u *pat, expand_T *xp, regmatch_T *regmatch,
char_u ***matches, int *numMatches,
char_u *((*func)(expand_T *, int)), int escaped);
static int ExpandFromContext(expand_T *xp, char_u *, char_u ***, int *, int);
static char_u *showmatches_gettail(char_u *s);
static int expand_showtail(expand_T *xp);
@@ -54,6 +51,8 @@ cmdline_fuzzy_completion_supported(expand_T *xp)
&& xp->xp_context != EXPAND_FILETYPE
&& xp->xp_context != EXPAND_HELP
&& xp->xp_context != EXPAND_OLD_SETTING
&& xp->xp_context != EXPAND_STRING_SETTING
&& xp->xp_context != EXPAND_SETTING_SUBTRACT
&& xp->xp_context != EXPAND_OWNSYNTAX
&& xp->xp_context != EXPAND_PACKADD
&& xp->xp_context != EXPAND_RUNTIME
@@ -696,8 +695,7 @@ win_redr_status_matches(
static char_u *
get_next_or_prev_match(
int mode,
expand_T *xp,
char_u *orig_save)
expand_T *xp)
{
int findex = xp->xp_selected;
int ht;
@@ -757,14 +755,14 @@ get_next_or_prev_match(
// When wrapping around, return the original string, set findex to -1.
if (findex < 0)
{
if (orig_save == NULL)
if (xp->xp_orig == NULL)
findex = xp->xp_numfiles - 1;
else
findex = -1;
}
if (findex >= xp->xp_numfiles)
{
if (orig_save == NULL)
if (xp->xp_orig == NULL)
findex = 0;
else
findex = -1;
@@ -780,7 +778,7 @@ get_next_or_prev_match(
xp->xp_selected = findex;
if (findex == -1)
return vim_strsave(orig_save);
return vim_strsave(xp->xp_orig);
return vim_strsave(xp->xp_files[findex]);
}
@@ -915,8 +913,8 @@ find_longest_match(expand_T *xp, int options)
* Return NULL for failure.
*
* "orig" is the originally expanded string, copied to allocated memory. It
* should either be kept in orig_save or freed. When "mode" is WILD_NEXT or
* WILD_PREV "orig" should be NULL.
* should either be kept in "xp->xp_orig" or freed. When "mode" is WILD_NEXT
* or WILD_PREV "orig" should be NULL.
*
* Results are cached in xp->xp_files and xp->xp_numfiles, except when "mode"
* is WILD_EXPAND_FREE or WILD_ALL.
@@ -956,7 +954,6 @@ ExpandOne(
int mode)
{
char_u *ss = NULL;
static char_u *orig_save = NULL; // kept value of orig
int orig_saved = FALSE;
int i;
long_u len;
@@ -964,13 +961,13 @@ ExpandOne(
// first handle the case of using an old match
if (mode == WILD_NEXT || mode == WILD_PREV
|| mode == WILD_PAGEUP || mode == WILD_PAGEDOWN)
return get_next_or_prev_match(mode, xp, orig_save);
return get_next_or_prev_match(mode, xp);
if (mode == WILD_CANCEL)
ss = vim_strsave(orig_save ? orig_save : (char_u *)"");
ss = vim_strsave(xp->xp_orig ? xp->xp_orig : (char_u *)"");
else if (mode == WILD_APPLY)
ss = vim_strsave(xp->xp_selected == -1
? (orig_save ? orig_save : (char_u *)"")
? (xp->xp_orig ? xp->xp_orig : (char_u *)"")
: xp->xp_files[xp->xp_selected]);
// free old names
@@ -978,7 +975,7 @@ ExpandOne(
{
FreeWild(xp->xp_numfiles, xp->xp_files);
xp->xp_numfiles = -1;
VIM_CLEAR(orig_save);
VIM_CLEAR(xp->xp_orig);
// The entries from xp_files may be used in the PUM, remove it.
if (compl_match_array != NULL)
@@ -991,8 +988,8 @@ ExpandOne(
if (xp->xp_numfiles == -1 && mode != WILD_APPLY && mode != WILD_CANCEL)
{
vim_free(orig_save);
orig_save = orig;
vim_free(xp->xp_orig);
xp->xp_orig = orig;
orig_saved = TRUE;
ss = ExpandOne_start(mode, xp, str, options);
@@ -1045,7 +1042,7 @@ ExpandOne(
if (mode == WILD_EXPAND_FREE || mode == WILD_ALL)
ExpandCleanup(xp);
// Free "orig" if it wasn't stored in "orig_save".
// Free "orig" if it wasn't stored in "xp->xp_orig".
if (!orig_saved)
vim_free(orig);
@@ -1075,6 +1072,7 @@ ExpandCleanup(expand_T *xp)
FreeWild(xp->xp_numfiles, xp->xp_files);
xp->xp_numfiles = -1;
}
VIM_CLEAR(xp->xp_orig);
}
/*
@@ -3106,6 +3104,10 @@ ExpandFromContext(
if (xp->xp_context == EXPAND_SETTINGS
|| xp->xp_context == EXPAND_BOOL_SETTINGS)
ret = ExpandSettings(xp, &regmatch, pat, numMatches, matches, fuzzy);
else if (xp->xp_context == EXPAND_STRING_SETTING)
ret = ExpandStringSetting(xp, &regmatch, numMatches, matches);
else if (xp->xp_context == EXPAND_SETTING_SUBTRACT)
ret = ExpandSettingSubtract(xp, &regmatch, numMatches, matches);
else if (xp->xp_context == EXPAND_MAPPINGS)
ret = ExpandMappings(pat, &regmatch, numMatches, matches);
#if defined(FEAT_EVAL)
@@ -3134,7 +3136,7 @@ ExpandFromContext(
*
* Returns OK when no problems encountered, FAIL for error (out of memory).
*/
static int
int
ExpandGeneric(
char_u *pat,
expand_T *xp,
@@ -3239,6 +3241,7 @@ ExpandGeneric(
// applies to the completion context. Menus and scriptnames should be kept
// in the specified order.
if (!fuzzy && xp->xp_context != EXPAND_MENUNAMES
&& xp->xp_context != EXPAND_STRING_SETTING
&& xp->xp_context != EXPAND_MENUS
&& xp->xp_context != EXPAND_SCRIPTNAMES)
sort_matches = TRUE;
+2
View File
@@ -2266,6 +2266,7 @@ diffopt_changed(void)
p = p_dip;
while (*p != NUL)
{
// Note: Keep this in sync with p_dip_values
if (STRNCMP(p, "filler", 6) == 0)
{
p += 6;
@@ -2343,6 +2344,7 @@ diffopt_changed(void)
}
else if (STRNCMP(p, "algorithm:", 10) == 0)
{
// Note: Keep this in sync with p_dip_algorithm_values.
p += 10;
if (STRNCMP(p, "myers", 5) == 0)
{
+25 -9
View File
@@ -2401,6 +2401,7 @@ EXTERN char e_io_file_requires_name_to_be_set[]
#ifdef FEAT_EVAL
EXTERN char e_invalid_callback_argument[]
INIT(= N_("E921: Invalid callback argument"));
// E922 unused
EXTERN char e_second_argument_of_function_must_be_list_or_dict[]
INIT(= N_("E923: Second argument of function() must be a list or a dict"));
#endif
@@ -2795,7 +2796,7 @@ EXTERN char e_no_white_space_allowed_after_dot[]
INIT(= N_("E1074: No white space allowed after dot"));
EXTERN char e_namespace_not_supported_str[]
INIT(= N_("E1075: Namespace not supported: %s"));
// E1076 was deleted
// E1076 unused (was deleted)
EXTERN char e_missing_argument_type_for_str[]
INIT(= N_("E1077: Missing argument type for %s"));
#endif
@@ -2863,6 +2864,7 @@ PLURAL_MSG(e_one_argument_too_many, "E1106: One argument too many",
EXTERN char e_string_list_dict_or_blob_required[]
INIT(= N_("E1107: String, List, Dict or Blob required"));
// E1108 unused
EXTERN char e_list_item_nr_is_not_list[]
INIT(= N_("E1109: List item %d is not a List"));
EXTERN char e_list_item_nr_does_not_contain_3_numbers[]
@@ -3215,6 +3217,7 @@ EXTERN char e_list_dict_blob_or_string_required_for_argument_nr[]
INIT(= N_("E1251: List, Dictionary, Blob or String required for argument %d"));
EXTERN char e_string_list_or_blob_required_for_argument_nr[]
INIT(= N_("E1252: String, List or Blob required for argument %d"));
// E1253 unused
EXTERN char e_cannot_use_script_variable_in_for_loop[]
INIT(= N_("E1254: Cannot use script variable in for loop"));
#endif
@@ -3528,19 +3531,32 @@ EXTERN char e_class_method_str_accessible_only_using_class_str[]
INIT(= N_("E1385: Class method \"%s\" accessible only using class \"%s\""));
EXTERN char e_object_method_str_accessible_only_using_object_str[]
INIT(= N_("E1386: Object method \"%s\" accessible only using class \"%s\" object"));
EXTERN char e_public_variable_not_supported_in_interface[]
INIT(= N_("E1387: Public variable not supported in an interface"));
EXTERN char e_public_keyword_not_supported_for_method[]
INIT(= N_("E1388: Public keyword not supported for a method"));
EXTERN char e_missing_name_after_implements[]
INIT(= N_("E1389: Missing name after implements"));
EXTERN char e_cannot_use_an_object_variable_except_with_the_new_method_str[]
INIT(= N_("E1390: Cannot use an object variable \"this.%s\" except with the \"new\" method"));
EXTERN char e_cannot_lock_object_variable_str[]
INIT(= N_("E1391: Cannot (un)lock variable \"%s\" in class \"%s\""));
EXTERN char e_cannot_lock_class_variable_str[]
INIT(= N_("E1392: Cannot (un)lock class variable \"%s\" in class \"%s\""));
#endif
// E1393 - E1499 unused (reserved for Vim9 class support)
EXTERN char e_cannot_mix_positional_and_non_positional_str[]
INIT(= N_("E1400: Cannot mix positional and non-positional arguments: %s"));
INIT(= N_("E1500: Cannot mix positional and non-positional arguments: %s"));
EXTERN char e_fmt_arg_nr_unused_str[]
INIT(= N_("E1401: format argument %d unused in $-style format: %s"));
INIT(= N_("E1501: format argument %d unused in $-style format: %s"));
EXTERN char e_positional_num_field_spec_reused_str_str[]
INIT(= N_("E1402: Positional argument %d used as field width reused as different type: %s/%s"));
INIT(= N_("E1502: Positional argument %d used as field width reused as different type: %s/%s"));
EXTERN char e_positional_nr_out_of_bounds_str[]
INIT(= N_("E1403: Positional argument %d out of bounds: %s"));
INIT(= N_("E1503: Positional argument %d out of bounds: %s"));
EXTERN char e_positional_arg_num_type_inconsistent_str_str[]
INIT(= N_("E1404: Positional argument %d type used inconsistently: %s/%s"));
INIT(= N_("E1504: Positional argument %d type used inconsistently: %s/%s"));
EXTERN char e_invalid_format_specifier_str[]
INIT(= N_("E1405: Invalid format specifier: %s"));
INIT(= N_("E1505: Invalid format specifier: %s"));
// E1506 - E1519 unused
EXTERN char e_aptypes_is_null_nr_str[]
INIT(= "E1408: Internal error: ap_types or ap_types[idx] is NULL: %d: %s");
// E1387 - E1399 unused
INIT(= "E1520: Internal error: ap_types or ap_types[idx] is NULL: %d: %s");
+95 -9
View File
@@ -985,6 +985,62 @@ eval_foldexpr(win_T *wp, int *cp)
}
#endif
/*
* Fill in "lp" using "root". This is used in a special case when
* "get_lval()" parses a bare word when "lval_root" is not NULL.
*
* This is typically called with "lval_root" as "root". For a class, find
* the name from lp in the class from root, fill in lval_T if found. For a
* complex type, list/dict use it as the result; just put the root into
* ll_tv.
*
* "lval_root" is a hack used during run-time/instr-execution to provide the
* starting point for "get_lval()" to traverse a chain of indexes. In some
* cases get_lval sees a bare name and uses this function to populate the
* lval_T.
*
* For setting up "lval_root" (currently only used with lockvar)
* compile_lock_unlock - pushes object on stack (which becomes lval_root)
* execute_instructions: ISN_LOCKUNLOCK - sets lval_root from stack.
*/
static void
get_lval_root(lval_T *lp, typval_T *root, int is_arg)
{
#ifdef LOG_LOCKVAR
ch_log(NULL, "LKVAR: get_lvalroot(): name %s", lp->ll_name);
#endif
if (!is_arg && root->v_type == VAR_CLASS)
{
if (root->vval.v_class != NULL)
{
// Special special case. Look for a bare class variable reference.
class_T *cl = root->vval.v_class;
int m_idx;
ocmember_T *m = class_member_lookup(cl, lp->ll_name,
lp->ll_name_end - lp->ll_name, &m_idx);
if (m != NULL)
{
// Assuming "inside class" since bare reference.
lp->ll_class = root->vval.v_class;
lp->ll_oi = m_idx;
lp->ll_valtype = m->ocm_type;
lp->ll_tv = &lp->ll_class->class_members_tv[m_idx];
#ifdef LOG_LOCKVAR
ch_log(NULL, "LKVAR: get_lvalroot() class member: name %s",
lp->ll_name);
#endif
return;
}
}
}
#ifdef LOG_LOCKVAR
ch_log(NULL, "LKVAR: get_lvalroot() any type");
#endif
lp->ll_tv = root;
lp->ll_is_root = TRUE;
}
/*
* Get an lval: variable, Dict item or List item that can be assigned a value
* to: "name", "na{me}", "name[expr]", "name[expr:expr]", "name[expr][expr]",
@@ -1028,6 +1084,11 @@ get_lval(
int writing = 0;
int vim9script = in_vim9script();
#ifdef LOG_LOCKVAR
ch_log(NULL, "LKVAR: get_lval(): name %s, lval_root %p",
name, (void*)lval_root);
#endif
// Clear everything in "lp".
CLEAR_POINTER(lp);
@@ -1122,6 +1183,7 @@ get_lval(
return NULL;
lp->ll_name_end = tp;
}
// TODO: check inside class?
}
}
if (lp->ll_name == NULL)
@@ -1157,7 +1219,11 @@ get_lval(
// Without [idx] or .key we are done.
if ((*p != '[' && *p != '.'))
{
if (lval_root != NULL)
get_lval_root(lp, lval_root, lval_root_is_arg);
return p;
}
if (vim9script && lval_root != NULL)
{
@@ -1220,8 +1286,7 @@ get_lval(
int r = OK;
if (v_type == VAR_LIST && lp->ll_tv->vval.v_list == NULL)
r = rettv_list_alloc(lp->ll_tv);
else if (v_type == VAR_BLOB
&& lp->ll_tv->vval.v_blob == NULL)
else if (v_type == VAR_BLOB && lp->ll_tv->vval.v_blob == NULL)
r = rettv_blob_alloc(lp->ll_tv);
if (r == FAIL)
return NULL;
@@ -1351,6 +1416,8 @@ get_lval(
}
}
lp->ll_list = NULL;
lp->ll_object = NULL;
lp->ll_class = NULL;
// a NULL dict is equivalent with an empty dict
if (lp->ll_tv->vval.v_dict == NULL)
@@ -1483,6 +1550,8 @@ get_lval(
clear_tv(&var1);
lp->ll_dict = NULL;
lp->ll_object = NULL;
lp->ll_class = NULL;
lp->ll_list = lp->ll_tv->vval.v_list;
lp->ll_li = check_range_index_one(lp->ll_list, &lp->ll_n1,
(flags & GLV_ASSIGN_WITH_OP) == 0, quiet);
@@ -1517,10 +1586,22 @@ get_lval(
}
else // v_type == VAR_CLASS || v_type == VAR_OBJECT
{
class_T *cl = (v_type == VAR_OBJECT
&& lp->ll_tv->vval.v_object != NULL)
? lp->ll_tv->vval.v_object->obj_class
: lp->ll_tv->vval.v_class;
lp->ll_dict = NULL;
lp->ll_list = NULL;
class_T *cl;
if (v_type == VAR_OBJECT && lp->ll_tv->vval.v_object != NULL)
{
cl = lp->ll_tv->vval.v_object->obj_class;
lp->ll_object = lp->ll_tv->vval.v_object;
}
else
{
cl = lp->ll_tv->vval.v_class;
lp->ll_object = NULL;
}
lp->ll_class = cl;
// TODO: what if class is NULL?
if (cl != NULL)
{
@@ -1540,6 +1621,7 @@ get_lval(
fp = method_lookup(cl,
round == 1 ? VAR_CLASS : VAR_OBJECT,
key, p - key, &m_idx);
lp->ll_oi = m_idx;
if (fp != NULL)
{
lp->ll_ufunc = fp;
@@ -1549,12 +1631,16 @@ get_lval(
}
}
// TODO: dont' check access if inside class
// TODO: is GLV_READ_ONLY the right thing to use
// for class/object member access?
// Probably in some cases. Need inside class check
if (lp->ll_valtype == NULL)
{
int m_idx;
ocmember_T *om;
om = member_lookup(cl, v_type, key, p - key, &m_idx);
ocmember_T *om
= member_lookup(cl, v_type, key, p - key, &m_idx);
lp->ll_oi = m_idx;
if (om != NULL)
{
switch (om->ocm_access)
+81 -2
View File
@@ -2125,6 +2125,30 @@ do_unlet(char_u *name, int forceit)
return FAIL;
}
static void
report_lockvar_member(char *msg, lval_T *lp)
{
int did_alloc = FALSE;
char_u *vname = (char_u *)"";
char_u *class_name = lp->ll_class != NULL
? lp->ll_class->class_name : (char_u *)"";
if (lp->ll_name != NULL)
{
if (lp->ll_name_end == NULL)
vname = lp->ll_name;
else
{
vname = vim_strnsave(lp->ll_name, lp->ll_name_end - lp->ll_name);
if (vname == NULL)
return;
did_alloc = TRUE;
}
}
semsg(_(msg), vname, class_name);
if (did_alloc)
vim_free(vname);
}
/*
* Lock or unlock variable indicated by "lp".
* "deep" is the levels to go (-1 for unlimited);
@@ -2143,6 +2167,10 @@ do_lock_var(
int cc;
dictitem_T *di;
#ifdef LOG_LOCKVAR
ch_log(NULL, "LKVAR: do_lock_var(): name %s, is_root %d", lp->ll_name, lp->ll_is_root);
#endif
if (lp->ll_tv == NULL)
{
cc = *name_end;
@@ -2203,10 +2231,13 @@ do_lock_var(
}
*name_end = cc;
}
else if (deep == 0)
else if (deep == 0 && lp->ll_object == NULL && lp->ll_class == NULL)
{
// nothing to do
}
else if (lp->ll_is_root)
// (un)lock the item.
item_lock(lp->ll_tv, deep, lock, FALSE);
else if (lp->ll_range)
{
listitem_T *li = lp->ll_li;
@@ -2222,13 +2253,57 @@ do_lock_var(
else if (lp->ll_list != NULL)
// (un)lock a List item.
item_lock(&lp->ll_li->li_tv, deep, lock, FALSE);
else if (lp->ll_object != NULL) // This check must be before ll_class.
{
// (un)lock an object variable.
report_lockvar_member(e_cannot_lock_object_variable_str, lp);
ret = FAIL;
}
else if (lp->ll_class != NULL)
{
// (un)lock a class variable.
report_lockvar_member(e_cannot_lock_class_variable_str, lp);
ret = FAIL;
}
else
{
// (un)lock a Dictionary item.
item_lock(&lp->ll_di->di_tv, deep, lock, FALSE);
if (lp->ll_di == NULL)
{
emsg(_(e_dictionary_required));
ret = FAIL;
}
else
item_lock(&lp->ll_di->di_tv, deep, lock, FALSE);
}
return ret;
}
#ifdef LOG_LOCKVAR
static char *
vartype_tostring(vartype_T vartype)
{
return
vartype == VAR_BOOL ? "v_number"
: vartype == VAR_SPECIAL ? "v_number"
: vartype == VAR_NUMBER ? "v_number"
: vartype == VAR_FLOAT ? "v_float"
: vartype == VAR_STRING ? "v_string"
: vartype == VAR_BLOB ? "v_blob"
: vartype == VAR_FUNC ? "v_string"
: vartype == VAR_PARTIAL ? "v_partial"
: vartype == VAR_LIST ? "v_list"
: vartype == VAR_DICT ? "v_dict"
: vartype == VAR_JOB ? "v_job"
: vartype == VAR_CHANNEL ? "v_channel"
: vartype == VAR_INSTR ? "v_instr"
: vartype == VAR_CLASS ? "v_class"
: vartype == VAR_OBJECT ? "v_object"
: "";
}
#endif
/*
* Lock or unlock an item. "deep" is nr of levels to go.
* When "check_refcount" is TRUE do not lock a list or dict with a reference
@@ -2245,6 +2320,10 @@ item_lock(typval_T *tv, int deep, int lock, int check_refcount)
hashitem_T *hi;
int todo;
#ifdef LOG_LOCKVAR
ch_log(NULL, "LKVAR: item_lock(): type %s", vartype_tostring(tv->v_type));
#endif
if (recurse >= DICT_MAXNEST)
{
emsg(_(e_variable_nested_too_deep_for_unlock));
+1
View File
@@ -2659,6 +2659,7 @@ check_opt_wim(void)
for (p = p_wim; *p; ++p)
{
// Note: Keep this in sync with p_wim_values.
for (i = 0; ASCII_ISALPHA(p[i]); ++i)
;
if (p[i] != NUL && p[i] != ',' && p[i] != ':')
+1
View File
@@ -1958,6 +1958,7 @@ EXTERN int timer_busy INIT(= 0); // when timer is inside vgetc() then > 0
EXTERN int input_busy INIT(= 0); // when inside get_user_input() then > 0
EXTERN typval_T *lval_root INIT(= NULL);
EXTERN int lval_root_is_arg INIT(= 0);
#endif
#ifdef FEAT_BEVAL_TERM
+1
View File
@@ -3814,6 +3814,7 @@ highlight_changed(void)
if (attr > HL_ALL) // Combination with ':' is not allowed.
return FAIL;
// Note: Keep this in sync with expand_set_highlight().
switch (*p)
{
case 'b': attr |= HL_BOLD;
+1
View File
@@ -871,6 +871,7 @@ briopt_check(win_T *wp)
p = wp->w_p_briopt;
while (*p != NUL)
{
// Note: Keep this in sync with p_briopt_values
if (STRNCMP(p, "shift:", 6) == 0
&& ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
{
+13
View File
@@ -5782,3 +5782,16 @@ f_charclass(typval_T *argvars, typval_T *rettv UNUSED)
rettv->vval.v_number = mb_get_class(argvars[0].vval.v_string);
}
#endif
/*
* Function given to ExpandGeneric() to obtain the possible arguments of the
* encoding options.
*/
char_u *
get_encoding_name(expand_T *xp UNUSED, int idx)
{
if (idx >= (int)(sizeof(enc_canon_table) / sizeof(enc_canon_table[0])))
return NULL;
return (char_u*)enc_canon_table[idx].name;
}
+323 -60
View File
@@ -1650,7 +1650,7 @@ stropt_copy_value(
// For MS-DOS and WIN32 backslashes before normal file name characters
// are not removed, and keep backslash at start, for "\\machine\path",
// but do remove it for "\\\\machine\\path".
// The reverse is found in ExpandOldSetting().
// The reverse is found in escape_option_str_cmdline().
while (*arg != NUL && !VIM_ISWHITE(*arg))
{
int i;
@@ -1855,7 +1855,7 @@ stropt_get_newval(
&(options[opt_idx]), OPT_GLOBAL));
else
{
++arg; // jump to after the '=' or ':'
++arg; // joption_value2stringump to after the '=' or ':'
// Set 'keywordprg' to ":help" if an empty
// value was passed to :set by the user.
@@ -7392,8 +7392,10 @@ set_imsearch_global(void)
}
static int expand_option_idx = -1;
static int expand_option_start_col = 0;
static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
static int expand_option_flags = 0;
static int expand_option_append = FALSE;
void
set_context_in_set_cmd(
@@ -7508,8 +7510,14 @@ set_context_in_set_cmd(
}
}
// handle "-=" and "+="
expand_option_append = FALSE;
int expand_option_subtract = FALSE;
if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
{
if (nextchar == '-')
expand_option_subtract = TRUE;
if (nextchar == '+' || nextchar == '^')
expand_option_append = TRUE;
++p;
nextchar = '=';
}
@@ -7519,22 +7527,20 @@ set_context_in_set_cmd(
xp->xp_context = EXPAND_UNSUCCESSFUL;
return;
}
if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
{
xp->xp_context = EXPAND_OLD_SETTING;
if (is_term_option)
expand_option_idx = -1;
else
expand_option_idx = opt_idx;
xp->xp_pattern = p + 1;
return;
}
xp->xp_context = EXPAND_NOTHING;
if (is_term_option || (flags & P_NUM))
return;
// Below are for handling expanding a specific option's value after the '='
// or ':'
if (is_term_option)
expand_option_idx = -1;
else
expand_option_idx = opt_idx;
xp->xp_pattern = p + 1;
expand_option_start_col = (int)(p + 1 - xp->xp_line);
// Certain options currently have special case handling to reuse the
// expansion logic with other commands.
#ifdef FEAT_SYN_HL
if (options[opt_idx].var == (char_u *)&p_syn)
{
@@ -7542,7 +7548,38 @@ set_context_in_set_cmd(
return;
}
#endif
if (options[opt_idx].var == (char_u *)&p_ft)
{
xp->xp_context = EXPAND_FILETYPE;
return;
}
// Now pick. If the option has a custom expander, use that. Otherwise, just
// fill with the existing option value.
if (expand_option_subtract)
{
xp->xp_context = EXPAND_SETTING_SUBTRACT;
return;
}
else if (expand_option_idx >= 0 &&
options[expand_option_idx].opt_expand_cb != NULL)
{
xp->xp_context = EXPAND_STRING_SETTING;
}
else if (*xp->xp_pattern == NUL)
{
xp->xp_context = EXPAND_OLD_SETTING;
return;
}
else
xp->xp_context = EXPAND_NOTHING;
if (is_term_option || (flags & P_NUM))
return;
// Only string options below
// Options that have P_EXPAND are considered to all use file/dir expansion.
if (flags & P_EXPAND)
{
p = options[opt_idx].var;
@@ -7563,10 +7600,6 @@ set_context_in_set_cmd(
else
xp->xp_backslash = XP_BS_ONE;
}
else if (p == (char_u *)&p_ft)
{
xp->xp_context = EXPAND_FILETYPE;
}
else
{
xp->xp_context = EXPAND_FILES;
@@ -7578,34 +7611,55 @@ set_context_in_set_cmd(
}
}
// For an option that is a list of file names, find the start of the
// last file name.
for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
// For an option that is a list of file names, or comma/colon-separated
// values, split it by the delimiter and find the start of the current
// pattern, while accounting for backslash-escaped space/commas/colons.
// Triple-backslashed escaped file names (e.g. 'path') can also be
// delimited by space.
if ((flags & P_EXPAND) || (flags & P_COMMA) || (flags & P_COLON))
{
// count number of backslashes before ' ' or ','
if (*p == ' ' || *p == ',')
for (p = arg + STRLEN(arg) - 1; p >= xp->xp_pattern; --p)
{
s = p;
while (s > xp->xp_pattern && *(s - 1) == '\\')
--s;
if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
|| (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
// count number of backslashes before ' ' or ',' or ':'
if (*p == ' ' || *p == ',' ||
(*p == ':' && (flags & P_COLON)))
{
xp->xp_pattern = p + 1;
break;
s = p;
while (s > xp->xp_pattern && *(s - 1) == '\\')
--s;
if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
|| (*p == ',' && (flags & P_COMMA) && ((p - s) % 1) == 0)
|| (*p == ':' && (flags & P_COLON)))
{
xp->xp_pattern = p + 1;
break;
}
}
}
#ifdef FEAT_SPELL
// for 'spellsuggest' start at "file:"
if (options[opt_idx].var == (char_u *)&p_sps
&& STRNCMP(p, "file:", 5) == 0)
{
xp->xp_pattern = p + 5;
break;
}
#endif
}
// An option that is a list of single-character flags should always start
// at the end as we don't complete words.
if (flags & P_FLAGLIST)
xp->xp_pattern = arg + STRLEN(arg);
// Some options can either be using file/dir expansions, or custom value
// expansion depending on what the user typed. Unfortunately we have to
// manually handle it here to make sure we have the correct xp_context set.
#ifdef FEAT_SPELL
if (options[opt_idx].var == (char_u *)&p_sps)
{
if (STRNCMP(xp->xp_pattern, "file:", 5) == 0)
{
xp->xp_pattern += 5;
return;
}
else if (options[expand_option_idx].opt_expand_cb != NULL)
{
xp->xp_context = EXPAND_STRING_SETTING;
}
}
#endif
}
/*
@@ -7624,7 +7678,7 @@ set_context_in_set_cmd(
* If 'test_only' is FALSE and 'fuzzy' is TRUE and if 'str' fuzzy matches
* 'fuzzystr', then stores the match details in fuzmatch[idx] and returns TRUE.
*/
static int
int
match_str(
char_u *str,
regmatch_T *regmatch,
@@ -7871,6 +7925,37 @@ ExpandSettings(
return OK;
}
// Escape an option value that can be used on the command-line with :set.
// Caller needs to free the returned string, unless NULL is returned.
static char_u*
escape_option_str_cmdline(char_u *var)
{
char_u *buf;
// A backslash is required before some characters. This is the reverse of
// what happens in do_set().
buf = vim_strsave_escaped(var, escape_chars);
if (buf == NULL)
return NULL;
#ifdef BACKSLASH_IN_FILENAME
// For MS-Windows et al. we don't double backslashes at the start and
// before a file name character.
// The reverse is found at stropt_copy_value().
for (var = buf; *var != NUL; MB_PTR_ADV(var))
if (var[0] == '\\' && var[1] == '\\'
&& expand_option_idx >= 0
&& (options[expand_option_idx].flags & P_EXPAND)
&& vim_isfilec(var[2])
&& (var[2] != '\\' || (var == buf && var[4] != '\\')))
STRMOVE(var, var + 1);
#endif
return buf;
}
/*
* Expansion handler for :set= when we just want to fill in with the existing value.
*/
int
ExpandOldSetting(int *numMatches, char_u ***matches)
{
@@ -7878,7 +7963,7 @@ ExpandOldSetting(int *numMatches, char_u ***matches)
char_u *buf;
*numMatches = 0;
*matches = ALLOC_ONE(char_u *);
*matches = ALLOC_MULT(char_u *, 1);
if (*matches == NULL)
return FAIL;
@@ -7899,33 +7984,210 @@ ExpandOldSetting(int *numMatches, char_u ***matches)
else if (var == NULL)
var = (char_u *)"";
// A backslash is required before some characters. This is the reverse of
// what happens in do_set().
buf = vim_strsave_escaped(var, escape_chars);
buf = escape_option_str_cmdline(var);
if (buf == NULL)
{
VIM_CLEAR(*matches);
return FAIL;
}
#ifdef BACKSLASH_IN_FILENAME
// For MS-Windows et al. we don't double backslashes at the start and
// before a file name character.
for (var = buf; *var != NUL; MB_PTR_ADV(var))
if (var[0] == '\\' && var[1] == '\\'
&& expand_option_idx >= 0
&& (options[expand_option_idx].flags & P_EXPAND)
&& vim_isfilec(var[2])
&& (var[2] != '\\' || (var == buf && var[4] != '\\')))
STRMOVE(var, var + 1);
#endif
*matches[0] = buf;
(*matches)[0] = buf;
*numMatches = 1;
return OK;
}
/*
* Expansion handler for :set=/:set+= when the option has a custom expansion handler.
*/
int
ExpandStringSetting(
expand_T *xp,
regmatch_T *regmatch,
int *numMatches,
char_u ***matches)
{
char_u *var = NULL; // init for GCC
char_u *buf;
if (expand_option_idx < 0 ||
options[expand_option_idx].opt_expand_cb == NULL)
{
// Not supposed to reach this. This function is only for options with
// custom expansion callbacks.
return FAIL;
}
optexpand_T args;
args.oe_varp = get_varp_scope(&options[expand_option_idx], expand_option_flags);
args.oe_append = expand_option_append;
args.oe_regmatch = regmatch;
args.oe_xp = xp;
args.oe_set_arg = xp->xp_line + expand_option_start_col;
args.oe_include_orig_val =
!expand_option_append &&
(*args.oe_set_arg == NUL);
// Retrieve the existing value, but escape it as a reverse of setting it.
// We technically only need to do this when oe_append or
// oe_include_orig_val is true.
option_value2string(&options[expand_option_idx], expand_option_flags);
var = NameBuff;
buf = escape_option_str_cmdline(var);
if (buf == NULL)
return FAIL;
args.oe_opt_value = buf;
int num_ret = options[expand_option_idx].opt_expand_cb(&args, numMatches, matches);
vim_free(buf);
return num_ret;
}
/*
* Expansion handler for :set-=
*/
int
ExpandSettingSubtract(
expand_T *xp,
regmatch_T *regmatch,
int *numMatches,
char_u ***matches)
{
if (expand_option_idx < 0)
// term option
return ExpandOldSetting(numMatches, matches);
char_u *option_val = *(char_u**)get_option_varp_scope(
expand_option_idx, expand_option_flags);
long_u option_flags = options[expand_option_idx].flags;
if (option_flags & P_NUM)
return ExpandOldSetting(numMatches, matches);
else if (option_flags & P_COMMA)
{
// Split the option by comma, then present each option to the user if
// it matches the pattern.
// This condition needs to go first, because 'whichwrap' has both
// P_COMMA and P_FLAGLIST.
garray_T ga;
char_u *item;
char_u *option_copy;
char_u *next_val;
char_u *comma;
if (*option_val == NUL)
return FAIL;
// Make a copy as we need to inject null characters destructively.
option_copy = vim_strsave(option_val);
if (option_copy == NULL)
return FAIL;
next_val = option_copy;
ga_init2(&ga, sizeof(char_u *), 10);
do
{
item = next_val;
comma = vim_strchr(next_val, ',');
while (comma != NULL && comma != next_val && *(comma - 1) == '\\')
{
// "\," is interpreted as a literal comma rather than option
// separator when reading options in copy_option_part(). Skip
// it.
comma = vim_strchr(comma + 1, ',');
}
if (comma != NULL)
{
*comma = NUL; // null-terminate this value, required by later functions
next_val = comma + 1;
}
else
next_val = NULL;
if (*item == NUL)
// empty value, don't add to list
continue;
if (!vim_regexec(regmatch, item, (colnr_T)0))
continue;
char_u *buf = escape_option_str_cmdline(item);
if (buf == NULL)
{
vim_free(option_copy);
ga_clear_strings(&ga);
return FAIL;
}
if (ga_add_string(&ga, buf) != OK)
{
vim_free(buf);
break;
}
} while (next_val != NULL);
vim_free(option_copy);
*matches = ga.ga_data;
*numMatches = ga.ga_len;
return OK;
}
else if (option_flags & P_FLAGLIST)
{
// Only present the flags that are set on the option as the other flags
// are not meaningful to do set-= on.
if (*xp->xp_pattern != NUL)
{
// Don't suggest anything if cmdline is non-empty. Vim's set-=
// behavior requires consecutive strings and it's usually
// unintuitive to users if ther try to subtract multiple flags at
// once.
return FAIL;
}
int num_flags = STRLEN(option_val);
if (num_flags == 0)
return FAIL;
*matches = ALLOC_MULT(char_u *, num_flags + 1);
if (*matches == NULL)
return FAIL;
int count = 0;
char_u *p;
p = vim_strsave(option_val);
if (p == NULL)
{
VIM_CLEAR(*matches);
return FAIL;
}
(*matches)[count++] = p;
if (num_flags > 1)
{
// If more than one flags, split the flags up and expose each
// character as individual choice.
for (char_u *flag = option_val; *flag != NUL; flag++)
{
char_u *p = vim_strnsave(flag, 1);
if (p == NULL)
break;
(*matches)[count++] = p;
}
}
*numMatches = count;
return OK;
}
return ExpandOldSetting(numMatches, matches);
}
/*
* Get the value for the numeric or string option *opp in a nice format into
* NameBuff[]. Must not be called with a hidden option!
@@ -8257,6 +8519,7 @@ fill_culopt_flags(char_u *val, win_T *wp)
p = val;
while (*p != NUL)
{
// Note: Keep this in sync with p_culopt_values.
if (STRNCMP(p, "line", 4) == 0)
{
p += 4;
+2 -1
View File
@@ -60,6 +60,7 @@
#define P_RWINONLY 0x10000000L // only redraw current window
#define P_MLE 0x20000000L // under control of 'modelineexpr'
#define P_FUNC 0x40000000L // accept a function reference or a lambda
#define P_COLON 0x80000000L // values use colons to create sublists
// Returned by get_option_value().
typedef enum {
@@ -230,7 +231,7 @@ typedef enum {
#define CPO_ALL "aAbBcCdDeEfFgHiIjJkKlLmMnoOpPqrRsStuvwWxXyZ$!%*-+<>#{|&/\\.;"
// characters for p_ww option:
#define WW_ALL "bshl<>[],~"
#define WW_ALL "bshl<>[]~"
// characters for p_mouse option:
#define MOUSE_NORMAL 'n' // use mouse in Normal mode
+639 -634
View File
File diff suppressed because it is too large Load Diff
+1122 -2
View File
File diff suppressed because it is too large Load Diff
+26 -7
View File
@@ -6723,14 +6723,17 @@ mch_expand_wildcards(
#define STYLE_GLOB 1 // use "glob", for csh
#define STYLE_VIMGLOB 2 // use "vimglob", for Posix sh
#define STYLE_PRINT 3 // use "print -N", for zsh
#define STYLE_BT 4 // `cmd` expansion, execute the pattern
// directly
#define STYLE_BT 4 // `cmd` expansion, execute the pattern directly
#define STYLE_GLOBSTAR 5 // use extended shell glob for bash (this uses extended
// globbing functionality using globstar, needs bash > 4)
int shell_style = STYLE_ECHO;
int check_spaces;
static int did_find_nul = FALSE;
int ampersand = FALSE;
// vimglob() function to define for Posix shell
static char *sh_vimglob_func = "vimglob() { while [ $# -ge 1 ]; do echo \"$1\"; shift; done }; vimglob >";
// vimglob() function with globstar setting enabled, only for bash >= 4.X
static char *sh_globstar_opt = "[[ ${BASH_VERSINFO[0]} -ge 4 ]] && shopt -s globstar; ";
*num_file = 0; // default: no files found
*file = NULL;
@@ -6777,6 +6780,8 @@ mch_expand_wildcards(
* If we use *zsh, "print -N" will work better than "glob".
* STYLE_VIMGLOB: NL separated
* If we use *sh*, we define "vimglob()".
* STYLE_GLOBSTAR: NL separated
* If we use *bash*, we define "vimglob() and enable globstar option".
* STYLE_ECHO: space separated.
* A shell we don't know, stay safe and use "echo".
*/
@@ -6791,9 +6796,13 @@ mch_expand_wildcards(
else if (STRCMP(p_sh + len - 3, "zsh") == 0)
shell_style = STYLE_PRINT;
}
if (shell_style == STYLE_ECHO && strstr((char *)gettail(p_sh),
"sh") != NULL)
shell_style = STYLE_VIMGLOB;
if (shell_style == STYLE_ECHO)
{
if (strstr((char *)gettail(p_sh), "bash") != NULL)
shell_style = STYLE_GLOBSTAR;
else if (strstr((char *)gettail(p_sh), "sh") != NULL)
shell_style = STYLE_VIMGLOB;
}
// Compute the length of the command. We need 2 extra bytes: for the
// optional '&' and for the NUL.
@@ -6801,6 +6810,9 @@ mch_expand_wildcards(
len = STRLEN(tempname) + 29;
if (shell_style == STYLE_VIMGLOB)
len += STRLEN(sh_vimglob_func);
else if (shell_style == STYLE_GLOBSTAR)
len += STRLEN(sh_vimglob_func)
+ STRLEN(sh_globstar_opt);
for (i = 0; i < num_pat; ++i)
{
@@ -6869,6 +6881,11 @@ mch_expand_wildcards(
STRCAT(command, "print -N >");
else if (shell_style == STYLE_VIMGLOB)
STRCAT(command, sh_vimglob_func);
else if (shell_style == STYLE_GLOBSTAR)
{
STRCAT(command, sh_globstar_opt);
STRCAT(command, sh_vimglob_func);
}
else
STRCAT(command, "echo >");
}
@@ -7053,7 +7070,9 @@ mch_expand_wildcards(
}
}
// file names are separated with NL
else if (shell_style == STYLE_BT || shell_style == STYLE_VIMGLOB)
else if (shell_style == STYLE_BT ||
shell_style == STYLE_VIMGLOB ||
shell_style == STYLE_GLOBSTAR)
{
buffer[len] = NUL; // make sure the buffer ends in NUL
p = buffer;
@@ -7134,7 +7153,7 @@ mch_expand_wildcards(
(*file)[i] = p;
// Space or NL separates
if (shell_style == STYLE_ECHO || shell_style == STYLE_BT
|| shell_style == STYLE_VIMGLOB)
|| shell_style == STYLE_VIMGLOB || shell_style == STYLE_GLOBSTAR)
{
while (!(shell_style == STYLE_ECHO && *p == ' ')
&& *p != '\n' && *p != NUL)
+98 -62
View File
@@ -10,8 +10,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Vim(Serbian)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-09-04 10:49+0400\n"
"PO-Revision-Date: 2023-09-04 13:00+0400\n"
"POT-Creation-Date: 2023-09-27 10:56+0400\n"
"PO-Revision-Date: 2023-09-27 11:45+0400\n"
"Last-Translator: Ivan Pešić <ivan.pesic@gmail.com>\n"
"Language-Team: Serbian\n"
"Language: sr\n"
@@ -5929,9 +5929,6 @@ msgstr "E613: Непознат фонт штампача: %s"
msgid "E614: Class required"
msgstr "E614: Потребна је класа"
msgid "E615: Object required"
msgstr "E615: Потребан је објекат"
#, c-format
msgid "E616: Object required for argument %d"
msgstr "E616: За аргумент %d је потребан објекат"
@@ -7131,8 +7128,8 @@ msgid "E962: Invalid action: '%s'"
msgstr "E962: Неисправна акција: ’%s’"
#, c-format
msgid "E963: Setting %s to value with wrong type"
msgstr "E963: Постављање %s на вредност погрешног типа"
msgid "E963: Setting v:%s to value with wrong type"
msgstr "E963: Постављање v:%s на вредност погрешног типа"
#, c-format
msgid "E964: Invalid column number: %ld"
@@ -8402,8 +8399,8 @@ msgid "E1316: Class can only be defined in Vim9 script"
msgstr "E1316: Класа може да се дефинише само у Vim9 скрипти"
#, c-format
msgid "E1317: Invalid object member declaration: %s"
msgstr "E1317: Неисправна декларација члана објекта: %s"
msgid "E1317: Invalid object variable declaration: %s"
msgstr "E1317: Неисправна декларација променљиве објекта: %s"
#, c-format
msgid "E1318: Not a valid command in a class: %s"
@@ -8432,8 +8429,8 @@ msgid "E1325: Method not found on class \"%s\": %s"
msgstr "E1325: Није пронађена метода класе „%s”: %s"
#, c-format
msgid "E1326: Member not found on object \"%s\": %s"
msgstr "E1326: Члан није пронађен у објекту „%s”: %s"
msgid "E1326: Variable not found on object \"%s\": %s"
msgstr "E1326: Променљива није пронађена у објекту „%s”: %s"
#, c-format
msgid "E1327: Object required, found %s"
@@ -8444,39 +8441,27 @@ msgid "E1328: Constructor default value must be v:none: %s"
msgstr "E1328: Подразумевана вредност конструктора мора бити v:none: %s"
#, c-format
msgid "E1329: Cannot get object member type from initializer: %s"
msgstr "E1329: Тип члана објекта не може да се одреди из иницијализатора: %s"
#, c-format
msgid "E1330: Invalid type for object member: %s"
msgstr "E1330: Неисправан тип члана објекта: %s"
msgid "E1330: Invalid type for object variable: %s"
msgstr "E1330: Неисправан тип променљиве објекта: %s"
msgid "E1331: Public must be followed by \"this\" or \"static\""
msgstr "E1331: Након Public мора да следи „this” или „static”"
#, c-format
msgid "E1332: Public member name cannot start with underscore: %s"
msgstr "E1332: Име Public члана не може почети доњом цртом: %s"
msgid "E1332: Public variable name cannot start with underscore: %s"
msgstr "E1332: Име Public променљиве не може почети доњом цртом: %s"
#, c-format
msgid "E1333: Cannot access private member: %s"
msgstr "E1333: Не може да се приступи приватном члану: %s"
msgid "E1333: Cannot access private variable: %s"
msgstr "E1333: Не може да се приступи приватној променљивој: %s"
#, c-format
msgid "E1334: Object member not found: %s"
msgstr "E1334: Члан објекта није пронађен: %s"
msgid "E1335: Variable \"%s\" in class \"%s\" is not writable"
msgstr "E1335: У променљиву „%s” у класи „%s” не може да се упише"
#, c-format
msgid "E1335: Member is not writable: %s"
msgstr "E1335: У члан не може да се уписује: %s"
#, c-format
msgid "E1337: Class member not found: %s"
msgstr "E1337: Није пронађен члан класе: %s"
#, c-format
msgid "E1338: Member not found on class \"%s\": %s"
msgstr "E1338: Није пронађен члан класе „%s”: %s"
msgid "E1337: Class variable \"%s\" not found in class \"%s\""
msgstr "E1337: Променљива класе „%s” није пронађена у класи „%s"
msgid ""
"E1339: Cannot add a textprop with text after using a textprop with a "
@@ -8500,8 +8485,8 @@ msgstr "E1342: Интерфејс може да се дефинише само
msgid "E1343: Interface name must start with an uppercase letter: %s"
msgstr "E1343: Име интерфејса мора да почне великим словом: %s"
msgid "E1344: Cannot initialize a member in an interface"
msgstr "E1344: Члан не може да се иницијализује у интерфејсу"
msgid "E1344: Cannot initialize a variable in an interface"
msgstr "E1344: Не може да се иницијализује променљива у интерфејсу"
#, c-format
msgid "E1345: Not a valid command in an interface: %s"
@@ -8516,12 +8501,12 @@ msgid "E1347: Not a valid interface: %s"
msgstr "E1347: Неважећи интерфејс: %s"
#, c-format
msgid "E1348: Member \"%s\" of interface \"%s\" not implemented"
msgstr "E1348: Члан „%s” интерфејса „%s” није имплементиран"
msgid "E1348: Variable \"%s\" of interface \"%s\" is not implemented"
msgstr "E1348: Није имплементирана променљива „%s” интерфејса „%s”"
#, c-format
msgid "E1349: Function \"%s\" of interface \"%s\" not implemented"
msgstr "E1349: Функција „%s” интерфејса „%s” није имплементирана"
msgid "E1349: Method \"%s\" of interface \"%s\" is not implemented"
msgstr "E1349: Није имплементирана функција „%s” интерфејса „%s”"
msgid "E1350: Duplicate \"implements\""
msgstr "E1350: Дупликат „implements”"
@@ -8548,14 +8533,14 @@ msgstr "E1355: Дуплирана функција: %s"
msgid "E1356: \"super\" must be followed by a dot"
msgstr "E1356: Након „super” мора да следи тачка"
msgid "E1357: Using \"super\" not in a class function"
msgstr "E1357:„super” се користи ван функције класе"
msgid "E1357: Using \"super\" not in a class method"
msgstr "E1357: „super” се користи ван методе класе"
msgid "E1358: Using \"super\" not in a child class"
msgstr "E1358: „super” се не користи у изведеној класи"
msgid "E1359: Cannot define a \"new\" function in an abstract class"
msgstr "E1359: Функција „new” не може да се дефинише у апстрактној класи"
msgid "E1359: Cannot define a \"new\" method in an abstract class"
msgstr "E1359: Метода „new” не може да се дефинише у апстрактној класи"
msgid "E1360: Using a null object"
msgstr "E1360: Користи се null објекат"
@@ -8572,26 +8557,85 @@ msgstr "E1363: Тип није комплетан"
msgid "E1364: Warning: Pointer block corrupted"
msgstr "E1364: Упозорење: Блок показивача је покварен"
msgid "E1365: Cannot use a return type with the \"new\" function"
msgstr "E1365: Повратни тип не може да се користи са функцијом „new”"
msgid "E1365: Cannot use a return type with the \"new\" method"
msgstr "E1365: Повратни тип не може да се користи са методом „new”"
#, c-format
msgid "E1366: Cannot access private method: %s"
msgstr "E1366: Не може да се приступи приватној методи: %s"
#, c-format
msgid "E1367: Access level of member \"%s\" of interface \"%s\" is different"
msgstr "E1367: Ниво приступа члана „%s” интерфејса „%s” се разликује"
msgid "E1367: Access level of variable \"%s\" of interface \"%s\" is different"
msgstr "E1367: Ниво приступа променљиве „%s” интерфејса „%s” се разликује"
msgid "E1368: Static cannot be followed by \"this\" in a member name"
msgstr "E1368: У имену члана након static не може да следи „this”"
msgid "E1368: Static cannot be followed by \"this\" in a variable name"
msgstr "E1368: У имену променљиве након static не може да следи „this”"
#, c-format
msgid "E1369: Duplicate member: %s"
msgstr "E1369: Дуплирани члан: %s"
msgid "E1369: Duplicate variable: %s"
msgstr "E1369: Дуплирана променљива: %s"
msgid "E1370: Cannot define a \"new\" function as static"
msgstr "E1370: Функција „new” не може да се дефинише као static"
msgid "E1370: Cannot define a \"new\" method as static"
msgstr "E1370: Метода „new” не може да се дефинише као static"
msgid "E1371: Abstract must be followed by \"def\" or \"static\""
msgstr "E1371: Након abstract мора да следи „def” или „static”"
#, c-format
msgid "E1372: Abstract method \"%s\" cannot be defined in a concrete class"
msgstr "E1372: Апстрактна метода „%s” не може да се дефинише у конкретној класи"
#, c-format
msgid "E1373: Abstract method \"%s\" is not implemented"
msgstr "E1373: Није имплементирана апстрактна метода „%s”"
#, c-format
msgid "E1374: Class variable \"%s\" accessible only inside class \"%s\""
msgstr "E1374: Променљивој класе „%s” може да се приступи само унутар класе „%s”"
#, c-format
msgid "E1375: Class variable \"%s\" accessible only using class \"%s\""
msgstr "E1375: Променљивој класе „%s” може да се приступи само употребом класе „%s”"
#, c-format
msgid "E1376: Object variable \"%s\" accessible only using class \"%s\" object"
msgstr "E1376: Променљивој објекта „%s” може да се приступи само употребом објекта класе „%s”"
#, c-format
msgid "E1377: Access level of method \"%s\" is different in class \"%s\""
msgstr "E1377: Ниво приступа методе „%s” у класи „%s” је другачији"
msgid "E1378: Static member not supported in an interface"
msgstr "E1378: У интерфејсу се не подржава статички члан"
msgid "E1379: Private variable not supported in an interface"
msgstr "E1379: У интерфејсу се не подржава приватна променљива"
msgid "E1380: Private method not supported in an interface"
msgstr "E1380: У интерфејсу се не подржава приватна метода"
msgid "E1381: Interface cannot use \"implements\""
msgstr "E1381: Интерфејс не може да користи „implements”"
#, c-format
msgid "E1382: Variable \"%s\": type mismatch, expected %s but got %s"
msgstr "E1382: Променљива „%s”: грешка типа, очекивао се %s али је наведен %s"
#, c-format
msgid "E1383: Method \"%s\": type mismatch, expected %s but got %s"
msgstr "E1383: Метода „%s”: грешка типа, очекивао се %s али је наведен %s"
#, c-format
msgid "E1384: Class method \"%s\" accessible only inside class \"%s\""
msgstr "E1384: Методи класе „%s” може да се приступи само унутар класе „%s”"
#, c-format
msgid "E1385: Class method \"%s\" accessible only using class \"%s\""
msgstr "E1385: Методи класе „%s” може да се приступи само користећи класу „%s”"
#, c-format
msgid "E1386: Object method \"%s\" accessible only using class \"%s\" object"
msgstr "E1386: Методи објекта „%s” може да се приступи само користећи објекат класе „%s”"
#, c-format
msgid "E1400: Cannot mix positional and non-positional arguments: %s"
@@ -8621,14 +8665,6 @@ msgstr "E1404: Позициони аргумент %d тип се не упот
msgid "E1405: Invalid format specifier: %s"
msgstr "E1405: Неисправни спецификатор формата: %s"
#, c-format
msgid "E1406: Member \"%s\": type mismatch, expected %s but got %s"
msgstr "E1406: Члан „%s”: неодговарајући тип, очекује се %s али је наведено %s"
#, c-format
msgid "E1407: Member \"%s\": type mismatch, expected %s but got %s"
msgstr "E1407: Члан „%s”: неодговарајући тип, очекује се %s али је наведено %s"
msgid "--No lines in buffer--"
msgstr "--У баферу нема линија--"
@@ -8978,7 +9014,7 @@ msgid "GVim"
msgstr "GVim"
msgid "Text Editor"
msgstr "Едитор текст"
msgstr "Едитор текста"
msgid "Edit text files"
msgstr "Уређујте текст фајлове"
+3
View File
@@ -1803,6 +1803,7 @@ parse_popup_option(win_T *wp, int is_preview)
dig = e + 1;
x = getdigits(&dig);
// Note: Keep this in sync with p_popup_option_values.
if (STRNCMP(s, "height:", 7) == 0)
{
if (dig != p)
@@ -1840,6 +1841,7 @@ parse_popup_option(win_T *wp, int is_preview)
}
else if (STRNCMP(s, "border:", 7) == 0)
{
// Note: Keep this in sync with p_popup_option_border_values.
char_u *arg = s + 7;
int on = STRNCMP(arg, "on", 2) == 0 && arg + 2 == p;
int off = STRNCMP(arg, "off", 3) == 0 && arg + 3 == p;
@@ -1858,6 +1860,7 @@ parse_popup_option(win_T *wp, int is_preview)
}
else if (STRNCMP(s, "align:", 6) == 0)
{
// Note: Keep this in sync with p_popup_option_align_values.
char_u *arg = s + 6;
int item = STRNCMP(arg, "item", 4) == 0 && arg + 4 == p;
int menu = STRNCMP(arg, "menu", 4) == 0 && arg + 4 == p;
+1
View File
@@ -39,6 +39,7 @@ int has_autocmd(event_T event, char_u *sfname, buf_T *buf);
char_u *get_augroup_name(expand_T *xp, int idx);
char_u *set_context_in_autocmd(expand_T *xp, char_u *arg, int doautocmd);
char_u *get_event_name(expand_T *xp, int idx);
char_u *get_event_name_no_group(expand_T *xp, int idx);
int autocmd_supported(char_u *name);
int au_exists(char_u *arg);
void f_autocmd_add(typval_T *argvars, typval_T *rettv);
+1
View File
@@ -9,6 +9,7 @@ int cmdline_compl_startcol(void);
char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode);
void ExpandInit(expand_T *xp);
void ExpandCleanup(expand_T *xp);
int ExpandGeneric(char_u *pat, expand_T *xp, regmatch_T *regmatch, char_u ***matches, int *numMatches, char_u *((*func)(expand_T *, int)), int escaped);
int showmatches(expand_T *xp, int wildmenu);
char_u *addstar(char_u *fname, int len, int context);
void set_expand_context(expand_T *xp);
+1
View File
@@ -88,4 +88,5 @@ char_u *string_convert_ext(vimconv_T *vcp, char_u *ptr, int *lenp, int *unconvle
void f_setcellwidths(typval_T *argvars, typval_T *rettv);
void f_getcellwidths(typval_T *argvars, typval_T *rettv);
void f_charclass(typval_T *argvars, typval_T *rettv);
char_u *get_encoding_name(expand_T *xp, int idx);
/* vim: set ft=c : */
+2
View File
@@ -139,6 +139,8 @@ void set_imsearch_global(void);
void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags);
int ExpandSettings(expand_T *xp, regmatch_T *regmatch, char_u *fuzzystr, int *numMatches, char_u ***matches, int can_fuzzy);
int ExpandOldSetting(int *numMatches, char_u ***matches);
int ExpandStringSetting(expand_T *xp, regmatch_T *regmatch, int *numMatches, char_u ***matches);
int ExpandSettingSubtract(expand_T *xp, regmatch_T *regmatch, int *numMatches, char_u ***matches);
int shortmess(int x);
void vimrc_found(char_u *fname, char_u *envname);
void change_compatible(int on);
+65
View File
@@ -126,6 +126,71 @@ char *did_set_wincolor(optset_T *args);
char *did_set_fuoptions(optset_T *args);
char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, char_u *value, char *errbuf, int opt_flags, int *value_checked);
int expand_set_ambiwidth(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_background(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_backspace(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_backupcopy(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_belloff(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_breakindentopt(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_browsedir(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_bufhidden(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_buftype(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_casemap(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_chars_option(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_clipboard(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_complete(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_completeopt(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_completeslash(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_concealcursor(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_cpoptions(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_cryptmethod(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_cursorlineopt(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_debug(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_diffopt(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_display(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_eadirection(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_encoding(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_eventignore(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_fileformat(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_foldclose(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_foldmethod(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_foldopen(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_formatoptions(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_guioptions(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_highlight(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_jumpoptions(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_keymodel(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_keyprotocol(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_lispoptions(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_mouse(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_mousemodel(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_nrformats(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_popupoption(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_printoptions(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_rightleftcmd(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_scrollopt(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_selection(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_selectmode(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_sessionoptions(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_shortmess(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_showcmdloc(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_signcolumn(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_spelloptions(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_spellsuggest(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_splitkeep(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_swapsync(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_switchbuf(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_tagcase(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_termwintype(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_toolbar(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_toolbariconsize(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_ttymouse(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_virtualedit(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_whichwrap(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_wildmode(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_wildoptions(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_winaltkeys(optexpand_T *args, int *numMatches, char_u ***matches);
int expand_set_wincolor(optexpand_T *args, int *numMatches, char_u ***matches);
int check_ff_value(char_u *p);
int check_fuoptions(void);
void save_clear_shm_value(void);
+2
View File
@@ -57,5 +57,7 @@ int screen_screencol(void);
int screen_screenrow(void);
char *set_fillchars_option(win_T *wp, char_u *val, int apply);
char *set_listchars_option(win_T *wp, char_u *val, int apply);
char_u * get_fillchars_name(expand_T *xp, int idx);
char_u * get_listchars_name(expand_T *xp, int idx);
char *check_chars_options(void);
/* vim: set ft=c : */
+1
View File
@@ -5,6 +5,7 @@ void init_term_props(int all);
void f_terminalprops(typval_T *argvars, typval_T *rettv);
void set_color_count(int nr);
keyprot_T match_keyprotocol(char_u *term);
void apply_keyprotocol(char_u *term, keyprot_T prot);
int set_termname(char_u *term);
void free_cur_term(void);
void getlinecol(long *cp, long *rp);
+2 -2
View File
@@ -1,5 +1,5 @@
/* vim9class.c */
int object_index_from_itf_index(class_T *itf, int is_method, int idx, class_T *cl, int is_static);
int object_index_from_itf_index(class_T *itf, int is_method, int idx, class_T *cl);
void ex_class(exarg_T *eap);
type_T *class_member_type(class_T *cl, int is_object, char_u *name, char_u *name_end, int *member_idx);
void ex_enum(exarg_T *eap);
@@ -29,5 +29,5 @@ int object_free_nonref(int copyID);
void method_not_found_msg(class_T *cl, vartype_T v_type, char_u *name, size_t len);
void member_not_found_msg(class_T *cl, vartype_T v_type, char_u *name, size_t len);
void f_instanceof(typval_T *argvars, typval_T *rettv);
int class_instance_of(class_T *cl, class_T *other_cl);
int class_instance_of(class_T *cl, class_T *other_cl, int covariance_check);
/* vim: set ft=c : */
+4 -3
View File
@@ -4,8 +4,8 @@ isn_T *generate_instr_drop(cctx_T *cctx, isntype_T isn_type, int drop);
isn_T *generate_instr_type(cctx_T *cctx, isntype_T isn_type, type_T *type);
isn_T *generate_instr_debug(cctx_T *cctx);
int generate_CONSTRUCT(cctx_T *cctx, class_T *cl);
int generate_GET_OBJ_MEMBER(cctx_T *cctx, int idx, type_T *type, int is_static);
int generate_GET_ITF_MEMBER(cctx_T *cctx, class_T *itf, int idx, type_T *type, int is_static);
int generate_GET_OBJ_MEMBER(cctx_T *cctx, int idx, type_T *type);
int generate_GET_ITF_MEMBER(cctx_T *cctx, class_T *itf, int idx, type_T *type);
int generate_STORE_THIS(cctx_T *cctx, int idx);
int may_generate_2STRING(int offset, int tolerant, cctx_T *cctx);
int generate_add_instr(cctx_T *cctx, vartype_T vartype, type_T *type1, type_T *type2, exprtype_T expr_type);
@@ -45,7 +45,7 @@ int generate_OLDSCRIPT(cctx_T *cctx, isntype_T isn_type, char_u *name, int sid,
int generate_VIM9SCRIPT(cctx_T *cctx, isntype_T isn_type, int sid, int idx, type_T *type);
int generate_NEWLIST(cctx_T *cctx, int count, int use_null);
int generate_NEWDICT(cctx_T *cctx, int count, int use_null);
int generate_FUNCREF(cctx_T *cctx, ufunc_T *ufunc, class_T *cl, int fi, isn_T **isnp);
int generate_FUNCREF(cctx_T *cctx, ufunc_T *ufunc, class_T *cl, int fi, int *isn_idx);
int generate_NEWFUNC(cctx_T *cctx, char_u *lambda_name, char_u *func_name);
int generate_DEF(cctx_T *cctx, char_u *name, size_t len);
int generate_JUMP(cctx_T *cctx, jumpwhen_T when, int where);
@@ -69,6 +69,7 @@ int generate_MULT_EXPR(cctx_T *cctx, isntype_T isn_type, int count);
int generate_ECHOWINDOW(cctx_T *cctx, int count, long time);
int generate_SOURCE(cctx_T *cctx, int sid);
int generate_PUT(cctx_T *cctx, int regname, linenr_T lnum);
int generate_LOCKUNLOCK(cctx_T *cctx, char_u *line, int is_arg);
int generate_EXEC_copy(cctx_T *cctx, isntype_T isntype, char_u *line);
int generate_EXEC(cctx_T *cctx, isntype_T isntype, char_u *str);
int generate_LEGACY_EVAL(cctx_T *cctx, char_u *line);
+63 -38
View File
@@ -4695,6 +4695,43 @@ get_encoded_char_adv(char_u **p)
return mb_ptr2char_adv(p);
}
struct charstab
{
int *cp;
char *name;
};
static fill_chars_T fill_chars;
static struct charstab filltab[] =
{
{&fill_chars.stl, "stl"},
{&fill_chars.stlnc, "stlnc"},
{&fill_chars.vert, "vert"},
{&fill_chars.fold, "fold"},
{&fill_chars.foldopen, "foldopen"},
{&fill_chars.foldclosed, "foldclose"},
{&fill_chars.foldsep, "foldsep"},
{&fill_chars.diff, "diff"},
{&fill_chars.eob, "eob"},
{&fill_chars.lastline, "lastline"},
};
static lcs_chars_T lcs_chars;
static struct charstab lcstab[] =
{
{&lcs_chars.eol, "eol"},
{&lcs_chars.ext, "extends"},
{&lcs_chars.nbsp, "nbsp"},
{&lcs_chars.prec, "precedes"},
{&lcs_chars.space, "space"},
{&lcs_chars.tab2, "tab"},
{&lcs_chars.trail, "trail"},
{&lcs_chars.lead, "lead"},
#ifdef FEAT_CONCEAL
{&lcs_chars.conceal, "conceal"},
#else
{NULL, "conceal"},
#endif
};
/*
* Handle setting 'listchars' or 'fillchars'.
* "value" points to either the global or the window-local value.
@@ -4714,46 +4751,8 @@ set_chars_option(win_T *wp, char_u *value, int is_listchars, int apply)
int multispace_len = 0; // Length of lcs-multispace string
int lead_multispace_len = 0; // Length of lcs-leadmultispace string
struct charstab
{
int *cp;
char *name;
};
struct charstab *tab;
static fill_chars_T fill_chars;
static struct charstab filltab[] =
{
{&fill_chars.stl, "stl"},
{&fill_chars.stlnc, "stlnc"},
{&fill_chars.vert, "vert"},
{&fill_chars.fold, "fold"},
{&fill_chars.foldopen, "foldopen"},
{&fill_chars.foldclosed, "foldclose"},
{&fill_chars.foldsep, "foldsep"},
{&fill_chars.diff, "diff"},
{&fill_chars.eob, "eob"},
{&fill_chars.lastline, "lastline"},
};
static lcs_chars_T lcs_chars;
struct charstab lcstab[] =
{
{&lcs_chars.eol, "eol"},
{&lcs_chars.ext, "extends"},
{&lcs_chars.nbsp, "nbsp"},
{&lcs_chars.prec, "precedes"},
{&lcs_chars.space, "space"},
{&lcs_chars.tab2, "tab"},
{&lcs_chars.trail, "trail"},
{&lcs_chars.lead, "lead"},
#ifdef FEAT_CONCEAL
{&lcs_chars.conceal, "conceal"},
#else
{NULL, "conceal"},
#endif
};
if (is_listchars)
{
tab = lcstab;
@@ -4993,6 +4992,32 @@ set_listchars_option(win_T *wp, char_u *val, int apply)
return set_chars_option(wp, val, TRUE, apply);
}
/*
* Function given to ExpandGeneric() to obtain possible arguments of the
* 'fillchars' option.
*/
char_u *
get_fillchars_name(expand_T *xp UNUSED, int idx)
{
if (idx >= (int)(sizeof(filltab) / sizeof(filltab[0])))
return NULL;
return (char_u*)filltab[idx].name;
}
/*
* Function given to ExpandGeneric() to obtain possible arguments of the
* 'listchars' option.
*/
char_u *
get_listchars_name(expand_T *xp UNUSED, int idx)
{
if (idx >= (int)(sizeof(lcstab) / sizeof(lcstab[0])))
return NULL;
return (char_u*)lcstab[idx].name;
}
/*
* Check all global and local values of 'listchars' and 'fillchars'.
* Return an untranslated error messages if any of them is invalid, NULL
+1
View File
@@ -424,6 +424,7 @@ spell_check_sps(void)
if (*s != NUL && !VIM_ISDIGIT(*s))
f = -1;
}
// Note: Keep this in sync with p_sps_values.
else if (STRCMP(buf, "best") == 0)
f = SPS_BEST;
else if (STRCMP(buf, "fast") == 0)
+47 -3
View File
@@ -610,6 +610,7 @@ typedef struct expand
// file name completion
int xp_col; // cursor position in line
int xp_selected; // selected index in completion
char_u *xp_orig; // originally expanded string
char_u **xp_files; // list of files
char_u *xp_line; // text being completed
#define EXPAND_BUF_LEN 256
@@ -4554,6 +4555,11 @@ typedef struct
* "tv" points to the (first) list item value
* "li" points to the (first) list item
* "range", "n1", "n2" and "empty2" indicate what items are used.
* For a member in a class/object: TODO: verify fields
* "name" points to the (expanded) variable name.
* "exp_name" NULL or non-NULL, to be freed later.
* "tv" points to the (first) list item value
* "oi" index into member array, see _type to determine which array
* For an existing Dict item:
* "name" points to the (expanded) variable name.
* "exp_name" NULL or non-NULL, to be freed later.
@@ -4590,6 +4596,11 @@ typedef struct lval_S
type_T *ll_valtype; // type expected for the value or NULL
blob_T *ll_blob; // The Blob or NULL
ufunc_T *ll_ufunc; // The function or NULL
object_T *ll_object; // The object or NULL, class is not NULL
class_T *ll_class; // The class or NULL, object may be NULL
int ll_oi; // The object/class member index
int ll_is_root; // Special case. ll_tv is lval_root,
// ignore the rest.
} lval_T;
// Structure used to save the current state. Used when executing Normal mode
@@ -4806,14 +4817,19 @@ typedef enum {
WT_ARGUMENT,
WT_VARIABLE,
WT_MEMBER,
WT_METHOD,
WT_METHOD, // object method
WT_METHOD_ARG, // object method argument type
WT_METHOD_RETURN // object method return type
} wherekind_T;
// Struct used to pass to error messages about where the error happened.
// Struct used to pass the location of a type check. Used in error messages to
// indicate where the error happened. Also used for doing covariance type
// check for object method return type and contra-variance type check for
// object method arguments.
typedef struct {
char *wt_func_name; // function name or NULL
char wt_index; // argument or variable index, 0 means unknown
wherekind_T wt_kind; // "variable" when TRUE, "argument" otherwise
wherekind_T wt_kind; // type check location
} where_T;
#define WHERE_INIT {NULL, 0, WT_UNKNOWN}
@@ -4922,6 +4938,34 @@ typedef struct
char *os_errbuf;
} optset_T;
/*
* Argument for the callback function (opt_expand_cb_T) invoked after a string
* option value is expanded for cmdline completion.
*/
typedef struct
{
// Pointer to the option variable. It's always a string.
char_u *oe_varp;
// The original option value, escaped.
char_u *oe_opt_value;
// TRUE if using set+= instead of set=
int oe_append;
// TRUE if we would like to add the original option value as the first
// choice.
int oe_include_orig_val;
// Regex from the cmdline, for matching potential options against.
regmatch_T *oe_regmatch;
// The expansion context.
expand_T *oe_xp;
// The full argument passed to :set. For example, if the user inputs
// ':set dip=icase,algorithm:my<Tab>', oe_xp->xp_pattern will only have
// 'my', but oe_set_arg will contain the whole 'icase,algorithm:my'.
char_u *oe_set_arg;
} optexpand_T;
/*
* Spell checking variables passed from win_update() to win_line().
*/
+19 -9
View File
@@ -1613,6 +1613,23 @@ apply_builtin_tcap(char_u *term, tcap_entry_T *entries, int overwrite)
}
}
/*
* Apply builtin termcap entries for a given keyprotocol.
*/
void
apply_keyprotocol(char_u *term, keyprot_T prot)
{
if (prot == KEYPROTOCOL_KITTY)
apply_builtin_tcap(term, builtin_kitty, TRUE);
if (prot == KEYPROTOCOL_MOK2)
apply_builtin_tcap(term, builtin_mok2, TRUE);
if (prot != KEYPROTOCOL_NONE)
// Some function keys may accept modifiers even though the
// terminfo/termcap entry does not indicate this.
accept_modifiers_for_function_keys();
}
/*
* Parsing of the builtin termcap entries.
* Caller should check if "term" is a valid builtin terminal name.
@@ -1902,6 +1919,7 @@ match_keyprotocol(char_u *term)
*colon = NUL;
keyprot_T prot;
// Note: Keep this in sync with p_kpc_protocol_values.
if (STRCMP(colon + 1, "none") == 0)
prot = KEYPROTOCOL_NONE;
else if (STRCMP(colon + 1, "mok2") == 0)
@@ -2089,10 +2107,7 @@ set_termname(char_u *term)
// Use the 'keyprotocol' option to adjust the t_TE and t_TI
// termcap entries if there is an entry matching "term".
keyprot_T kpc = match_keyprotocol(term);
if (kpc == KEYPROTOCOL_KITTY)
apply_builtin_tcap(term, builtin_kitty, TRUE);
else if (kpc == KEYPROTOCOL_MOK2)
apply_builtin_tcap(term, builtin_mok2, TRUE);
apply_keyprotocol(term, kpc);
#ifdef FEAT_TERMGUICOLORS
// There is no good way to detect that the terminal supports RGB
@@ -2104,11 +2119,6 @@ set_termname(char_u *term)
&& term_strings_not_set(KS_8U))
apply_builtin_tcap(term, builtin_rgb, TRUE);
#endif
if (kpc != KEYPROTOCOL_NONE)
// Some function keys may accept modifiers even though the
// terminfo/termcap entry does not indicate this.
accept_modifiers_for_function_keys();
}
/*
+16
View File
@@ -3549,4 +3549,20 @@ func Test_custom_completion()
delfunc Check_customlist_completion
endfunc
func Test_custom_completion_with_glob()
func TestGlobComplete(A, L, P)
return split(glob('Xglob*'), "\n")
endfunc
command -nargs=* -complete=customlist,TestGlobComplete TestGlobComplete :
call writefile([], 'Xglob1', 'D')
call writefile([], 'Xglob2', 'D')
call feedkeys(":TestGlobComplete \<Tab> \<Tab>\<C-N> \<Tab>\<C-P>;\<C-B>\"\<CR>", 'xt')
call assert_equal('"TestGlobComplete Xglob1 Xglob2 ;', @:)
delcommand TestGlobComplete
delfunc TestGlobComplete
endfunc
" vim: shiftwidth=2 sts=2 expandtab
+56 -56
View File
@@ -107,65 +107,65 @@ func Test_printf_pos_misc()
call v9.CheckLegacyAndVim9Failure(["call printf('%1$d%2$d', 1, 3, 4)"], "E767:")
call v9.CheckLegacyAndVim9Failure(["call printf('%2$d%d', 1, 3)"], "E1400:")
call v9.CheckLegacyAndVim9Failure(["call printf('%d%2$d', 1, 3)"], "E1400:")
call v9.CheckLegacyAndVim9Failure(["call printf('%2$*1$d%d', 1, 3)"], "E1400:")
call v9.CheckLegacyAndVim9Failure(["call printf('%d%2$*1$d', 1, 3)"], "E1400:")
call v9.CheckLegacyAndVim9Failure(["call printf('%2$.*1$d%d', 1, 3)"], "E1400:")
call v9.CheckLegacyAndVim9Failure(["call printf('%d%2$.*1$d', 1, 3)"], "E1400:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$%')"], "E1400:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$')"], "E1400:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$_')"], "E1400:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*3$.*d', 3)"], "E1400:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*.*2$d', 3)"], "E1400:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*.*d', 3)"], "E1400:")
call v9.CheckLegacyAndVim9Failure(["call printf('%*.*1$d', 3)"], "E1400:")
call v9.CheckLegacyAndVim9Failure(["call printf('%*1$.*d', 3)"], "E1400:")
call v9.CheckLegacyAndVim9Failure(["call printf('%*1$.*1$d', 3)"], "E1400:")
call v9.CheckLegacyAndVim9Failure(["call printf('%2$d%d', 1, 3)"], "E1500:")
call v9.CheckLegacyAndVim9Failure(["call printf('%d%2$d', 1, 3)"], "E1500:")
call v9.CheckLegacyAndVim9Failure(["call printf('%2$*1$d%d', 1, 3)"], "E1500:")
call v9.CheckLegacyAndVim9Failure(["call printf('%d%2$*1$d', 1, 3)"], "E1500:")
call v9.CheckLegacyAndVim9Failure(["call printf('%2$.*1$d%d', 1, 3)"], "E1500:")
call v9.CheckLegacyAndVim9Failure(["call printf('%d%2$.*1$d', 1, 3)"], "E1500:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$%')"], "E1500:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$')"], "E1500:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$_')"], "E1500:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*3$.*d', 3)"], "E1500:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*.*2$d', 3)"], "E1500:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*.*d', 3)"], "E1500:")
call v9.CheckLegacyAndVim9Failure(["call printf('%*.*1$d', 3)"], "E1500:")
call v9.CheckLegacyAndVim9Failure(["call printf('%*1$.*d', 3)"], "E1500:")
call v9.CheckLegacyAndVim9Failure(["call printf('%*1$.*1$d', 3)"], "E1500:")
call v9.CheckLegacyAndVim9Failure(["call printf('%2$d', 3, 3)"], "E1401:")
call v9.CheckLegacyAndVim9Failure(["call printf('%2$d', 3, 3)"], "E1501:")
call v9.CheckLegacyAndVim9Failure(["call printf('%2$*1$d %1$ld', 3, 3)"], "E1402:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$s %1$*1$d', 3)"], "E1402:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$p %1$*1$d', 3)"], "E1402:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$f %1$*1$d', 3)"], "E1402:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$lud %1$*1$d', 3)"], "E1402:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$llud %1$*1$d', 3)"], "E1402:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$lld %1$*1$d', 3)"], "E1402:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$s %1$*1$d', 3)"], "E1402:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$c %1$*1$d', 3)"], "E1402:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$ld %1$*1$d', 3)"], "E1402:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$ld %2$*1$d', 3, 3)"], "E1402:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*1$ld', 3)"], "E1402:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*1$.*1$ld', 3)"], "E1402:")
call v9.CheckLegacyAndVim9Failure(["call printf('%2$*1$d %1$ld', 3, 3)"], "E1502:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$s %1$*1$d', 3)"], "E1502:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$p %1$*1$d', 3)"], "E1502:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$f %1$*1$d', 3)"], "E1502:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$lud %1$*1$d', 3)"], "E1502:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$llud %1$*1$d', 3)"], "E1502:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$lld %1$*1$d', 3)"], "E1502:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$s %1$*1$d', 3)"], "E1502:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$c %1$*1$d', 3)"], "E1502:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$ld %1$*1$d', 3)"], "E1502:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$ld %2$*1$d', 3, 3)"], "E1502:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*1$ld', 3)"], "E1502:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*1$.*1$ld', 3)"], "E1502:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$d%2$d', 3)"], "E1403:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$d%2$d', 3)"], "E1503:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$d %1$s', 3)"], "E1404:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$ld %1$s', 3)"], "E1404:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$ud %1$d', 3)"], "E1404:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$s %1$f', 3.0)"], "E1404:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*1$d %1$ld', 3)"], "E1404:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$s %1$d', 3)"], "E1404:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$p %1$d', 3)"], "E1404:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$f %1$d', 3)"], "E1404:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$lud %1$d', 3)"], "E1404:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$llud %1$d', 3)"], "E1404:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$lld %1$d', 3)"], "E1404:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$s %1$d', 3)"], "E1404:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$c %1$d', 3)"], "E1404:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$ld %1$d', 3)"], "E1404:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$d %1$s', 3)"], "E1504:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$ld %1$s', 3)"], "E1504:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$ud %1$d', 3)"], "E1504:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$s %1$f', 3.0)"], "E1504:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*1$d %1$ld', 3)"], "E1504:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$s %1$d', 3)"], "E1504:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$p %1$d', 3)"], "E1504:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$f %1$d', 3)"], "E1504:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$lud %1$d', 3)"], "E1504:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$llud %1$d', 3)"], "E1504:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$lld %1$d', 3)"], "E1504:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$s %1$d', 3)"], "E1504:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$c %1$d', 3)"], "E1504:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$ld %1$d', 3)"], "E1504:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$.2$d', 3)"], "E1405:")
call v9.CheckLegacyAndVim9Failure(["call printf('%01$d', 3)"], "E1405:")
call v9.CheckLegacyAndVim9Failure(["call printf('%01$0d', 3)"], "E1405:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*2d', 3)"], "E1405:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*3.*2$d', 3)"], "E1405:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*3$.2$d', 3)"], "E1405:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*3$.*2d', 3)"], "E1405:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$1$.5d', 5)"], "E1405:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$5.1$d', 5)"], "E1405:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$1$.1$d', 5)"], "E1405:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$.2$d', 3)"], "E1505:")
call v9.CheckLegacyAndVim9Failure(["call printf('%01$d', 3)"], "E1505:")
call v9.CheckLegacyAndVim9Failure(["call printf('%01$0d', 3)"], "E1505:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*2d', 3)"], "E1505:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*3.*2$d', 3)"], "E1505:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*3$.2$d', 3)"], "E1505:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$*3$.*2d', 3)"], "E1505:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$1$.5d', 5)"], "E1505:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$5.1$d', 5)"], "E1505:")
call v9.CheckLegacyAndVim9Failure(["call printf('%1$1$.1$d', 5)"], "E1505:")
endfunc
func Test_printf_pos_float()
@@ -296,9 +296,9 @@ func Test_printf_pos_errors()
call v9.CheckLegacyAndVim9Failure(['echo printf("%1$d", [])'], 'E745:')
call v9.CheckLegacyAndVim9Failure(['echo printf("%1$d", 1, 2)'], 'E767:')
call v9.CheckLegacyAndVim9Failure(['echo printf("%*d", 1)'], 'E766:')
call v9.CheckLegacyAndVim9Failure(['echo printf("%1$s")'], 'E1403:')
call v9.CheckLegacyAndVim9Failure(['echo printf("%1$s")'], 'E1503:')
call v9.CheckLegacyAndVim9Failure(['echo printf("%1$d", 1.2)'], 'E805:')
call v9.CheckLegacyAndVim9Failure(['echo printf("%1$f")'], 'E1403:')
call v9.CheckLegacyAndVim9Failure(['echo printf("%1$f")'], 'E1503:')
endfunc
func Test_printf_pos_64bit()
+22
View File
@@ -3625,4 +3625,26 @@ func Test_fullcommand()
call assert_equal('', fullcommand(10))
endfunc
" Test for glob() with shell special patterns
func Test_glob_extended_bash()
CheckExecutable bash
CheckNotMSWindows
CheckNotMac " The default version of bash is old on macOS.
let _shell = &shell
set shell=bash
call mkdir('Xtestglob/foo/bar/src', 'p')
call writefile([], 'Xtestglob/foo/bar/src/foo.sh')
call writefile([], 'Xtestglob/foo/bar/src/foo.h')
call writefile([], 'Xtestglob/foo/bar/src/foo.cpp')
" Sort output of glob() otherwise we end up with different
" ordering depending on whether file system is case-sensitive.
let expected = ['Xtestglob/foo/bar/src/foo.cpp', 'Xtestglob/foo/bar/src/foo.h']
call assert_equal(expected, sort(glob('Xtestglob/**/foo.{h,cpp}', 0, 1)))
call delete('Xtestglob', 'rf')
let &shell=_shell
endfunc
" vim: shiftwidth=2 sts=2 expandtab
+297 -7
View File
@@ -295,11 +295,11 @@ func Test_set_completion()
call assert_equal('"set tabstop thesaurus thesaurusfunc ttyscroll', @:)
" Expand current value
call feedkeys(":set fileencodings=\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set fileencodings=ucs-bom,utf-8,default,latin1', @:)
call feedkeys(":set suffixes=\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set suffixes=.bak,~,.o,.h,.info,.swp,.obj', @:)
call feedkeys(":set fileencodings:\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set fileencodings:ucs-bom,utf-8,default,latin1', @:)
call feedkeys(":set suffixes:\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set suffixes:.bak,~,.o,.h,.info,.swp,.obj', @:)
" Expand key codes.
call feedkeys(":set <H\<C-A>\<C-B>\"\<CR>", 'tx')
@@ -360,13 +360,17 @@ func Test_set_completion()
call assert_equal("\"set invtabstop=", @:)
" Expand options for 'spellsuggest'
call feedkeys(":set spellsuggest=best,file:xyz\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal("\"set spellsuggest=best,file:xyz", @:)
call feedkeys(":set spellsuggest=file:test_options.v\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal("\"set spellsuggest=file:test_options.vim", @:)
call feedkeys(":set spellsuggest=best,file:test_options.v\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal("\"set spellsuggest=best,file:test_options.vim", @:)
" Expand value for 'key'
set key=abcd
call feedkeys(":set key=\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set key=*****', @:)
call feedkeys(":set key-=\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set key-=*****', @:)
set key=
" Expand values for 'filetype'
@@ -382,6 +386,278 @@ func Test_set_completion()
call assert_equal('"set syntax=' .. getcompletion('a*', 'syntax')->join(), @:)
endfunc
" Test handling of expanding individual string option values
func Test_set_completion_string_values()
"
" Test basic enum string options that have well-defined enum names
"
call assert_equal(getcompletion('set display=', 'cmdline'), ['lastline', 'truncate', 'uhex'])
call assert_equal(getcompletion('set display=t', 'cmdline'), ['truncate'])
call assert_equal(getcompletion('set display=*ex*', 'cmdline'), ['uhex'])
" Test that if a value is set, it will populate the results, but only if
" typed value is empty.
set display=uhex,lastline
call assert_equal(getcompletion('set display=', 'cmdline'), ['uhex,lastline', 'lastline', 'truncate', 'uhex'])
call assert_equal(getcompletion('set display=u', 'cmdline'), ['uhex'])
" If the set value is part of the enum list, it will show as the first
" result with no duplicate.
set display=uhex
call assert_equal(getcompletion('set display=', 'cmdline'), ['uhex', 'lastline', 'truncate'])
" If empty value, will just show the normal list without an empty item
set display=
call assert_equal(getcompletion('set display=', 'cmdline'), ['lastline', 'truncate', 'uhex'])
" Test escaping of the values
call assert_equal(getcompletion('set fillchars=', 'cmdline')[0], 'vert:\|,fold:-,eob:~,lastline:@')
" Test comma-separated lists will expand after a comma.
call assert_equal(getcompletion('set display=truncate,*ex*', 'cmdline'), ['uhex'])
" Also test the positioning of the expansion is correct
call feedkeys(":set display=truncate,l\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set display=truncate,lastline', @:)
set display&
" Test single-value options will not expand after a comma
call assert_equal(getcompletion('set ambw=single,', 'cmdline'), [])
" Test the other simple options to make sure they have basic auto-complete,
" but don't exhaustively validate their results.
call assert_equal(getcompletion('set ambw=', 'cmdline')[0], 'single')
call assert_match('light\|dark', getcompletion('set bg=', 'cmdline')[1])
call assert_equal(getcompletion('set backspace=', 'cmdline')[0], 'indent')
call assert_equal(getcompletion('set backupcopy=', 'cmdline')[1], 'yes')
call assert_equal(getcompletion('set belloff=', 'cmdline')[1], 'backspace')
call assert_equal(getcompletion('set briopt=', 'cmdline')[1], 'min:')
if exists('+browsedir')
call assert_equal(getcompletion('set browsedir=', 'cmdline')[1], 'current')
endif
call assert_equal(getcompletion('set bufhidden=', 'cmdline')[1], 'unload')
call assert_equal(getcompletion('set buftype=', 'cmdline')[1], 'nowrite')
call assert_equal(getcompletion('set casemap=', 'cmdline')[1], 'internal')
if exists('+clipboard')
call assert_match('unnamed', getcompletion('set clipboard=', 'cmdline')[1])
endif
call assert_equal(getcompletion('set complete=', 'cmdline')[1], '.')
call assert_equal(getcompletion('set completeopt=', 'cmdline')[1], 'menu')
if exists('+completeslash')
call assert_equal(getcompletion('set completeslash=', 'cmdline')[1], 'backslash')
endif
if exists('+cryptmethod')
call assert_equal(getcompletion('set cryptmethod=', 'cmdline')[1], 'zip')
endif
if exists('+cursorlineopt')
call assert_equal(getcompletion('set cursorlineopt=', 'cmdline')[1], 'line')
endif
call assert_equal(getcompletion('set debug=', 'cmdline')[1], 'throw')
call assert_equal(getcompletion('set eadirection=', 'cmdline')[1], 'ver')
call assert_equal(getcompletion('set fileformat=', 'cmdline')[2], 'mac')
if exists('+foldclose')
call assert_equal(getcompletion('set foldclose=', 'cmdline')[0], 'all')
endif
if exists('+foldmethod')
call assert_equal(getcompletion('set foldmethod=', 'cmdline')[1], 'expr')
endif
if exists('+foldopen')
call assert_equal(getcompletion('set foldopen=', 'cmdline')[1], 'all')
endif
call assert_equal(getcompletion('set jumpoptions=', 'cmdline')[0], 'stack')
call assert_equal(getcompletion('set keymodel=', 'cmdline')[1], 'stopsel')
call assert_equal(getcompletion('set lispoptions=', 'cmdline')[1], 'expr:1')
call assert_match('popup', getcompletion('set mousemodel=', 'cmdline')[2])
call assert_equal(getcompletion('set nrformats=', 'cmdline')[1], 'bin')
if exists('+rightleftcmd')
call assert_equal(getcompletion('set rightleftcmd=', 'cmdline')[0], 'search')
endif
call assert_equal(getcompletion('set scrollopt=', 'cmdline')[1], 'ver')
call assert_equal(getcompletion('set selection=', 'cmdline')[1], 'exclusive')
call assert_equal(getcompletion('set selectmode=', 'cmdline')[1], 'key')
if exists('+ssop')
call assert_equal(getcompletion('set ssop=', 'cmdline')[1], 'buffers')
endif
call assert_equal(getcompletion('set showcmdloc=', 'cmdline')[1], 'statusline')
if exists('+signcolumn')
call assert_equal(getcompletion('set signcolumn=', 'cmdline')[1], 'yes')
endif
if exists('+spelloptions')
call assert_equal(getcompletion('set spelloptions=', 'cmdline')[0], 'camel')
endif
if exists('+spellsuggest')
call assert_equal(getcompletion('set spellsuggest+=', 'cmdline')[0], 'best')
endif
call assert_equal(getcompletion('set splitkeep=', 'cmdline')[1], 'screen')
call assert_equal(getcompletion('set swapsync=', 'cmdline')[1], 'sync')
call assert_equal(getcompletion('set switchbuf=', 'cmdline')[1], 'usetab')
call assert_equal(getcompletion('set tagcase=', 'cmdline')[1], 'ignore')
if exists('+termwintype')
call assert_equal(getcompletion('set termwintype=', 'cmdline')[1], 'conpty')
endif
if exists('+toolbar')
call assert_equal(getcompletion('set toolbar=', 'cmdline')[1], 'text')
endif
if exists('+tbis')
call assert_equal(getcompletion('set tbis=', 'cmdline')[2], 'medium')
endif
if exists('+ttymouse')
set ttymouse=
call assert_equal(getcompletion('set ttymouse=', 'cmdline')[1], 'xterm2')
set ttymouse&
endif
call assert_equal(getcompletion('set virtualedit=', 'cmdline')[1], 'insert')
call assert_equal(getcompletion('set wildmode=', 'cmdline')[1], 'longest')
call assert_equal(getcompletion('set wildmode=list,longest:', 'cmdline')[0], 'full')
call assert_equal(getcompletion('set wildoptions=', 'cmdline')[1], 'tagfile')
if exists('+winaltkeys')
call assert_equal(getcompletion('set winaltkeys=', 'cmdline')[1], 'yes')
endif
" Other string options that queries the system rather than fixed enum names
call assert_equal(getcompletion('set eventignore=', 'cmdline')[0:1], ['all', 'BufAdd'])
call assert_equal(getcompletion('set fileencodings=', 'cmdline')[1], 'latin1')
call assert_equal(getcompletion('set printoptions=', 'cmdline')[0], 'top')
call assert_equal(getcompletion('set wincolor=', 'cmdline')[0], 'SpecialKey')
call assert_equal(getcompletion('set listchars+=', 'cmdline')[0], 'eol')
call assert_equal(getcompletion('setl listchars+=', 'cmdline')[0], 'eol')
call assert_equal(getcompletion('set fillchars+=', 'cmdline')[0], 'stl')
call assert_equal(getcompletion('setl fillchars+=', 'cmdline')[0], 'stl')
"
" Unique string options below
"
" keyprotocol: only auto-complete when after ':' with known protocol types
call assert_equal(getcompletion('set keyprotocol=', 'cmdline'), [&keyprotocol])
call feedkeys(":set keyprotocol+=someterm:m\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set keyprotocol+=someterm:mok2', @:)
set keyprotocol&
" previewpopup / completepopup
call assert_equal(getcompletion('set previewpopup=', 'cmdline')[0], 'height:')
call assert_equal(getcompletion('set previewpopup=highlight:End*Buffer', 'cmdline')[0], 'EndOfBuffer')
call feedkeys(":set previewpopup+=border:\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set previewpopup+=border:on', @:)
call feedkeys(":set completepopup=height:10,align:\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set completepopup=height:10,align:item', @:)
call assert_equal(getcompletion('set completepopup=bogusname:', 'cmdline'), [])
set previewpopup& completepopup&
" diffopt: special handling of algorithm:<alg_list>
call assert_equal(getcompletion('set diffopt+=', 'cmdline')[0], 'filler')
call assert_equal(getcompletion('set diffopt+=iblank,foldcolumn:', 'cmdline'), [])
call assert_equal(getcompletion('set diffopt+=iblank,algorithm:pat*', 'cmdline')[0], 'patience')
" highlight: special parsing, including auto-completing highlight groups
" after ':'
call assert_equal(getcompletion('set hl=', 'cmdline')[0:1], [&hl, '8'])
call assert_equal(getcompletion('set hl+=', 'cmdline')[0], '8')
call assert_equal(getcompletion('set hl+=8', 'cmdline')[0:2], ['8:', '8b', '8i'])
call assert_equal(getcompletion('set hl+=8b', 'cmdline')[0], '8bi')
call assert_equal(getcompletion('set hl+=8:No*ext', 'cmdline')[0], 'NonText')
" If all the display modes are used up we should be suggesting nothing. Make
" a hl typed option with all the modes which will look like '8bi-nrsuc2d=t',
" and make sure nothing is suggested from that.
let hl_display_modes = join(
\ filter(map(getcompletion('set hl+=8', 'cmdline'),
\ {idx, val -> val[1]}),
\ {idx, val -> val != ':'}),
\ '')
call assert_equal(getcompletion('set hl+=8'..hl_display_modes, 'cmdline'), [])
"
" Test flag lists
"
" Test set=. Show the original value if nothing is typed after '='.
" Otherwise, the list should avoid showing what's already typed.
set mouse=v
call assert_equal(getcompletion('set mouse=', 'cmdline'), ['v','a','n','i','c','h','r'])
set mouse=nvi
call assert_equal(getcompletion('set mouse=', 'cmdline'), ['nvi','a','n','v','i','c','h','r'])
call assert_equal(getcompletion('set mouse=hn', 'cmdline'), ['a','v','i','c','r'])
" Test set+=. Never show original value, and it also tries to avoid listing
" flags that's already in the option value.
call assert_equal(getcompletion('set mouse+=', 'cmdline'), ['a','c','h','r'])
call assert_equal(getcompletion('set mouse+=hn', 'cmdline'), ['a','c','r'])
call assert_equal(getcompletion('set mouse+=acrhn', 'cmdline'), [])
" Test that the position of the expansion is correct (even if there are
" additional values after the current cursor)
call feedkeys(":set mouse=hn\<Left>\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set mouse=han', @:)
set mouse&
" Test that other flag list options have auto-complete, but don't
" exhaustively validate their results.
if exists('+concealcursor')
call assert_equal(getcompletion('set cocu=', 'cmdline')[0], 'n')
endif
call assert_equal(getcompletion('set cpo=', 'cmdline')[1], 'a')
call assert_equal(getcompletion('set fo=', 'cmdline')[1], 't')
if exists('+guioptions')
call assert_equal(getcompletion('set go=', 'cmdline')[1], '!')
endif
call assert_equal(getcompletion('set shortmess=', 'cmdline')[1], 'r')
call assert_equal(getcompletion('set whichwrap=', 'cmdline')[1], 'b')
"
"Test set-=
"
" Normal single-value option just shows the existing value
set ambiwidth=double
call assert_equal(getcompletion('set ambw-=', 'cmdline'), ['double'])
set ambiwidth&
" Works on numbers and term options as well
call assert_equal(getcompletion('set laststatus-=', 'cmdline'), [string(&laststatus)])
set t_Ce=testCe
call assert_equal(getcompletion('set t_Ce-=', 'cmdline'), ['testCe'])
set t_Ce&
" Comma-separated lists should present each option
set diffopt=context:123,,,,,iblank,iwhiteall
call assert_equal(getcompletion('set diffopt-=', 'cmdline'), ['context:123', 'iblank', 'iwhiteall'])
call assert_equal(getcompletion('set diffopt-=*n*', 'cmdline'), ['context:123', 'iblank'])
call assert_equal(getcompletion('set diffopt-=i', 'cmdline'), ['iblank', 'iwhiteall'])
" Don't present more than one option as it doesn't make sense in set-=
call assert_equal(getcompletion('set diffopt-=iblank,', 'cmdline'), [])
" Test empty option
set diffopt=
call assert_equal(getcompletion('set diffopt-=', 'cmdline'), [])
set diffopt&
" Test escaping output
call assert_equal(getcompletion('set fillchars-=', 'cmdline')[0], 'vert:\|')
" Test files with commas in name are being parsed and escaped properly
set path=has\\\ space,file\\,with\\,comma,normal_file
if exists('+completeslash')
call assert_equal(getcompletion('set path-=', 'cmdline'), ['has\\\ space', 'file\,with\,comma', 'normal_file'])
else
call assert_equal(getcompletion('set path-=', 'cmdline'), ['has\\\ space', 'file\\,with\\,comma', 'normal_file'])
endif
set path&
" Flag list should present orig value, then individual flags
set mouse=v
call assert_equal(getcompletion('set mouse-=', 'cmdline'), ['v'])
set mouse=avn
call assert_equal(getcompletion('set mouse-=', 'cmdline'), ['avn','a','v','n'])
" Don't auto-complete when we have at least one flags already
call assert_equal(getcompletion('set mouse-=n', 'cmdline'), [])
" Test empty option
set mouse=
call assert_equal(getcompletion('set mouse-=', 'cmdline'), [])
set mouse&
" 'whichwrap' is an odd case where it's both flag list and comma-separated
set ww=b,h
call assert_equal(getcompletion('set ww-=', 'cmdline'), ['b','h'])
set ww&
endfunc
func Test_set_option_errors()
call assert_fails('set scroll=-1', 'E49:')
call assert_fails('set backupcopy=', 'E474:')
@@ -1452,7 +1728,7 @@ func Test_opt_cdhome()
set cdhome&
endfunc
func Test_set_completion_2()
func Test_set_completion_fuzzy()
CheckOption termguicolors
" Test default option completion
@@ -1866,4 +2142,18 @@ func Test_binary_depending_options()
call delete('Xoutput_bin')
endfunc
func Test_set_keyprotocol()
CheckNotGui
let term = &term
set term=ansi
call assert_equal('', &t_TI)
" Setting 'keyprotocol' should affect terminal codes without needing to
" reset 'term'
set keyprotocol+=ansi:kitty
call assert_equal("\<Esc>[=1;1u", &t_TI)
let &term = term
endfunc
" vim: shiftwidth=2 sts=2 expandtab
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -3052,15 +3052,15 @@ def Test_disassemble_interface_static_member()
var lines =<< trim END
vim9script
interface I
public this.o_var: number
public this.o_var2: number
this.o_var: number
this.o_var2: number
endinterface
class C implements I
public static s_var: number
public this.o_var: number
this.o_var: number
public static s_var2: number
public this.o_var2: number
this.o_var2: number
endclass
def F1(i: I)
+50
View File
@@ -4636,6 +4636,56 @@ def Test_free_type_before_use()
v9.CheckScriptSuccess(lines)
enddef
" The following complicated script used to cause an internal error (E340)
" because the funcref instruction memory was referenced after the instruction
" memory was reallocated (Github issue #13178)
def Test_refer_funcref_instr_after_realloc()
var lines =<< trim END
vim9script
def A(d: bool)
var e = abs(0)
var f = &emoji
&emoji = true
if ['', '', '']->index('xxx') == 0
eval 0 + 0
endif
if &filetype == 'xxx'
var g = abs(0)
while g > 0
if getline(g) == ''
break
endif
--g
endwhile
if g == 0
return
endif
if d
feedkeys($'{g}G')
g = abs(0)
endif
var h = abs(0)
var i = abs(0)
var j = abs(0)
while j < 0
if abs(0) < h && getline(j) != ''
break
endif
++j
endwhile
feedkeys($'{g}G{j}G')
return
endif
def B()
enddef
def C()
enddef
enddef
A(false)
END
v9.CheckScriptSuccess(lines)
enddef
" Keep this last, it messes up highlighting.
def Test_substitute_cmd()
new
+10
View File
@@ -320,6 +320,16 @@ get_function_args(
++p;
char_u *argend = p;
// object variable this. can be used only in a constructor
if (STRNCMP(eap->arg, "new", 3) != 0)
{
c = *argend;
*argend = NUL;
semsg(_(e_cannot_use_an_object_variable_except_with_the_new_method_str), arg);
*argend = c;
break;
}
if (*skipwhite(p) == '=')
{
char_u *defval = skipwhite(skipwhite(p) + 1);
+36
View File
@@ -714,6 +714,42 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1959,
/**/
1958,
/**/
1957,
/**/
1956,
/**/
1955,
/**/
1954,
/**/
1953,
/**/
1952,
/**/
1951,
/**/
1950,
/**/
1949,
/**/
1948,
/**/
1947,
/**/
1946,
/**/
1945,
/**/
1944,
/**/
1943,
/**/
1942,
/**/
1941,
/**/
+17 -1
View File
@@ -825,7 +825,9 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
#define EXPAND_BREAKPOINT 51
#define EXPAND_SCRIPTNAMES 52
#define EXPAND_RUNTIME 53
#define EXPAND_MACACTION 54
#define EXPAND_STRING_SETTING 54
#define EXPAND_SETTING_SUBTRACT 55
#define EXPAND_MACACTION 56
// Values for exmode_active (0 is no exmode)
#define EXMODE_NORMAL 1
@@ -2337,6 +2339,20 @@ typedef enum {
*/
typedef char *(*opt_did_set_cb_T)(optset_T *args);
/*
* Type for the callback function that is invoked when expanding possible
* string option values during cmdline completion.
*
* Strings in returned matches will be managed and freed by caller.
*
* Returns OK if the expansion succeeded (numMatches and matches have to be
* set). Otherwise returns FAIL.
*
* Note: If returned FAIL or *numMatches is 0, *matches will NOT be freed by
* caller.
*/
typedef int (*opt_expand_cb_T)(optexpand_T *args, int *numMatches, char_u ***matches);
// Flags for assignment functions.
#define ASSIGN_VAR 0 // ":var" (nothing special)
#define ASSIGN_FINAL 0x01 // ":final"
+8 -1
View File
@@ -498,14 +498,20 @@ typedef struct {
typedef struct {
class_T *cm_class;
int cm_idx;
int cm_static;
} classmember_T;
// arguments to ISN_STOREINDEX
typedef struct {
vartype_T si_vartype;
class_T *si_class;
} storeindex_T;
// arguments to ISN_LOCKUNLOCK
typedef struct {
char_u *string; // for exec_command
int is_arg; // is lval_root a function arg
} lockunlock_T;
/*
* Instruction
*/
@@ -562,6 +568,7 @@ struct isn_S {
construct_T construct;
classmember_T classmember;
storeindex_T storeindex;
lockunlock_T lockunlock;
} isn_arg;
};
+115 -56
View File
@@ -220,12 +220,10 @@ add_members_to_class(
* "cl" implementing that interface.
*/
int
object_index_from_itf_index(class_T *itf, int is_method, int idx, class_T *cl,
int is_static)
object_index_from_itf_index(class_T *itf, int is_method, int idx, class_T *cl)
{
if (idx >= (is_method ? itf->class_obj_method_count
: is_static ? itf->class_class_member_count
: itf->class_obj_member_count))
: itf->class_obj_member_count))
{
siemsg("index %d out of range for interface %s", idx, itf->class_name);
return 0;
@@ -255,9 +253,7 @@ object_index_from_itf_index(class_T *itf, int is_method, int idx, class_T *cl,
if (searching && is_method)
// The parent class methods are stored after the current class
// methods.
method_offset += is_static
? super->class_class_function_count_child
: super->class_obj_method_count_child;
method_offset += super->class_obj_method_count_child;
}
if (i2c == NULL)
{
@@ -265,26 +261,12 @@ object_index_from_itf_index(class_T *itf, int is_method, int idx, class_T *cl,
cl->class_name, itf->class_name);
return 0;
}
if (is_static)
{
// TODO: Need a table for fast lookup?
char_u *name = itf->class_class_members[idx].ocm_name;
int m_idx = class_member_idx(i2c->i2c_class, name, 0);
if (m_idx >= 0)
return m_idx;
siemsg("class %s, interface %s, static %s not found",
cl->class_name, itf->class_name, name);
return 0;
}
else
{
// A table follows the i2c for the class
int *table = (int *)(i2c + 1);
// "method_offset" is 0, if method is in the current class. If method
// is in a parent class, then it is non-zero.
return table[idx] + method_offset;
}
// A table follows the i2c for the class
int *table = (int *)(i2c + 1);
// "method_offset" is 0, if method is in the current class. If method
// is in a parent class, then it is non-zero.
return table[idx] + method_offset;
}
/*
@@ -893,24 +875,52 @@ check_func_arg_names(
}
/*
* Returns TRUE if the member "varname" is already defined.
* Returns TRUE if 'varname' is a reserved keyword name
*/
static int
is_duplicate_member(garray_T *mgap, char_u *varname, char_u *varname_end)
is_reserved_varname(char_u *varname, char_u *varname_end)
{
int reserved = FALSE;
char_u save_varname_end = *varname_end;
*varname_end = NUL;
reserved = check_reserved_name(varname, FALSE) == FAIL;
*varname_end = save_varname_end;
return reserved;
}
/*
* Returns TRUE if the variable "varname" is already defined either as a class
* variable or as an object variable.
*/
static int
is_duplicate_variable(
garray_T *class_members,
garray_T *obj_members,
char_u *varname,
char_u *varname_end)
{
char_u *name = vim_strnsave(varname, varname_end - varname);
char_u *pstr = (*name == '_') ? name + 1 : name;
int dup = FALSE;
for (int i = 0; i < mgap->ga_len; ++i)
for (int loop = 1; loop <= 2; loop++)
{
ocmember_T *m = ((ocmember_T *)mgap->ga_data) + i;
char_u *qstr = *m->ocm_name == '_' ? m->ocm_name + 1 : m->ocm_name;
if (STRCMP(pstr, qstr) == 0)
// loop == 1: class variables, loop == 2: object variables
garray_T *vgap = (loop == 1) ? class_members : obj_members;
for (int i = 0; i < vgap->ga_len; ++i)
{
semsg(_(e_duplicate_variable_str), name);
dup = TRUE;
break;
ocmember_T *m = ((ocmember_T *)vgap->ga_data) + i;
char_u *qstr = *m->ocm_name == '_' ? m->ocm_name + 1
: m->ocm_name;
if (STRCMP(pstr, qstr) == 0)
{
semsg(_(e_duplicate_variable_str), name);
dup = TRUE;
break;
}
}
}
@@ -1430,11 +1440,19 @@ ex_class(exarg_T *eap)
{
char_u *impl_end = find_name_end(arg, NULL, NULL,
FNE_CHECK_START);
if (!IS_WHITE_OR_NUL(*impl_end) && *impl_end != ',')
if ((!IS_WHITE_OR_NUL(*impl_end) && *impl_end != ',')
|| (*impl_end == ','
&& !IS_WHITE_OR_NUL(*(impl_end + 1))))
{
semsg(_(e_white_space_required_after_name_str), arg);
goto early_ret;
}
if (impl_end - arg == 0)
{
emsg(_(e_missing_name_after_implements));
goto early_ret;
}
char_u *iname = vim_strnsave(arg, impl_end - arg);
if (iname == NULL)
goto early_ret;
@@ -1539,6 +1557,11 @@ early_ret:
semsg(_(e_command_cannot_be_shortened_str), line);
break;
}
if (!is_class)
{
emsg(_(e_public_variable_not_supported_in_interface));
break;
}
has_public = TRUE;
p = skipwhite(line + 6);
@@ -1633,7 +1656,13 @@ early_ret:
&varname_end, &type_list, &type,
is_class ? &init_expr: NULL) == FAIL)
break;
if (is_duplicate_member(&objmembers, varname, varname_end))
if (is_reserved_varname(varname, varname_end))
{
vim_free(init_expr);
break;
}
if (is_duplicate_variable(&classmembers, &objmembers, varname,
varname_end))
{
vim_free(init_expr);
break;
@@ -1664,7 +1693,20 @@ early_ret:
exarg_T ea;
garray_T lines_to_free;
// TODO: error for "public static def Func()"?
if (has_public)
{
// "public" keyword is not supported when defining an object or
// class method
emsg(_(e_public_keyword_not_supported_for_method));
break;
}
if (*p == NUL)
{
// No method name following def
semsg(_(e_not_valid_command_in_class_str), line);
break;
}
CLEAR_FIELD(ea);
ea.cmd = line;
@@ -1742,7 +1784,13 @@ early_ret:
&varname_end, &type_list, &type,
is_class ? &init_expr : NULL) == FAIL)
break;
if (is_duplicate_member(&classmembers, varname, varname_end))
if (is_reserved_varname(varname, varname_end))
{
vim_free(init_expr);
break;
}
if (is_duplicate_variable(&classmembers, &objmembers, varname,
varname_end))
{
vim_free(init_expr);
break;
@@ -2513,7 +2561,7 @@ inside_class(cctx_T *cctx_arg, class_T *cl)
{
for (cctx_T *cctx = cctx_arg; cctx != NULL; cctx = cctx->ctx_outer)
if (cctx->ctx_ufunc != NULL
&& class_instance_of(cctx->ctx_ufunc->uf_class, cl))
&& class_instance_of(cctx->ctx_ufunc->uf_class, cl, TRUE))
return TRUE;
return FALSE;
}
@@ -2823,29 +2871,39 @@ member_not_found_msg(class_T *cl, vartype_T v_type, char_u *name, size_t len)
* interfaces matches the class "other_cl".
*/
int
class_instance_of(class_T *cl, class_T *other_cl)
class_instance_of(class_T *cl, class_T *other_cl, int covariance_check)
{
if (cl == other_cl)
return TRUE;
// Recursively check the base classes.
for (; cl != NULL; cl = cl->class_extends)
if (covariance_check)
{
if (cl == other_cl)
return TRUE;
// Check the implemented interfaces and the super interfaces
for (int i = cl->class_interface_count - 1; i >= 0; --i)
// Recursively check the base classes.
for (; cl != NULL; cl = cl->class_extends)
{
class_T *intf = cl->class_interfaces_cl[i];
while (intf != NULL)
if (cl == other_cl)
return TRUE;
// Check the implemented interfaces and the super interfaces
for (int i = cl->class_interface_count - 1; i >= 0; --i)
{
if (intf == other_cl)
return TRUE;
// check the super interfaces
intf = intf->class_extends;
class_T *intf = cl->class_interfaces_cl[i];
while (intf != NULL)
{
if (intf == other_cl)
return TRUE;
// check the super interfaces
intf = intf->class_extends;
}
}
}
}
else
{
// contra-variance
for (; other_cl != NULL; other_cl = other_cl->class_extends)
if (cl == other_cl)
return TRUE;
}
return FALSE;
}
@@ -2880,7 +2938,7 @@ f_instanceof(typval_T *argvars, typval_T *rettv)
}
if (class_instance_of(object_tv->vval.v_object->obj_class,
li->li_tv.vval.v_class) == TRUE)
li->li_tv.vval.v_class, TRUE) == TRUE)
{
rettv->vval.v_number = VVAL_TRUE;
return;
@@ -2889,8 +2947,9 @@ f_instanceof(typval_T *argvars, typval_T *rettv)
}
else if (classinfo_tv->v_type == VAR_CLASS)
{
rettv->vval.v_number = class_instance_of(object_tv->vval.v_object->obj_class,
classinfo_tv->vval.v_class);
rettv->vval.v_number = class_instance_of(
object_tv->vval.v_object->obj_class,
classinfo_tv->vval.v_class, TRUE);
}
}
+70 -11
View File
@@ -189,10 +189,15 @@ compile_lock_unlock(
int cc = *name_end;
char_u *p = lvp->ll_name;
int ret = OK;
size_t len;
char_u *buf;
isntype_T isn = ISN_EXEC;
char *cmd = eap->cmdidx == CMD_lockvar ? "lockvar" : "unlockvar";
int is_arg = FALSE;
#ifdef LOG_LOCKVAR
ch_log(NULL, "LKVAR: compile_lock_unlock(): cookie %p, name %s",
coookie, p);
#endif
if (cctx->ctx_skip == SKIP_YES)
return OK;
@@ -207,20 +212,68 @@ compile_lock_unlock(
if (p[1] != ':')
{
char_u *end = find_name_end(p, NULL, NULL, FNE_CHECK_START);
// If name is is locally accessible, except for local var,
// then put it on the stack to use with ISN_LOCKUNLOCK.
// This could be v.memb, v[idx_key]; bare class variable,
// function arg. The local variable on the stack, will be passed
// to ex_lockvar() indirectly.
if (lookup_local(p, end - p, NULL, cctx) == OK)
char_u *name = NULL;
int len = end - p;
if (lookup_local(p, len, NULL, cctx) == OK)
{
char_u *s = p;
if (*end != '.' && *end != '[')
// Handle "this", "this.val", "anyvar[idx]"
if (*end != '.' && *end != '['
&& (len != 4 || STRNCMP("this", p, len) != 0))
{
emsg(_(e_cannot_lock_unlock_local_variable));
return FAIL;
}
// For "d.member" put the local variable on the stack, it will be
// passed to ex_lockvar() indirectly.
if (compile_load(&s, end, cctx, FALSE, FALSE) == FAIL)
// Push the local on the stack, could be "this".
name = p;
#ifdef LOG_LOCKVAR
ch_log(NULL, "LKVAR: compile... lookup_local: name %s", name);
#endif
}
if (name == NULL)
{
class_T *cl;
if (cctx_class_member_idx(cctx, p, len, &cl) >= 0)
{
if (*end != '.' && *end != '[')
{
// Push the class of the bare class variable name
name = cl->class_name;
len = STRLEN(name);
#ifdef LOG_LOCKVAR
ch_log(NULL, "LKVAR: compile... cctx_class_member: name %s",
name);
#endif
}
}
}
if (name == NULL)
{
int idx;
type_T *type;
// Can lockvar any function arg.
// TODO: test arg[idx]/arg.member
if (arg_exists(p, len, &idx, &type, NULL, cctx) == OK)
{
name = p;
is_arg = TRUE;
#ifdef LOG_LOCKVAR
ch_log(NULL, "LKVAR: compile... arg_exists: name %s", name);
#endif
}
}
if (name != NULL)
{
#ifdef LOG_LOCKVAR
ch_log(NULL, "LKVAR: compile... INS_LOCKUNLOCK %s", name);
#endif
if (compile_load(&name, name + len, cctx, FALSE, FALSE) == FAIL)
return FAIL;
isn = ISN_LOCKUNLOCK;
}
@@ -228,7 +281,7 @@ compile_lock_unlock(
// Checking is done at runtime.
*name_end = NUL;
len = name_end - p + 20;
size_t len = name_end - p + 20;
buf = alloc(len);
if (buf == NULL)
ret = FAIL;
@@ -238,7 +291,13 @@ compile_lock_unlock(
vim_snprintf((char *)buf, len, "%s! %s", cmd, p);
else
vim_snprintf((char *)buf, len, "%s %d %s", cmd, deep, p);
ret = generate_EXEC_copy(cctx, isn, buf);
#ifdef LOG_LOCKVAR
ch_log(NULL, "LKVAR: compile... buf %s", buf);
#endif
if (isn == ISN_LOCKUNLOCK)
ret = generate_LOCKUNLOCK(cctx, buf, is_arg);
else
ret = generate_EXEC_copy(cctx, isn, buf);
vim_free(buf);
*name_end = cc;
+9 -6
View File
@@ -1029,7 +1029,7 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx, garray_T *lines_to_free)
ufunc_T *ufunc;
int r = FAIL;
compiletype_T compile_type;
isn_T *funcref_isn = NULL;
int funcref_isn_idx = -1;
lvar_T *lvar = NULL;
if (eap->forceit)
@@ -1148,7 +1148,7 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx, garray_T *lines_to_free)
ASSIGN_CONST, ufunc->uf_func_type);
if (lvar == NULL)
goto theend;
if (generate_FUNCREF(cctx, ufunc, NULL, 0, &funcref_isn) == FAIL)
if (generate_FUNCREF(cctx, ufunc, NULL, 0, &funcref_isn_idx) == FAIL)
goto theend;
r = generate_STORE(cctx, ISN_STORE, lvar->lv_idx, NULL);
}
@@ -1178,8 +1178,12 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx, garray_T *lines_to_free)
#endif
// If a FUNCREF instruction was generated, set the index after compiling.
if (funcref_isn != NULL && ufunc->uf_def_status == UF_COMPILED)
if (funcref_isn_idx != -1 && ufunc->uf_def_status == UF_COMPILED)
{
isn_T *funcref_isn = ((isn_T *)cctx->ctx_instr.ga_data) +
funcref_isn_idx;
funcref_isn->isn_arg.funcref.fr_dfunc_idx = ufunc->uf_dfunc_idx;
}
theend:
vim_free(lambda_name);
@@ -2245,9 +2249,8 @@ compile_load_lhs_with_index(lhs_T *lhs, char_u *var_start, cctx_T *cctx)
return FAIL;
}
if (cl->class_flags & CLASS_INTERFACE)
return generate_GET_ITF_MEMBER(cctx, cl, lhs->lhs_member_idx, type,
FALSE);
return generate_GET_OBJ_MEMBER(cctx, lhs->lhs_member_idx, type, FALSE);
return generate_GET_ITF_MEMBER(cctx, cl, lhs->lhs_member_idx, type);
return generate_GET_OBJ_MEMBER(cctx, lhs->lhs_member_idx, type);
}
compile_load_lhs(lhs, var_start, NULL, cctx);
+30 -34
View File
@@ -535,6 +535,15 @@ call_dfunc(
// If this is an object method, the object is just before the arguments.
typval_T *obj = STACK_TV_BOT(0) - argcount - vararg_count - 1;
if (IS_OBJECT_METHOD(ufunc) && !IS_CONSTRUCTOR_METHOD(ufunc)
&& obj->v_type == VAR_OBJECT && obj->vval.v_object == NULL)
{
// If this is not a constructor method, then a valid object is
// needed.
emsg(_(e_using_null_object));
return FAIL;
}
// Check the argument types.
if (check_ufunc_arg_types(ufunc, argcount, vararg_count, ectx) == FAIL)
return FAIL;
@@ -601,15 +610,6 @@ call_dfunc(
// the first local variable.
if (IS_OBJECT_METHOD(ufunc))
{
if (obj->v_type == VAR_OBJECT && obj->vval.v_object == NULL
&& !IS_CONSTRUCTOR_METHOD(ufunc))
{
// If this is not a constructor method, then a valid object is
// needed.
emsg(_(e_using_null_object));
return FAIL;
}
*STACK_TV_VAR(0) = *obj;
obj->v_type = VAR_UNKNOWN;
}
@@ -1957,7 +1957,7 @@ fill_partial_and_closure(
* Execute iptr->isn_arg.string as an Ex command.
*/
static int
exec_command(isn_T *iptr)
exec_command(isn_T *iptr, char_u *cmd_string)
{
source_cookie_T cookie;
@@ -1965,8 +1965,7 @@ exec_command(isn_T *iptr)
// Pass getsourceline to get an error for a missing ":end" command.
CLEAR_FIELD(cookie);
cookie.sourcing_lnum = iptr->isn_lnum - 1;
if (do_cmdline(iptr->isn_arg.string,
getsourceline, &cookie,
if (do_cmdline(cmd_string, getsourceline, &cookie,
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED) == FAIL
|| did_emsg)
return FAIL;
@@ -2318,7 +2317,7 @@ execute_storeindex(isn_T *iptr, ectx_T *ectx)
if (itf != NULL)
// convert interface member index to class member index
lidx = object_index_from_itf_index(itf, FALSE, lidx,
obj->obj_class, FALSE);
obj->obj_class);
}
else
{
@@ -3182,7 +3181,7 @@ exec_instructions(ectx_T *ectx)
// execute Ex command line
case ISN_EXEC:
if (exec_command(iptr) == FAIL)
if (exec_command(iptr, iptr->isn_arg.string) == FAIL)
goto on_error;
break;
@@ -4179,16 +4178,24 @@ exec_instructions(ectx_T *ectx)
case ISN_LOCKUNLOCK:
{
// TODO: could put lval_root info in struct
typval_T *lval_root_save = lval_root;
int lval_root_is_arg_save = lval_root_is_arg;
int res;
#ifdef LOG_LOCKVAR
ch_log(NULL, "LKVAR: execute INS_LOCKUNLOCK isn_arg %s",
iptr->isn_arg.string);
#endif
// Stack has the local variable, argument the whole :lock
// or :unlock command, like ISN_EXEC.
--ectx->ec_stack.ga_len;
lval_root = STACK_TV_BOT(0);
res = exec_command(iptr);
lval_root_is_arg = iptr->isn_arg.lockunlock.is_arg;
res = exec_command(iptr, iptr->isn_arg.lockunlock.string);
clear_tv(lval_root);
lval_root = lval_root_save;
lval_root_is_arg = lval_root_is_arg_save;
if (res == FAIL)
goto on_error;
}
@@ -4262,8 +4269,7 @@ exec_instructions(ectx_T *ectx)
// convert the interface index to the object index
int idx = object_index_from_itf_index(mfunc->cmf_itf,
TRUE, mfunc->cmf_idx, cl,
FALSE);
TRUE, mfunc->cmf_idx, cl);
if (call_ufunc(cl->class_obj_methods[idx], NULL,
mfunc->cmf_argcount, ectx, NULL, NULL) == FAIL)
@@ -4412,8 +4418,7 @@ exec_instructions(ectx_T *ectx)
// convert the interface index to the object index
int idx = object_index_from_itf_index(extra->fre_class,
TRUE, extra->fre_method_idx, cl,
FALSE);
TRUE, extra->fre_method_idx, cl);
ufunc = cl->class_obj_methods[idx];
}
else if (extra == NULL || extra->fre_func_name == NULL)
@@ -5392,7 +5397,6 @@ exec_instructions(ectx_T *ectx)
goto on_error;
}
int is_static = iptr->isn_arg.classmember.cm_static;
int idx;
if (iptr->isn_type == ISN_GET_OBJ_MEMBER)
idx = iptr->isn_arg.classmember.cm_idx;
@@ -5402,15 +5406,11 @@ exec_instructions(ectx_T *ectx)
// convert the interface index to the object index
idx = object_index_from_itf_index(
iptr->isn_arg.classmember.cm_class,
FALSE, idx, obj->obj_class, is_static);
FALSE, idx, obj->obj_class);
}
// The members are located right after the object struct.
typval_T *mtv;
if (is_static)
mtv = &obj->obj_class->class_members_tv[idx];
else
mtv = ((typval_T *)(obj + 1)) + idx;
typval_T *mtv = ((typval_T *)(obj + 1)) + idx;
copy_tv(mtv, tv);
// Unreference the object after getting the member, it may
@@ -7157,17 +7157,13 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc)
case ISN_MEMBER: smsg("%s%4d MEMBER", pfx, current); break;
case ISN_STRINGMEMBER: smsg("%s%4d MEMBER %s", pfx, current,
iptr->isn_arg.string); break;
case ISN_GET_OBJ_MEMBER: smsg("%s%4d OBJ_MEMBER %d%s", pfx, current,
(int)iptr->isn_arg.classmember.cm_idx,
iptr->isn_arg.classmember.cm_static
? " [STATIC]" : "");
case ISN_GET_OBJ_MEMBER: smsg("%s%4d OBJ_MEMBER %d", pfx, current,
(int)iptr->isn_arg.classmember.cm_idx);
break;
case ISN_GET_ITF_MEMBER: smsg("%s%4d ITF_MEMBER %d on %s%s",
case ISN_GET_ITF_MEMBER: smsg("%s%4d ITF_MEMBER %d on %s",
pfx, current,
(int)iptr->isn_arg.classmember.cm_idx,
iptr->isn_arg.classmember.cm_class->class_name,
iptr->isn_arg.classmember.cm_static
? " [STATIC]" : "");
iptr->isn_arg.classmember.cm_class->class_name);
break;
case ISN_STORE_THIS: smsg("%s%4d STORE_THIS %d", pfx, current,
(int)iptr->isn_arg.number); break;
+2 -3
View File
@@ -413,9 +413,8 @@ compile_class_object_index(cctx_T *cctx, char_u **arg, type_T *type)
*arg = name_end;
if (cl->class_flags & (CLASS_INTERFACE | CLASS_EXTENDED))
return generate_GET_ITF_MEMBER(cctx, cl, m_idx, m->ocm_type,
FALSE);
return generate_GET_OBJ_MEMBER(cctx, m_idx, m->ocm_type, FALSE);
return generate_GET_ITF_MEMBER(cctx, cl, m_idx, m->ocm_type);
return generate_GET_OBJ_MEMBER(cctx, m_idx, m->ocm_type);
}
// Could be a function reference: "obj.Func".
+27 -10
View File
@@ -136,7 +136,7 @@ generate_CONSTRUCT(cctx_T *cctx, class_T *cl)
* index.
*/
int
generate_GET_OBJ_MEMBER(cctx_T *cctx, int idx, type_T *type, int is_static)
generate_GET_OBJ_MEMBER(cctx_T *cctx, int idx, type_T *type)
{
RETURN_OK_IF_SKIP(cctx);
@@ -147,7 +147,6 @@ generate_GET_OBJ_MEMBER(cctx_T *cctx, int idx, type_T *type, int is_static)
isn->isn_arg.classmember.cm_class = NULL;
isn->isn_arg.classmember.cm_idx = idx;
isn->isn_arg.classmember.cm_static = is_static;
return push_type_stack2(cctx, type, &t_any);
}
@@ -156,8 +155,7 @@ generate_GET_OBJ_MEMBER(cctx_T *cctx, int idx, type_T *type, int is_static)
* by index.
*/
int
generate_GET_ITF_MEMBER(cctx_T *cctx, class_T *itf, int idx, type_T *type,
int is_static)
generate_GET_ITF_MEMBER(cctx_T *cctx, class_T *itf, int idx, type_T *type)
{
RETURN_OK_IF_SKIP(cctx);
@@ -169,7 +167,6 @@ generate_GET_ITF_MEMBER(cctx_T *cctx, class_T *itf, int idx, type_T *type,
isn->isn_arg.classmember.cm_class = itf;
++itf->class_refcount;
isn->isn_arg.classmember.cm_idx = idx;
isn->isn_arg.classmember.cm_static = is_static;
return push_type_stack2(cctx, type, &t_any);
}
@@ -1378,7 +1375,9 @@ generate_NEWDICT(cctx_T *cctx, int count, int use_null)
* Generate an ISN_FUNCREF instruction.
* For "obj.Method" "cl" is the class of the object (can be an interface or a
* base class) and "fi" the index of the method on that class.
* "isnp" is set to the instruction, so that fr_dfunc_idx can be set later.
* "isn_idx" is set to the index of the instruction, so that fr_dfunc_idx can
* be set later. The index is used instead of a pointer to the instruction
* because the instruction memory can be reallocated.
*/
int
generate_FUNCREF(
@@ -1386,7 +1385,7 @@ generate_FUNCREF(
ufunc_T *ufunc,
class_T *cl,
int fi,
isn_T **isnp)
int *isn_idx)
{
isn_T *isn;
type_T *type;
@@ -1397,8 +1396,9 @@ generate_FUNCREF(
RETURN_OK_IF_SKIP(cctx);
if ((isn = generate_instr(cctx, ISN_FUNCREF)) == NULL)
return FAIL;
if (isnp != NULL)
*isnp = isn;
if (isn_idx != NULL)
// save the index of the new instruction
*isn_idx = cctx->ctx_instr.ga_len - 1;
has_vars = get_loop_var_info(cctx, &loopinfo);
if (ufunc->uf_def_status == UF_NOT_COMPILED || has_vars || cl != NULL)
@@ -1419,7 +1419,7 @@ generate_FUNCREF(
extra->fre_func_name = vim_strsave(ufunc->uf_name);
if (ufunc->uf_def_status != UF_NOT_COMPILED && cl == NULL)
{
if (isnp == NULL && ufunc->uf_def_status == UF_TO_BE_COMPILED)
if (isn_idx == NULL && ufunc->uf_def_status == UF_TO_BE_COMPILED)
// compile the function now, we need the uf_dfunc_idx value
(void)compile_def_function(ufunc, FALSE, CT_NONE, NULL);
isn->isn_arg.funcref.fr_dfunc_idx = ufunc->uf_dfunc_idx;
@@ -2169,6 +2169,23 @@ generate_PUT(cctx_T *cctx, int regname, linenr_T lnum)
return OK;
}
/*
* Generate an EXEC instruction that takes a string argument.
* A copy is made of "line".
*/
int
generate_LOCKUNLOCK(cctx_T *cctx, char_u *line, int is_arg)
{
isn_T *isn;
RETURN_OK_IF_SKIP(cctx);
if ((isn = generate_instr(cctx, ISN_LOCKUNLOCK)) == NULL)
return FAIL;
isn->isn_arg.lockunlock.string = vim_strsave(line);
isn->isn_arg.lockunlock.is_arg = is_arg;
return OK;
}
/*
* Generate an EXEC instruction that takes a string argument.
* A copy is made of "line".
+21 -3
View File
@@ -759,6 +759,8 @@ type_mismatch_where(type_T *expected, type_T *actual, where_T where)
where.wt_func_name, typename1, typename2);
break;
case WT_METHOD:
case WT_METHOD_ARG:
case WT_METHOD_RETURN:
semsg(_(e_method_str_type_mismatch_expected_str_but_got_str),
where.wt_func_name, typename1, typename2);
break;
@@ -869,8 +871,15 @@ check_type_maybe(
{
if (actual->tt_member != NULL
&& actual->tt_member != &t_unknown)
{
where_T func_where = where;
if (where.wt_kind == WT_METHOD)
func_where.wt_kind = WT_METHOD_RETURN;
ret = check_type_maybe(expected->tt_member,
actual->tt_member, FALSE, where);
actual->tt_member, FALSE,
func_where);
}
else
ret = MAYBE;
}
@@ -887,14 +896,20 @@ check_type_maybe(
for (i = 0; i < expected->tt_argcount
&& i < actual->tt_argcount; ++i)
{
where_T func_where = where;
if (where.wt_kind == WT_METHOD)
func_where.wt_kind = WT_METHOD_ARG;
// Allow for using "any" argument type, lambda's have them.
if (actual->tt_args[i] != &t_any && check_type(
expected->tt_args[i], actual->tt_args[i], FALSE,
where) == FAIL)
func_where) == FAIL)
{
ret = FAIL;
break;
}
}
}
if (ret == OK && expected->tt_argcount >= 0
&& actual->tt_argcount == -1)
@@ -910,7 +925,10 @@ check_type_maybe(
if (actual->tt_class == NULL)
return OK; // A null object matches
if (class_instance_of(actual->tt_class, expected->tt_class) == FALSE)
// For object method arguments, do a contra-variance type check in
// an extended class. For all others, do a co-variance type check.
if (class_instance_of(actual->tt_class, expected->tt_class,
where.wt_kind != WT_METHOD_ARG) == FALSE)
ret = FAIL;
}