overdue commit

This commit is contained in:
Henrik Bakken
2020-09-29 02:49:42 +02:00
parent 6cdb7ecc61
commit df57e62c5f
16 changed files with 397 additions and 562 deletions
+68 -249
View File
@@ -20,7 +20,7 @@ call plug#begin('~/.config/nvim/plugged')
" tools
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'junegunn/fzf', {'dir': '~/.fzf', 'do': './install --all'}
Plug 'junegunn/fzf.vim'
"Plug 'junegunn/fzf.vim'
Plug 'sheerun/vim-polyglot' " language syntax
Plug 'godlygeek/tabular' " help aligning text on tabs
Plug 'tpope/vim-fugitive'
@@ -75,8 +75,8 @@ if has("nvim")
endif
endif
"let g:airline_theme='molokai'
"let g:airline_theme='qwq'
let g:airline_theme='badwolf'
let g:airline_theme='qwq'
"let g:airline_theme='badwolf'
"let g:airline_theme='silver'
"let g:airline_theme='raven'
@@ -94,8 +94,9 @@ let g:BASH_Ctrl_l='off' " avoid 'C-l' being overridden to newline
set updatetime=300
set timeoutlen=500
set lazyredraw
" set shell=/usr/bin/bash
" let $SHELL = "/usr/bin/bash"
set shell=/usr/bin/bash
let $SHELL = "/usr/bin/bash"
set conceallevel=2
" fold config
set foldmethod=indent
@@ -106,10 +107,6 @@ set foldlevelstart=20
" zi toggle folds
" zi zj move to next / prev fold
" concealment
set conceallevel=2
let g:tex_conceal='bd'
" indentation
set ai " auto indent
set si " smart indent
@@ -123,7 +120,6 @@ autocmd BufEnter * if &filetype == "" | setlocal ft=markdown | endif
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set fileformat=unix
au Filetype python set
\ tabstop=4
@@ -134,6 +130,7 @@ au Filetype markdown,yaml set
\ tabstop=2
\ softtabstop=2
\ shiftwidth=2
set expandtab
"
" Disables automatic commenting on newline:
"autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
@@ -224,29 +221,24 @@ nmap <silent> <C-Right> :execute 'silent! tabmove ' . (tabpagenr()+1)<cr>
"nmap <C-p>r :Rg<ENTER>
"nmap <C-p>b :Buffers<ENTER>
"nmap <C-p>c :Commands<ENTER>
nmap <C-p>t :Colors<ENTER>
"nmap <C-p>t :Colors<ENTER>
"nmap <C-p>m :Marks<ENTER>
"nmap <C-p>w :Windows<ENTER>
"nmap <F2> :Maps<ENTER>
nmap <C-p> [fzf-p]
xmap <C-p> [fzf-p]
nnoremap <silent> [fzf-p]f :<C-u>CocCommand fzf-preview.FromResources project_mru git<CR>
nnoremap <silent> [fzf-p]F :<C-u>CocCommand fzf-preview.DirectoryFiles<CR>
nnoremap <silent> [fzf-p]g :<C-u>CocCommand fzf-preview.GitStatus<CR>
nnoremap <silent> [fzf-p]G :<C-u>CocCommand fzf-preview.GitActions<CR>
nnoremap <silent> [fzf-p]b :<C-u>CocCommand fzf-preview.Buffers<CR>
nnoremap <silent> [fzf-p]B :<C-u>CocCommand fzf-preview.AllBuffers<CR>
" nnoremap <silent> [fzf-p]o :<C-u>CocCommand fzf-preview.FromResources buffer project_mru<CR>
" nnoremap <silent> [fzf-p]<C-o> :<C-u>CocCommand fzf-preview.Jumps<CR>
" nnoremap <silent> [fzf-p]g; :<C-u>CocCommand fzf-preview.Changes<CR>
nnoremap <silent> [fzf-p]/ :<C-u>CocCommand fzf-preview.Lines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'"<CR>
nnoremap <silent> [fzf-p]* :<C-u>CocCommand fzf-preview.Lines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'<C-r>=expand('<cword>')<CR>"<CR>
nnoremap [fzf-p]l :<C-u>CocCommand fzf-preview.ProjectGrep<Space>
xnoremap [fzf-p]l "sy:CocCommand fzf-preview.ProjectGrep<Space>-F<Space>"<C-r>=substitute(substitute(@s, '\n', '', 'g'), '/', '\\/', 'g')<CR>"
nnoremap <silent> [fzf-p]t :<C-u>CocCommand fzf-preview.BufferTags<CR>
"nnoremap <silent> [fzf-p]q :<C-u>CocCommand fzf-preview.QuickFix<CR>
"nnoremap <silent> [fzf-p]l :<C-u>CocCommand fzf-preview.LocationList<CR>
nmap <M-w> :<C-u>CocCommand fzf-preview.ProjectGrep<Space>
xmap <M-w> "sy:CocCommand fzf-preview.ProjectGrep<Space>-F<Space>"<C-r>=substitute(substitute(@s, '\n', '', 'g'), '/', '\\/', 'g')<CR>"
nmap <M-W> :<C-u>CocCommand fzf-preview.ProjectGrep<Space>
nmap <silent> <M-e> :<C-u>CocCommand fzf-preview.Lines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'"<CR>
nmap <silent> <M-E> :<C-u>CocCommand fzf-preview.Lines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'<C-r>=expand('<cword>')<CR>"<CR>
nmap <silent> <M-r> :<C-u>CocCommand fzf-preview.MruFiles<CR>
nmap <silent> <M-R> :<C-u>CocCommand fzf-preview.ProjectMruFiles<CR>
nmap <silent> <M-f> :<C-u>CocCommand fzf-preview.DirectoryFiles<CR>
nmap <silent> <M-F> :<C-u>CocCommand fzf-preview.ProjectFiles<CR>
nmap <silent> <M-g> :<C-u>CocCommand fzf-preview.GitStatus<CR>
nmap <silent> <M-G> :<C-u>CocCommand fzf-preview.GitActions<CR>
nmap <silent> <M-b> :<C-u>CocCommand fzf-preview.Buffers<CR>
nmap <silent> <M-B> :<C-u>CocCommand fzf-preview.AllBuffers<CR>
" Close preview window when completion is done
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
@@ -272,6 +264,7 @@ nmap <leader>gp <Plug>(coc-git-prevchunk)
nmap <leader>g<cr> <Plug>(coc-git-chunkinfo)
nmap <leader>gs :CocCommand git.chunkStage<CR>
vmap <leader>gs :CocCommand git.chunkStage<CR>
nmap <leader>gX :CocCommand git.chunkUndo<CR>
vmap <leader>gX :CocCommand git.chunkUndo<CR>
" vim-fugitive
@@ -279,7 +272,7 @@ vmap <leader>gX :CocCommand git.chunkUndo<CR>
nmap <leader>gg :vertical Gstatus<cr>:vertical resize 60<cr>
" nerdtree
map <leader>N :NERDTreeToggle<cr>
map <C-f> :NERDTreeToggle<cr>
" nerdcommenter
" '<leader>c ', '<leader>cl' aligned and '<leader>cu>' remove
@@ -304,10 +297,8 @@ map z# <Plug>(asterisk-z#)
map gz# <Plug>(asterisk-gz#)
" buffergator
map <leader>b :BuffergatorOpen<cr>
map <leader>B :BuffergatorClose<cr>
map <leader>t :BuffergatorTabsOpen<cr>
map <leader>T :BuffergatorTabsClose<cr>
map <C-b> :BuffergatorToggle<cr>
map <C-t> :BuffergatorTabsToggle<cr>
nmap <leader>j :BuffergatorMruCyclePrev<cr>
nmap <leader>k :BuffergatorMruCycleNext<cr>
@@ -364,7 +355,10 @@ let g:airline_powerline_fonts=1
" vim-markdown
let g:vim_markdown_new_list_item_indent=0
let g:vim_markdown_conceal=1
let g:vim_markdown_conceal=0
let g:vim_markdown_conceal_code_blocks=0
let g:vim_markdown_math=1
let g:vim_markdown_folding_disabled=0
let g:vim_markdown_math=0
" markdown preview
@@ -397,6 +391,7 @@ endfunction
nmap <silent> K :call <SID>show_documentation()<CR>
let g:coc_node_path = '/usr/bin/node'
let g:fzf_preview_command = 'bat --color=always --plain {-1}' " Installed bat
let g:fzf_preview_grep_cmd = 'rg --smart-case --line-number --no-heading --color=never'
" vim asterisk
let g:asterisk#keeppos = 1
@@ -481,44 +476,6 @@ endif
" 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 ttymouse=xterm2
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 wildignorecase
@@ -528,7 +485,6 @@ set scrolloff=3 " Minumum lines to keep above and below cursor
set nowrap " Do not wrap long lines
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 ruler " Show the ruler
@@ -538,13 +494,8 @@ 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
" 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:↶
@@ -567,45 +518,10 @@ 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
set nobackup
set noswapfile
set nowritebackup
" 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
"set background=dark " Assume dark background
set cursorline " Highlight current line
set fileformats=unix,dos,mac " Use Unix as the standard file type
set number " Line numbers on
@@ -614,12 +530,8 @@ set fillchars=vert:│,stl:\ ,stlnc:\
" 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
@@ -627,132 +539,39 @@ else
set clipboard+=unnamed
endif
if get(g:, 'vim_better_default_persistent_undo', 1)
if has('persistent_undo')
set undofile " Persistent undo
set undolevels=500 " Maximum number of changes that can be undone
set undoreload=5000 " Maximum number lines to save for undo on a buffer reload
endif
endif
set undofile " Persistent undo
set undolevels=500 " Maximum number of changes that can be undone
set undoreload=5000 " Maximum number lines to save for undo on a buffer reload
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
if get(g:, 'vim_better_default_key_mapping', 1)
" Basic {
if get(g:, 'vim_better_default_basic_key_mapping', 1)
" Insert mode shortcut
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
inoremap <C-b> <BS>
" 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>
" 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$
" Open shell in vim
if has('nvim') || has('terminal')
map <Leader>' :terminal<CR>
else
map <Leader>' :shell<CR>
endif
endif
" }
" Buffer {
if get(g:, 'vim_better_default_buffer_key_mapping', 0)
nnoremap <Leader>bp :bprevious<CR>
nnoremap <Leader>bn :bnext<CR>
nnoremap <Leader>bf :bfirst<CR>
nnoremap <Leader>bl :blast<CR>
nnoremap <Leader>bd :bp<bar>sp<bar>bn<bar>bd<cr>
nnoremap <Leader>bk :bw<CR>
endif
" }
" File {
if get(g:, 'vim_better_default_file_key_mapping', 0)
" File save
nnoremap <Leader>fs :update<CR>
endif
" }
" Fold {
if get(g:, 'vim_better_default_fold_key_mapping', 0)
nnoremap <Leader>f0 :set foldlevel=0<CR>
nnoremap <Leader>f1 :set foldlevel=1<CR>
nnoremap <Leader>f2 :set foldlevel=2<CR>
nnoremap <Leader>f3 :set foldlevel=3<CR>
nnoremap <Leader>f4 :set foldlevel=4<CR>
nnoremap <Leader>f5 :set foldlevel=5<CR>
nnoremap <Leader>f6 :set foldlevel=6<CR>
nnoremap <Leader>f7 :set foldlevel=7<CR>
nnoremap <Leader>f8 :set foldlevel=8<CR>
nnoremap <Leader>f9 :set foldlevel=9<CR>
endif
" }
" Window {
if get(g:, 'vim_better_default_window_key_mapping', 1)
" resize
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>w<BAR> <C-W><BAR>
nnoremap <Leader>w- <C-W>_
nnoremap <Leader>wg :Goyo<cr>
" move
nnoremap <Leader>H <C-W>H
nnoremap <Leader>L <C-W>L
nnoremap <Leader>J <C-W>J
nnoremap <Leader>K <C-W>K
" rotate
nnoremap <Leader>wr <C-W>r
nnoremap <Leader>wR <C-W>R
nnoremap <Leader>wx <C-W>x
" tabs
nnoremap <Leader>wo <C-W>o
endif
" }
endif
let &cpo = s:save_cpo
unlet s:save_cpo
" Insert mode shortcut
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
inoremap <C-b> <BS>
" 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>
" Quit visual mode
vnoremap v <Esc>
" Move to the start of line
nmap H ^
" Move to the end of line
nmap L $
" Quick command mode
nmap <CR> :
" In the quickfix window, <CR> is used to jump to the error under the
" cursor, so undefine the mapping there.
autocmd BufReadPost quickfix nmap <buffer> <CR> <CR>
" Open shell in vim
map <Leader>' :terminal<CR>