Skip to content

Commit 86f6e2c

Browse files
authored
ftplugin(python): E16 fix, async keyword support for define (#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 <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 9c0ff47 commit 86f6e2c

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

runtime/ftplugin/python.vim

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
" Vim filetype plugin file
22
" Language: python
3-
" Maintainer: Tom Picton <tom@tompicton.co.uk>
3+
" Maintainer: Tom Picton <tom@tompicton.com>
44
" Previous Maintainer: James Sully <[email protected]>
55
" Previous Maintainer: Johannes Zellner <[email protected]>
6-
" Last Change: Mon, 5 October 2020
7-
" 2024 Jan 14 by Vim Project (browsefilter)
6+
" Last Change: 2024/05/11
87
" https://github.com/tpict/vim-ftplugin-python
98

109
if exists("b:did_ftplugin") | finish | endif
@@ -15,7 +14,7 @@ set cpo&vim
1514
setlocal cinkeys-=0#
1615
setlocal indentkeys-=0#
1716
setlocal include=^\\s*\\(from\\\|import\\)
18-
setlocal define=^\\s*\\(def\\\|class\\)
17+
setlocal define=^\\s*\\([async ]\\?def\\\|class\\)
1918

2019
" For imports with leading .., append / and replace additional .s with ../
2120
let b:grandparent_match = '^\(.\.\)\(\.*\)'
@@ -57,14 +56,14 @@ let b:next_end='\v\S\n*(%$\|^(\s*\n*)*(class\|def\|async def)\|^\S)'
5756
let b:prev_end='\v\S\n*(^(\s*\n*)*(class\|def\|async def)\|^\S)'
5857

5958
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>"
61-
execute "nnoremap <silent> <buffer> [[ :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>"
63-
execute "nnoremap <silent> <buffer> [] :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>"
65-
execute "nnoremap <silent> <buffer> [m :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>"
67-
execute "nnoremap <silent> <buffer> [M :call <SID>Python_jump('n', '". b:prev_end."', 'Wb', v:count1, 0)<cr>"
59+
execute "nnoremap <silent> <buffer> ]] :<C-U>call <SID>Python_jump('n', '". b:next_toplevel."', 'W', v:count1)<cr>"
60+
execute "nnoremap <silent> <buffer> [[ :<C-U>call <SID>Python_jump('n', '". b:prev_toplevel."', 'Wb', v:count1)<cr>"
61+
execute "nnoremap <silent> <buffer> ][ :<C-U>call <SID>Python_jump('n', '". b:next_endtoplevel."', 'W', v:count1, 0)<cr>"
62+
execute "nnoremap <silent> <buffer> [] :<C-U>call <SID>Python_jump('n', '". b:prev_endtoplevel."', 'Wb', v:count1, 0)<cr>"
63+
execute "nnoremap <silent> <buffer> ]m :<C-U>call <SID>Python_jump('n', '". b:next."', 'W', v:count1)<cr>"
64+
execute "nnoremap <silent> <buffer> [m :<C-U>call <SID>Python_jump('n', '". b:prev."', 'Wb', v:count1)<cr>"
65+
execute "nnoremap <silent> <buffer> ]M :<C-U>call <SID>Python_jump('n', '". b:next_end."', 'W', 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>"
6867

6968
execute "onoremap <silent> <buffer> ]] :call <SID>Python_jump('o', '". b:next_toplevel."', 'W', v:count1)<cr>"
7069
execute "onoremap <silent> <buffer> [[ :call <SID>Python_jump('o', '". b:prev_toplevel."', 'Wb', v:count1)<cr>"

0 commit comments

Comments
 (0)