"LEMON'S VIMRC - 16 NOVEMBER 2014
" Preamble {{{...
set t_Co=256
set background=dark
set path+=**
"}}}
"
" set syntax on
syntax on
" vertical diff please
set diffopt=vertical
" twdft colouring and syntaxing
autocmd BufNewFile,BufRead *.twdft set syntax=markdown
" macro to create and delete a 'check a box'
"nmap 1 0f[lrx
nmap 1 0f rx
nmap 2 0fxr
"
" Remap the leader key {{{...
let mapleader = ","
"...}}}
"
" map ESCAPE to exit to Normal mode in neovim terminal {{{...
tnoremap <Esc> <C-\><C-N>
" ...}}}
"
" Signify mapping & config
nnoremap <leader>R :SignifyRefresh<CR>
let g:signify_realtime = 1
"
" Basic options {{{...
set cmdheight=1
set termguicolors
set inccommand=split
set foldmethod=manual
set encoding=utf-8
set modelines=0
set relativenumber
set autoindent
set showmode
set cursorline
set ttyfast
set ttimeout
set notimeout
set nottimeout
set backspace=indent,eol,start
set ruler
set laststatus=2
set history=1000 " remember more commands and search history
set undolevels=1000 " use many muchos levels of undo
set wildignore=*.swp,*.bak,*.pyc,*.class
set title " change the terminal's title
set visualbell " don't beep
set noerrorbells " don't beep
set number
set fillchars=diff:⣿,vert:\|
set noswapfile
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set vb
"set list
set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮
set lazyredraw
set matchtime=3
set showbreak=↪
set shell=/usr/local/bin/fish
set splitbelow
set splitright
set autowrite
set autoread
set linebreak
set hidden
"set colorcolumn=80
"...}}}
" Wildmenu completion {{{
set wildmenu
" set wildmode=list:longest " don't like this
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.DS_Store " OSX bullshit
set wildignore+=*.luac " Lua byte code
set wildignore+=migrations " Django migrations
set wildignore+=*.pyc " Python byte code
set wildignore+=*.orig " Merge resolution files
" Clojure/Leiningen
set wildignore+=classes
set wildignore+=lib
" }}}
" Make Vim able to edit crontab files ... {{{
set backupskip=/tmp/*,/private/tmp/*"
"...}}}
" Remaps ...{{{
"NERDTree!
nmap \e :NERDTreeToggle<CR>
let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree
" targbar handler
nmap <F8> :TagbarToggle<CR>
" Don't use Ex mode, use Q for formatting
"map Q gq
" easier formatting of paragraphs
" from https://github.com/thesheff17/youtube/blob/master/vim/vimrc
vmap Q gq
nmap Q gqap
" set trailing whitespace to be visible with using special chars with ,s
"set listchars=tab:>-,trail:*,eol:$
"nmap <silent> <leader>s :set nolist!<CR>
" some misc settings
:nmap \l :setlocal number!<CR>
:nmap \o :set paste!<CR>
" map sort function to a key
" from https://github.com/thesheff17/youtube/blob/master/vim/vimrc
vnoremap <Leader>s :sort<CR>
" Plug Plugs...{{{
call plug#begin('~/.config/nvim/plugged')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
"Plug 'lervag/vimtex' " does not work with Latex Box in vim-polyglot
Plug 'google/yapf', { 'rtp': 'plugins/vim', 'for': 'python' }
Plug 'hdima/python-syntax'
Plug 'deoplete-plugins/deoplete-go', {'do': 'make'}
Plug 'junegunn/rainbow_parentheses.vim'
Plug 'rust-lang/rust.vim'
Plug 'reewr/vim-monokai-phoenix'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'zchee/deoplete-jedi'
Plug 'mhinz/vim-signify' " marking changes in repo
Plug 'anekos/hledger-vim'
Plug 'fatih/vim-go', {'do': ':GoUpdateBinaries'}
Plug 'buoto/gotests-vim'
Plug 'bitc/vim-hdevtools'
Plug 'NLKNguyen/papercolor-theme'
Plug 'neovimhaskell/haskell-vim'
Plug 'ledger/vim-ledger'
Plug 'sophacles/vim-bundle-mako'
"Plug 'zchee/deoplete-clang'
Plug 'chriskempson/vim-tomorrow-theme'
Plug 'sbdchd/neoformat'
Plug 'w0rp/ale'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-unimpaired'
"Plug 'rking/ag.vim'
Plug 'tmhedberg/SimpylFold'
Plug 'tpope/vim-surround'
Plug 'plasticboy/vim-markdown'
Plug 'scrooloose/nerdtree'
Plug 'scrooloose/nerdcommenter'
Plug 'dag/vim-fish'
Plug 'majutsushi/tagbar'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'jlanzarotta/bufexplorer'
Plug 'jmcantrell/vim-virtualenv'
Plug 'sukima/xmledit'
Plug 'mileszs/ack.vim'
Plug 'klen/python-mode'
Plug 'Shougo/neosnippet'
Plug 'Shougo/neosnippet-snippets'
Plug 'itchyny/lightline.vim'
Plug 'mhinz/vim-grepper'
Plug 'sickill/vim-pasta'
Plug 'sheerun/vim-polyglot'
Plug 'tommcdo/vim-fubitive'
Plug 'janko-m/vim-test'
Plug 'tpope/vim-dispatch'
Plug 'radenling/vim-dispatch-neovim'
Plug 'sunaku/vim-dasht'
Plug 'Shougo/neoinclude.vim'
Plug 'sebdah/vim-delve'
Plug 'ambv/black'
Plug 'drewtempelmeyer/palenight.vim'
Plug 'bitc/vim-hdevtools'
Plug 'tweekmonster/django-plus.vim'
Plug 'morhetz/gruvbox'
Plug 'junegunn/limelight.vim'
Plug 'nathangrigg/vim-beancount'
Plug 'junegunn/vim-peekaboo'
Plug 'cormacrelf/vim-colors-github'
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
"Plug 'autozimu/LanguageClient-neovim', {
" \ 'branch': 'next',
" \ 'do': 'bash install.sh',
" \ }
call plug#end()
" point neovim to virtualenv specific to neovim (using 3.7)
let g:python3_host_prog = "/home/lemon/.virtualenvs/neovim3.7/bin/python3"
"..{{{ rainbow_parentheses
"activation based on file type
augroup rainbow_lisp
autocmd!
autocmd FileType lisp,clojure,scheme,python RainbowParentheses
augroup END
"..}}}
""..{{{ lightline and coc
"
"function! StatusDiagnostic() abort
" let info = get(b:, 'coc_diagnostic_info', {})
" if empty(info) | return '' | endif
" let msgs = []
" if get(info, 'error', 0)
" call add(msgs, 'E' . info['error'])
" endif
" if get(info, 'warning', 0)
" call add(msgs, 'W' . info['warning'])
" endif
" return join(msgs, ' ') . ' ' . get(g:, 'coc_status', '')
"endfunction
"
"let g:lightline = {
" \ 'colorscheme': 'monokai-phoenix',
" \ 'active': {
" \ 'left': [ [ 'mode', 'paste' ],
" \ [ 'cocstatus', 'readonly', 'filename', 'modified' ] ]
" \},
" \ 'component_function': {
" \ 'cocstatus': 'StatusDiagnostic'
" \ },
" \}
"autocmd User CocStatusChange,CocDiagnosticsChange call lightline#update()
""..}}}
"
"" ..{{{ coc.vim
"let g:coc_node_path = "/usr/bin/nodejs"
"" ..}}}
"
"" Some servers have issues with backup files, see #649
"set nobackup
"set nowritebackup
"
"" Better display for messages
"set cmdheight=2
"
"" You will have bad experience for diagnostic messages when it's default 4000.
"set updatetime=300
"
"" don't give |ins-completion-menu| messages.
"set shortmess+=c
"
"" always show signcolumns
"set signcolumn=yes
"
"" Use tab for trigger completion with characters ahead and navigate.
"" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
"inoremap <silent><expr> <TAB>
" \ pumvisible() ? "\<C-n>" :
" \ <SID>check_back_space() ? "\<TAB>" :
" \ coc#refresh()
"inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
"
"function! s:check_back_space() abort
" let col = col('.') - 1
" return !col || getline('.')[col - 1] =~# '\s'
"endfunction
"
"" Use <c-space> to trigger completion.
"inoremap <silent><expr> <c-space> coc#refresh()
"
"" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
"" Coc only does snippet and additional edit on confirm.
"inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
"
"" Use `[c` and `]c` to navigate diagnostics
"nmap <silent> [c <Plug>(coc-diagnostic-prev)
"nmap <silent> ]c <Plug>(coc-diagnostic-next)
"
"" Remap keys for gotos
"nmap <silent> gd <Plug>(coc-definition)
"nmap <silent> gy <Plug>(coc-type-definition)
"nmap <silent> gi <Plug>(coc-implementation)
"nmap <silent> gr <Plug>(coc-references)
"
"" Use K to show documentation in preview window
"nnoremap <silent> K :call <SID>show_documentation()<CR>
"
"function! s:show_documentation()
" if (index(['vim','help'], &filetype) >= 0)
" execute 'h '.expand('<cword>')
" else
" call CocAction('doHover')
" endif
"endfunction
"
"" Highlight symbol under cursor on CursorHold
"autocmd CursorHold * silent call CocActionAsync('highlight')
"
"" Remap for rename current word
"nmap <leader>rn <Plug>(coc-rename)
"
"" Remap for format selected region
"xmap <leader>f <Plug>(coc-format-selected)
"nmap <leader>f <Plug>(coc-format-selected)
"
"augroup mygroup
" autocmd!
" " Setup formatexpr specified filetype(s).
" autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" " Update signature help on jump placeholder
" autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
"augroup end
"
"" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
"xmap <leader>a <Plug>(coc-codeaction-selected)
"nmap <leader>a <Plug>(coc-codeaction-selected)
"
"" Remap for do codeAction of current line
"nmap <leader>ac <Plug>(coc-codeaction)
"" Fix autofix problem of current line
"nmap <leader>qf <Plug>(coc-fix-current)
"
"" Use <tab> for select selections ranges, needs server support, like: coc-tsserver, coc-python
"nmap <silent> <TAB> <Plug>(coc-range-select)
"xmap <silent> <TAB> <Plug>(coc-range-select)
"xmap <silent> <S-TAB> <Plug>(coc-range-select-backword)
"
"" Use `:Format` to format current buffer
"command! -nargs=0 Format :call CocAction('format')
"
"" Use `:Fold` to fold current buffer
"command! -nargs=? Fold :call CocAction('fold', <f-args>)
"
"" use `:OR` for organize import of current buffer
"command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
"
"
"" Add status line support, for integration with other plugin, checkout `:h coc-status`
""set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
"
"" Using CocList
"" Show all diagnostics
"nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
"" Manage extensions
"nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
"" Show commands
"nnoremap <silent> <space>c :<C-u>CocList commands<cr>
"" Find symbol of current document
"nnoremap <silent> <space>o :<C-u>CocList outline<cr>
"" Search workspace symbols
"nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
"" Do default action for next item.
"nnoremap <silent> <space>j :<C-u>CocNext<CR>
"" Do default action for previous item.
"nnoremap <silent> <space>k :<C-u>CocPrev<CR>
"" Resume latest coc list
"nnoremap <silent> <space>p :<C-u>CocListResume<CR>
"
"
"
" ..{{{ LanguageClient config (base from github
"
" Required for operations modifying multiple buffers like rename.
"set hidden
"let g:LanguageClient_serverCommands = {
" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" \ 'python': ['/usr/local/bin/pyls' '-vv', '--log-file', '~/pyls.log'],
" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
" \ }
" Instuctions for clangd here: https://clang.llvm.org/extra/clangd/Installation.html
"let g:LanguageClient_serverCommands = {
" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
" \ 'python': ['/usr/local/bin/pyls'],
" \ 'cpp': ['clangd'],
" \ 'c': ['clangd'],
" \ }
"let g:LanguageClient_settingsPath = 'ls-settings.json'
" NOT REQUIRED WITH COC
"let g:LanguageClient_useVirtualText = 1
"let g:LanguageClient_diagnosticsEnable = 0
"let g:LanguageClient_settingsPath=expand('~/.local/share/nvim/settings.json')
"
"nnoremap <F5> :call LanguageClient_contextMenu()<CR>
"" Or map each action separately
"nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
"nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
"nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
"nnoremap <silent> <F3> :call LanguageClient#textDocument_typeDefinition()<CR>
"nnoremap <silent> <F4> :call LanguageClient#textDocument_documentSymbol()<CR>
"nnoremap <silent> <F6> :call LanguageClient#textDocument_references()<CR>
"nnoremap <silent> <F7> :call LanguageClient#workspace_symbol()<CR>
"autocmd FileType * call LC_maps()
" ..}}}
" ..{{{ Rust
let g:autofmt_autosave = 1
" ...}}}
" ..{{{ gruvbox config
let g:gruvbox_contrast_dark = "hard"
let g:gruvbox_invert_signs = 1
let g:gruvbox_italic = 1
let g:gruvbox_invert_indent_guides = 1
"let g:gruvbox_italicize_strings = 1
" ...}}}
" vim-hdevtools for Haskell ..{{
au FileType haskell nnoremap <buffer> <F1> :HdevtoolsType<CR>
au FileType haskell nnoremap <buffer> <silent> <F2> :HdevtoolsClear<CR>
" }}
" vim-test config ..{{{
" use vim-dispatch to run tests in the quickfix window
" from Modern Vim Ch.4
" the mappings below are from vim-test
" https://github.com/janko/vim-test
" dispatch opens send test output to quickfix window
"let test#strategy = "dispatch"
" neovim strategy runs the test in the neovim terminal
let test#strategy = "neovim"
let test#neovim#term_position = "topleft"
let test#python#pytest#options = '-vvv --tb=short'
" To run mypy using vim-dispath -with Dispatch
autocmd FileType python let b:dispatch = 'mypy --ignore-missing-imports'
nmap <silent> t<C-n> :TestNearest<CR>
nmap <silent> t<C-f> :TestFile<CR>
nmap <silent> t<C-s> :TestSuite<CR>
"nmap <silent> t<C-l> :TestLast<CR>
nmap <silent> <S-F10> :TestLast<CR>
nmap <silent> t<C-g> :TestVisit<CR>
" }}}
"
"
"
" clang support ... for Debian Stretch only!{{{
"let g:deoplete#sources#clang#libclang_path = '/usr/lib/llvm-3.8/lib/libclang.so.1'
"let g:deoplete#sources#clang#clang_header = '/usr/lib/llvm-3.8/lib/clang/3.8.1/include'
" works on Debian Buster anyway
let g:deoplete#sources#clang#clang_header = '/usr/lib/llvm-6.0/lib/clang/6.0.1/include/'
let g:deoplete#sources#clang#libclang_path = '/usr/lib/llvm-6.0/lib/libclang.so.1'
"}}}
"
" deoplete omnifuc {{{
let g:deoplete#enable_at_startup = 1
let g:deoplete#disable_auto_complete = 0
"call deoplete#custom#option('auto_complete', 0)
"call deoplete#custom#source('jedi', 'debug_enabled', 1)
"call deoplete#enable_logging('DEBUG', '/tmp/deoplete.log')
"inoremap <silent><expr><C-Space> deoplete#mappings#manual_complete()
"}}}
"
" golang stuff {{{
let g:go_term_mode = "split"
let g:go_term_height = 10
"autocmd FileType go nmap <leader>r :w<CR>:split <bar> terminal go run %<CR>
autocmd FileType go nmap <leader>r :GoRun<CR>
" highlights the variable in the file for you..
"let g:go_auto_sameids = 1
" auto import...
let g:go_fmt_command = "goimports"
" automatic type info on cursor
let g:go_auto_type_info = 1
let g:go_snippet_engine = "neosnippet"
au Filetype go nmap <leader>ga <Plug>(go-alternate-edit)
au Filetype go nmap <leader>gah <Plug>(go-alternate-split)
au Filetype go nmap <leader>gav <Plug>(go-alternate-vertical)
au FileType go nmap <F10> :GoTest -short<cr>
" }}}
"
" NEOSNIPPET
" Plugin key-mappings.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
"imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
"END OF NEOSNIPPET
"
" ultisnips... {{{
"inoremap <silent><expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
"let g:UltiSnipsExpandTrigger="<tab>"
"let g:UltiSnipsSnippetsDir = "/home/lemon/dotfiles/Ultisnips"
"let g:UltiSnipsSnippetDirectories=["/home/lemon/dotfiles/Ultisnips"]
"" let g:UltiSnipsJumpForwardTrigger="<c-n>"
"" let g:UltiSnipsJumpBackwardTrigger="<c-p>"
"let g:UltiSnipsJumpForwardTrigger="<c-j>"
"let g:UltiSnipsJumpBackwardTrigger="<c-k>"
" }}}
"
" yapf - format python code (https://github.com/google/yapf)...{{{
map <leader>y :call yapf#YAPF()<cr>
imap <leader>y :call yapf#YAPF()<cr>
"autocmd FileType python nnoremap <leader>yy :0,$!yapf<Cr><C-o>
" ...}}}
"
" isort - sort python imports (https://github.com/timothycrosley/isort) ...{{{
let maplocalleader = "\\"
autocmd FileType python nnoremap <LocalLeader>j :!isort %<CR><CR>
" ...}}}
"
" Tabs, spaces, wrapping ...{{{
set tabstop=4
set shiftwidth=4
set shiftround
set softtabstop=4
set expandtab
set tw=79 " width of document(used by gd)
set nowrap "don't automatically wrap on load
set formatoptions=qrn1j
set fo-=t " don't automatically wrap text when typing
"set colorcolumn=+1
" ...}}}
"
" Enable folding ...{{{
set foldmethod=manual
set foldlevel=99
"...}}}
"
" Pymode stuff ...{{{
let g:pymode = 1
let g:pymode_options_colorcolumn = 0
" Python 3 syntax
let g:pymode_python = 'python3'
let g:pymode_rope = 1
let g:pymode_rope_completion = 0
let g:pymode_rope_complete_on_dot = 0
let g:pymode_rope_organize_imports_bind = '<C-c>ro'
let g:pymode_rope_enable_autoimport = 0
" Set quickfix window
let g:pymode_quickfix_minheight = 3
let g:pymode_quickfix_maxheight = 3
" Sort indentation
let g:pymode_indent = 1
" Documentation
let g:pymode_doc = 0
"let g:pymode_doc_key = 'K'
"Linting
let g:pymode_lint = 0
let g:pymode_lint_checker = "flake8"
" Auto check on save
let g:pymode_lint_write = 0
" Support virtualenv
let g:pymode_virtualenv = 1
let g:pymode_virtualenv_path = $VIRTUAL_ENV
"Enable breakpoints plugin
let g:pymode_breakpoint = 1
let g:pymode_breakpoint_bind = '<leader>b'
let g:pymode_breakpoint_cmd = 'breakpoint()'
"let g:pymode_breakpoint_cmd = 'from pdb import set_trace; set_trace()'
" more debug - this probably does pudb if you have that instead of ipdb
" map <Leader>b Oimport ipdb; ipdb.set_trace() # BREAKPOINT<C-c>
" syntax highlighting
let g:pymode_syntax = 0
let g:pymode_syntax_all = 1
let g:pymode_syntax_indent_errors = g:pymode_syntax_all
let g:pymode_syntax_space_errors = g:pymode_syntax_all
" Don't autofold code
let g:pymode_folding = 0
" Rope rename
let g:pymode_rope_rename_bind = '<C-c>rr'
" Rope extract variable/method
let g:pymode_rope_extract_method_bind = '<C-c>rm'
let g:pymode_rope_extract_variable_bind = '<C-c>rl'
" SimplyFold config
let g:SimpylFold_docstring_preview=1 " docstrings for folded code
let python_highlight_all=1
" ...}}}
"
" Line return (make sure Vim goes where you left it ...{{{
" Make sure Vim returns to the same line when you reopen a file.
augroup line_return
au!
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup END
"}}}
"
"
" Backups ...{{{
set undodir=~/.nvim-tmp/tmp/undo// "undo files
set backupdir=~/.nvim-tmp/tmp/backup// " backups
set directory=~/.nvim-tmp/tmp/swap// " swap files
set backup " enable backups
"}}}
"
" Highlight VCS conflict markers ...{{{
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
"}}}
"
" Searching and movement ...{{{
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set incsearch
set showmatch
set hlsearch
set gdefault
set scrolloff=3
set sidescroll=1
set sidescrolloff=10
set virtualedit+=block
nnoremap <leader><space> :noh<cr>:call clearmatches()<cr>
" search for the word you're looking at
nmap <M-k> :Ack! "\b<cword>\b" <CR>
"nmap <Esc>k :Ack! "\b<cword>\b" <CR>
nmap <M-S-k> :Ggrep! "\b<cword>\b" <CR>
"nmap <Esc>K :Ggrep! "\b<cword>\b" <CR>
nmap \x :cclose<CR>
" Don't move on *
nnoremap * *<c-o>
" Easier to type move extreme left and right
noremap H ^
noremap L g_
" Use ctrl-e and ctrl-a
inoremap <c-a> <esc>I
inoremap <c-e> <esc>A
" open a Quickfix window for the last search
nnoremap <silent> <leader>/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>
"}}}
"
" Ag! ... {{{
nnoremap <leader>a :Ack!<space>
let g:ackprg = 'ag --smart-case --nogroup --nocolor --column'
" }}}
"
" Folding ... {{{
" Enable folding with the spacebar
nnoremap <space> za
nnoremap <leader>fm :set foldmethod=manual<CR>
" Make zO recursively open whatever fold we're in, even if it's partially open.
nnoremap zO zczO
" Use ,z to "focus" the current fold
nnoremap <leader>z zMzvzz
" }}}
"
"" Quick Editing ...{{{
nnoremap <leader>ev <C-w>s<C-w>j<C-w>L:e $MYVIMRC<cr>
" }}}
"
" Convenience mappings ... {{{
" No more help key.
noremap <F1> :checktime<cr>
inoremap <F1> <esc>:checktime<cr>
" Kill window
"nnoremap <leader>K :q<cr>
" Wrap
nnoremap <leader>W :set wrap!<cr>
" Change case
noremap <C-u> gUiw
inoremap <C-u> <esc> gUiwea
" Substitute
nnoremap <leader>su :%s//<left>
nnoremap <Leader>s :%s/<C-r><C-w>//g<Left><Left>
"
" Emacs bindings in command line mode
cnoremap <c-a> <home>
cnoremap <c-e> <end>
" Turn off vimdiff
nnoremap <leader>D :diffoff!<cr>
" Formatting, like Textmate
nnoremap Q gqip
" Easier linewise reselection
nnoremap <leader>V V`]
" Split line (colleague of Join lines)
nnoremap S i<cr><esc><right>
" Source the current line
vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
" Select (charwise) the contents of the current line, excluding indentation.
" Great for pasting Python lines into REPLs.
nnoremap vv ^vg_
" }}}
"
" Ack motions ... {{{
" Motions to Ack for things. Works with pretty much everything, including:
"
" w, W, e, E, b, B, t*, f*, i*, a*, and custom text objects
"
" Awesome.
"
" Note: If the text covered by a motion contains a newline it won't work. Ack
" searches line-by-line.
nnoremap <silent> <leader>B :set opfunc=<SID>AckMotion<CR>g@
xnoremap <silent> <leader>B :<C-U>call <SID>AckMotion(visualmode())<CR>
"nnoremap <bs> :Ack! '\b<c-r><c-w>\b'<cr>
xnoremap <silent> <bs> :<C-U>call <SID>AckMotion(visualmode())<CR>
function! s:CopyMotionForType(type)
if a:type ==# 'v'
silent execute "normal! `<" . a:type . "`>y"
elseif a:type ==# 'char'
silent execute "normal! `[v`]y"
endif
endfunction
function! s:AckMotion(type) abort
let reg_save = @@
call s:CopyMotionForType(a:type)
execute "normal! :Ack! --literal " . shellescape(@@) . "\<cr>"
let @@ = reg_save
endfunction
" }}}
"
" Mutt ... {{{
augroup ft_muttrc
au!
au BufRead,BufNewFile *.muttrc set ft=muttrc
au FileType muttrc setlocal foldmethod=marker foldmarker={{{,}}}
augroup END
" }}}
"
" perldoc ... {{{
let g:perldoc_split_modifier = '10v'
"}}}
"
" vim-fugitive ... {{{
" prevent buffer build-up
autocmd BufReadPost fugitive://* set bufhidden=delete
"}}}
"
" ALE statusline ...{{{
"set statusline+=%{ALEGetStatusLine()}
"let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '• ok']
"let g:ale_linters = {'python': ['flake8'],}
"...}}}
"
" ale setting..{{{
"let g:ale_lint_on_text_changed = 'never'
" black config ...{{{
"let g:black_virtualenv = "/home/lemon/.virtualenvs/black-for-vim/"
"nmap <leader>l :Black<CR>
" LET'S RUN VIRTUALENV BLACK ON SAVE!
"autocmd BufWritePre *.py execute ':Black'
"let g:black_virtualenv = $VIRTUAL_ENV
" }}}
let g:ale_enabled = 1
let g:ale_sign_column_always = 1
let g:ale_open_list = 0
let g:ale_set_highlights = 1
let g:ale_set_signs = 1
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%linter% - %code: %%s'
let g:ale_loclist_msg_format = '%linter% - %code: %%s'
let g:ale_echo_msg_warning_str = 'Warning'
"let g:ale_linters = {'python': ['flake8', 'mypy', 'pyls', 'pylint'],
"\ 'ocaml': ['merlin'],
" \}
let g:ale_linters = {'python': ['flake8', 'mypy'],
\ 'ocaml': ['merlin'],
\ 'cpp': ['clang'],
\ 'go': ['gometalinter', 'gofmt'],
\}
"let g:ale_linters_ignore = {'python': ['pyls']}
let g:ale_fixers = {'python': ['isort']} " we want to run black manually
let g:ale_python_mypy_ignore_invalid_syntax = 1
let g:ale_python_mypy_executable = 'mypy'
let g:ale_python_mypy_options = '--config-file mypy.ini'
" let g:ale_sign_error = '>>'
let g:ale_sign_warning = '--'
let g:ale_fix_on_save = 1
let g:ale_linters_explicit = 0
" Mappings in the style of unimpaired-next
nmap [W <Plug>(ale_first)
nmap [w <Plug>(ale_previous)
nmap ]w <Plug>(ale_next)
nmap ]W <Plug>(ale_last)
" }}}
"
" More Haskell stuff - May 2017 ...{{{
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
let g:haskell_backpack = 1 " to enable highlighting of backpack keywords}
let g:haskell_indent_if = 3
let g:haskell_indent_case = 2
let g:haskell_indent_let = 4
let g:haskell_indent_where = 6
let g:haskell_indent_before_where = 2
let g:haskell_indent_after_bare_where = 2
let g:haskell_indent_do = 3
let g:haskell_indent_in = 1
let g:haskell_indent_guard = 2
"}}}
"
" Bufexplorer config ... {{{
let g:bufExplorerDefaultHelp=1 " Show default help.
let g:bufExplorerShowNoName=1 " Show "No Name" buffers.
let g:bufExplorerShowUnlisted=1 " Show unlisted buffers.
"}}}
"
" Django ... {{{
augroup ft_django
au!
au BufNewFile,BufRead urls.py setlocal nowrap
au BufNewFile,BufRead urls.py normal! zR
au BufNewFile,BufRead dashboard.py normal! zR
au BufNewFile,BufRead local_settings.py normal! zR
au BufNewFile,BufRead admin.py setlocal filetype=python.django
au BufNewFile,BufRead urls.py setlocal filetype=python.django
au BufNewFile,BufRead models.py setlocal filetype=python.django
au BufNewFile,BufRead views.py setlocal filetype=python.django
au BufNewFile,BufRead settings.py setlocal filetype=python.django
au BufNewFile,BufRead settings.py setlocal foldmethod=marker
au BufNewFile,BufRead forms.py setlocal filetype=python.django
au BufNewFile,BufRead common_settings.py setlocal filetype=python.django
au BufNewFile,BufRead common_settings.py setlocal foldmethod=marker
augroup END
" vim-markdown ...{{{
let g:vim_markdown_folding_disabled=1
set foldenable
let g:vim_markdown_initial_foldlevel=1
let g:vim_markdown_no_default_key_mappings=1
let g:vim_markdown_math=1
let g:vim_markdown_frontmatter=1
"}}}
"
" get rid of annoying Press ENTER prompts etc ...{{{
"set shortmess=atI
"}}}
"
" Remap movement in windows ...{{{
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
"}}}
"
nnoremap <Leader>c :set cursorline!<CR>
":nnoremap <Leader>c :set cursorline! cursorcolumn!<CR>
"}}}
"
" General python properness ...{{{
autocmd FileType python set sw=4
autocmd FileType python set ts=4
autocmd FileType python set sts=4
"}}}
"
" Escape sudo heck ...{{{
cmap w!! %!sudo tee > /dev/null %
"}}}
"
" Colorscheme ...{{{
"let g:github_colors_soft = "1
" from https://github.com/thesheff17/youtube/blob/master/vim/vimrc
"color wombat256mod
"color Tomorrow-Night-Bright
"color monokai-phoenix
"colorscheme github
"colorscheme gruvbox
"color afterglow
colorscheme PaperColor
"
" if we are using default colorscheme, you want to switch off horrid
" grey gutter colour
highlight clear SignColumn
"
" Cursor and column highlighting ...{{{
" hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=#4b5260 guifg=white
" use guibg and guifg because I have set termguicolors switched on in this file
" The pythonSelf is a pymode thing...
"hi pythonSelf ctermfg=68 guifg=#5f87d7 cterm=bold gui=bold
"hi pythonSelf ctermfg=16 guifg=#5f87d7 cterm=bold gui=bold
"hi pythonNumber ctermfg=16 guifg=#aa4aef cterm=bold gui=bold
"hi pythonFloat ctermfg=16 guifg=#aa4aef cterm=bold gui=bold
"hi pythonHexNumber ctermfg=16 guifg=#aa4aef cterm=bold gui=bold
"
" my todo.todo... {{
autocmd BufNewFile,BufRead *.todo set syntax=markdown
"autocmd BufWritePost *.todo !todo-push
nmap <F2> a<C-R>=strftime("%c")<CR><Esc>
"let @d=':r! date _kb-I
ikb ($a)0"+dd:!xlcipkbkbkbkbclip -o >> /home/lemon/todo/done.todo
'
let @d='0$a(k2a)0"+dd:!xlcipkbkbkbkbclip -o >> /home/lemon/todo/done.todo
'
" ...}}
" Grepper ...{{{
nmap gs <plug>(GrepperOperator)
xmap gs <plug>(GrepperOperator)
" ...}}}
"
" FZF ...{{{
" This is the default extra key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~40%' }
" Customize fzf colors to match your color scheme
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
" {{{ More fzf settings
" (https://github.com/zenbro/dotfiles/blob/master/.nvimrc#L151-L187)
let g:fzf_nvim_statusline = 0 " disable statusline overwriting
nnoremap <C-p> :<C-u>FZF<CR>
nnoremap <leader><C-p> :<C-u>FZF!<CR>
nnoremap ; :Buffers<CR>
nnoremap <leader>t :Files<CR>
nnoremap <leader>o :Tags<CR>
nnoremap <leader>h :History<CR>
nnoremap <silent> <leader>0 :Files<CR>
nnoremap <silent> <leader>A :Windows<CR>
nnoremap <silent> <leader>; :BLines<CR>
nnoremap <silent> <leader>l :Lines<CR>
" nnoremap <silent> <leader># :Lines<CR>
nnoremap <silent> <leader>o :BTags<CR>
" command history is :History:
nnoremap <silent> <leader>? :History:<CR>
nnoremap <silent> <leader>/ :execute 'Ag ' . input('Ag/')<CR>
" nnoremap <silent> <leader>. :AgIn #
" nnoremap <silent> <leader>a :Buffers<CR>
" nnoremap <silent> <leader>O :Tags<CR>
nnoremap <silent> <leader>P :call SearchWordWithAg()<CR>
vnoremap <silent> <leader>P :call SearchVisualSelectionWithAg()<CR>
" nnoremap <silent> <leader>gl :Commits<CR>
" nnoremap <silent> <leader>ga :BCommits<CR>
nnoremap <silent> <leader>ft :Filetypes<CR>
imap <C-x><C-f> <plug>(fzf-complete-file-ag)
imap <C-x><C-l> <plug>(fzf-complete-line)
function! SearchWordWithAg()
execute 'Ag' expand('<cword>')
endfunction
function! SearchVisualSelectionWithAg() range
let old_reg = getreg('"')
let old_regtype = getregtype('"')
let old_clipboard = &clipboard
set clipboard&
normal! ""gvy
let selection = getreg('"')
call setreg('"', old_reg, old_regtype)
let &clipboard = old_clipboard
execute 'Ag' selection
endfunction
" function! SearchWithAgInDirectory(...)
" call fzf#vim#ag(join(a:000[1:], ' '), extend({'dir': a:1}, g:fzf#vim#default_layout))
" endfunction
" command! -nargs=+ -complete=dir AgIn call SearchWithAgInDirectory(<f-args>)
" }}}
" Enable per-command history.
" CTRL-N and CTRL-P will be automatically bound to next-history and
" previous-history instead of down and up. If you don't like the change,
" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS.
let g:fzf_history_dir = '~/.local/share/fzf-history'
"
" Mapping selecting mappings
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
" 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-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
" Advanced customization using autoload functions
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'left': '15%'}
" ...}}}
"
" Ocaml/merlin
"let g:opamshare = substitute(system('opam config var share'),'\n$','','''')
"execute "set rtp+=" . g:opamshare . "/merlin/vim"
"set rtp^="/home/lemon/.opam/4.06.1/share/ocp-indent/vim"
"
" Search from git root via :Rag (Root Ag)
" Thanks! https://github.com/fortes/dotfiles/blob/7ba6ea651edde8fbc24fdf9df52ba06f7e956efc/stowed-files/nvim/.vimrc
" :Rag - hidden preview enabled with "?" key
" :Rag! - fullscreen and preview window above
" Change to git root of current file (if in a repo)
function! FindGitRootCD()
let root = systemlist('git -C ' . expand('%:p:h') . ' rev-parse --show-toplevel')[0]
if v:shell_error
return ''
else
return {'dir': root}
endif
endfunction
function! GitRootCD()
let result = FindGitRootCD()
if type(result) == type({})
execute 'lcd' fnameescape(result['dir'])
echo 'Now in '.result['dir']
else
echo 'Not in git repo!'
endif
endfunction
command! GitRootCD :call GitRootCD()
command! -bang -nargs=* Rag
\ call GitRootCD() | call fzf#vim#ag(<q-args>,
\ <bang>0 ? fzf#vim#with_preview('up:60%', '?')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
" Use fuzzy searching for K & Q, select items to go into quickfix
nnoremap L :Rag! <C-R><C-W><cr>
vnoremap L :<C-u>norm! gv"sy<cr>:silent! Rag! <C-R>s<cr>
nnoremap Q :Rag!<SPACE>
"highlight ColorColumn ctermbg=0
highlight NonText cterm=NONE