fisadev / vim-isort

Vim plugin to sort python imports using https://github.com/timothycrosley/isort
MIT License
219 stars 32 forks source link

Vim 8 is slow to start due to vim-isort #33

Open haruanm opened 5 years ago

haruanm commented 5 years ago

For some reason vim isort is taking 1.5 sec to start, i'm using Pathogen, some idea about what to check?

times in msec
 clock   self+sourced   self:  sourced script
 clock   elapsed:              other lines

000.006  000.006: --- VIM STARTING ---
000.125  000.119: Allocated generic buffers
000.184  000.059: locale set
000.191  000.007: window checked
000.776  000.585: inits 1
000.897  000.121: parsing arguments
000.901  000.004: expanding arguments
000.924  000.023: shell init
001.289  000.365: Termcap init
001.322  000.033: inits 2
001.538  000.216: init highlight
002.089  000.418  000.418: sourcing /usr/share/vim/vim80/debian.vim
004.266  001.902  001.902: sourcing /usr/share/vim/vim80/syntax/syncolor.vim
004.630  002.362  000.460: sourcing /usr/share/vim/vim80/syntax/synload.vim
015.975  011.206  011.206: sourcing /usr/share/vim/vim80/filetype.vim
016.020  013.850  000.282: sourcing /usr/share/vim/vim80/syntax/syntax.vim
016.044  014.463  000.195: sourcing $VIM/vimrc
016.486  000.176  000.176: sourcing /home/hjustino/.vim/autoload/pathogen.vim
024.359  001.991  001.991: sourcing /usr/share/vim/vim80/ftoff.vim
032.430  000.032  000.032: sourcing /home/hjustino/.vim/bundle/ultisnips/ftdetect/snippets.vim
032.549  000.018  000.018: sourcing /home/hjustino/.vim/bundle/vim-fugitive/ftdetect/fugitive.vim
032.783  000.021  000.021: sourcing /home/hjustino/.vim/bundle/vim-vue/ftdetect/vue.vim
033.012  007.800  007.729: sourcing /usr/share/vim/vim80/filetype.vim
033.624  000.374  000.374: sourcing /usr/share/vim/vim80/syntax/nosyntax.vim
034.584  000.277  000.277: sourcing /usr/share/vim/vim80/syntax/syncolor.vim
034.762  000.807  000.530: sourcing /usr/share/vim/vim80/syntax/synload.vim
034.810  001.627  000.446: sourcing /usr/share/vim/vim80/syntax/syntax.vim
035.126  000.023  000.023: sourcing /usr/share/vim/vim80/filetype.vim
035.504  000.082  000.082: sourcing /usr/share/vim/vim80/ftplugin.vim
035.945  000.116  000.116: sourcing /usr/share/vim/vim80/indent.vim
038.334  001.938  001.938: sourcing /usr/share/vim/vim80/syntax/nosyntax.vim
039.069  000.181  000.181: sourcing /usr/share/vim/vim80/syntax/syncolor.vim
039.196  000.592  000.411: sourcing /usr/share/vim/vim80/syntax/synload.vim
039.224  002.890  000.360: sourcing /usr/share/vim/vim80/syntax/syntax.vim
039.391  000.011  000.011: sourcing /usr/share/vim/vim80/filetype.vim
039.560  000.008  000.008: sourcing /usr/share/vim/vim80/ftplugin.vim
039.723  000.008  000.008: sourcing /usr/share/vim/vim80/indent.vim
040.444  000.160  000.160: sourcing /usr/share/vim/vim80/syntax/syncolor.vim
040.992  000.188  000.188: sourcing /usr/share/vim/vim80/syntax/syncolor.vim
041.374  000.152  000.152: sourcing /usr/share/vim/vim80/syntax/syncolor.vim
041.617  000.085  000.085: sourcing /home/hjustino/.vim/bundle/onedark.vim/autoload/onedark.vim
060.263  019.735  019.310: sourcing /home/hjustino/.vim/bundle/onedark.vim/colors/onedark.vim
060.990  000.388  000.388: sourcing /usr/share/vim/vim80/syntax/nosyntax.vim
061.858  000.255  000.255: sourcing /usr/share/vim/vim80/syntax/syncolor.vim
062.448  000.221  000.221: sourcing /usr/share/vim/vim80/syntax/syncolor.vim
080.994  019.745  019.269: sourcing /home/hjustino/.vim/bundle/onedark.vim/colors/onedark.vim
081.104  019.939  000.194: sourcing /usr/share/vim/vim80/syntax/synload.vim
081.135  020.569  000.242: sourcing /usr/share/vim/vim80/syntax/syntax.vim
081.869  000.254  000.254: sourcing /usr/share/vim/vim80/syntax/syncolor.vim
082.531  000.248  000.248: sourcing /usr/share/vim/vim80/syntax/syncolor.vim
102.411  021.191  020.689: sourcing /home/hjustino/.vim/bundle/onedark.vim/colors/onedark.vim
102.942  086.859  010.472: sourcing $HOME/.vimrc
102.946  000.086: sourcing vimrc file(s)
103.474  000.387  000.387: sourcing /home/hjustino/.vim/bundle/ReplaceWithRegister/plugin/ReplaceWithRegister.vim
103.738  000.203  000.203: sourcing /home/hjustino/.vim/bundle/ack.vim/plugin/ack.vim
104.716  000.107  000.107: sourcing /home/hjustino/.vim/bundle/ale/autoload/ale/events.vim
105.050  001.253  001.146: sourcing /home/hjustino/.vim/bundle/ale/plugin/ale.vim
105.311  000.203  000.203: sourcing /home/hjustino/.vim/bundle/commentary/plugin/commentary.vim
105.783  000.387  000.387: sourcing /home/hjustino/.vim/bundle/conflict-marker.vim/plugin/conflict_marker.vim
106.247  000.196  000.196: sourcing /home/hjustino/.vim/bundle/ctrlp.vim/autoload/ctrlp/mrufiles.vim
106.476  000.633  000.437: sourcing /home/hjustino/.vim/bundle/ctrlp.vim/plugin/ctrlp.vim
107.040  000.125  000.125: sourcing /home/hjustino/.vim/bundle/nerdtree/autoload/nerdtree.vim
108.134  000.445  000.445: sourcing /home/hjustino/.vim/bundle/nerdtree/lib/nerdtree/path.vim
108.321  000.121  000.121: sourcing /home/hjustino/.vim/bundle/nerdtree/lib/nerdtree/menu_controller.vim
108.453  000.073  000.073: sourcing /home/hjustino/.vim/bundle/nerdtree/lib/nerdtree/menu_item.vim
108.606  000.095  000.095: sourcing /home/hjustino/.vim/bundle/nerdtree/lib/nerdtree/key_map.vim
108.948  000.284  000.284: sourcing /home/hjustino/.vim/bundle/nerdtree/lib/nerdtree/bookmark.vim
109.239  000.219  000.219: sourcing /home/hjustino/.vim/bundle/nerdtree/lib/nerdtree/tree_file_node.vim
109.683  000.382  000.382: sourcing /home/hjustino/.vim/bundle/nerdtree/lib/nerdtree/tree_dir_node.vim
109.922  000.180  000.180: sourcing /home/hjustino/.vim/bundle/nerdtree/lib/nerdtree/opener.vim
110.191  000.210  000.210: sourcing /home/hjustino/.vim/bundle/nerdtree/lib/nerdtree/creator.vim
110.306  000.056  000.056: sourcing /home/hjustino/.vim/bundle/nerdtree/lib/nerdtree/flag_set.vim
110.485  000.122  000.122: sourcing /home/hjustino/.vim/bundle/nerdtree/lib/nerdtree/nerdtree.vim
110.808  000.269  000.269: sourcing /home/hjustino/.vim/bundle/nerdtree/lib/nerdtree/ui.vim
110.895  000.029  000.029: sourcing /home/hjustino/.vim/bundle/nerdtree/lib/nerdtree/event.vim
110.995  000.043  000.043: sourcing /home/hjustino/.vim/bundle/nerdtree/lib/nerdtree/notifier.vim
111.418  000.358  000.358: sourcing /home/hjustino/.vim/bundle/nerdtree/autoload/nerdtree/ui_glue.vim
113.639  000.098  000.098: sourcing /home/hjustino/.vim/bundle/nerdtree/nerdtree_plugin/exec_menuitem.vim
114.194  000.537  000.537: sourcing /home/hjustino/.vim/bundle/nerdtree/nerdtree_plugin/fs_menu.vim
114.251  000.038  000.038: sourcing /home/hjustino/.vim/bundle/nerdtree/nerdtree_plugin/vcs.vim
114.889  000.579  000.579: sourcing /home/hjustino/.vim/bundle/nerdtree-git-plugin/nerdtree_plugin/git_status.vim
115.214  008.681  004.418: sourcing /home/hjustino/.vim/bundle/nerdtree/plugin/NERD_tree.vim
115.679  000.083  000.083: sourcing /home/hjustino/.vim/bundle/ultisnips/autoload/UltiSnips/map_keys.vim
115.769  000.473  000.390: sourcing /home/hjustino/.vim/bundle/ultisnips/plugin/UltiSnips.vim
116.173  000.096  000.096: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/init.vim
116.600  000.091  000.091: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/parts.vim
117.611  000.118  000.118: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/util.vim
117.639  001.817  001.512: sourcing /home/hjustino/.vim/bundle/vim-airline/plugin/airline.vim
118.145  000.446  000.446: sourcing /home/hjustino/.vim/bundle/vim-buffergator/plugin/buffergator.vim
122.076  003.870  003.870: sourcing /home/hjustino/.vim/bundle/vim-ctags/plugin/ctags.vim
122.856  000.648  000.648: sourcing /home/hjustino/.vim/bundle/vim-fugitive/plugin/fugitive.vim
123.409  000.164  000.164: sourcing /home/hjustino/.vim/bundle/vim-gitgutter/autoload/gitgutter/utility.vim
123.871  000.114  000.114: sourcing /home/hjustino/.vim/bundle/vim-gitgutter/autoload/gitgutter/highlight.vim
124.931  001.989  001.711: sourcing /home/hjustino/.vim/bundle/vim-gitgutter/plugin/gitgutter.vim
1615.779  1490.774  1490.774: sourcing /home/hjustino/.vim/bundle/vim-isort/plugin/python_vimisort.vim
1616.014  000.111  000.111: sourcing /home/hjustino/.vim/bundle/vim-snippets/plugin/vimsnippets.vim
1616.246  000.177  000.177: sourcing /home/hjustino/.vim/bundle/vim-sort-motion/plugin/sort_motion.vim
1616.907  000.601  000.601: sourcing /home/hjustino/.vim/bundle/vim-surround/plugin/surround.vim
1617.189  000.220  000.220: sourcing /home/hjustino/.vim/bundle/vim-system-copy/plugin/system_copy.vim
1617.978  000.499  000.499: sourcing /home/hjustino/.vim/bundle/vim-textobj-user/autoload/textobj/user.vim
1619.368  002.082  001.583: sourcing /home/hjustino/.vim/bundle/vim-textobj-entire/plugin/textobj/entire.vim
1621.888  002.440  002.440: sourcing /home/hjustino/.vim/bundle/vim-textobj-indent/plugin/textobj/indent.vim
1623.320  001.351  001.351: sourcing /home/hjustino/.vim/bundle/vim-textobj-line/plugin/textobj/line.vim
1623.630  000.090  000.090: sourcing /usr/share/vim/vim80/plugin/getscriptPlugin.vim
1623.973  000.325  000.325: sourcing /usr/share/vim/vim80/plugin/gzip.vim
1624.252  000.261  000.261: sourcing /usr/share/vim/vim80/plugin/logiPat.vim
1624.285  000.014  000.014: sourcing /usr/share/vim/vim80/plugin/manpager.vim
1624.500  000.201  000.201: sourcing /usr/share/vim/vim80/plugin/matchparen.vim
1625.236  000.718  000.718: sourcing /usr/share/vim/vim80/plugin/netrwPlugin.vim
1625.278  000.017  000.017: sourcing /usr/share/vim/vim80/plugin/rrhelper.vim
1625.329  000.033  000.033: sourcing /usr/share/vim/vim80/plugin/spellfile.vim
1625.542  000.195  000.195: sourcing /usr/share/vim/vim80/plugin/tarPlugin.vim
1625.662  000.099  000.099: sourcing /usr/share/vim/vim80/plugin/tohtml.vim
1625.909  000.228  000.228: sourcing /usr/share/vim/vim80/plugin/vimballPlugin.vim
1626.116  000.186  000.186: sourcing /usr/share/vim/vim80/plugin/zipPlugin.vim
1626.124  002.065: loading plugins
1626.169  000.045: loading packages
1626.373  000.124  000.124: sourcing /home/hjustino/.vim/bundle/ultisnips/after/plugin/UltiSnips_after.vim
1626.388  000.095: loading after plugins
1626.401  000.013: inits 3
1628.833  002.432: reading viminfo
1628.860  000.027: setting raw mode
1628.866  000.006: start termcap
1628.919  000.053: clearing screen
1631.622  000.534  000.534: sourcing /usr/share/vim/vim80/scripts.vim
1634.983  002.553  002.553: sourcing /usr/share/vim/vim80/ftplugin/text.vim
1637.007  000.308  000.308: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/extensions.vim
1637.212  000.065  000.065: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/extensions/quickfix.vim
1637.658  000.338  000.338: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline.vim
1637.924  000.088  000.088: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/extensions/netrw.vim
1638.145  000.087  000.087: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/extensions/term.vim
1638.436  000.148  000.148: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/extensions/ctrlp.vim
1638.811  000.192  000.192: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/extensions/hunks.vim
1639.371  000.379  000.379: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/extensions/branch.vim
1639.663  000.086  000.086: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/extensions/fugitiveline.vim
1640.129  000.250  000.250: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/extensions/ale.vim
1640.783  000.245  000.245: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/extensions/whitespace.vim
1641.294  000.140  000.140: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/extensions/po.vim
1641.671  000.224  000.224: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/extensions/wordcount.vim
1642.181  000.109  000.109: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/extensions/keymap.vim
1648.484  000.420  000.420: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/section.vim
1649.303  000.486  000.486: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/highlighter.vim
1652.730  000.132  000.132: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/themes.vim
1653.307  001.105  000.973: sourcing /home/hjustino/.vim/bundle/onedark.vim/autoload/airline/themes/onedark.vim
1655.374  000.904  000.904: sourcing /home/hjustino/.vim/bundle/onedark.vim/autoload/airline/themes/onedark.vim
1680.466  000.391  000.391: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/builder.vim
1681.453  000.313  000.313: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/extensions/wordcount/formatters/default.vim
1681.995  000.200  000.200: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/extensions/default.vim
1704.193  000.082  000.082: sourcing /home/hjustino/.vim/bundle/conflict-marker.vim/autoload/conflict_marker/detect.vim
1709.568  004.957  004.957: sourcing /home/hjustino/.vim/bundle/vim-fugitive/autoload/fugitive.vim
1710.774  000.168  000.168: sourcing /home/hjustino/.vim/bundle/ale/autoload/ale.vim
1711.183  000.287  000.287: sourcing /home/hjustino/.vim/bundle/ale/autoload/ale/util.vim
1711.604  000.304  000.304: sourcing /home/hjustino/.vim/bundle/ale/autoload/ale/linter.vim
1712.675  000.203  000.203: sourcing /home/hjustino/.vim/bundle/ale/autoload/ale/handlers/alex.vim
1713.071  001.005  000.802: sourcing /home/hjustino/.vim/bundle/ale/ale_linters/text/alex.vim
1713.671  000.296  000.296: sourcing /home/hjustino/.vim/bundle/ale/autoload/ale/handlers/languagetool.vim
1714.151  001.055  000.759: sourcing /home/hjustino/.vim/bundle/ale/ale_linters/text/languagetool.vim
1714.858  000.673  000.673: sourcing /home/hjustino/.vim/bundle/ale/ale_linters/text/proselint.vim
1715.474  000.580  000.580: sourcing /home/hjustino/.vim/bundle/ale/ale_linters/text/redpen.vim
1716.089  000.580  000.580: sourcing /home/hjustino/.vim/bundle/ale/ale_linters/text/textlint.vim
1716.682  000.558  000.558: sourcing /home/hjustino/.vim/bundle/ale/ale_linters/text/vale.vim
1717.242  000.354  000.354: sourcing /home/hjustino/.vim/bundle/ale/autoload/ale/handlers/writegood.vim
1717.735  001.019  000.665: sourcing /home/hjustino/.vim/bundle/ale/ale_linters/text/writegood.vim
1718.930  000.198  000.198: sourcing /home/hjustino/.vim/bundle/ctrlp.vim/autoload/ctrlp/utils.vim
1738.532  088.582: opening buffers
1739.113  000.196  000.196: sourcing /home/hjustino/.vim/bundle/vim-gitgutter/autoload/gitgutter.vim
1739.804  000.087  000.087: sourcing /home/hjustino/.vim/bundle/vim-gitgutter/autoload/gitgutter/async.vim
1740.030  000.096  000.096: sourcing /home/hjustino/.vim/bundle/vim-gitgutter/autoload/gitgutter/debug.vim
1749.738  007.839  007.839: sourcing /home/hjustino/.vim/bundle/vim-gitgutter/autoload/gitgutter/diff.vim
1756.289  000.471  000.471: sourcing /home/hjustino/.vim/bundle/vim-gitgutter/autoload/gitgutter/hunk.vim
1756.833  000.241  000.241: sourcing /home/hjustino/.vim/bundle/vim-gitgutter/autoload/gitgutter/sign.vim
1757.234  009.772: BufEnter autocommands
1757.238  000.004: editing files in windows
1757.622  000.384: VimEnter autocommands
1757.623  000.001: before starting main loop
1763.060  000.311  000.311: sourcing /home/hjustino/.vim/bundle/vim-airline/autoload/airline/async.vim
1767.047  001.045  001.045: sourcing /home/hjustino/.vim/bundle/ale/autoload/ale/engine.vim
1767.582  000.281  000.281: sourcing /home/hjustino/.vim/bundle/ale/autoload/ale/statusline.vim
1776.928  017.668: first screen update
1776.948  000.020: --- VIM STARTED ---

