diff options
Diffstat (limited to '.vimrc')
-rw-r--r-- | .vimrc | 105 |
1 files changed, 40 insertions, 65 deletions
@@ -1,44 +1,28 @@ -" General options -set wrap linebreak " break on words not chars -set ruler " show the cursor position all the time -set showcmd " display incomplete commands -set ttimeout " time out for key codes -set ttimeoutlen=100 " wait up to 100ms after Esc for special key -set display=truncate " show @@@ in the last line if it is truncated -set scrolloff=5 " show a few lines around the cursor -set number -set relativenumber " relative line numbering -set tabstop=4 " 4-space tabs -set softtabstop=4 " 4-space tabs -set shiftwidth=4 " 4-space shiftwidth -set backspace=indent,eol,start " backspace over everything in insert -set directory=$HOME/.vim/swapfiles// " common swap directory -set fillchars+=vert:\ -set showtabline=2 " always show tab bar -syntax enable " switch syntax highlighting on, used to be syntax on - -" Matching and key mappings -":match ErrorMsg '\%>80v.\+' " right-hand drift warning +" 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 -" Automatically finish closing tags -augroup html_vue_hbs - au! - autocmd BufNewFile,BufRead *.php|*.html|*.vue|*.hbs :inoremap <lt>/ </<C-x><C-o><Esc>==gi - autocmd BufNewFile,BufRead *.hbs set filetype=handlebars syntax=html -augroup END +inoremap <Tab> <C-R>=TabOrComplete()<CR> " only do this if autocommands enabled if has("autocmd") - autocmd InsertEnter * :set norelativenumber - autocmd InsertLeave * :set relativenumber - " 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! - - "at startup, jump to last cursor position if valid autocmd BufReadPost * \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit' \ | exe "normal! g`\"" @@ -46,42 +30,33 @@ if has("autocmd") augroup END endif - - -if empty(glob('~/.vim/autoload/plug.vim')) - silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs - \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - autocmd VimEnter * PlugInstall --sync | source $MYVIMRC -endif - -call plug#begin('~/.vim/plugged') -Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'} -Plug 'rust-lang/rust.vim' -call plug#end() - -" rust.vim -let g:rustfmt_autosave = 1 - -" COC.VIM -"let g:coc_global_extensions = ['coc-rust-analyzer', 'coc-prettier'] - -inoremap <silent><expr> <TAB> -\ pumvisible() ? "\<C-n>" : -\ <SID>check_back_space() ? "\<TAB>" : -\ coc#refresh() -inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" - " in normal mode tab key cycles through tabs nnoremap <Tab> :tabnext<CR> nnoremap <S-Tab> :tabprev<CR> -function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction +" 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 -highlight CocFloating ctermbg=black +" startup +set directory=~/.vim/swapfiles//,/tmp// " common swap directory + +" no bars for vertical split +set fillchars+=vert:\ -" Auto-reloading scripts -autocmd BufWritePost .aliases !source ~/.aliases -autocmd BufWritePost ~/.Xresources !xrdb % +" switch syntax highlighting on +syntax enable |