Marty Oehme
6298daeca2
Can be set through environment variable WIKIROOT. By default points to ~/Nextcloud/Notes/ but is kept configurable for each computer. Will be picked up by vim wiki plugin to enable wiki functionality for the respective directory.
402 lines
14 KiB
VimL
402 lines
14 KiB
VimL
" vim: set foldmethod=marker foldlevel=0 nomodeline:
|
|
" ================================================================================
|
|
" .init.vim / .vimrc of Marty Oehme {{{
|
|
" ================================================================================
|
|
"
|
|
" - stolen from many different sources including
|
|
" Steve Losh
|
|
" Junegunn Choi
|
|
" Tim Pope
|
|
|
|
" this config does not set nocompatible - neovim does this automatically
|
|
" this config does not set filetype plugin - vim-sensible does this
|
|
" }}}
|
|
" PLUGIN INSTALLATION - handled by VIM-PLUG {{{
|
|
" ================================================================================
|
|
"
|
|
" automatically install vim-plug if it does not exist
|
|
" Note: this installs it in the neovim folder, not the vim folder
|
|
if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
|
|
silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs
|
|
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
|
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC | q
|
|
endif
|
|
|
|
" automatically install any missing plugins
|
|
autocmd VimEnter *
|
|
\ if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
|
|
\| PlugInstall --sync | q
|
|
\| endif
|
|
|
|
" defines plugin directory
|
|
" Install plugins from vim with :PlugInstall
|
|
silent! if plug#begin('~/.local/share/nvim/plugged')
|
|
|
|
" Base
|
|
" a minimal definition of variables TODO still necessary for nvim?
|
|
Plug 'tpope/vim-sensible'
|
|
" add seamless movement between vim and tmux, switch windows with C-hjkl
|
|
Plug 'christoomey/vim-tmux-navigator'
|
|
" automatically switch between relative and absolute numbers as buffers move
|
|
" into / out of focus (requires number & relativenumber to be set)
|
|
Plug 'jeffkreeftmeijer/vim-numbertoggle'
|
|
|
|
" " Workflow
|
|
Plug 'tpope/vim-commentary' " easily toggle comments for lines, paragraphs etc with gc
|
|
Plug 'tommcdo/vim-exchange' " adds exchange operator with cx. common use: cxiw . on 2 words to switch
|
|
Plug 'tpope/vim-surround' " lets you change surrounding things with cs (or ds to del, ys to add)
|
|
|
|
Plug 'kana/vim-textobj-user' " dependency for most other textobj plugins
|
|
Plug 'reedes/vim-textobj-sentence' " extends the capabilities of sentence detection
|
|
" and allows you to jump to the *end* of this <g)> or last <g(> sentence.
|
|
|
|
|
|
" " Ecosystem
|
|
" " Plug 'tpope/vim-fugitive' - Will have to take a closer look some other time
|
|
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } " show a directory listing within vim
|
|
Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' } " show git status in nerdtree for files and dirs
|
|
Plug 'Yggdroot/LeaderF', { 'on': ['Leaderf', 'LeaderfFile', 'LeaderfBuffer'], 'do': './install.sh' } " fuzzy matcher, apparently faster than fzf, ctrlp, unit, denite
|
|
Plug 'dyng/ctrlsf.vim'
|
|
|
|
" Language Integration
|
|
Plug 'sheerun/vim-polyglot' " syntax plugins for almost every language
|
|
Plug 'stephpy/vim-yaml'
|
|
Plug 'mhartington/nvim-typescript', {'for': 'typescript','do': './install.sh'}
|
|
|
|
" HTML Workflow
|
|
Plug 'valloric/matchtagalways', { 'on': [] }
|
|
Plug 'alvan/vim-closetag', { 'on': [] }
|
|
Plug 'jiangmiao/auto-pairs', { 'on': [] } " Auto close brackets and ''
|
|
augroup load_html_utils
|
|
autocmd!
|
|
autocmd InsertEnter * call plug#load('matchtagalways', 'vim-closetag', 'auto-pairs')
|
|
\| autocmd! load_html_utils
|
|
augroup END
|
|
|
|
" Markdown & Prose Workflow
|
|
Plug 'reedes/vim-pencil', { 'for': ['markdown', 'txt'], 'on': 'Goyo' } " provide md convenience functions like hard/softwrap
|
|
Plug 'junegunn/goyo.vim', { 'for': ['markdown', 'txt'], 'on': 'Goyo' } " provide distraction free writing
|
|
Plug 'junegunn/limelight.vim', { 'for': ['markdown', 'txt'], 'on': 'Goyo' } " provide even distraction free-er writing (lowlight paragraphs)
|
|
Plug 'rhysd/vim-grammarous', { 'for': ['markdown', 'txt'], 'on': 'Goyo' } " integrate vim with languagetool for grammar checking (needs java8)
|
|
|
|
" Note-Taking Workflow
|
|
Plug 'lervag/wiki.vim'
|
|
|
|
" For async completion
|
|
Plug 'Shougo/deoplete.nvim', { 'on': [] } " automatic suggestions, can also perhaps be changed for newer plugs
|
|
Plug 'w0rp/ale', { 'on': [] } " asynchronous linting - might be superseded by lsp or coc.nvim at some point
|
|
" lazy loading since they require a lot of startup time
|
|
augroup load_ide_features
|
|
autocmd!
|
|
autocmd InsertEnter * call plug#load('ale', 'deoplete.nvim')
|
|
\| autocmd! load_ide_features
|
|
autocmd InsertEnter * call deoplete#enable()
|
|
augroup END
|
|
|
|
" Design
|
|
Plug 'vim-airline/vim-airline'
|
|
Plug 'vim-airline/vim-airline-themes'
|
|
Plug 'edkolev/tmuxline.vim'
|
|
|
|
" Colorschemes
|
|
Plug 'Nequo/vim-allomancer'
|
|
Plug 'morhetz/gruvbox'
|
|
Plug 'nightsense/snow'
|
|
|
|
call plug#end()
|
|
endif
|
|
|
|
" }}}
|
|
" PLUGIN CONFIGURATION {{{
|
|
" ================================================================================
|
|
|
|
" PLUGIN: NERDTree
|
|
" highlight the line the cursor is on
|
|
let NERDTreeHighlightCursorline = 1
|
|
|
|
" remove Press ? for help
|
|
let NERDTreeMinimalUI=1
|
|
|
|
" loads nerdtree plugin when starting vim with a directory
|
|
" this is necessary when we lazyload nerdtree with vimplug above
|
|
" since it would only get loaded with nttoggle otherwise, and run netrw
|
|
augroup nerd_loader
|
|
autocmd!
|
|
autocmd VimEnter * silent! autocmd! FileExplorer
|
|
autocmd BufEnter,BufNew *
|
|
\ if isdirectory(expand('<amatch>'))
|
|
\| call plug#load('nerdtree')
|
|
\| execute 'autocmd! nerd_loader'
|
|
\| endif
|
|
augroup END
|
|
|
|
" PLUGIN: markdown-group
|
|
" unify markdown extensions to all use markdown filetype
|
|
au! BufRead,BufNewFile *.markdown set filetype=markdown
|
|
au! BufRead,BufNewFile *.md set filetype=markdown
|
|
au! BufRead,BufNewFile *.mkd set filetype=markdown
|
|
" automatically enables markdown plugins for md & txt files
|
|
function! Prose()
|
|
call pencil#init()
|
|
" PLUGIN: vim-textobj-sentence
|
|
" enable extended sentence textobject use on md and plaintext files
|
|
call textobj#sentence#init()
|
|
" hide the markdown cruft
|
|
set conceallevel=3
|
|
endfunction
|
|
" enable syntax highlighting for codeblocks WITHIN markdown
|
|
let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'javascipt', 'go']
|
|
|
|
" call the prose function defined above for any md files
|
|
autocmd FileType markdown,txt call Prose()
|
|
" or invoke it manually by writing :Prose
|
|
command! -nargs=0 Prose call Prose()
|
|
|
|
" PLUGIN: wiki.vim
|
|
if $WIKIROOT ==? ""
|
|
let g:wiki_root = '~/Nextcloud/Notes/'
|
|
else
|
|
let g:wiki_root = $WIKIROOT
|
|
endif
|
|
" filetypes to automatically enable the plugin for, seems to take file endings
|
|
" rather than vim ft
|
|
let g:wiki_filetypes = ['md', 'mkd', 'markdown', 'wiki']
|
|
let g:wiki_link_extension = '.md'
|
|
let g:wiki_link_target_type = 'md'
|
|
|
|
" PLUGIN: vim-pencil
|
|
" set default wrap mode to hard - TODO test which mode works better for
|
|
" me, it seems hardmode has trouble with markdown lists (see issue #31)
|
|
let g:pencil#wrapModeDefault = 'soft' " default is 'hard'
|
|
|
|
" PLUGIN: goyo
|
|
" set up functions for entering/exiting distraction free mode, or leaving it
|
|
function! s:goyo_enter()
|
|
" remove the tmux status bar for actual distraction free environment
|
|
silent !tmux set status off
|
|
" maximize the tmux pane that vim is in if any (usually I have vim open as the only pane)
|
|
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
|
|
" disable line highlighting, we really don't need it for prose
|
|
set nocursorline
|
|
" enable limelight which highlights whatever paragraph you are in and lowlights the rest
|
|
Limelight
|
|
endfunction
|
|
function! s:goyo_leave()
|
|
silent !tmux set status on
|
|
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
|
|
set cursorline
|
|
Limelight!
|
|
endfunction
|
|
" actually call the functions on entering/leaving goyo
|
|
autocmd! User GoyoEnter nested call <SID>goyo_enter()
|
|
autocmd! User GoyoLeave nested call <SID>goyo_leave()
|
|
|
|
" PLUGIN: DEOPLETE
|
|
" enable deoplete at startup
|
|
let g:deoplete#enable_at_startup = 0
|
|
let g:deoplete#enable_ignore_case = 1
|
|
let g:deoplete#enable_smart_case = 1
|
|
let g:deoplete#enable_camel_case = 1
|
|
let g:deoplete#enable_refresh_always = 1
|
|
let g:deoplete#max_abbr_width = 0
|
|
let g:deoplete#max_menu_width = 0
|
|
let g:deoplete#omni#input_patterns = get(g:,'deoplete#omni#input_patterns',{})
|
|
|
|
" PLUGIN: ALE
|
|
let g:ale_fix_on_save = 1
|
|
let g:ale_fixers = {
|
|
\'javascipt': ['eslint', 'prettier'],
|
|
\'html': ['tidy','prettier'],
|
|
\'typescript': ['prettier','tslint'],
|
|
\'*': ['remove_trailing_lines', 'trim_whitespace'],
|
|
\}
|
|
|
|
" PLUGIN: AIRLINE
|
|
" PLUGIN: TMUXLINE
|
|
let g:airline_powerline_fonts=1
|
|
let g:airline_theme='raven'
|
|
colorscheme gruvbox
|
|
|
|
" disable automatically refreshing the mux statusbar since it breaks tmux
|
|
" prefix highlighting. Instead, when changing vim statusbar just create
|
|
" snapshot with :TmuxlineSnapshot file and stick it into tmux config manually
|
|
let g:airline#extensions#tmuxline#enabled = 0
|
|
" custom preset with left-justified window list
|
|
let g:tmuxline_preset = {
|
|
\'a' : '#S',
|
|
\'b' : '#(whoami)',
|
|
\'c' : '#I:#P',
|
|
\'win' : '#I #W',
|
|
\'cwin' : [' ', '#I #W'],
|
|
\'x' : '#{prefix_highlight} %H:%M:%S',
|
|
\'y' : '%d-%b-%y',
|
|
\'z' : '#H',
|
|
\'options' : {}}
|
|
|
|
" automatically save the current buffer when navigating away from vim
|
|
let g:tmux_navigator_save_on_switch = 1
|
|
|
|
" }}}
|
|
" VIM SETTINGS {{{
|
|
" ================================================================================
|
|
"
|
|
" set truecolor (neovim)
|
|
set termguicolors
|
|
|
|
" sets tabs to be 2 characters, expanded into spaces, but still removable with
|
|
" one press of backspace.
|
|
" great explanation: http://vimcasts.org/transcripts/2/en/
|
|
set tabstop=2
|
|
set shiftwidth=2
|
|
set softtabstop=2
|
|
set expandtab
|
|
|
|
" set cursor line highlighting, esp useful when using with bracket
|
|
" highlighting and you don't know which side of the brace the cursor is on
|
|
set cursorline
|
|
|
|
" shows linenumbers relative to the one you are on, for easy movement and
|
|
" dNUMBERd deletions
|
|
set number relativenumber
|
|
|
|
" keeps an undofile next to files so that you can even undo if vim is closed
|
|
" in between
|
|
set undofile
|
|
|
|
" ignores case by default but will use case when search is specifically not
|
|
" all lowercased
|
|
set ignorecase
|
|
set smartcase
|
|
|
|
" whenever vim loses focus, save
|
|
au FocusLost * :wa
|
|
|
|
" disables showing us the current mode in the command line since airline takes
|
|
" care of it
|
|
set noshowmode
|
|
|
|
" highlight everything that goes over 80 columns
|
|
highlight ColorColumn ctermbg=magenta
|
|
call matchadd('ColorColumn', '\%81v', 100)
|
|
|
|
" }}}
|
|
" KEYBINDINGS {{{
|
|
" ================================================================================
|
|
"
|
|
" set our leader key to space since with hjkl, space is largely useless
|
|
let mapleader = "\<Space>"
|
|
" maps the leader for buffer local mappings (e.g. vim-waikiki for files under
|
|
" the root dir to the same key -- might lead to incompatibilities, will have
|
|
" to test)
|
|
let maplocalleader = "\<Space>"
|
|
" set jk to escape, in case capslock is not mapped to escape on the system
|
|
inoremap jk <ESC>
|
|
|
|
" remove search highlights by pressing space+/ - the key for searching the
|
|
" first place
|
|
nnoremap <leader>/ :noh<cr>
|
|
|
|
" split buffers vertically/horizontally with the leader \ or - (mirrors my
|
|
" tmux setup)
|
|
nnoremap <leader>- :sp<cr>
|
|
nnoremap <leader>\ :vsp<cr>
|
|
|
|
" move around between matching brackets with tab
|
|
nnoremap <tab> %
|
|
nnoremap <tab> %
|
|
|
|
" select the whole buffer with <leader>-a
|
|
nnoremap <leader>a ggVG
|
|
|
|
" quickly edit vimrc with leader+V
|
|
nnoremap <leader>V :vsp $MYVIMRC<cr>
|
|
" automatically source the vimrc file whenever it is saved (causes slowdown
|
|
" when done in MANY successions)
|
|
" au BufWritePost init.vim so ~/.config/nvim/init.vim
|
|
" source vimrc with keystroke combination
|
|
nnoremap <leader>VV :source $MYVIMRC<cr>
|
|
|
|
" since u undoes, would it not make sense that U redoes?
|
|
nnoremap U <C-r>
|
|
|
|
" when in insertion mode, C-u uppercases the current word, C-l lowercases it,
|
|
inoremap <C-u> <esc>gUiw`]a
|
|
inoremap <C-l> <esc>guiw`]a
|
|
|
|
" get rid of the help message popping up when I miss esc and hit F1
|
|
nnoremap <F1> <ESC>
|
|
inoremap <F1> <ESC>
|
|
vnoremap <F1> <ESC>
|
|
|
|
" remove all trailing whitespaces
|
|
" on pressing space+W
|
|
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
|
|
" automatically on saving
|
|
" autocmd BufWritePre * :%s/\s\+$//e
|
|
|
|
" 'open new buffer' with leader-t (opens new buffer and switches to it)
|
|
" open actual new tab with leader-T
|
|
nnoremap <leader>t :vsp .<cr>
|
|
nnoremap <leader>T :tabedit .<cr>
|
|
|
|
" open/close NERDtree with leader-e
|
|
" whatever method tree has been opened by, leader-e closes it again
|
|
nnoremap <leader>e :NERDTreeToggle<CR>
|
|
" open root of current VCS project in tree
|
|
nnoremap <leader><C-e> :NERDTreeVCS<CR>
|
|
" open current nerdtree with current file highlighted
|
|
nnoremap <leader>E :NERDTreeFind<CR>
|
|
|
|
" Call leaderf with <leader-f> (necessary to enable leaderf lazyloading)
|
|
nnoremap <leader>f :LeaderfFile<cr>
|
|
nnoremap <leader>F :LeaderfBuffer<cr>
|
|
|
|
function! SearchWiki()
|
|
let l:curpath=getcwd()
|
|
:execute(":cd " . g:wiki_root)
|
|
let l:texttofind=input("Search in Notes: ")
|
|
:execute(":CtrlSF " . l:texttofind)
|
|
:CtrlSFFocus
|
|
:execute(":cd " . l:curpath)
|
|
endfunction
|
|
|
|
" search in wiki with ctrlsf
|
|
nnoremap <leader>wf :execute(":call SearchWiki()")<cr>
|
|
nnoremap <C-F> <Plug>CtrlSFPrompt
|
|
vnoremap <C-F> <Plug>CtrlSFVwordPath
|
|
|
|
" Mostly dealing with Prose writing from here on out
|
|
" Format current Paragraph (esp useful in prose writing)
|
|
nnoremap <silent> <leader>q gqap
|
|
xnoremap <silent> <leader>q gq
|
|
nnoremap <silent> <leader>Q vapJgqap
|
|
|
|
" Enter distraction free prose mode with F11
|
|
noremap <F11> :Goyo<CR>
|
|
|
|
" surround stuff with quotes, from normal or visual mode
|
|
nnoremap <leader>" viw<esc>a"<esc>bi"<esc>lel
|
|
vnoremap <leader>" <esc>`<i"<esc>`>la"<esc>l
|
|
|
|
" stronger versions of left,right - move all the way
|
|
nnoremap H ^
|
|
nnoremap L $
|
|
|
|
" }}}
|
|
" ABBREVIATIONS {{{
|
|
|
|
" Typos
|
|
iabbrev adn and
|
|
iabbrev waht what
|
|
iabbrev tehn then
|
|
iabbrev whit with
|
|
iabbrev whith with
|
|
|
|
" Text expansion
|
|
iabbrev @@ marty.oehme@gmail.com
|
|
iabbrev ccopy Copyright 2019 Marty Oehme, all rights reserved.
|
|
|
|
"
|
|
" }}}
|
|
" END
|
|
" ================================================================================
|