dotfiles/.vimrc
Patrick Wadström bc2f2a0e1c
Latest from work
2023-02-11 19:51:08 +01:00

162 lines
3.5 KiB
VimL

" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'sickill/vim-monokai'
Plug 'airblade/vim-gitgutter'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'udalov/kotlin-vim'
Plug 'rust-lang/rust.vim'
Plug 'zivyangll/git-blame.vim'
Plug 'mfukar/robotframework-vim'
Plug 'dense-analysis/ale'
Plug 'arcticicestudio/nord-vim'
" Initialize plugin system
call plug#end()
" Coloring
syntax enable
colorscheme nord
" Airline
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
let g:airline_theme='nord'
" -- Buffer/Window Workflow
" Allow hidden buffers
set hidden
" Line numbers
set number
" Marker line at col 80
set cc=80
" Stop mouse from selecting numbers
set mouse=a
" Show tab characters
set list
set listchars=tab:▒░,trail:▓
" Space-indentation please
set expandtab
set shiftwidth=4
set tabstop=4
autocmd FileType typescript setlocal shiftwidth=2 softtabstop=2 expandtab
autocmd FileType typescriptreact setlocal shiftwidth=2 softtabstop=2 expandtab
" Default to UTF-8 encoding
set encoding=utf-8
" Some languages have different indentation preferences. Try to use them.
filetype plugin indent on
" Don't try to be Vi compatible. Just stick to Vim!
set nocompatible
" Allow backspace to always work, across linebreaks/indentation etc.
set backspace=indent,eol,start
" Blink matching bracket
set showmatch
" We never use octals, but we do use zero-prefixed numbers.
set nrformats-=octal
" We are fast, don't get stuck in an old aborted command
set ttimeout
set ttimeoutlen=50
" Always retain the status line
set laststatus=2
" Enable ruler to show column position
set ruler
" Retain last command in command line
set showcmd
" Give me a menu for completion in the command line
set wildmenu
" Stop asking me, just reload the changed file!
set autoread
" Don't litter backup files. Don't do swaps (we're not that paranoid)
set nobackup
set nowritebackup
set noswapfile
" Check for file endings
set fileformats=unix,dos
" Quicky to exit insert mode
inoremap <C-c> <Esc>
" Smartcase search
set ignorecase
set smartcase
" Incremental search
set incsearch
" Highlight search
set hlsearch
" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<CR><C-L>
endif
"
" Plugins config
"
" Ripgrep FZF
function! RipgrepFzf(query, fullscreen)
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true'
let initial_command = printf(command_fmt, shellescape(a:query))
let reload_command = printf(command_fmt, '{q}')
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
endfunction
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
" FZF
nnoremap <C-p> :Files<Cr>
nnoremap <C-j> :Buffers<Cr>
" Tabs
nnoremap <Tab> :tabnext<CR>
nnoremap <S-Tab> :tabprevious<CR>
" Rust
let g:rustfmt_autosave = 1
" Git Blame
nnoremap <C-b> :<C-u>call gitblame#echo()<CR>
" JSX
let g:jsx_ext_required = 0
" this machine config
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif
" CTags
set tags+=.tags " We like hidden files
let g:fzf_tags_command = 'ctags -R -f .tags --exclude=@.ctagsignore'
" ALE
highlight ALEWarning ctermbg=DarkGrey