Magically rebuild Vim spell files if word lists are modified outside of Vim. One use case would be if word lists are stored in a source control system like Git and shared across multiple computers\. SpellSync also creates `.gitignore` and `.gitattributes` files in Vim's spell directories to exclude binary spell files and uses its union merge driver to avoid conflicts. [link]](https://github.com/micarmst/vim-spellsync)
352 lines
14 KiB
VimL
352 lines
14 KiB
VimL
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> .vimrc
|
|
|
|
set nocompatible " be iMproved, required
|
|
set number " turn on line numbers
|
|
set relativenumber " lines are numbered relative to current line
|
|
set scrolloff=10 " number of lines to keep above and below the cursor
|
|
set belloff=all " no sound/flash on errors
|
|
|
|
set autoread " set to auto read when a file is changed from the outside
|
|
set cursorcolumn " highlight current column
|
|
set cursorline " highlight current row
|
|
set incsearch " make search act like search in modern browsers
|
|
set showmatch " show matching brackets when text indicator is over them
|
|
|
|
set term=xterm-256color " LOTS of colors
|
|
set path+=** " Search Globally
|
|
set wildmenu
|
|
|
|
autocmd! bufwritepost .vimrc source ~/.vimrc " When vimrc is edited, reload it
|
|
|
|
" Turn line numbers on/off for active/inactive buffers
|
|
augroup BgHighlight
|
|
autocmd!
|
|
autocmd WinEnter * set number
|
|
autocmd WinEnter * set relativenumber
|
|
autocmd WinLeave * set nonumber
|
|
autocmd WinLeave * set norelativenumber
|
|
augroup end
|
|
|
|
syntax enable
|
|
filetype plugin on
|
|
|
|
" Native Markdown syntax highlighting for specified languages
|
|
let g:markdown_fenced_languages = ['html', 'python', 'sh', 'vim', 'yaml']
|
|
|
|
" Open my personal helpfile
|
|
nmap <leader>h :e $HOME/.vim/vim-keys-help.md<CR>
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> From Vim Zero: https://www.oliversherouse.com/2017/08/21/vim_zero.html
|
|
|
|
" General
|
|
let mapleader = '\'
|
|
set hidden " Allow background buffers without saving
|
|
set splitright " Split to right by default
|
|
set formatoptions-=ro " Turn off autoinsert of comment char on newline
|
|
|
|
" Text Wrapping
|
|
set textwidth=120 " Set textwidth
|
|
set colorcolumn= " disable colorzing <textwidth> column
|
|
set nowrap " turn off word wrapping at <textwidth>
|
|
|
|
" Search and Substitute
|
|
set gdefault " use global flag by default in s: commands
|
|
set hlsearch " highlight searches
|
|
set ignorecase " ignore case in searches
|
|
set smartcase " don't ignore capitals in searches
|
|
|
|
" Tabs
|
|
set tabstop=4
|
|
set softtabstop=4
|
|
set shiftwidth=4
|
|
set expandtab
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> Plugins with VimPlug
|
|
" A minimalist Vim plugin manager
|
|
" https://github.com/junegunn/vim-plug
|
|
|
|
if has("win32")
|
|
call plug#begin('~/vimfiles/plugged')
|
|
else
|
|
call plug#begin('~/.vim/plugged')
|
|
endif
|
|
|
|
" Think of sensible.vim as one step above 'nocompatible' mode: a universal set of defaults that (hopefully) everyone can agree on
|
|
" https://github.com/tpope/vim-sensible
|
|
Plug 'tpope/vim-sensible'
|
|
|
|
" One stop shop for vim colorschemes
|
|
" https://github.com/flazz/vim-colorschemes
|
|
Plug 'flazz/vim-colorschemes'
|
|
|
|
" Command Line Fuzzy Finder
|
|
" https://github.com/junegunn/fzf
|
|
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
|
|
Plug 'junegunn/fzf.vim'
|
|
|
|
" Fugitive is the premier Vim plugin for Git. Or maybe it's the premier Git plugin for Vim? Either way,
|
|
" it's so awesome, it should be illegal. That's why it's called Fugitive
|
|
" https://github.com/tpope/vim-fugitivefugitive.vim for git
|
|
Plug 'tpope/vim-fugitive'
|
|
|
|
" ALE displays warnings and errors in files being edited before being saved back to the filesystem
|
|
" https://github.com/dense-analysis/ale
|
|
Plug 'dense-analysis/ale'
|
|
|
|
" VimWiki - VimWiki is a personal wiki for Vim
|
|
" [VimWiki](https://mkaz.blog/working-with-vim/vimwiki/)
|
|
" Plug 'vimwiki/vimwiki'
|
|
" Removed 2024-02-22 - might not be using this after all
|
|
|
|
" Vim Markdown
|
|
" Suggestions from [Writing Markdown in Vim](https://codeinthehole.com/tips/writing-markdown-in-vim/)
|
|
" [Vim Markdown](https://github.com/preservim/vim-markdown)
|
|
Plug 'godlygeek/tabular'
|
|
Plug 'preservim/vim-markdown'
|
|
|
|
" Vim Spellsync
|
|
" Magically rebuild Vim spell files if word lists are modified outside of Vim
|
|
" https://github.com/micarmst/vim-spellsync
|
|
Plug 'micarmst/vim-spellsync'
|
|
|
|
call plug#end()
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> Plugin Options
|
|
" Options and overrides for installed plugins
|
|
|
|
" Vim Markdown
|
|
" Set default conceallevel to hide links and some formatting
|
|
set conceallevel=2
|
|
" strikethrough
|
|
let g:vim_markdown_strikethrough = 1
|
|
" follow anchors - allow <ge> to follow anchors just like links
|
|
let g:vim_markdown_follow_anchor = 1
|
|
" multi-line bullets in markdown
|
|
" [Reference](https://vimdoc.sourceforge.net/htmldoc/change.html#fo-table)
|
|
" j - remove a comment leader when joining lines.
|
|
" l - long lines are not broken in insert mode
|
|
" n - Recognize numbered lists
|
|
" r - Continue comments when pressing Enter
|
|
" t - autowrap lines using text width value
|
|
autocmd FileType markdown set formatoptions=jlnrt
|
|
" Open folds by default
|
|
au BufWinEnter * normal zR
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> Colors
|
|
" Term GUI Colors
|
|
" Testing different colorschemes
|
|
" Only the last uncommented colorscheme will be used
|
|
"colorscheme slate
|
|
"colorscheme marklar
|
|
colorscheme automation
|
|
"colorscheme advantage
|
|
|
|
"highlight colorcolumn ctermbg=darkyellow guibg=darkyellow
|
|
"highlight VertSplit ctermbg=black guibg=black ctermfg=darkgray guifg=darkgray
|
|
highlight cursorcolumn cterm=NONE ctermbg=black ctermfg=white guibg=darkred guifg=white
|
|
"highlight visual cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
|
|
|
|
" In split windows - active buffer status bar is yellow, inactive is black
|
|
"hi statuslinenc ctermbg=gray ctermfg=black
|
|
"hi statusline ctermbg=yellow ctermfg=green
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" => Statusline
|
|
" Ideas from http://got-ravings.blogspot.com/2008/08/vim-pr0n-making-statuslines-that-own.html
|
|
|
|
set laststatus=2 " always show statusline
|
|
set statusline= " clear on reload
|
|
set statusline+=[\ b%n\ ] " buffer number
|
|
set statusline+=\ %f " filename
|
|
set statusline+=\ [%{strlen(&fenc)?&fenc:'none'}, " file encoding
|
|
set statusline+=\ %{&ff}] " file format
|
|
set statusline+=\ %y " filetype
|
|
set statusline+=\ %H\ %m\ %r\ %W " flags
|
|
set statusline+=%= " left/right separator
|
|
set statusline+=l:%l/%L " cursor line/total lines
|
|
set statusline+=\ c:%c " cursor column
|
|
set statusline+=\ %P " percent through file
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" => Keymaps: Highlights
|
|
|
|
" <leader><leader> to turn off search highlight
|
|
nnoremap <leader><space> :nohls <enter>
|
|
|
|
" <leader>C to toggle row/column highlight
|
|
nnoremap <leader>C :set cursorline! cursorcolumn!<CR>
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> Keymaps: Buffers & Panes
|
|
|
|
" <ctrl>H to move to previous BUFFER
|
|
nnoremap <C-H> :bp <enter>
|
|
|
|
" <ctrl>L to move to next BUFFER
|
|
nnoremap <C-L> :bn <enter>
|
|
|
|
" <ctrl>J to move to lower PANE
|
|
nnoremap <C-J> <C-W><C-J>
|
|
|
|
" <ctrl>K to move to upper PANE
|
|
nnoremap <C-K> <C-W><C-K>
|
|
|
|
" <leader> b to open FZF buffers
|
|
map <leader>b :Buffers<CR>
|
|
|
|
" <leader>s to save buffer
|
|
nnoremap <leader>s :w <enter>
|
|
|
|
" <leader>q to quit vim
|
|
nnoremap <leader>q :q <enter>
|
|
|
|
" <leader>c to close buffer
|
|
nnoremap <leader>c :bd <enter>
|
|
|
|
" <leader>a to abandon buffer
|
|
nnoremap <leader>a :bd! <enter>
|
|
|
|
" <leader>x to bring up the copy buffer
|
|
noremap <leader>x "+
|
|
|
|
" <F5> to refresh buffer
|
|
nnoremap <F5> <C-R>:checktime <CR>
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> Keymaps
|
|
|
|
" <leader>f to open FZF files
|
|
map <leader>f :Files<CR>
|
|
map <leader><leader> :Files<CR>
|
|
|
|
" <leader>r to open registers
|
|
map <leader>r :registers<CR>
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> Keymaps: Text bubbling (http://vimcasts.org/episodes/bubbling-text/)
|
|
|
|
" Bubble single lines
|
|
nmap <C-k> ddkP
|
|
nmap <C-j> ddp
|
|
|
|
" Bubble multiple lines
|
|
vmap <C-k> xkP`[V`]
|
|
vmap <C-j> xp`[V`]
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> Keymaps: Movement keys
|
|
|
|
" Navigate according to displayed lines, not physical lines
|
|
nnoremap j gj
|
|
nnoremap k gk
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> Keymaps: Date and Time stamps
|
|
|
|
imap <F2> <C-R>=strftime("%Y-%m-%d %H:%M:%S")<CR>
|
|
imap <F3> <C-R>=strftime("%Y-%m-%d %a")<CR>
|
|
imap <F4> <C-R>=strftime("%H:%M")<CR>
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> Spellcheck
|
|
|
|
" Toggle spell check highlights with <F10>
|
|
nnoremap <F10> :setlocal spell! spelllang=en_us<CR>
|
|
|
|
" auto-complete spelling suggestions with <ctrl-p>
|
|
set complete+=kspell
|
|
|
|
" ==> Spellcheck: only certain file types
|
|
" https://robots.thoughtbot.com/vim-spell-checking
|
|
|
|
" turn off for files with no extension
|
|
autocmd BufRead,BufNewFile * setlocal nospell
|
|
|
|
" turn off for files with any extension
|
|
autocmd BufRead,BufNewFile *.* setlocal nospell
|
|
|
|
" turn on for markdown files
|
|
autocmd BufRead,BufNewFile *.md setlocal spell
|
|
|
|
" turn on for text files
|
|
autocmd BufRead,BufNewFile *.txt setlocal spell
|
|
|
|
" ==> Spellcheck Colors
|
|
" I hate spellcheck's default colors
|
|
" (http://stackoverflow.com/questions/6008921/how-do-i-change-the-highlight-style-in-vim-spellcheck)
|
|
" Vim Colors: (http://alvinalexander.com/linux/vi-vim-editor-color-scheme-syntax)
|
|
hi clear SpellBad
|
|
hi clear SpellCap
|
|
hi clear SpellErrors
|
|
hi clear SpellLocal
|
|
hi clear SpellRare
|
|
hi SpellBad cterm=underline ctermbg=black ctermfg=red
|
|
hi SpellCap cterm=underline ctermbg=black ctermfg=red
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> Templates: markdown documents (.md)
|
|
|
|
autocmd BufNewFile *.md so $HOME/.vim/templates/md
|
|
autocmd BufNewFile *.md %s/title/\=expand('%:t:r')/g
|
|
autocmd BufNewFile *.md exe "g/^- Created :.*/s//- Created : " .strftime("%Y-%m-%d")
|
|
autocmd BufNewFile *.md exe "normal Go"
|
|
autocmd BufWritePre,filewritepre *.md execute "normal ma"
|
|
autocmd BufWritePre,filewritepre *.md exe "g/^- Updated :.*/s//- Updated : " .strftime("%Y-%m-%d %H:%M")
|
|
autocmd bufWritePost,filewritepost *.md execute "normal `a"
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> Templates: shell scripts (.sh)
|
|
|
|
autocmd BufNewFile *.sh so $HOME/.vim/templates/sh
|
|
autocmd BufNewFile *.sh %s/FILE:.*/\='FILE: '.expand('%:t:r')/e
|
|
autocmd BufNewFile *.sh exe "g/CREATED:.*/s//CREATED: " .strftime("%c")
|
|
autocmd BufNewFile *.sh exe "normal Go"
|
|
autocmd BufWritePre,filewritepre *.sh execute "normal ma"
|
|
autocmd BufWritePre,filewritepre *.sh exe "g/UPDATED:.*/s//UPDATED: " .strftime("%c")
|
|
autocmd bufWritePost,filewritepost *.sh execute "normal `a"
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> Snippets
|
|
" Pasting pre-made things
|
|
|
|
" section banner
|
|
nnoremap ,ban :-1read $HOME/.vim/templates/banner<CR>jA
|
|
|
|
" section begin/end
|
|
nnoremap ,begend :-1read $HOME/.vim/templates/begend<CR>jA
|
|
|
|
" section shell script header
|
|
"nnoremap ,sh :-1read $HOME/.vim/templates/sh<CR>jA
|
|
|
|
" section markdown file header
|
|
nnoremap ,md :-1read $HOME/.vim/templates/md<CR>jA
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> NetrwTreeListing readonly fix (https://vi.stackexchange.com/a/13012)
|
|
" Per default, netrw leaves unmodified buffers open. This autocommand
|
|
" deletes netrw's buffer once it's hidden (using ':q', for example)
|
|
|
|
autocmd FileType netrw setl bufhidden=delete
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> yaml stuff (https://lornajane.net/posts/2018/vim-settings-for-working-with-yaml)
|
|
"
|
|
"autocmd BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml
|
|
"autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
|
|
|
|
" ---------------------------------------------------------------------------------------------------------------------
|
|
" ==> VimWiki
|
|
" Use MarkDown
|
|
" Default directory
|
|
"let g:vimwiki_list = [{'path': '$HOME/repos/thevimwiki/', 'syntax': 'markdown', 'ext': '.md'}]
|
|
"let g:vimwiki_global_ext = 0
|
|
"let g:vimwiki_autowriteall = 1
|
|
"au FileType vimwiki setlocal shiftwidth=6 tabstop=6 noexpandtab
|
|
|