summaryrefslogblamecommitdiff
path: root/.vimrc
blob: b84dcbec23e6f0fc8643a027e29f19d54f94b095 (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                                        
 
                                        





                                                          



                                                   
                                                           

                          






                                                                                           



                                            
















                                                                                               
 



                                                               
                     
 

                               





                                                                                                 
" in insert mode tab key autocompletes
function! TabOrComplete()
	let line = getline('.')
	let col = col('.')
	if col > 1 && strpart(line, col - 2, 3) =~ '^\w'
		return "\<C-N>"
	else
		return "\<Tab>"
	endif
endfunction

inoremap <Tab> <C-R>=TabOrComplete()<CR>

" only do this if autocommands enabled
if has("autocmd")
	" enable file type detection and load indent files
	filetype plugin indent on

	" line numbering toggle
	autocmd InsertEnter * :set norelativenumber
	autocmd InsertLeave * :set relativenumber

	" at startup, jump to last cursor position if valid
	augroup vimStartup
		au!
		autocmd BufReadPost *
		\ 	if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
		\ 	| exe "normal! g`\""
		\ 	| endif
	augroup END
endif

" in normal mode tab key cycles through tabs
nnoremap <Tab> :tabnext<CR>
nnoremap <S-Tab> :tabprev<CR>

" display
set display=truncate 		    " show @@@ in the last line if it is truncated
set number						" enable line numbering
set relativenumber				" relative line numbering
set ruler						" show the cursor position all the time
set scrolloff=5					" show a few lines around the cursor
set showcmd						" display incomplete commands
set showtabline=2				" always show tab bar
set wrap linebreak				" break on words not chars

" editing
set backspace=indent,eol,start 	" backspace over everything in insert
set shiftwidth=4 				" 4-space shiftwidth
set softtabstop=4 				" 4-space tabs
set tabstop=4 					" 4-space tabs
set ttimeout 					" time out for key codes
set ttimeoutlen=100 			" wait up to 100ms after esc for special key

" startup
set directory=~/.vim/swapfiles//,/tmp// " common swap directory

" no bars for vertical split
set fillchars+=vert:\

" switch syntax highlighting on
syntax enable

" ale
let g:ale_fix_on_save = 1
let g:ale_linters = { 'rust': [ 'analyzer' ] }
let g:ale_fixers = { 'rust': [ 'rustfmt' ], '*': [ 'trim_whitespace', 'remove_trailing_lines' ] }
let g:ale_rust_analyzer_config = { 'check': { 'command': 'clippy' } }