Files
dotfiles/vim/vimrc

272 lines
5.7 KiB
VimL
Raw Normal View History

2013-09-18 15:07:35 +02:00
set nocompatible
filetype off
2017-09-01 20:39:05 +02:00
call plug#begin('~/.local/share/nvim/plugged')
" === plugins ===
2022-09-05 15:19:52 +02:00
function! Cond(Cond, ...)
let opts = get(a:000, 0, {})
return a:Cond ? opts : extend(opts, { 'on': [], 'for': [] })
endfunction
" editing plugins
Plug 'godlygeek/tabular', Cond(!exists('g:vscode'))
Plug 'nathanaelkane/vim-indent-guides', Cond(!exists('g:vscode'))
Plug 'tpope/vim-commentary', Cond(!exists('g:vscode'))
Plug 'airblade/vim-gitgutter', Cond(!exists('g:vscode'))
" ui
Plug 'sickill/vim-monokai', Cond(!exists('g:vscode'))
Plug 'itchyny/lightline.vim', Cond(!exists('g:vscode'))
" lang integrations
Plug 'lepture/vim-jinja', Cond(!exists('g:vscode'))
Plug 'fatih/vim-go', Cond(!exists('g:vscode'))
Plug 'hashivim/vim-terraform', Cond(!exists('g:vscode'))
Plug 'editorconfig/editorconfig-vim', Cond(!exists('g:vscode'))
Plug 'rust-lang/rust.vim', Cond(!exists('g:vscode'))
Plug 'rodjek/vim-puppet', Cond(!exists('g:vscode'))
" helpers
"" distraction free writing
Plug 'junegunn/limelight.vim', Cond(!exists('g:vscode'))
Plug 'junegunn/goyo.vim', Cond(!exists('g:vscode'))
Plug 'reedes/vim-pencil', Cond(!exists('g:vscode'))
"" markdown
Plug 'suan/vim-instant-markdown', Cond(!exists('g:vscode'))
2021-11-18 12:10:46 +01:00
2017-09-01 20:39:05 +02:00
call plug#end()
2014-09-30 19:55:51 +02:00
filetype plugin indent on
2014-04-17 19:38:16 +02:00
2015-09-26 02:46:37 +02:00
" == formatting ==
2015-09-26 01:55:47 +02:00
set tabstop=4
set smarttab
set softtabstop=4
set shiftround
set shiftwidth=4
2015-09-25 20:22:53 +02:00
set autoindent
set expandtab
2015-09-26 01:55:47 +02:00
set smartindent
2020-12-08 22:03:20 +01:00
set formatoptions=tcqjron
"set formatoptions=
2015-09-26 01:55:47 +02:00
" == ui ==
set cursorline
set showcmd
set number
set wildmode=list:longest
2015-09-25 21:19:59 +02:00
set lazyredraw
2015-09-26 01:55:47 +02:00
set wildmenu
2015-10-02 04:00:34 +02:00
set noshowmatch
2015-09-26 01:55:47 +02:00
set colorcolumn=80
set laststatus=2
2015-09-25 21:19:59 +02:00
set matchtime=5
2015-09-25 20:22:53 +02:00
set mouse=a
set mousehide
set noerrorbells
2017-09-01 20:39:05 +02:00
set noshowmode
2015-09-25 20:22:53 +02:00
set numberwidth=2
set relativenumber
2022-07-05 22:27:10 +02:00
set shortmess=rtiF
2015-09-25 20:22:53 +02:00
set ruler
set scrolloff=7
set title
set titlestring=""
set ttyfast
2015-09-26 01:55:47 +02:00
" == searching ==
set hlsearch
set incsearch
set gdefault
set ignorecase
set magic
set smartcase
" == folding ==
set foldenable
set foldmethod=indent
set foldnestmax=2
set foldlevelstart=2
" == backups ==
set nobackup
set backupcopy=no
set nowritebackup
" == swap ==
set swapfile
2015-09-25 20:22:53 +02:00
set updatecount=200
set updatetime=10000
2015-09-26 01:55:47 +02:00
" == undo ==
set undolevels=1000
set undoreload=10000
set undodir=~/.vim/undo
set undofile
" == environment / directories ==
2018-08-16 07:26:50 +02:00
set autochdir
2015-09-26 01:55:47 +02:00
set directory=/var/tmp,/tmp
2015-09-25 20:22:53 +02:00
set viewdir=~/.vim/view
2015-09-26 01:55:47 +02:00
" == misc ==
set autoread
set confirm
set encoding=utf-8
set history=1000
set modeline
set modelines=5
set notildeop
2015-09-25 20:22:53 +02:00
set wildignore=*.swp,*.bak,*.pyc,*~,*.o
2015-09-26 01:55:47 +02:00
set hidden
" == editing ==
set backspace=indent,eol,start
2017-09-01 20:39:05 +02:00
" set esckeys
2015-09-26 02:46:37 +02:00
set matchpairs=(:),{:},[:],<:>
2015-09-26 01:55:47 +02:00
set notimeout
set ttimeout
set timeoutlen=1000
set ttimeoutlen=0
set virtualedit=block
2015-10-02 04:00:34 +02:00
set whichwrap=b,s
2015-09-26 01:55:47 +02:00
" == line breaking ==
set linebreak
2015-09-25 20:22:53 +02:00
set wrap
set wrapscan
2015-09-26 01:55:47 +02:00
2022-06-30 22:05:06 +02:00
" == to use guicolors in terminal ==
set termguicolors
2015-09-26 01:55:47 +02:00
" === keybinds ===
set pastetoggle=<F11>
2017-08-09 21:54:47 +02:00
let maplocalleader = "ö"
2014-06-14 00:26:03 +02:00
let mapleader = "\<Space>"
2017-08-26 10:23:36 +02:00
" map <leader>w: w!<cr>
2015-09-25 20:22:53 +02:00
2017-08-26 10:23:36 +02:00
" nnoremap <leader>w :w<CR>
2015-09-26 01:55:47 +02:00
nmap <leader><leader> za
2014-06-14 00:26:03 +02:00
map , :
vnoremap <silent> y y`]
vnoremap <silent> p p`]
nnoremap <silent> p p`]
nnoremap <leader>, :nohlsearch<CR>
2013-09-24 18:40:40 +02:00
2014-06-14 00:26:03 +02:00
noremap gV `[v`]
2013-09-18 15:07:35 +02:00
2015-09-25 20:22:53 +02:00
map Y y$
map j gj
map k gk
2013-09-18 15:07:35 +02:00
2014-11-07 17:37:04 +01:00
2015-09-26 02:46:37 +02:00
map N Nzz
map n nzz
2014-06-14 00:26:03 +02:00
inoremap jj <ESC>
2022-09-05 15:19:52 +02:00
" no more ex mode
nnoremap Q <nop>
2014-06-14 00:26:03 +02:00
2022-09-05 15:19:52 +02:00
" Use // in visual mode to search for selection
" https://vim.fandom.com/wiki/Search_for_visually_selected_text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
2018-01-29 11:36:52 +01:00
2022-09-05 15:19:52 +02:00
if exists('g:vscode')
xmap gc <Plug>VSCodeCommentary
nmap gc <Plug>VSCodeCommentary
omap gc <Plug>VSCodeCommentary
nmap gcc <Plug>VSCodeCommentaryLine
else
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
2015-09-26 02:46:37 +02:00
2022-09-05 15:19:52 +02:00
nmap <C-n> :bnext<CR>
nmap <C-p> :bprev<CR>
2014-11-07 17:37:04 +01:00
2022-09-05 15:19:52 +02:00
nnoremap <leader>m :InstantMarkdownPreview<CR>
2021-10-03 09:51:07 +02:00
2022-09-05 15:19:52 +02:00
nnoremap <leader>u :GundoToggle<CR>
nnoremap <leader>d :diffupdate<CR>
2021-10-03 09:51:22 +02:00
2022-09-05 15:19:52 +02:00
nmap <F9> :Goyo<CR>:TogglePencil<CR>:Limelight!!<CR>
nmap <leader>w :Goyo<CR>:TogglePencil<CR>:Limelight!!<CR>
2014-06-14 00:26:03 +02:00
2022-09-05 15:19:52 +02:00
nmap <leader>c :%w !xclip -selection clipboard<CR>
nmap <leader>x :r !xclip -out -selection -clipboard<CR><CR>
nmap <leader>f :Autoformat<CR>
nnoremap <leader>v <C-w>v<C-w>l
syntax enable
silent! colorscheme monokai
let g:lightline = {
2022-06-30 22:10:17 +02:00
\ 'colorscheme': 'wombat',
2018-12-28 18:19:00 +01:00
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename', 'modified', 'helloworld' ] ],
\ 'right': [ [ 'gitbranch' ],
\ [ 'lineinfo' ],
\ [ 'percent' ],
\ [ 'fileformat', 'fileencoding', 'filetype', 'charvaluehex' ],
\ [ 'directory' ] ],
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#head',
\ 'directory': 'LightLineFilename',
\ },
\ 'component': {
\ },
2017-09-01 20:39:05 +02:00
\ }
2015-09-25 21:19:59 +02:00
2022-09-05 15:19:52 +02:00
function! LightLineFilename()
return fnamemodify(expand('%F'), ":~:h")
endfunction
2017-08-09 21:54:47 +02:00
2022-09-05 15:19:52 +02:00
" == pencil ==
let g:pencil#textwidth = 80
let g:pencil#autoformat = 1
let g:pencil#cursorwrap = 1
let g:pencil#wrapModeDefault = 'soft'
let g:pencil#cursorwrap = 0
2017-09-01 09:53:09 +02:00
2022-09-05 15:19:52 +02:00
" == goyo ==
let g:goyo_width = 100
let g:goyo_height = "90%"
let g:goyo_linenr = 0
2018-01-29 11:36:52 +01:00
2022-09-05 15:19:52 +02:00
" == limelight ==
let g:limelight_default_coefficient = 0.5
2018-08-10 17:23:37 +02:00
2022-09-05 15:19:52 +02:00
" === functions ===
function! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//e
exe "normal `z"
endfunction
autocmd BufWritePre * :call DeleteTrailingWS()
2018-08-17 21:17:00 +02:00
2022-09-05 15:19:52 +02:00
autocmd FileType yaml set shiftwidth=2
autocmd FileType toml set shiftwidth=2
autocmd FileType html setl shiftwidth=2
2019-04-14 11:54:29 +02:00
2022-09-05 15:19:52 +02:00
let g:instant_markdown_autostart = 0
2019-04-14 11:54:29 +02:00
2022-09-05 15:19:52 +02:00
let g:terraform_align = 1
let g:terraform_fmt_on_save=1
2022-09-05 15:19:52 +02:00
let g:rustfmt_autosave = 1
2020-03-31 16:25:00 +02:00
2022-09-05 15:19:52 +02:00
" https://stackoverflow.com/a/8585343
map <leader>q :bp<bar>sp<bar>bn<bar>bd<CR>
2020-03-31 16:25:00 +02:00
endif