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 | |
| 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)
| -rw-r--r-- | .config/nvim/after/ftplugin/python.vim | 24 | ||||
| -rw-r--r-- | .config/nvim/init.vim | 2 |
2 files changed, 25 insertions, 1 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\\)\\> diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index c8566a3..1d9a9be 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -17,7 +17,7 @@ set nu rnu set mouse=a " this is for better file searching -set path+=** +set path=.,** set wildmenu " more intuitive splits |