This is my vimrc file:

" This is Haruan Justino's .vimrc file

" remove all existing autocmds
autocmd!

execute pathogen#infect()
syntax on
filetype plugin indent on

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" BASIC EDITING CONFIGURATION
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
" allow unsaved background buffers and remember marks/undo for them
set hidden
" remember more commands and search history
set history=10000
set expandtab
set number
set tabstop=4
set shiftwidth=4
set softtabstop=4
set autoindent
set laststatus=2
set showmatch
set incsearch
set hlsearch
" make searches case-sensitive only if they contain upper-case characters
set ignorecase smartcase
" highlight current line
set cursorline
set cmdheight=1
set switchbuf=useopen
" Always show tab bar at the top
set showtabline=2
set winwidth=79
" This makes RVM work inside Vim. I have no idea why.
set shell=bash
" Prevent Vim from clobbering the scrollback buffer. See
" http://www.shallowsky.com/linux/noaltscreen.html
" set t_ti= t_te=
" keep more context when scrolling off the end of a buffer
set scrolloff=3
" Don't make backups at all
set nobackup
set nowritebackup
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" display incomplete commands
set showcmd
" Enable highlighting for syntax
syntax on
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" use emacs-style tab completion when selecting files, etc
set wildmode=longest,list
" make tab completion for files/buffers act like bash
set wildmenu
let mapleader=","
" Fix slow O inserts
:set timeout timeoutlen=1000 ttimeoutlen=100
" Normally, Vim messes with iskeyword when you open a shell file. This can
" leak out, polluting other file types even after a 'set ft=' change. This
" variable prevents the iskeyword change so it can't hurt anyone.
let g:sh_noisk=1
" Modelines (comments that set vim options on a per-file basis)
set modeline
set modelines=3
" Turn folding off for real, hopefully
set foldmethod=manual
set nofoldenable
" Insert only one space when joining lines that contain sentence-terminating
" punctuation like `.`.
set nojoinspaces
" If a file is changed outside of vim, automatically reload it without asking
set autoread
" Use the old vim regex engine (version 1, as opposed to version 2, which was
" introduced in Vim 7.3.969). The Ruby syntax highlighting is significantly
" slower with the new regex engine.
set re=1
" Stop SQL language files from doing unholy things to the C-c key
let g:omni_sql_no_default_maps = 1

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CUSTOM AUTOCMDS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
augroup vimrcEx
  " Clear all autocmds in the group
  autocmd!
  autocmd FileType text setlocal textwidth=78
  " Jump to last cursor position unless it's invalid or in an event handler
  autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal g`\"" |
    \ endif

  "for ruby, autoindent with two spaces, always expand tabs
  autocmd FileType ruby,haml,eruby,yaml,html,sass,cucumber set ai sw=2 sts=2 et
  autocmd FileType python set sw=4 sts=4 et

  autocmd! BufRead,BufNewFile *.sass setfiletype sass

  autocmd BufRead *.mkd  set ai formatoptions=tcroqn2 comments=n:&gt;
  autocmd BufRead *.markdown  set ai formatoptions=tcroqn2 comments=n:&gt;

  " Indent p tags
  " autocmd FileType html,eruby if g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif

  " Don't syntax highlight markdown because it's often wrong
  autocmd! FileType mkd setlocal syn=off

  " Leave the return key alone when in command line windows, since it's used
  " to run commands there.
  autocmd! CmdwinEnter * :unmap <cr>
  autocmd! CmdwinLeave * :call MapCR()

  " *.md is markdown
  autocmd! BufNewFile,BufRead *.md setlocal ft=

  " indent slim two spaces, not four
  autocmd! FileType slim set sw=2 sts=2 et

  " javascript
  autocmd! FileType javascript set sw=2 sts=2 expandtab autoindent smartindent nocindent

  " Expand tabs in Go. Was gofmt raised in a barn?!
  autocmd! FileType go set sw=4 sts=4 expandtab | retab
augroup END

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" COLOR
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
:set background=dark
:color onedark

if exists('+termguicolors')
  let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
  let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
  set termguicolors
endif

" Theme
syntax enable
set cursorline
colorscheme onedark

let g:enable_bold_font = 1
let g:enable_italic_font = 1
let g:hybrid_transparent_background = 1

let g:airline_theme='onedark'
let g:airline_powerline_fonts = 1

highlight OverLength ctermbg=darkred ctermfg=white guibg=#592929
match OverLength /\%>120v.\+/
if exists('+colorcolumn')
  set colorcolumn=120
else
  au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>120v.\+', -1)
endif

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" AUTOCLOSE MAPS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
noremap " ""<left>
inoremap ' ''<left>
inoremap ( ()<left>
inoremap [ []<left>
inoremap { {}<left>
inoremap {<CR> {<CR>}<ESC>O
inoremap {;<CR> {<CR>};<ESC>O

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" FIX SOME TYPOS  
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
:abbr lenght length
:abbr heigth height
:abbr rigth right

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"  ULTISNIPS CONFIG
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:UltiSnipsExpandTrigger = ',<tab>'

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ACK.VIM CONFIG
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ackprg = 'ag --nogroup --nocolor --column'

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PYDOCSTRING CONFIG
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <Leader>d :Pydocstring<CR>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" BUFFERGATOR CONFIG
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <C-b> :CtrlPTag<CR>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CTRLP CONFIG
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
let g:ctrlp_show_hidden = 1
nnoremap <C-t> :CtrlPTag<CR>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ALE CONFIG
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ale_sign_column_always = 1
let g:ale_sign_error = '>>'
let g:ale_sign_warning = '--'
let b:ale_linters = ['pylint', 'flake8']
let g:ale_python_pylint_options = '--load-plugins pylint_django'

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" VIM VUE CONFIG
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd FileType vue syntax sync fromstart
autocmd BufRead,BufNewFile *.vue setlocal filetype=vue.html.javascript.css
autocmd! FileType vue set sw=2 sts=2 expandtab autoindent smartindent nocindent

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" NERDTREE CONFIG
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <silent><Leader>m :NERDTreeToggle<CR>
:let g:NERDTreeWinSize=30

let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
let NERDTreeAutoDeleteBuffer = 1
let NERDTreeShowHidden=1

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" TAGBAR CONFIG
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <silent><Leader>t :TagbarToggle<CR>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" GITGUTTER CONFIG
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
highlight clear SignColumn
highlight GitGutterAdd ctermfg=green guifg=darkgreen
highlight GitGutterChange ctermfg=yellow guifg=darkyellow
highlight GitGutterDelete ctermfg=red guifg=darkred
highlight GitGutterChangeDelete ctermfg=yellow guifg=darkyellow

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MISC KEY MAPS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>y "*y
" Move around splits with <c-hjkl>
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" Insert a hash rocket with <c-l>
imap <c-l> <space>=><space>
" Can't be bothered to understand ESC vs <c-c> in insert mode
imap <c-c> <esc>
nnoremap <leader><leader> <c-^>
" Align selected lines
vnoremap <leader>ib :!align<cr>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" SHORTCUT TO REFERENCE CURRENT FILE'S PATH IN COMMAND LINE MODE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
cnoremap <expr> %% expand('%:h').'/'

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RENAME CURRENT FILE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! RenameFile()
    let old_name = expand('%')
    let new_name = input('New file name: ', expand('%'), 'file')
    if new_name != '' && new_name != old_name
        exec ':saveas ' . new_name
        exec ':silent !rm ' . old_name
        redraw!
    endif
endfunction
map <leader>n :call RenameFile()<cr>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PROMOTE VARIABLE TO RSPEC LET
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! PromoteToLet()
  :normal! dd
  " :exec '?^\s*it\>'
  :normal! P
  :.s/\(\w\+\) = \(.*\)$/let(:\1) { \2 }/
  :normal ==
endfunction
:command! PromoteToLet :call PromoteToLet()
:map <leader>p :PromoteToLet<cr>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" EXTRACT VARIABLE (SKETCHY)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! ExtractVariable()
    let name = input("Variable name: ")
    if name == ''
        return
    endif
    " Enter visual mode (not sure why this is needed since we're already in
    " visual mode anyway)
    normal! gv

    " Replace selected text with the variable name
    exec "normal c" . name
    " Define the variable on the line above
    exec "normal! O" . name . " = "
    " Paste the original selected text to be the variable value
    normal! $p
endfunction
vnoremap <leader>rv :call ExtractVariable()<cr>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" INLINE VARIABLE (SKETCHY)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! InlineVariable()
    " Copy the variable under the cursor into the 'a' register
    :let l:tmp_a = @a
    :normal "ayiw
    " Delete variable and equals sign
    :normal 2daW
    " Delete the expression into the 'b' register
    :let l:tmp_b = @b
    :normal "bd$
    " Delete the remnants of the line
    :normal dd
    " Go to the end of the previous line so we can start our search for the
    " usage of the variable to replace. Doing '0' instead of 'k$' doesn't
    " work; I'm not sure why.
    normal k$
    " Find the next occurence of the variable
    exec '/\<' . @a . '\>'
    " Replace that occurence with the text we yanked
    exec ':.s/\<' . @a . '\>/' . escape(@b, "/")
    :let @a = l:tmp_a
    :let @b = l:tmp_b
endfunction
nnoremap <leader>ri :call InlineVariable()<cr>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" OpenChangedFiles COMMAND
" Open a split for each dirty file in git
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! OpenChangedFiles()
  only " Close all windows, unless they're modified
  let status = system('git status -s | grep "^ \?\(M\|A\|UU\)" | sed "s/^.\{3\}//"')
  let filenames = split(status, "\n")
  exec "edit " . filenames[0]
  for filename in filenames[1:]
    exec "sp " . filename
  endfor
endfunction
command! OpenChangedFiles :call OpenChangedFiles()

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" InsertTime COMMAND
" Insert the current time
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
command! InsertTime :normal a<c-r>=strftime('%F %H:%M:%S.0 %z')<cr>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" FindConditionals COMMAND
" Start a search for conditional branches, both implicit and explicit
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
command! FindConditionals :normal /\<if\>\|\<unless\>\|\<and\>\|\<or\>\|||\|&&<cr>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RemoveFancyCharacters COMMAND
" Remove smart quotes, etc.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! RemoveFancyCharacters()
    let typo = {}
    let typo["“"] = '"'
    let typo["”"] = '"'
    let typo["‘"] = "'"
    let typo["’"] = "'"
    let typo["–"] = '--'
    let typo["—"] = '---'
    let typo["…"] = '...'
    :exe ":%s/".join(keys(typo), '\|').'/\=typo[submatch(0)]/ge'
endfunction
command! RemoveFancyCharacters :call RemoveFancyCharacters()

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MULTIPURPOSE TAB KEY
" Indent if we're at the beginning of a line. Else, do completion.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! InsertTabWrapper()
    let col = col('.') - 1
    if !col || getline('.')[col - 1] !~ '\k'
        return "\<tab>"
    else
        return "\<c-p>"
    endif
endfunction
inoremap <s-tab> <c-n>
inoremap <expr> <tab> InsertTabWrapper()
haruanm commented 5 years ago

I debuged the python_vimisort.vim file, when it tries to import isort on line 37:

from isort import SortImports

I commented this line, now the plugin does not verify if the isort exists, but starts fast.

As soon as Iave some time, I will try to workarround this problem with some more elegant way and do a pull request.

karambaq commented 5 years ago

Same here

jrd commented 3 years ago

wrap the import in a load_isort function and use it in isort function:

def load_isort():
    try:
        # Try isort >= 5
        from isort import code
        from isort.settings import Config
        return code, Config, None
    except ImportError:
        try:
            # Try isort < 5
            from isort import SortImports
            return None, None, SortImports
        except ImportError:
            return None, None, None

Then

def isort(text_range):
    code, Config, SortImports = load_isort()
    if code is None and Config is None and SortImports is None:
        ...
fisadev commented 3 years ago

Good idea! I'll implement this (unless you want to send a PR)

asiojxzcijvi commented 3 years ago

same here

Skeen commented 3 years ago

What's the status on this?