comparison runtime/ftplugin/python.vim @ 35165:d0498ef60b5b

ftplugin(python): E16 fix, async keyword support for define (#14751) Commit: https://github.com/vim/vim/commit/86f6e2c2eed7df2bf5c60cc74d08d7a8d3c75f45 Author: Tom Picton <tom@tompicton.com> Date: Sat May 11 14:26:06 2024 -0400 ftplugin(python): E16 fix, async keyword support for define (https://github.com/vim/vim/issues/14751) This change includes the following changes: - Fix "E16: Invalid range" when using a count with jump to start/end of class/method - Update define with optional async keyword - Update maintainer email Signed-off-by: Tom Picton <tom@tompicton.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 11 May 2024 20:30:08 +0200
parents 8ae680be2a51
children df99ac9547f6
comparison
equal deleted inserted replaced
35164:dd9981469bd6 35165:d0498ef60b5b
1 " Vim filetype plugin file 1 " Vim filetype plugin file
2 " Language: python 2 " Language: python
3 " Maintainer: Tom Picton <tom@tompicton.co.uk> 3 " Maintainer: Tom Picton <tom@tompicton.com>
4 " Previous Maintainer: James Sully <sullyj3@gmail.com> 4 " Previous Maintainer: James Sully <sullyj3@gmail.com>
5 " Previous Maintainer: Johannes Zellner <johannes@zellner.org> 5 " Previous Maintainer: Johannes Zellner <johannes@zellner.org>
6 " Last Change: Mon, 5 October 2020 6 " Last Change: 2024/05/11
7 " 2024 Jan 14 by Vim Project (browsefilter)
8 " https://github.com/tpict/vim-ftplugin-python 7 " https://github.com/tpict/vim-ftplugin-python
9 8
10 if exists("b:did_ftplugin") | finish | endif 9 if exists("b:did_ftplugin") | finish | endif
11 let b:did_ftplugin = 1 10 let b:did_ftplugin = 1
12 let s:keepcpo= &cpo 11 let s:keepcpo= &cpo
13 set cpo&vim 12 set cpo&vim
14 13
15 setlocal cinkeys-=0# 14 setlocal cinkeys-=0#
16 setlocal indentkeys-=0# 15 setlocal indentkeys-=0#
17 setlocal include=^\\s*\\(from\\\|import\\) 16 setlocal include=^\\s*\\(from\\\|import\\)
18 setlocal define=^\\s*\\(def\\\|class\\) 17 setlocal define=^\\s*\\([async ]\\?def\\\|class\\)
19 18
20 " For imports with leading .., append / and replace additional .s with ../ 19 " For imports with leading .., append / and replace additional .s with ../
21 let b:grandparent_match = '^\(.\.\)\(\.*\)' 20 let b:grandparent_match = '^\(.\.\)\(\.*\)'
22 let b:grandparent_sub = '\=submatch(1)."/".repeat("../",strlen(submatch(2)))' 21 let b:grandparent_sub = '\=submatch(1)."/".repeat("../",strlen(submatch(2)))'
23 22
55 let b:prev='\v^\s*(class\|def\|async def)>' 54 let b:prev='\v^\s*(class\|def\|async def)>'
56 let b:next_end='\v\S\n*(%$\|^(\s*\n*)*(class\|def\|async def)\|^\S)' 55 let b:next_end='\v\S\n*(%$\|^(\s*\n*)*(class\|def\|async def)\|^\S)'
57 let b:prev_end='\v\S\n*(^(\s*\n*)*(class\|def\|async def)\|^\S)' 56 let b:prev_end='\v\S\n*(^(\s*\n*)*(class\|def\|async def)\|^\S)'
58 57
59 if !exists('g:no_plugin_maps') && !exists('g:no_python_maps') 58 if !exists('g:no_plugin_maps') && !exists('g:no_python_maps')
60 execute "nnoremap <silent> <buffer> ]] :call <SID>Python_jump('n', '". b:next_toplevel."', 'W', v:count1)<cr>" 59 execute "nnoremap <silent> <buffer> ]] :<C-U>call <SID>Python_jump('n', '". b:next_toplevel."', 'W', v:count1)<cr>"
61 execute "nnoremap <silent> <buffer> [[ :call <SID>Python_jump('n', '". b:prev_toplevel."', 'Wb', v:count1)<cr>" 60 execute "nnoremap <silent> <buffer> [[ :<C-U>call <SID>Python_jump('n', '". b:prev_toplevel."', 'Wb', v:count1)<cr>"
62 execute "nnoremap <silent> <buffer> ][ :call <SID>Python_jump('n', '". b:next_endtoplevel."', 'W', v:count1, 0)<cr>" 61 execute "nnoremap <silent> <buffer> ][ :<C-U>call <SID>Python_jump('n', '". b:next_endtoplevel."', 'W', v:count1, 0)<cr>"
63 execute "nnoremap <silent> <buffer> [] :call <SID>Python_jump('n', '". b:prev_endtoplevel."', 'Wb', v:count1, 0)<cr>" 62 execute "nnoremap <silent> <buffer> [] :<C-U>call <SID>Python_jump('n', '". b:prev_endtoplevel."', 'Wb', v:count1, 0)<cr>"
64 execute "nnoremap <silent> <buffer> ]m :call <SID>Python_jump('n', '". b:next."', 'W', v:count1)<cr>" 63 execute "nnoremap <silent> <buffer> ]m :<C-U>call <SID>Python_jump('n', '". b:next."', 'W', v:count1)<cr>"
65 execute "nnoremap <silent> <buffer> [m :call <SID>Python_jump('n', '". b:prev."', 'Wb', v:count1)<cr>" 64 execute "nnoremap <silent> <buffer> [m :<C-U>call <SID>Python_jump('n', '". b:prev."', 'Wb', v:count1)<cr>"
66 execute "nnoremap <silent> <buffer> ]M :call <SID>Python_jump('n', '". b:next_end."', 'W', v:count1, 0)<cr>" 65 execute "nnoremap <silent> <buffer> ]M :<C-U>call <SID>Python_jump('n', '". b:next_end."', 'W', v:count1, 0)<cr>"
67 execute "nnoremap <silent> <buffer> [M :call <SID>Python_jump('n', '". b:prev_end."', 'Wb', v:count1, 0)<cr>" 66 execute "nnoremap <silent> <buffer> [M :<C-U>call <SID>Python_jump('n', '". b:prev_end."', 'Wb', v:count1, 0)<cr>"
68 67
69 execute "onoremap <silent> <buffer> ]] :call <SID>Python_jump('o', '". b:next_toplevel."', 'W', v:count1)<cr>" 68 execute "onoremap <silent> <buffer> ]] :call <SID>Python_jump('o', '". b:next_toplevel."', 'W', v:count1)<cr>"
70 execute "onoremap <silent> <buffer> [[ :call <SID>Python_jump('o', '". b:prev_toplevel."', 'Wb', v:count1)<cr>" 69 execute "onoremap <silent> <buffer> [[ :call <SID>Python_jump('o', '". b:prev_toplevel."', 'Wb', v:count1)<cr>"
71 execute "onoremap <silent> <buffer> ][ :call <SID>Python_jump('o', '". b:next_endtoplevel."', 'W', v:count1, 0)<cr>" 70 execute "onoremap <silent> <buffer> ][ :call <SID>Python_jump('o', '". b:next_endtoplevel."', 'W', v:count1, 0)<cr>"
72 execute "onoremap <silent> <buffer> [] :call <SID>Python_jump('o', '". b:prev_endtoplevel."', 'Wb', v:count1, 0)<cr>" 71 execute "onoremap <silent> <buffer> [] :call <SID>Python_jump('o', '". b:prev_endtoplevel."', 'Wb', v:count1, 0)<cr>"