Cleaned up vim config
parent
f5cdff4a86
commit
b76ae2c541
|
@ -0,0 +1,111 @@
|
||||||
|
" Use Vim settings, rather than Vi settings (much better!).
|
||||||
|
" This must be first, because it changes other options as a side effect.
|
||||||
|
" Avoid side effects when it was already reset.
|
||||||
|
if &compatible
|
||||||
|
set nocompatible
|
||||||
|
endif
|
||||||
|
|
||||||
|
" When the +eval feature is missing, the set command above will be skipped.
|
||||||
|
" Use a trick to reset compatible only when the +eval feature is missing.
|
||||||
|
silent! while 0
|
||||||
|
set nocompatible
|
||||||
|
silent! endwhile
|
||||||
|
|
||||||
|
" Allow backspacing over everything in insert mode.
|
||||||
|
set backspace=indent,eol,start
|
||||||
|
|
||||||
|
set history=200 " keep 200 lines of command line history
|
||||||
|
set ruler " show the cursor position all the time
|
||||||
|
set showcmd " display incomplete commands
|
||||||
|
set wildmenu " display completion matches in a status line
|
||||||
|
|
||||||
|
set ttimeout " time out for key codes
|
||||||
|
set ttimeoutlen=100 " wait up to 100ms after Esc for special key
|
||||||
|
|
||||||
|
" Show @@@ in the last line if it is truncated.
|
||||||
|
set display=truncate
|
||||||
|
|
||||||
|
" Show a few lines of context around the cursor. Note that this makes the
|
||||||
|
" text scroll if you mouse-click near the start or end of the window.
|
||||||
|
set scrolloff=5
|
||||||
|
|
||||||
|
" Do incremental searching when it's possible to timeout.
|
||||||
|
if has('reltime')
|
||||||
|
set incsearch
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it
|
||||||
|
" confusing.
|
||||||
|
set nrformats-=octal
|
||||||
|
|
||||||
|
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries.
|
||||||
|
if has('win32')
|
||||||
|
set guioptions-=t
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Don't use Ex mode, use Q for formatting.
|
||||||
|
" Revert with ":unmap Q".
|
||||||
|
map Q gq
|
||||||
|
|
||||||
|
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
|
||||||
|
" so that you can undo CTRL-U after inserting a line break.
|
||||||
|
" Revert with ":iunmap <C-U>".
|
||||||
|
inoremap <C-U> <C-G>u<C-U>
|
||||||
|
|
||||||
|
" In many terminal emulators the mouse works just fine. By enabling it you
|
||||||
|
" can position the cursor, Visually select and scroll with the mouse.
|
||||||
|
" Only xterm can grab the mouse events when using the shift key, for other
|
||||||
|
" terminals use ":", select text and press Esc.
|
||||||
|
if has('mouse')
|
||||||
|
if &term =~ 'xterm'
|
||||||
|
set mouse=a
|
||||||
|
else
|
||||||
|
set mouse=nvi
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Switch syntax highlighting on when the terminal has colors or when using the
|
||||||
|
" GUI (which always has colors).
|
||||||
|
if &t_Co > 2 || has("gui_running")
|
||||||
|
" Revert with ":syntax off".
|
||||||
|
syntax on
|
||||||
|
|
||||||
|
" I like highlighting strings inside C comments.
|
||||||
|
" Revert with ":unlet c_comment_strings".
|
||||||
|
let c_comment_strings=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Only do this part when Vim was compiled with the +eval feature.
|
||||||
|
if 1
|
||||||
|
" Enable file type detection.
|
||||||
|
" Use the default filetype settings, so that mail gets 'tw' set to 72,
|
||||||
|
" 'cindent' is on in C files, etc.
|
||||||
|
" Also load indent files, to automatically do language-dependent indenting.
|
||||||
|
" Revert with ":filetype off".
|
||||||
|
filetype plugin indent on
|
||||||
|
|
||||||
|
" Put these in an autocmd group, so that you can revert them with:
|
||||||
|
" ":augroup vimStartup | au! | augroup END"
|
||||||
|
augroup vimStartup
|
||||||
|
au!
|
||||||
|
|
||||||
|
" When editing a file, always jump to the last known cursor position.
|
||||||
|
" Don't do it when the position is invalid, when inside an event handler
|
||||||
|
" (happens when dropping a file on gvim) and for a commit message (it's
|
||||||
|
" likely a different one than last time).
|
||||||
|
autocmd BufReadPost *
|
||||||
|
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
|
||||||
|
\ | exe "normal! g`\""
|
||||||
|
\ | endif
|
||||||
|
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
if has('langmap') && exists('+langremap')
|
||||||
|
" Prevent that the langmap option applies to characters that result from a
|
||||||
|
" mapping. If set (default), this may break plugins (but it's backward
|
||||||
|
" compatible).
|
||||||
|
set nolangremap
|
||||||
|
endif
|
269
vimrc
269
vimrc
|
@ -1,154 +1,38 @@
|
||||||
" __ ___ ____ __ _ _
|
|
||||||
" \ \ / (_)_ __ ___ | _ \ ___ / _| __ _ _ _| | |_ ___
|
|
||||||
" \ \ / /| | '_ ` _ \ | | | |/ _ \ |_ / _` | | | | | __/ __|
|
|
||||||
" \ V / | | | | | | | | |_| | __/ _| (_| | |_| | | |_\__ \
|
|
||||||
" \_/ |_|_| |_| |_| |____/ \___|_| \__,_|\__,_|_|\__|___/
|
|
||||||
" Default Vim options. Some have been modified.
|
" Default Vim options. Some have been modified.
|
||||||
" These used to be loaded through 'source $VIMRUNTIME/defaults.vim'
|
|
||||||
|
source ~/.vim/defaults.vim
|
||||||
|
|
||||||
|
|
||||||
" Use Vim settings, rather than Vi settings (much better!).
|
|
||||||
" This must be first, because it changes other options as a side effect.
|
|
||||||
" Avoid side effects when it was already reset.
|
|
||||||
if &compatible
|
|
||||||
set nocompatible
|
|
||||||
endif
|
|
||||||
|
|
||||||
" When the +eval feature is missing, the set command above will be skipped.
|
|
||||||
" Use a trick to reset compatible only when the +eval feature is missing.
|
|
||||||
silent! while 0
|
|
||||||
set nocompatible
|
|
||||||
silent! endwhile
|
|
||||||
|
|
||||||
" Allow backspacing over everything in insert mode.
|
|
||||||
set backspace=indent,eol,start
|
|
||||||
|
|
||||||
set history=200 " keep 200 lines of command line history
|
|
||||||
set ruler " show the cursor position all the time
|
|
||||||
set showcmd " display incomplete commands
|
|
||||||
set wildmenu " display completion matches in a status line
|
|
||||||
|
|
||||||
set ttimeout " time out for key codes
|
|
||||||
set ttimeoutlen=100 " wait up to 100ms after Esc for special key
|
|
||||||
|
|
||||||
" Show @@@ in the last line if it is truncated.
|
|
||||||
set display=truncate
|
|
||||||
|
|
||||||
" Show a few lines of context around the cursor. Note that this makes the
|
|
||||||
" text scroll if you mouse-click near the start or end of the window.
|
|
||||||
set scrolloff=5
|
|
||||||
|
|
||||||
" Do incremental searching when it's possible to timeout.
|
|
||||||
if has('reltime')
|
|
||||||
set incsearch
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it
|
|
||||||
" confusing.
|
|
||||||
set nrformats-=octal
|
|
||||||
|
|
||||||
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries.
|
|
||||||
if has('win32')
|
|
||||||
set guioptions-=t
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Don't use Ex mode, use Q for formatting.
|
|
||||||
" Revert with ":unmap Q".
|
|
||||||
map Q gq
|
|
||||||
|
|
||||||
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
|
|
||||||
" so that you can undo CTRL-U after inserting a line break.
|
|
||||||
" Revert with ":iunmap <C-U>".
|
|
||||||
inoremap <C-U> <C-G>u<C-U>
|
|
||||||
|
|
||||||
" In many terminal emulators the mouse works just fine. By enabling it you
|
|
||||||
" can position the cursor, Visually select and scroll with the mouse.
|
|
||||||
" Only xterm can grab the mouse events when using the shift key, for other
|
|
||||||
" terminals use ":", select text and press Esc.
|
|
||||||
if has('mouse')
|
|
||||||
if &term =~ 'xterm'
|
|
||||||
set mouse=a
|
|
||||||
else
|
|
||||||
set mouse=nvi
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Switch syntax highlighting on when the terminal has colors or when using the
|
|
||||||
" GUI (which always has colors).
|
|
||||||
if &t_Co > 2 || has("gui_running")
|
|
||||||
" Revert with ":syntax off".
|
|
||||||
syntax on
|
|
||||||
|
|
||||||
" I like highlighting strings inside C comments.
|
|
||||||
" Revert with ":unlet c_comment_strings".
|
|
||||||
let c_comment_strings=1
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Only do this part when Vim was compiled with the +eval feature.
|
|
||||||
if 1
|
|
||||||
|
|
||||||
" Enable file type detection.
|
|
||||||
" Use the default filetype settings, so that mail gets 'tw' set to 72,
|
|
||||||
" 'cindent' is on in C files, etc.
|
|
||||||
" Also load indent files, to automatically do language-dependent indenting.
|
|
||||||
" Revert with ":filetype off".
|
|
||||||
filetype plugin indent on
|
|
||||||
|
|
||||||
" Put these in an autocmd group, so that you can revert them with:
|
|
||||||
" ":augroup vimStartup | au! | augroup END"
|
|
||||||
augroup vimStartup
|
|
||||||
au!
|
|
||||||
|
|
||||||
" When editing a file, always jump to the last known cursor position.
|
|
||||||
" Don't do it when the position is invalid, when inside an event handler
|
|
||||||
" (happens when dropping a file on gvim) and for a commit message (it's
|
|
||||||
" likely a different one than last time).
|
|
||||||
autocmd BufReadPost *
|
|
||||||
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
|
|
||||||
\ | exe "normal! g`\""
|
|
||||||
\ | endif
|
|
||||||
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Convenient command to see the difference between the current buffer and the
|
" Convenient command to see the difference between the current buffer and the
|
||||||
" file it was loaded from, thus the changes you made.
|
" file it was loaded from, thus the changes you made.
|
||||||
" Only define it when not defined already.
|
" Only define it when not defined already.
|
||||||
" Revert with: ":delcommand DiffOrig".
|
" Revert with: ":delcommand DiffOrig".
|
||||||
if !exists(":DiffOrig")
|
if !exists(":DiffOrig")
|
||||||
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
|
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
|
||||||
\ | wincmd p | diffthis
|
\ | wincmd p | diffthis
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has('langmap') && exists('+langremap')
|
|
||||||
" Prevent that the langmap option applies to characters that result from a
|
|
||||||
" mapping. If set (default), this may break plugins (but it's backward
|
|
||||||
" compatible).
|
|
||||||
set nolangremap
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if has("vms")
|
if has("vms")
|
||||||
set nobackup " do not keep a backup file, use versions instead
|
set nobackup " do not keep a backup file, use versions instead
|
||||||
else
|
else
|
||||||
set backup " keep a backup file (restore to previous version)
|
set backup " keep a backup file (restore to previous version)
|
||||||
if has('persistent_undo')
|
if has('persistent_undo')
|
||||||
set undofile " keep an undo file (undo changes after closing)
|
set undofile " keep an undo file (undo changes after closing)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Don't clutter directories with swap files.
|
||||||
|
" Save them in /tmp instead.
|
||||||
|
set backupdir=/tmp//,.
|
||||||
|
set directory=/tmp//,.
|
||||||
|
set undodir=/tmp//,.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if &t_Co > 2 || has("gui_running")
|
if &t_Co > 2 || has("gui_running")
|
||||||
" Switch on highlighting the last used search pattern.
|
" Switch on highlighting the last used search pattern.
|
||||||
set hlsearch
|
set hlsearch
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Put these in an autocmd group, so that we can delete them easily.
|
" Put these in an autocmd group, so that we can delete them easily.
|
||||||
|
@ -160,13 +44,6 @@ endif
|
||||||
"augroup END
|
"augroup END
|
||||||
|
|
||||||
|
|
||||||
" _ _ _ _ _ _
|
|
||||||
" / \ __| | __| | ___ __| | | (_)_ __ ___ ___
|
|
||||||
" / _ \ / _` |/ _` |/ _ \/ _` | | | | '_ \ / _ \/ __|
|
|
||||||
" / ___ \ (_| | (_| | __/ (_| | | | | | | | __/\__ \
|
|
||||||
" /_/ \_\__,_|\__,_|\___|\__,_| |_|_|_| |_|\___||___/
|
|
||||||
" All text below is not from the default vimrc.
|
|
||||||
|
|
||||||
|
|
||||||
" Enable syntax highlighting if the terminal supports color
|
" Enable syntax highlighting if the terminal supports color
|
||||||
if &t_Co > 1
|
if &t_Co > 1
|
||||||
|
@ -187,69 +64,80 @@ set numberwidth=4
|
||||||
"set relativenumber
|
"set relativenumber
|
||||||
|
|
||||||
" Display invisible characters.
|
" Display invisible characters.
|
||||||
" Show tabs as '<--->', and trailing spaces as '·'
|
" Here's a helpful list of chars:
|
||||||
|
" ␠ ⎵ ⏎ ·
|
||||||
set list
|
set list
|
||||||
" set listchars=tab:<->,trail:·
|
|
||||||
set listchars=tab:\|\ \|,trail:·,nbsp:⎵
|
set listchars=tab:\|\ \|,trail:·,nbsp:⎵
|
||||||
" Special char list: ␠⎵⏎
|
|
||||||
|
|
||||||
" Don't clutter directories with swap files.
|
|
||||||
" Save them in /tmp instead.
|
|
||||||
set backupdir=/tmp//,.
|
|
||||||
set directory=/tmp//,.
|
|
||||||
set undodir=/tmp//,.
|
|
||||||
|
|
||||||
|
|
||||||
" _ __ __ __ _
|
" Configure and load conceal chars
|
||||||
" | |/ /___ _ _ | \/ | __ _ _ __ _ __ (_)_ __ __ _ ___
|
"
|
||||||
" | ' // _ \ | | | | |\/| |/ _` | '_ \| '_ \| | '_ \ / _` / __|
|
"set conceallevel=0 " Nothing is hidden
|
||||||
" | . \ __/ |_| | | | | | (_| | |_) | |_) | | | | | (_| \__ \
|
"set conceallevel=1 " Hide stuff as concealchar, or as listchar.
|
||||||
" |_|\_\___|\__, | |_| |_|\__,_| .__/| .__/|_|_| |_|\__, |___/
|
"set conceallevel=2 " Hide stuff as concealchar, or completely.
|
||||||
" |___/ |_| |_| |___/
|
"set conceallevel=3 " Hide completely.
|
||||||
" Custom keybinds and commands
|
"
|
||||||
|
"syntax keyword ConcealedX kw_hide_x conceal concealchar=x
|
||||||
|
"syntax keyword ConcealedY kw_hide_y conceal concealchar=y
|
||||||
|
"syntax keyword ConcealedMe kw_hide_me conceal
|
||||||
|
"syntax keyword NoConceal kw_normal
|
||||||
|
"
|
||||||
|
"highlight ConcealedX ctermfg=2
|
||||||
|
"highlight ConcealedY ctermfg=3
|
||||||
|
"highlight ConcealedMe ctermfg=4
|
||||||
|
"highlight NoConceal ctermfg=5
|
||||||
|
"
|
||||||
|
:set conceallevel=2
|
||||||
|
highlight Conceal ctermbg=NONE ctermfg=green guibg=NONE guifg=NONE
|
||||||
|
source ~/.vim/conceal.vim
|
||||||
|
|
||||||
" jh to escape in insert mode, 'cuz esc is hard to reach.
|
|
||||||
inoremap jh <Esc>
|
|
||||||
|
|
||||||
" Map F5 to clear all trailing whitespace in normal mode.
|
" jh to escape in insert mode, esc is hard to reach.
|
||||||
" the _s variable is used to preserve the search pattern register.
|
"inoremap jh <Esc>
|
||||||
nnoremap <silent> <F5> :let _s=@/ <Bar> :%s/\s\+$//e <Bar> :let @/=_s <Bar> :nohl <Bar> :unlet _s <CR>
|
|
||||||
|
|
||||||
" Map Ctrl-k to toggle invisibles in normal mode
|
" Clears trailing whitespace while preserving cursor.
|
||||||
nnoremap <C-k> :set list! <CR>
|
function StripTrailingWhitespaces()
|
||||||
|
let l = line(".")
|
||||||
|
let c = col(".")
|
||||||
|
%s/\s\+$//e
|
||||||
|
call cursor(l, c)
|
||||||
|
endfun
|
||||||
|
|
||||||
" A command that makes figlet titles
|
|
||||||
command -nargs=1 F :r !figlet <q-args><CR>
|
|
||||||
command -nargs=1 Ff :r !figlet -f small <q-args><CR>
|
|
||||||
|
|
||||||
|
augroup clearwhitespace_gp
|
||||||
|
autocmd!
|
||||||
|
autocmd BufWritePre * :call StripTrailingWhitespaces()
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
|
||||||
|
" Toggle invisibles in normal mode
|
||||||
|
nnoremap <F3> :set list! <CR>
|
||||||
|
|
||||||
|
" Tab size shortcuts
|
||||||
|
" TODO: VSCode-like tab menu
|
||||||
nnoremap <C-p> :set tabstop=4 shiftwidth=4 noexpandtab<CR>
|
nnoremap <C-p> :set tabstop=4 shiftwidth=4 noexpandtab<CR>
|
||||||
nnoremap <C-o> :set tabstop=8 shiftwidth=8 noexpandtab<CR>
|
nnoremap <C-o> :set tabstop=8 shiftwidth=8 noexpandtab<CR>
|
||||||
|
|
||||||
|
|
||||||
" Autodetect filetypes and set proper indentation
|
" Autodetect filetypes and set proper indentation
|
||||||
" Default: 8
|
" Default: 4, with tabs.
|
||||||
:set tabstop=8 shiftwidth=8 noexpandtab
|
set tabstop=4 shiftwidth=4 noexpandtab
|
||||||
:autocmd Filetype py setlocal tabstop=4 shiftwidth=4 noexpandtab
|
augroup tabsize_gp
|
||||||
:autocmd Filetype lua setlocal tabstop=4 shiftwidth=4 noexpandtab
|
autocmd!
|
||||||
|
autocmd Filetype py setlocal tabstop=4 shiftwidth=4 noexpandtab
|
||||||
|
autocmd Filetype lua setlocal tabstop=4 shiftwidth=4 noexpandtab
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
|
||||||
" ____ _ _
|
" Plugins
|
||||||
" | _ \| |_ _ __ _(_)_ __ ___
|
|
||||||
" | |_) | | | | |/ _` | | '_ \/ __|
|
|
||||||
" | __/| | |_| | (_| | | | | \__ \
|
|
||||||
" |_| |_|\__,_|\__, |_|_| |_|___/
|
|
||||||
" |___/
|
|
||||||
|
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
|
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-goyo.git'
|
||||||
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-goyo.git'
|
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-gitgutter.git'
|
||||||
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-gitgutter.git'
|
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-nerdtree.git'
|
||||||
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-nerdtree.git'
|
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-hexHighlight.git'
|
||||||
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-hexHighlight.git'
|
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-pencil.git'
|
||||||
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-pencil.git'
|
"Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-wordchipper.git'
|
||||||
"Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-wordchipper.git'
|
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-boxdraw.git'
|
||||||
Plug 'ssh://git@git.betalupi.com:33/mirrors/vim-boxdraw.git'
|
|
||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
|
|
||||||
|
@ -263,7 +151,6 @@ endif
|
||||||
|
|
||||||
nmap <F2> <Plug>ToggleHexHighlight
|
nmap <F2> <Plug>ToggleHexHighlight
|
||||||
|
|
||||||
"filetype plugin on " may already be in your .vimrc
|
|
||||||
|
|
||||||
let g:pencil#textwidth = 70
|
let g:pencil#textwidth = 70
|
||||||
augroup pencil
|
augroup pencil
|
||||||
|
@ -276,7 +163,3 @@ augroup END
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" Configure and load conceal chars
|
|
||||||
:set conceallevel=2
|
|
||||||
highlight Conceal ctermbg=NONE ctermfg=green guibg=NONE guifg=NONE
|
|
||||||
source ~/.vim/conceal.vim
|
|
||||||
|
|
Loading…
Reference in New Issue