Files
dotfiles/.vimrc

394 lines
11 KiB
VimL
Raw Normal View History

2019-02-06 17:12:59 -08:00
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
"/usr/share/vim/vim81/defaults.vim, normally sourced in default arch linux vim
source ~/.config/nvim/defaults.vim
"https://wiki.archlinux.org/index.php/Neovim
"ln -s ~/.vimrc ~/.config/nvim/init.vim
"set rtp^=/usr/share/vim/vimfiles/
2019-05-30 17:20:31 -07:00
" change textwidth for mutt mail program text
" au BufRead /tmp/mutt-* set tw=72
2019-02-06 17:12:59 -08:00
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
2019-05-30 17:20:31 -07:00
autocmd FileType text setlocal textwidth=0
2019-02-06 17:12:59 -08:00
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
2019-04-03 19:38:20 -07:00
"Setup vim-plugin
2019-02-06 17:12:59 -08:00
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug '/usr/bin/fzf'
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-sensible'
2021-05-10 11:18:19 -07:00
Plug 'chriskempson/base16-vim'
2019-02-06 17:12:59 -08:00
2019-04-03 19:38:20 -07:00
" Writing mode toggle `:Goyo` and `:Limelight`
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
"Comments
2019-02-06 17:12:59 -08:00
"use \cc \cl c<space>, \cm \ci for commenting lines blocks in vis, norm modes
"use ,c<space> to comment out line(s)
Plug 'scrooloose/nerdcommenter'
Plug 'majutsushi/tagbar'
2019-04-03 19:38:20 -07:00
" Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
" https://github.com/tpope/vim-surround
" cs, ds, yss to change, delete surroundings and operate on a line
" with a selection in visual mode use S
" deoplete is for autocompletion
" if has('nvim')
" Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
" else
" Plug 'Shougo/deoplete.nvim'
" Plug 'roxma/nvim-yarp'
" Plug 'roxma/vim-hug-neovim-rpc'
" endif
" let g:deoplete#enable_at_startup = 1
"
2019-02-06 17:12:59 -08:00
2019-04-03 19:38:20 -07:00
"Commonly used vim helpers
" Plug 'ycm-core/YouCompleteMe'
2019-04-03 19:38:20 -07:00
" Plug 'jedi-vim'
" Plug 'bling/vim-airline'
" Plug 'vim-airline/vim-airline-themes'
"Denite, like emacs 'Helm' app
" Plug 'Shougo/denite.nvim'
" Plug 'mg979/vim-visual-multi', {'branch': 'master'}
2019-02-06 17:12:59 -08:00
2019-04-03 19:38:20 -07:00
"Search
" Plug 'ctrlpvim/ctrlp.vim'
" Plug 'vim-grepper'
" Plug 'vim-netranger'
2019-02-06 17:12:59 -08:00
2019-04-03 19:38:20 -07:00
"Git integration
" Plug 'tpope/vim-fugitive'
" Plug 'airblade/vim-gitgutter'
"Linting
2019-02-06 17:12:59 -08:00
" Plug 'neomake/neomake'
" Plug 'w0rp/ale'
2019-12-13 14:00:23 -08:00
2019-04-03 19:38:20 -07:00
"Syntax
" Plug 'sheerun/vim-polyglot'
" Plug 'matthewbdaly/vim-filetype-settings'
" Plug 'rhysd/vim-grammarous' "cmd :GrammarousCheck, req java
2019-02-06 17:12:59 -08:00
"todo.txt: https://github.com/freitass/todo.txt-vim
Plug 'freitass/todo.txt-vim'
" if localleader is '\' then for todo.txt files:
" <localleader>s sort
" <localleader>s+ sort on projects
" <localleader>j Decrease the priority of the current line
" <localleader>sd sort on dates
" <localleader>d set task's date
" <localleader>x mark task done
" see ':h todo.txt' for more
2019-02-06 17:12:59 -08:00
"External languages, interpreter/repl integration
" Plug 'kassio/neoterm'
"
2019-12-13 14:00:23 -08:00
" Plug 'jpalardy/vim-slime'
" #:IPython. F5 exec current line or visual selection
" Plug 'bfredl/nvim-ipy'
2019-02-06 17:12:59 -08:00
" Plug 'jalvesaq/Nvim-R'
" Plug 'python-mode/python-mode', { 'for': 'python', 'branch': 'develop' }
" jupyter independent ipython repl and other languages too
" Plug 'Vigemus/iron.nvim'
2021-05-10 11:18:19 -07:00
Plug 'jupyter-vim/jupyter-vim'
2019-02-06 17:12:59 -08:00
"latex
2019-04-03 19:38:20 -07:00
" Plug 'lervag/vimtex'
" Plug 'vim-pandoc/vim-pandoc'
2019-02-06 17:12:59 -08:00
2019-04-03 19:38:20 -07:00
"Markdown
" Plug 'vimwiki/vimwiki'
" Plug 'suan/vim-instant-markdown' " Markdown preview instant-markdown-d
2019-02-06 17:12:59 -08:00
"next one uses a rust lib for fast async md, requires rust/cargo install
2019-04-03 19:38:20 -07:00
" Plug 'euclio/vim-markdown-composer'
" Plug 'aaren/notedown'
2019-02-06 17:12:59 -08:00
"https://github.com/iamcco/markdown-preview.nvim
2019-04-03 19:38:20 -07:00
"if have nodejs and yarn, this is markdown-it js lib based
2019-02-06 17:12:59 -08:00
" Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
call plug#end()
filetype plugin indent on
"Syntax highlighting in Markdown
2020-10-19 17:07:35 -07:00
" au BufNewFile,BufReadPost *.md, *.mkd set filetype=markdown
2019-02-06 17:12:59 -08:00
"let g:polyglot_disabled = ['markdown']
2021-09-18 16:08:13 -07:00
let g:markdown_fenced_languages = ['html','r', 'javascript', 'python', 'sh', 'bash=sh', 'css', 'js=javascript', 'json=javascript', 'sql']
2019-02-06 17:12:59 -08:00
2019-04-03 19:38:20 -07:00
"Tagbar config
nmap <F8> :TagbarToggle<CR>
" from Universal Ctags 0.0.0(a3c87ab5), ctags --list-kinds
2019-02-06 17:12:59 -08:00
let g:tagbar_type_markdown = {
\ 'ctagstype' : 'Markdown',
2019-02-06 17:12:59 -08:00
\ 'kinds' : [
\ 'c:Heading_L1',
\ 's:Heading_L2',
\ 'S:Heading_L3',
\ 't:Heading_L4',
\ 'T:Heading_L5',
\ 'u:Heading_L6'
2019-02-06 17:12:59 -08:00
\ ]
\ }
let g:tagbar_type_bib = {
\ 'ctagstype' : 'BibTex',
2019-02-06 17:12:59 -08:00
\ 'kinds' : [
\ 'a:Articles',
\ 'b:Books',
\ 'B:Booklets',
2019-02-06 17:12:59 -08:00
\ 'c:Conferences',
\ 'i:Inbook',
\ 'I:Incollection',
\ 'J:Inproceedings',
2019-02-06 17:12:59 -08:00
\ 'm:Manuals',
\ 'M:Masterstheses',
\ 'n:Misc',
\ 'p:Phdtheses',
\ 'P:Proceedings',
\ 't:Techreports',
2019-02-06 17:12:59 -08:00
\ 'u:Unpublished',
\ 's:string'
2019-02-06 17:12:59 -08:00
\ ]
\ }
2019-04-03 19:38:20 -07:00
"Python repl config
" let g:loaded_python_provider = 0
2021-05-10 11:18:19 -07:00
let g:python3_host_prog = '/usr/bin/python3'
" let g:slime_target = 'tmux'
" let g:slime_python_ipython = 1
"
"use C-c, C-c to send paragraph or selected text
":SlimeConfig
" https://github.com/jpalardy/vim-slime
2019-02-06 17:12:59 -08:00
2021-05-10 11:18:19 -07:00
" jupyter-vim config
let g:jupyter_cell_separators = ['##', '#%%', '# %%', '# <codecell>', '```']
nnoremap <buffer> <silent> <localleader>r :JupyterSendCell<CR>
" execute lines in visual mode: <localleader>e
" buffer local var for kernel can be python, ir, javascript, julia, rust
" b:jupyter_kernel_type =
"JupyterSendRange
2019-02-06 17:12:59 -08:00
":vertical terminal ipython
"set updatetime=100
2019-12-13 14:00:23 -08:00
"split navigations
" nnoremap <C-J> <C-W><C-J>
" nnoremap <C-K> <C-W><C-K>
" nnoremap <C-L> <C-W><C-L>
" nnoremap <C-H> <C-W><C-H>
2019-02-06 17:12:59 -08:00
"nnoremap yr :IronRepl<cr>
"nmap ,r <Plug>(iron-send-motion)
"xmap ,r <Plug>(iron-send-motion)
"nmap yR V,r
2019-12-13 14:00:23 -08:00
"R repl config
"" start R with F2 key
"" map <F2> <Plug>RStart
"" imap <F2> <Plug>RStart
"" vmap <F2> <Plug>RStart
"" R version can be specified like this:
"" let vimrplugin_r_path = '/opt/R/3.1.2-release/bin/R'
"" Send selection or line to R with space bar, respectively.
" vmap <Space> <Plug>RDSendSelection
" nmap <Space> <Plug>RDSendLine
2019-04-03 19:38:20 -07:00
"Neomake config
2019-02-06 17:12:59 -08:00
" Full config: when writing or reading a buffer, and on changes in insert and
" normal mode (after 1s; no delay when writing).
"call neomake#configure#automake('nrwi', 500)
2019-04-03 19:38:20 -07:00
"General vim config
2021-09-18 16:08:13 -07:00
set tabstop=8
set softtabstop=4
2019-02-06 17:12:59 -08:00
set shiftwidth=4
set expandtab
" set number
" set relativenumber
" set hlsearch
" set spell
2019-04-03 19:38:20 -07:00
augroup configgroup
autocmd!
autocmd FileType html setlocal tabstop=2
autocmd FileType html setlocal shiftwidth=2
autocmd FileType html setlocal softtabstop=2
autocmd FileType css setlocal tabstop=2
autocmd FileType css setlocal shiftwidth=2
autocmd FileType css setlocal softtabstop=2
autocmd FileType javascript setlocal tabstop=2
autocmd FileType javascript setlocal shiftwidth=2
autocmd FileType javascript setlocal softtabstop=2
" autocmd FileType html setlocal commentstring=#\ %s
autocmd BufEnter *.sh setlocal tabstop=2
autocmd BufEnter *.sh setlocal shiftwidth=2
autocmd BufEnter *.sh setlocal softtabstop=2
augroup END
" au BufNewFile,BufRead *.js, *.html, *.css set tabstop=2 softtabstop=2 set shiftwidth=2 expandtab
2019-04-03 19:38:20 -07:00
"Mouse/trackpad pointer config
2019-02-06 17:12:59 -08:00
" set mouse=a "already set by defaults.vim
set mouse=n
" OR try set mouse=r mouse=&
2019-04-03 19:38:20 -07:00
" Shortcuts for next or prev file like after vim *.py
2019-02-06 17:12:59 -08:00
" :map v :n<enter>
" :map V :N<enter>
" or just use :n or :N followed by the dot . cmd!
2019-04-03 19:38:20 -07:00
"Quick save config
imap ;s <ESC>:update<enter>
2020-05-10 22:22:24 -07:00
nmap ;s <ESC>:update<enter>
" imap jjw <ESC>:update<enter>
2019-02-06 17:12:59 -08:00
"<CR> vs <enter> and running code
2019-04-03 19:38:20 -07:00
"Quick mode exit config
2019-02-06 17:12:59 -08:00
" Two semicolons are easy to type. The `^ fixes the cursor position.
2019-04-03 19:38:20 -07:00
imap ;; <ESC>`^
2019-02-06 17:12:59 -08:00
inoremap <Tab> <Esc>`^
2020-05-10 22:22:24 -07:00
2019-04-03 19:38:20 -07:00
" Just press Space to enter insert mode while in normal mode.
2019-02-06 17:12:59 -08:00
nmap <Space> i
" On gvim and Linux console Vim, you can also use ctrl-Space.
" :imap <C-Space> <>
2019-04-03 19:38:20 -07:00
"Clipboard config
" copy with ctrl-c in visual highlight mode
2019-02-06 17:12:59 -08:00
vmap <C-c> "+y
"use system clipboard: Now yank y, delete d, or paste p work to/from system
set clipboard=unnamedplus
2021-05-10 11:18:19 -07:00
" link yanking and pasting to system clipboard under Wayland
" from https://github.com/vim/vim/issues/5157
xnoremap "+y y:call system("wl-copy", @")<cr>
nnoremap "+p :let @"=substitute(system("wl-paste --no-newline"), '<C-v><C-m>', '', 'g')<cr>p
nnoremap "*p :let @"=substitute(system("wl-paste --no-newline --primary"), '<C-v><C-m>', '', 'g')<cr>p
2019-02-06 17:12:59 -08:00
2019-04-03 19:38:20 -07:00
"Auto fix common spelling errors
2019-02-06 17:12:59 -08:00
:ab teh the
:ab Teh The
:ab adn and
:ab Adn And
let mapleader = ','
augroup resCur
autocmd!
autocmd BufReadPost * call setpos(".", getpos("'\""))
augroup END
set title
2021-05-10 11:18:19 -07:00
" Triger `autoread` when files changes on disk
" https://unix.stackexchange.com/questions/149209/refresh-changed-content-of-file-opened-in-vim/383044#383044
" https://vi.stackexchange.com/questions/13692/prevent-focusgained-autocmd-running-in-command-line-editing-mode
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *
\ if mode() !~ '\v(c|r.?|!|t)' && getcmdwintype() == '' | checktime | endif
" Notification after file change
" https://vi.stackexchange.com/questions/13091/autocmd-event-for-autoread
autocmd FileChangedShellPost *
\ echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None
"
2019-04-03 19:38:20 -07:00
"latex settings
" let g:tex_flavor="latex"
" let g:Tex_DefaultTargetFormat =" pdf"
" let g:Tex_IgnoredWarnings =''
2019-02-06 17:12:59 -08:00
" vim-pandoc settings
" let g:pandoc#filetypes#handled = ["pandoc", "markdown"]
" let g:pandoc#filetypes#pandoc_markdown = 0
" let g:pandoc#completion#bib#mode = "citeproc"
" let g:pandoc#modules#disabled = ["folding"]
" vim-pandoc with deoplete autocomplete for nvim
" if !exists('g:deoplete#omni#input_patterns')
" let g:deoplete#omni#input_patterns = {}
" endif
" let g:deoplete#omni#input_patterns.pandoc = ['@']
"
" vim-pandoc with youcompleteme
" if !exists('g:ycm_semantic_triggers')
" let g:ycm_semantic_triggers = {}
" endif
" let g:ycm_semantic_triggers.pandoc = ['@']
" let g:ycm_filetype_blacklist = {}
2019-04-03 19:38:20 -07:00
"make vimtex work with neovim
" let g:vimtex_compiler_progname='nvr'
" let g:vimtex_view_use_temp_files=2
" let g:vimtex_view_method='zathura'
" let g:vimtex_quickfix_mode=0 " do not open the quickfix window automatically
2019-02-06 17:12:59 -08:00
" use <ctrl-x><ctrl-o> with fzf in insert mode to insert project file name
" inoremap <expr> <c-x><c-o> fzf#vim#complete#path('git ls-files $(git rev-parse --show-toplevel)')
" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file)
2019-04-03 19:38:20 -07:00
"Allow commenting and inverting empty lines (useful when commenting a region
2019-02-06 17:12:59 -08:00
let g:NERDCommentEmptyLines = 1
2019-04-03 19:38:20 -07:00
"Add spaces after comment delimiters by default
2019-02-06 17:12:59 -08:00
let g:NERDSpaceDelims = 1
2019-04-03 19:38:20 -07:00
"Use compact syntax for prettified multi-line comments
2019-02-06 17:12:59 -08:00
let g:NERDCompactSexyComs = 1
" set background=dark
if filereadable(expand("~/.vimrc_background"))
let base16colorspace=256
source ~/.vimrc_background
endif
colorscheme base16-gruvbox-dark-hard
2019-04-03 19:38:20 -07:00
"gvim options
" if &t_Co > 2 || has("gui_running")
if has("gui_running")
" Switch on highlighting the last used search pattern.
set hlsearch
" Set font
2021-05-10 11:18:19 -07:00
set gfn=Inconsolata\ 19
2019-04-03 19:38:20 -07:00
" Can toggle gui toolbar with `T` and menu with `m` in guioptions:
" default is go=aegimrLtT
set go=aegLt
":set go+=m or go-=m to toggle menu
2021-05-10 11:18:19 -07:00
colorscheme base16-atelier-dune
2019-04-03 19:38:20 -07:00
autocmd VimEnter * Goyo
2019-12-13 14:00:23 -08:00
autocmd VimEnter * Limelight0.8
2019-04-03 19:38:20 -07:00
"Switch cursor blink rate to 0msec
set guicursor+=a:blinkon0
endif