Skip to content

Instantly share code, notes, and snippets.

@ja-mf
Created June 26, 2021 14:27
Show Gist options
  • Save ja-mf/c04d020c24857e7b1c7ffa60d7fe4782 to your computer and use it in GitHub Desktop.
Save ja-mf/c04d020c24857e7b1c7ffa60d7fe4782 to your computer and use it in GitHub Desktop.
.vimrc python
call plug#begin('~/.vim/plugged')
Plug 'williamjameshandley/vimteractive'
Plug 'valloric/youcompleteme'
Plug 'gruvbox-community/gruvbox'
Plug 'lervag/vimtex'
Plug 'tpope/vim-surround'
Plug 'anosillus/vim-ipynb'
Plug 'jpalardy/vim-slime', { 'for': 'python' }
Plug 'hanschen/vim-ipython-cell', { 'for': 'python' }
Plug 'ludovicchabant/vim-gutentags'
Plug 'tmhedberg/SimpylFold'
Plug 'preservim/tagbar'
Plug 'tpope/vim-markdown'
Plug 'instant-markdown/vim-instant-markdown', {'for': 'markdown'}
Plug '907th/vim-auto-save'
call plug#end()
filetype plugin on
"Uncomment to override defaults:
let g:instant_markdown_slow = 1
let g:instant_markdown_autostart = 0
"let g:instant_markdown_open_to_the_world = 1
"let g:instant_markdown_allow_unsafe_content = 1
"let g:instant_markdown_allow_external_content = 0
"let g:instant_markdown_mathjax = 1
"let g:instant_markdown_mermaid = 1
let g:instant_markdown_logfile = '/tmp/instant_markdown.log'
"let g:instant_markdown_autoscroll = 0
"let g:instant_markdown_port = 8888
"let g:instant_markdown_python = 1
let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'php']
let g:vimtex_view_method = 'skim'
set guifont=MesloLGSForPowerline-Regular:h19
set number
if has("gui_running")
colorscheme gruvbox
else
colorscheme desert
endif
set tabstop=4
" set textwidth=80
set wrap lbr
set linebreak
set shiftwidth=4
set bg=dark
let g:tex_flavor = 'latex'
let g:slime_target = "vimterminal"
let g:slime_python_ipython = 1
let g:slime_vimterminal_config = 'vertical'
"let g:slime_paste_file = "$HOME/.slime_paste"
"let g:slime_cell_delimiter = "# %%"
"nmap <leader>ss <Plug>SlimeLineSend
"nmap <leader>sc <Plug>SlimeSendCell
"nmap <leader>sr <Plug>SlimeParagraphSend
"xmap <leader>sr <Plug>SlimeRegionSend
"nmap <leader>sf <Plug>SlimeConfig
"let g:slime_default_config = {"socket_name": "default", "target_pane": "{last}"}
"noremap <silent> <Leader>w :call ToggleWrap()<CR>
"function ToggleWrap()
" if &wrap
" echo "Wrap OFF"
" setlocal nowrap
" set virtualedit=all
" silent! nunmap <buffer> <Up>
" silent! nunmap <buffer> <Down>
" silent! nunmap <buffer> <Home>
" silent! nunmap <buffer> <End>
" silent! iunmap <buffer> <Up>
" silent! iunmap <buffer> <Down>
" silent! iunmap <buffer> <Home>
" silent! iunmap <buffer> <End>
" else
" echo "Wrap ON"
" setlocal wrap linebreak nolist
" set virtualedit=
" setlocal display+=lastline
" noremap <buffer> <silent> <Up> gk
" noremap <buffer> <silent> <Down> gj
" noremap <buffer> <silent> <Home> g<Home>
" noremap <buffer> <silent> <End> g<End>
" inoremap <buffer> <silent> <Up> <C-o>gk
" inoremap <buffer> <silent> <Down> <C-o>gj
" inoremap <buffer> <silent> <Home> <C-o>g<Home>
" inoremap <buffer> <silent> <End> <C-o>g<End>
" endif
"endfunction
let g:vimteractive_vertical = 1
let g:vimteractive_default_shells = { 'python': 'ipython' }
" for scrolling the terminal, just press control-b
tnoremap <c-b> <c-\><c-n>
"------------------------------------------------------------------------------
" ipython-cell configuration
"------------------------------------------------------------------------------
" Keyboard mappings. <Leader> is \ (backslash) by default
" map <Leader>s to start IPython
nnoremap <Leader>s :SlimeSend1 ipython --matplotlib<CR>
" map <Leader>r to run script
nnoremap <Leader>r :IPythonCellRun<CR>
" map <Leader>R to run script and time the execution
nnoremap <Leader>R :IPythonCellRunTime<CR>
" map <Leader>c to execute the current cell
nnoremap <Leader>c :IPythonCellExecuteCellVerbose<CR>
" map <Leader>C to execute the current cell and jump to the next cell
nnoremap <Leader>C :IPythonCellExecuteCellJumpVerbose<CR>
" map <Leader>l to clear IPython screen
nnoremap <Leader>l :IPythonCellClear<CR>
" map <Leader>x to close all Matplotlib figure windows
nnoremap <Leader>x :IPythonCellClose<CR>
" map [c and ]c to jump to the previous and next cell header
nnoremap [c :IPythonCellPrevCell<CR>
nnoremap ]c :IPythonCellNextCell<CR>
" map <Leader>h to send the current line or current selection to IPython
nmap <Leader>h <Plug>SlimeLineSend
xmap <Leader>h <Plug>SlimeRegionSend
" map <Leader>p to run the previous command
nnoremap <Leader>p :IPythonCellPrevCommand<CR>
" map <Leader>Q to restart ipython
nnoremap <Leader>Q :IPythonCellRestart<CR>
" map <Leader>d to start debug mode
nnoremap <Leader>d :SlimeSend1 %debug<CR>
" map <Leader>q to exit debug mode or IPython
nnoremap <Leader>q :SlimeSend1 exit<CR>
" map <F9> and <F10> to insert a cell header tag above/below and enter insert mode
nmap <F9> :IPythonCellInsertAbove<CR>a
nmap <F10> :IPythonCellInsertBelow<CR>a
" also make <F9> and <F10> work in insert mode
imap <F9> <C-o>:IPythonCellInsertAbove<CR>
imap <F10> <C-o>:IPythonCellInsertBelow<CR>
" autosave
let g:auto_save = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment