[vim] change everything

* set defaults from vim-better-defaults with few changes in
  `~/.vim/default.vim`
* use space-vim-dark colorscheme
* use eleline
This commit is contained in:
odrling 2020-02-10 23:48:03 +01:00
parent 2cc857ae54
commit c636bf08ff
10 changed files with 336 additions and 177 deletions

View file

@ -1,18 +1,7 @@
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=500
set number relativenumber
" By default ClapQuery will use the bold fg of Normal and the same bg of ClapInput
hi ClapDefaultPreview ctermbg=237 guibg=#3E4452
hi default link ClapPreview ClapDefaultPreview
hi default link ClapDisplay ClapDefaultPreview
hi default link ClapSelected ClapDefaultSelected
hi default link ClapCurrentSelection ClapDefaultCurrentSelection
source ~/.vim/default.vim
" Enable filetype plugins
filetype plugin on
@ -22,167 +11,37 @@ filetype indent on
set path+=**
set wildmenu
" Set to auto read when a file is changed from the outside
set autoread
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
nmap <leader>j :wn<cr>
nmap <leader>k :wN<cr>
nmap <leader>b :w<CR>:b<SPACE>
" Oh well
nmap <leader>; A;<esc>
" :W sudo saves the file
" (useful for handling the permission-denied error)
command W w !sudo tee % > /dev/null
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 5 lines to the cursor - when moving vertically using j/k
set so=5
" Avoid garbled characters in Chinese language windows OS
let $LANG='en'
set langmenu=en
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
" Turn on the Wild menu
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
if has("win16") || has("win32")
set wildignore+=.git\*,.hg\*,.svn\*
else
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
endif
"Always show current position
set ruler
" Height of the command bar
set cmdheight=1
" A buffer becomes hidden when it is abandoned
set hid
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" Don't redraw while executing macros (good performance config)
set lazyredraw
" For regular expressions turn magic on
set magic
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Properly disable sound on errors on MacVim
if has("gui_macvim")
autocmd GUIEnter * set vb t_vb=
endif
" Add a bit extra margin to the left
set foldcolumn=1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
" use true colors
set termguicolors
" Enable 256 colors palette in Gnome Terminal
" if $COLORTERM == 'gnome-terminal'
" set t_Co=256
" endif
let g:airline_theme='minimalist'
set background=dark
" fix weird pink color in coc popups
highlight Pmenu guibg=black gui=bold
" Set extra options when running in GUI mode
if has("gui_running")
set guioptions-=T
set guioptions-=e
set t_Co=256
set guitablabel=%M\ %t
endif
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
" Use Unix as the standard file type
set ffs=unix,dos,mac
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs ;)
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Linebreak on 500 characters
set lbr
set tw=500
set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines
let g:airline_theme='minimalist'
""""""""""""""""""""""""""""""
" => Visual mode related
@ -196,9 +55,6 @@ vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs, windows and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search)
"map <space> /
"map <c-space> ?
" Disable highlight when <leader><cr> is pressed
map <silent> <leader><cr> :noh<cr>
@ -328,11 +184,6 @@ map <leader>x :e ~/buffer.md<cr>
" Toggle paste mode on and off
map <leader>pp :setlocal paste!<cr>
" Move to the next marker
inoremap <C-j> <Esc>/<++><CR>"_c4l
inoremap <C-j><C-j> <++>
nnoremap <Space> a<++><ESC>
" copy line to clipboard
nnoremap <C-c> "+yy
vnoremap <C-c> "+y
@ -349,19 +200,6 @@ inoremap <S-Enter> <Esc>O
" bulk rename (with dirvish)
nnoremap <C-S-r> :%Shdo mv {} {}<cr>
" adathings
autocmd FileType ada ab if<space> if then<CR><++><CR>end if;<CR><++><Esc>3k0ea
autocmd FileType ada ab while while loop<CR><++><CR>end loop;<CR><++><Esc>3k0ea
autocmd FileType ada ab for for loop<CR><++><CR>end loop;<CR><++><Esc>3k0ea
autocmd FileType ada ab proc procedure is<CR>begin<CR><++><CR>end;<CR><++><ESC>4k^ea
autocmd FileType ada ab pros procedure;<CR><++><ESC>k^ea
autocmd FileType ada ab func function(<++>) return <++><CR>end;<CR><++><ESC>3kea
autocmd FileType ada ab funs function(<++>) return <++>;<CR><++><ESC>k^ea
autocmd FileType ada ab pack package is<CR><++><CR>end;<CR><++><ESC>3kea
autocmd FileType ada ab use use <ESC>0wyf;$pa
autocmd FileType ada ab case case is<CR>when others => <++><CR>end case;<ESC>2k^ea
autocmd FileType ada ab loop loop<CR>end loop;<ESC>kA
" pythonthings
autocmd FileType python map #! ggi#!/usr/bin/env python3<CR><ESC>:silent exec "!chmod +x %"<CR>
autocmd FileType python map ;m oif __name__ == '__main__':<CR>main()<ESC>^
@ -452,10 +290,6 @@ endfunction
" if hidden is not set, TextEdit might fail.
set hidden
" Some servers have issues with backup files, see #649
set nobackup
set nowritebackup
" Better display for messages
set cmdheight=2
@ -539,7 +373,7 @@ nmap <leader>ac <Plug>(coc-codeaction)
" Fix autofix problem of current line
nmap <leader>qf <Plug>(coc-fix-current)
" Create mappings for function text object, requires document symbols feature of languageserver.
" Create mappings for function t<++>ext object, requires document symbols feature of languageserver.
xmap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap if <Plug>(coc-funcobj-i)
@ -581,3 +415,5 @@ nnoremap <silent> <space>p :<C-u>CocListResume<CR>
execute pathogen#infect('~/.vim/bundle/{}')
colorscheme space-vim-dark

9
.gitmodules vendored
View file

@ -69,9 +69,12 @@
[submodule ".vim/bundle/vim-clap"]
path = .vim/bundle/vim-clap
url = https://github.com/liuchengxu/vim-clap.git
[submodule ".vim/bundle/gruvbox"]
path = .vim/bundle/gruvbox
url = https://github.com/morhetz/gruvbox.git
[submodule ".vim/bundle/coc.nvim"]
path = .vim/bundle/coc.nvim
url = https://github.com/neoclide/coc.nvim.git
[submodule ".vim/bundle/space-vim-dark"]
path = .vim/bundle/space-vim-dark
url = https://github.com/liuchengxu/space-vim-dark.git
[submodule ".vim/bundle/eleline.vim"]
path = .vim/bundle/eleline.vim
url = https://github.com/liuchengxu/eleline.vim.git

@ -1 +1 @@
Subproject commit 687af54a67e20d6bb1e1760f6e702fb751591157
Subproject commit 9bb31f9d03af2fc52f98ec65020b34efdc496883

@ -0,0 +1 @@
Subproject commit 0a28b6602ee5d3503df2ed21190c8fc9759b510f

@ -1 +0,0 @@
Subproject commit cb4e7a5643f7d2dd40e694bcbd28c4b89b185e86

@ -0,0 +1 @@
Subproject commit d24c6c27b49c1ab49416a47d96979481281f53b5

@ -1 +0,0 @@
Subproject commit 099dd92eebe09ab27a483e381f2a708945e34330

@ -1 +0,0 @@
Subproject commit 6270e7d58828999da7239785ad4269899fab99b5

@ -1 +1 @@
Subproject commit 3c17243c97a27812709e6e408cf8a1abf90f85bc
Subproject commit 4fc3759cb6b1e63e74ff9b6c2ef0f6a451f4e46a

321
.vim/default.vim Normal file
View file

@ -0,0 +1,321 @@
" default.vim - Better vim than the default
" Maintainer: Liu-Cheng Xu <https://github.com/liuchengxu>
" Version: 1.0
" vim: et ts=2 sts=2 sw=2
scriptencoding utf-8
if &compatible || exists('g:loaded_vim_better_default')
finish
endif
let g:loaded_vim_better_default = 1
let s:save_cpo = &cpo
set cpo&vim
" Neovim has set these as default
if !has('nvim')
set nocompatible
syntax on " Syntax highlighting
filetype plugin indent on " Automatically detect file types
set autoindent " Indent at the same level of the previous line
set autoread " Automatically read a file changed outside of vim
set backspace=indent,eol,start " Backspace for dummies
set complete-=i " Exclude files completion
set display=lastline " Show as much as possible of the last line
set encoding=utf-8 " Set default encoding
set history=10000 " Maximum history record
set hlsearch " Highlight search terms
set incsearch " Find as you type search
set laststatus=2 " Always show status line
set mouse=a " Automatically enable mouse usage
set smarttab " Smart tab
set ttyfast " Faster redrawing
set viminfo+=! " Viminfo include !
set wildmenu " Show list instead of just completing
set ttymouse=xterm2
endif
set shortmess=atOI " No help Uganda information, and overwrite read messages to avoid PRESS ENTER prompts
set ignorecase " Case insensitive search
set smartcase " ... but case sensitive when uc present
set scrolljump=1 " Line to scroll when cursor leaves screen
set scrolloff=5 " Minumum lines to keep above and below cursor
set nowrap " Do not wrap long lines
set shiftwidth=4 " Use indents of 4 spaces
set tabstop=4 " An indentation every four columns
set softtabstop=4 " Let backspace delete indent
set splitright " Puts new vsplit windows to the right of the current
set splitbelow " Puts new split windows to the bottom of the current
set autowrite " Automatically write a file when leaving a modified buffer
set mousehide " Hide the mouse cursor while typing
set hidden " Allow buffer switching without saving
set t_Co=256 " Use 256 colors
set ruler " Show the ruler
set showcmd " Show partial commands in status line and Selected characters/lines in visual mode
set showmode " Show current mode in command-line
set showmatch " Show matching brackets/parentthesis
set matchtime=5 " Show matching time
set report=0 " Always report changed lines
set linespace=0 " No extra spaces between rows
set pumheight=20 " Avoid the pop up menu occupying the whole screen
if !exists('g:vim_better_default_tabs_as_spaces') || g:vim_better_default_tabs_as_spaces
set expandtab " Tabs are spaces, not tabs
end
" http://stackoverflow.com/questions/6427650/vim-in-tmux-background-color-changes-when-paging/15095377#15095377
set t_ut=
set winminheight=0
set wildmode=list:longest,full
set listchars=tab:→\ ,eol:↵,trail,extends:↷,precedes:↶
set whichwrap+=<,>,h,l " Allow backspace and cursor keys to cross line boundaries
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set wildignore+=*swp,*.class,*.pyc,*.png,*.jpg,*.gif,*.zip
set wildignore+=*/tmp/*,*.o,*.obj,*.so " Unix
set wildignore+=*\\tmp\\*,*.exe " Windows
" Visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv
" Treat long lines as break lines (useful when moving around in them)
nmap j gj
nmap k gk
vmap j gj
vmap k gk
" :W sudo saves the file
" (useful for handling the permission-denied error)
command! W w !sudo tee % > /dev/null
" Change cursor shape for iTerm2 on macOS {
" bar in Insert mode
" inside iTerm2
if $TERM_PROGRAM =~# 'iTerm'
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
" inside tmux
if exists('$TMUX') && $TERM != 'xterm-kitty'
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_SR = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
endif
" inside neovim
if has('nvim')
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=2
endif
" }
if get(g:, 'vim_better_default_minimum', 0)
finish
endif
if get(g:, 'vim_better_default_backup_on', 0)
set backup
else
set nobackup
set noswapfile
set nowritebackup
endif
if get(g:, 'vim_better_default_enable_folding', 1)
set foldenable
set foldmarker={,}
set foldlevel=0
set foldmethod=marker
" set foldcolumn=3
set foldlevelstart=99
endif
set background=dark
set cursorline " Highlight current line
set fileformats=unix,dos,mac " Use Unix as the standard file type
set number " Line numbers on
set relativenumber " Relative numbers on
set fillchars=stl:\ ,stlnc:\ ,fold:\ ,vert:│
" Annoying temporary files
set directory=/tmp//,.
set backupdir=/tmp//,.
if v:version >= 703
set undodir=/tmp//,.
endif
highlight clear SignColumn " SignColumn should match background
" highlight clear LineNr " Current line number row will have same background color in relative mode
if has('unnamedplus')
set clipboard=unnamedplus,unnamed
else
set clipboard+=unnamed
endif
if get(g:, 'vim_better_default_persistent_undo', 0)
if has('persistent_undo')
set undofile " Persistent undo
set undolevels=1000 " Maximum number of changes that can be undone
set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
endif
endif
if has('gui_running')
set guioptions-=r " Hide the right scrollbar
set guioptions-=L " Hide the left scrollbar
set guioptions-=T
set guioptions-=e
set shortmess+=c
" No annoying sound on errors
set noerrorbells
set novisualbell
set visualbell t_vb=
endif
" Key (re)Mappings {
if get(g:, 'vim_better_default_key_mapping', 1)
" Basic {
if get(g:, 'vim_better_default_basic_key_mapping', 1)
" Add <slient> for the rhs is Ex-cmd as some GUI app, e.g., gnvim,
" flashes when you use these mappings.
" Quit normal mode
nnoremap <silent> <Leader>q :q<CR>
nnoremap <silent> <Leader>Q :qa!<CR>
" Move half page faster
nnoremap <Leader>d <C-d>
nnoremap <Leader>u <C-u>
" Insert mode shortcut
inoremap <C-h> <BS>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-b> <Left>
inoremap <C-f> <Right>
" Bash like
inoremap <C-a> <Home>
inoremap <C-e> <End>
inoremap <C-d> <Delete>
" Command mode shortcut
cnoremap <C-h> <BS>
cnoremap <C-j> <Down>
cnoremap <C-k> <Up>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-d> <Delete>
" jj | escaping
inoremap jj <Esc>
cnoremap jj <C-c>
" Quit visual mode
vnoremap v <Esc>
" Move to the start of line
nnoremap H ^
" Move to the end of line
nnoremap L $
" Redo
nnoremap U <C-r>
" Quick command mode
nnoremap <CR> :
" In the quickfix window, <CR> is used to jump to the error under the
" cursor, so undefine the mapping there.
autocmd BufReadPost quickfix nnoremap <buffer> <CR> <CR>
" Yank to the end of line
nnoremap Y y$
" Auto indent pasted text
" nnoremap p p=`]<C-o>
" Open shell in vim
if has('nvim') || has('terminal')
map <silent> <Leader>' :terminal<CR>
else
map <silent> <Leader>' :shell<CR>
endif
" Search result highlight countermand
nnoremap <silent> <Leader>sc :nohlsearch<CR>
" Toggle pastemode
nnoremap <silent> <Leader>tp :setlocal paste!<CR>
endif
" }
" Buffer {
if get(g:, 'vim_better_default_buffer_key_mapping', 1)
nnoremap <silent> <Leader>bp :bprevious<CR>
nnoremap <silent> <Leader>bn :bnext<CR>
nnoremap <silent> <Leader>bf :bfirst<CR>
nnoremap <silent> <Leader>bl :blast<CR>
nnoremap <silent> <Leader>bd :bd<CR>
nnoremap <silent> <Leader>bk :bw<CR>
endif
" }
" File {
if get(g:, 'vim_better_default_file_key_mapping', 1)
" File save
nnoremap <silent> <Leader>fs :update<CR>
endif
" }
" Fold {
if get(g:, 'vim_better_default_fold_key_mapping', 1)
nnoremap <silent> <Leader>f0 :set foldlevel=0<CR>
nnoremap <silent> <Leader>f1 :set foldlevel=1<CR>
nnoremap <silent> <Leader>f2 :set foldlevel=2<CR>
nnoremap <silent> <Leader>f3 :set foldlevel=3<CR>
nnoremap <silent> <Leader>f4 :set foldlevel=4<CR>
nnoremap <silent> <Leader>f5 :set foldlevel=5<CR>
nnoremap <silent> <Leader>f6 :set foldlevel=6<CR>
nnoremap <silent> <Leader>f7 :set foldlevel=7<CR>
nnoremap <silent> <Leader>f8 :set foldlevel=8<CR>
nnoremap <silent> <Leader>f9 :set foldlevel=9<CR>
endif
" }
" Window {
if get(g:, 'vim_better_default_window_key_mapping', 1)
nnoremap <Leader>ww <C-W>w
nnoremap <Leader>wr <C-W>r
nnoremap <Leader>wd <C-W>c
nnoremap <Leader>wq <C-W>q
nnoremap <Leader>wj <C-W>j
nnoremap <Leader>wk <C-W>k
nnoremap <Leader>wh <C-W>h
nnoremap <Leader>wl <C-W>l
if has('nvim') || has('terminal')
tnoremap <Leader>wj <C-W>j
tnoremap <Leader>wk <C-W>k
tnoremap <Leader>wh <C-W>h
tnoremap <Leader>wl <C-W>l
endif
nnoremap <Leader>wH <C-W>5<
nnoremap <Leader>wL <C-W>5>
nnoremap <Leader>wJ :resize +5<CR>
nnoremap <Leader>wK :resize -5<CR>
nnoremap <Leader>w= <C-W>=
nnoremap <Leader>ws <C-W>s
nnoremap <Leader>w- <C-W>s
nnoremap <Leader>wv <C-W>v
nnoremap <Leader>w\| <C-W>v
nnoremap <Leader>w2 <C-W>v
endif
" }
endif
" }
let &cpo = s:save_cpo
unlet s:save_cpo