aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/change.txt15
-rw-r--r--runtime/doc/eval.txt26
-rw-r--r--runtime/doc/mlang.txt12
-rw-r--r--runtime/doc/options.txt12
-rw-r--r--runtime/doc/treesitter.txt5
-rw-r--r--runtime/lua/vim/lsp/util.lua6
-rw-r--r--runtime/lua/vim/treesitter/query.lua22
7 files changed, 91 insertions, 7 deletions
diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt
index 19a8be1102..b2e910a834 100644
--- a/runtime/doc/change.txt
+++ b/runtime/doc/change.txt
@@ -1771,7 +1771,7 @@ Vim has a sorting function and a sorting command. The sorting function can be
found here: |sort()|, |uniq()|.
*:sor* *:sort*
-:[range]sor[t][!] [b][f][i][n][o][r][u][x] [/{pattern}/]
+:[range]sor[t][!] [b][f][i][l][n][o][r][u][x] [/{pattern}/]
Sort lines in [range]. When no range is given all
lines are sorted.
@@ -1779,6 +1779,16 @@ found here: |sort()|, |uniq()|.
With [i] case is ignored.
+ With [l] sort uses the current collation locale.
+ Implementation details: strcoll() is used to compare
+ strings. See |:language| to check or set the collation
+ locale. Example: >
+ :language collate en_US.UTF-8
+ :%sort l
+< |v:collate| can also used to check the current locale.
+ Sorting using the locale typically ignores case.
+ This does not work properly on Mac.
+
Options [n][f][x][o][b] are mutually exclusive.
With [n] sorting is done on the first decimal number
@@ -1847,8 +1857,7 @@ found here: |sort()|, |uniq()|.
Note that using `:sort` with `:global` doesn't sort the matching lines, it's
quite useless.
-The details about sorting depend on the library function used. There is no
-guarantee that sorting obeys the current locale. You will have to try it out.
+`:sort` does not use the current locale unless the l flag is used.
Vim does do a "stable" sort.
The sorting can be interrupted, but if you interrupt it too late in the
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 6aec6c3db6..b19583ed61 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1508,6 +1508,15 @@ v:cmdarg This variable is used for two purposes:
the argument for the ":hardcopy" command. This can be used
in 'printexpr'.
+ *v:collate* *collate-variable*
+v:collate The current locale setting for collation order of the runtime
+ environment. This allows Vim scripts to be aware of the
+ current locale encoding. Technical: it's the value of
+ LC_COLLATE. When not using a locale the value is "C".
+ This variable can not be set directly, use the |:language|
+ command.
+ See |multi-lang|.
+
*v:cmdbang* *cmdbang-variable*
v:cmdbang Set like v:cmdarg for a file read/write command. When a "!"
was used the value is 1, otherwise it is 0. Note that this
@@ -8128,6 +8137,23 @@ sort({list} [, {func} [, {dict}]]) *sort()* *E702*
When {func} is given and it is '1' or 'i' then case is
ignored.
+ When {func} is given and it is 'l' then the current collation
+ locale is used for ordering. Implementation details: strcoll()
+ is used to compare strings. See |:language| check or set the
+ collation locale. |v:collate| can also be used to check the
+ current locale. Sorting using the locale typically ignores
+ case. Example: >
+ " ö is sorted similarly to o with English locale.
+ :language collate en_US.UTF8
+ :echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
+< ['n', 'o', 'O', 'ö', 'p', 'z'] ~
+>
+ " ö is sorted after z with Swedish locale.
+ :language collate sv_SE.UTF8
+ :echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
+< ['n', 'o', 'O', 'p', 'z', 'ö'] ~
+ This does not work properly on Mac.
+
When {func} is given and it is 'n' then all items will be
sorted numerical (Implementation detail: this uses the
strtod() function to parse numbers, Strings, Lists, Dicts and
diff --git a/runtime/doc/mlang.txt b/runtime/doc/mlang.txt
index b57d2b592a..9d3a51302d 100644
--- a/runtime/doc/mlang.txt
+++ b/runtime/doc/mlang.txt
@@ -31,6 +31,7 @@ use of "-" and "_".
:lan[guage] mes[sages]
:lan[guage] cty[pe]
:lan[guage] tim[e]
+:lan[guage] col[late]
Print the current language (aka locale).
With the "messages" argument the language used for
messages is printed. Technical: LC_MESSAGES.
@@ -38,15 +39,19 @@ use of "-" and "_".
character encoding is printed. Technical: LC_CTYPE.
With the "time" argument the language used for
strftime() is printed. Technical: LC_TIME.
+ With the "collate" argument the language used for
+ collation order is printed. Technical: LC_COLLATE.
Without argument all parts of the locale are printed
(this is system dependent).
The current language can also be obtained with the
- |v:lang|, |v:ctype| and |v:lc_time| variables.
+ |v:lang|, |v:ctype|, |v:collate| and |v:lc_time|
+ variables.
:lan[guage] {name}
:lan[guage] mes[sages] {name}
:lan[guage] cty[pe] {name}
:lan[guage] tim[e] {name}
+:lan[guage] col[late] {name}
Set the current language (aka locale) to {name}.
The locale {name} must be a valid locale on your
system. Some systems accept aliases like "en" or
@@ -66,7 +71,10 @@ use of "-" and "_".
With the "time" argument the language used for time
and date messages is set. This affects strftime().
This sets $LC_TIME.
- Without an argument both are set, and additionally
+ With the "collate" argument the language used for the
+ collation order is set. This affects sorting of
+ characters. This sets $LC_COLLATE.
+ Without an argument all are set, and additionally
$LANG is set.
The LC_NUMERIC value will always be set to "C" so
that floating point numbers use '.' as the decimal
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 2527a91cc8..4a6ae0245b 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -5923,6 +5923,18 @@ A jump table for the options with a short description can be found at |Q_op|.
Note that there is no '%' before the closing '}'. The
expression cannot contain a '}' character, call a function to
work around that. See |stl-%{| below.
+ {% - This is almost same as { except the result of the expression is
+ re-evaluated as a statusline format string. Thus if the
+ return value of expr contains % items they will get expanded.
+ The expression can contain the } character, the end of
+ expression is denoted by %}.
+ The For example: >
+ func! Stl_filename() abort
+ return "%t"
+ endfunc
+< `stl=%{Stl_filename()}` results in `"%t"`
+ `stl=%{%Stl_filename()%}` results in `"Name of current file"`
+ } - End of `{%` expression
( - Start of item group. Can be used for setting the width and
alignment of a section. Must be followed by %) somewhere.
) - End of item group. No width fields allowed.
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt
index 1f4b5d3097..39522898f9 100644
--- a/runtime/doc/treesitter.txt
+++ b/runtime/doc/treesitter.txt
@@ -212,6 +212,11 @@ Here is a list of built-in predicates :
((identifier) @foo (#contains? @foo "foo"))
((identifier) @foo-bar (#contains @foo-bar "foo" "bar"))
<
+ `any-of?` *ts-predicate-any-of?*
+ Will check if the text is the same as any of the following
+ arguments : >
+ ((identifier) @foo (#any-of? @foo "foo" "bar"))
+<
*lua-treesitter-not-predicate*
Each predicate has a `not-` prefixed predicate that is just the negation of
the predicate.
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index ce8468aa8a..57919e907c 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -1595,6 +1595,12 @@ function M.make_given_range_params(start_pos, end_pos)
if B[2] > 0 then
B = {B[1], M.character_offset(0, B[1], B[2])}
end
+ -- we need to offset the end character position otherwise we loose the last
+ -- character of the selection, as LSP end position is exclusive
+ -- see https://microsoft.github.io/language-server-protocol/specification#range
+ if vim.o.selection ~= 'exclusive' then
+ B[2] = B[2] + 1
+ end
return {
textDocument = M.make_text_document_params(),
range = {
diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua
index 9b4d28e09a..b81eb18945 100644
--- a/runtime/lua/vim/treesitter/query.lua
+++ b/runtime/lua/vim/treesitter/query.lua
@@ -231,7 +231,7 @@ local predicate_handlers = {
local compiled_vim_regexes = setmetatable({}, {
__index = function(t, pattern)
- local res = vim.regex(check_magic(vim.fn.escape(pattern, '\\')))
+ local res = vim.regex(check_magic(pattern))
rawset(t, pattern, res)
return res
end
@@ -260,7 +260,25 @@ local predicate_handlers = {
end
return false
- end
+ end,
+
+ ["any-of?"] = function(match, _, source, predicate)
+ local node = match[predicate[2]]
+ local node_text = M.get_node_text(node, source)
+
+ -- Since 'predicate' will not be used by callers of this function, use it
+ -- to store a string set built from the list of words to check against.
+ local string_set = predicate["string_set"]
+ if not string_set then
+ string_set = {}
+ for i=3,#predicate do
+ string_set[predicate[i]] = true
+ end
+ predicate["string_set"] = string_set
+ end
+
+ return string_set[node_text]
+ end,
}
-- As we provide lua-match? also expose vim-match?