diff options
| author | la-ninpre <leobrekalini@gmail.com> | 2020-11-25 20:24:02 +0300 |
|---|---|---|
| committer | la-ninpre <leobrekalini@gmail.com> | 2020-11-25 20:24:02 +0300 |
| commit | dcdd7544ffd49d2ff94bf3316d507b09b37499d8 (patch) | |
| tree | 2a1b85ac39581297cea59ed5dd759a9daa9d4030 /.config/nvim/after/ftplugin/python.vim | |
| parent | 7e044d5c92091a626d81635e6fbe2e8ad4068221 (diff) | |
| download | dotfiles-dcdd7544ffd49d2ff94bf3316d507b09b37499d8.tar.gz dotfiles-dcdd7544ffd49d2ff94bf3316d507b09b37499d8.zip | |
add good python stuff
PyInclude function is ripped from Leeren's python.vim
(https://youtube.com/watch?v=Gs1VDYnS-Ac)
Diffstat (limited to '.config/nvim/after/ftplugin/python.vim')
| -rw-r--r-- | .config/nvim/after/ftplugin/python.vim | 24 |
1 files changed, 24 insertions, 0 deletions
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\\)\\> |
