1
0
forked from aniani/vim

patch 9.1.1239: if_python: no tuple data type support

Problem:  if_python: no tuple data type support (after v9.1.1232)
Solution: Add support for using Vim tuple in the python interface
          (Yegappan Lakshmanan)

closes: #16964

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Yegappan Lakshmanan
2025-03-26 18:46:21 +01:00
committed by Christian Brabandt
parent 9d5487f6fd
commit 038be2701d
17 changed files with 1065 additions and 32 deletions

View File

@@ -1,4 +1,4 @@
*builtin.txt* For Vim version 9.1. Last change: 2025 Mar 24
*builtin.txt* For Vim version 9.1. Last change: 2025 Mar 26
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -8336,13 +8336,14 @@ py3eval({expr} [, {locals}]) *py3eval()*
converted to Vim data structures.
If a {locals} |Dictionary| is given, it defines set of local
variables available in the expression. The keys are variable
names and the values are the variable values. |Dictionary| and
|List| values are referenced, and may be updated by the
expression (as if |python-bindeval| was used).
names and the values are the variable values. |Dictionary|,
|List| and |Tuple| values are referenced, and may be updated
by the expression (as if |python-bindeval| was used).
Numbers and strings are returned as they are (strings are
copied though, Unicode strings are additionally converted to
'encoding').
Lists are represented as Vim |List| type.
Tuples are represented as Vim |Tuple| type.
Dictionaries are represented as Vim |Dictionary| type with
keys converted to strings.
Note that in a `:def` function local variables are not visible
@@ -8364,6 +8365,7 @@ pyeval({expr} [, {locals}]) *pyeval()*
Numbers and strings are returned as they are (strings are
copied though).
Lists are represented as Vim |List| type.
Tuples are represented as Vim |Tuple| type.
Dictionaries are represented as Vim |Dictionary| type,
non-string keys result in error.
Note that in a `:def` function local variables are not visible

View File

@@ -1,4 +1,4 @@
*if_pyth.txt* For Vim version 9.1. Last change: 2024 Nov 09
*if_pyth.txt* For Vim version 9.1. Last change: 2025 Mar 26
VIM REFERENCE MANUAL by Paul Moore
@@ -184,8 +184,9 @@ vim.eval(str) *python-eval*
evaluator (see |expression|). Returns the expression result as:
- a string if the Vim expression evaluates to a string or number
- a list if the Vim expression evaluates to a Vim list
- a tuple if the Vim expression evaluates to a Vim tuple
- a dictionary if the Vim expression evaluates to a Vim dictionary
Dictionaries and lists are recursively expanded.
Dictionaries, lists and tuples are recursively expanded.
Examples: >
:" value of the 'textwidth' option
:py text_width = vim.eval("&tw")
@@ -196,6 +197,8 @@ vim.eval(str) *python-eval*
:" Result is a string! Use string.atoi() to convert to a number.
:py str = vim.eval("12+12")
:
:py tuple = vim.eval('(1, 2, 3)')
:
:py tagList = vim.eval('taglist("eval_expr")')
< The latter will return a python list of python dicts, for instance:
[{'cmd': '/^eval_expr(arg, nextcmd)$/', 'static': 0, 'name': ~
@@ -207,8 +210,8 @@ vim.eval(str) *python-eval*
vim.bindeval(str) *python-bindeval*
Like |python-eval|, but returns special objects described in
|python-bindeval-objects|. These python objects let you modify (|List|
or |Dictionary|) or call (|Funcref|) vim objects.
|python-bindeval-objects|. These python objects let you modify
(|List|, |Tuple| or |Dictionary|) or call (|Funcref|) vim objects.
vim.strwidth(str) *python-strwidth*
Like |strwidth()|: returns number of display cells str occupies, tab
@@ -688,6 +691,22 @@ vim.List object *python-List*
print isinstance(l, vim.List) # True
class List(vim.List): # Subclassing
vim.Tuple object *python-Tuple*
Sequence-like object providing access to vim |Tuple| type.
Supports `.locked` attribute, see |python-.locked|. Also supports the
following methods:
Method Description ~
__new__(), __new__(iterable)
You can use `vim.Tuple()` to create new vim tuples.
Without arguments constructs empty list.
Examples: >
t = vim.Tuple("abc") # Constructor, result: ('a', 'b', 'c')
print t[1:] # slicing
print t[0] # getting item
for i in t: # iteration
print isinstance(t, vim.Tuple) # True
class Tuple(vim.Tuple): # Subclassing
vim.Function object *python-Function*
Function-like object, acting like vim |Funcref| object. Accepts special
keyword argument `self`, see |Dictionary-function|. You can also use

View File

@@ -9683,6 +9683,7 @@ python-2-and-3 if_pyth.txt /*python-2-and-3*
python-Dictionary if_pyth.txt /*python-Dictionary*
python-Function if_pyth.txt /*python-Function*
python-List if_pyth.txt /*python-List*
python-Tuple if_pyth.txt /*python-Tuple*
python-VIM_SPECIAL_PATH if_pyth.txt /*python-VIM_SPECIAL_PATH*
python-_get_paths if_pyth.txt /*python-_get_paths*
python-bindeval if_pyth.txt /*python-bindeval*