From dcdd7544ffd49d2ff94bf3316d507b09b37499d8 Mon Sep 17 00:00:00 2001 From: la-ninpre Date: Wed, 25 Nov 2020 20:24:02 +0300 Subject: add good python stuff PyInclude function is ripped from Leeren's python.vim (https://youtube.com/watch?v=Gs1VDYnS-Ac) --- .config/nvim/after/ftplugin/python.vim | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .config/nvim/after/ftplugin/python.vim (limited to '.config/nvim/after/ftplugin/python.vim') diff --git a/.config/nvim/after/ftplugin/python.vim b/.config/nvim/after/ftplugin/python.vim new file mode 100644 index 0000000..97a0bcc --- /dev/null +++ b/.config/nvim/after/ftplugin/python.vim @@ -0,0 +1,24 @@ +set shiftwidth=4 tabstop=4 softtabstop=4 expandtab autoindent smartindent + +setlocal path=.,** +setlocal wildignore=*/__pycache__/*,*.pyc + +set include=^\\s*\\(from\\\|import\\)\\s*\\zs\\(\\S\\+\\s\\{-}\\)*\\ze\\($\\\|\ as\\) + +function! PyInclude(fname) + let parts = split(a:fname, ' import ') + let l = parts[0] + if len(parts) > 1 + let r = parts[1] + let joined = join([l, r], '.') + let fp = substitute(joined, '\.', '/', 'g') . '.py' + let found = glob(fp, 1) + if len(found) + return substitute(joined, '\.', '/', 'g') . '.py' + endif + endif + return substitute(joined, '\.', '/', 'g') . '.py' +endfunction + +setlocal includeexpr=PyInclude(v:fname) +setlocal define=^\\s*\\<\\(def\\\|class\\)\\> -- cgit v1.2.3