This repository has been archived on 2024-09-01. You can view files and clone it, but cannot push or open issues or pull requests.
al-skel/base/.vimrc

134 lines
3.8 KiB
VimL
Raw Normal View History

2018-05-13 17:21:50 -05:00
" Sane vim defaults for ArchLabs
scriptencoding utf8
2018-05-13 17:21:50 -05:00
" Arch defaults
runtime! archlinux.vim
2019-08-18 02:50:07 -05:00
" create the backup and undo directories
silent! call mkdir($HOME.'/.config/nvim/undo', 'p')
silent! call mkdir($HOME.'/.config/nvim/backup', 'p')
2019-03-03 17:25:39 -06:00
" leader key
let g:mapleader = "\<Space>"
syntax enable
2019-08-18 02:50:07 -05:00
set clipboard^=unnamed,unnamedplus " system clipboard (requires +clipboard)
set number " enable line numbers
set backup " create backup files in runtimepath/backup/
set undofile " persistent undo files in runtimepath/undo/
set modeline " enable vim modelines
set hlsearch " highlight search items
set incsearch " searches are performed as you type
set confirm " ask confirmation like save before quit.
set tabstop=4 " tab is equivalent to how many spaces
set softtabstop=4 " tab is equivalent to how many spaces
set shiftwidth=4 " amount of spaces for indentation
set shortmess+=aAcws " hide or shorten certain messages
set wildmenu " tab completion menu in command mode
2019-03-03 17:25:39 -06:00
set linebreak breakindent
set list listchars=tab:>>,trail:~
2019-08-18 02:50:07 -05:00
set wildignore+=*~,*.pyc,*/.git/*,*.so,*.swp,*.o,*.zip,*.zwc,*.png,*.jpg
2019-03-03 17:25:39 -06:00
set mouse=niv " use the terminal mouse in command mode (:)
2019-08-18 02:50:07 -05:00
if has('mouse_sgr') " sgr mouse is better but not every term supports it
2019-03-03 17:25:39 -06:00
set ttymouse=sgr
endif
2018-07-15 00:11:15 -05:00
let g:netrw_altv = 1
let g:netrw_liststyle = 3
let g:netrw_browse_split = 3
2019-03-03 17:25:39 -06:00
if $TERM !=? 'linux'
set termguicolors
if has('multi_byte') && $TERM !=? 'linux'
set list listchars=tab:▏\ ,extends:,precedes:
set fillchars=vert:┃ showbreak=
endif
endif
2019-03-03 17:25:39 -06:00
" set the colorscheme variant.. midnight, night, or day
2019-03-02 21:41:03 -06:00
let g:jinx_theme = 'midnight'
try
2019-03-03 17:25:39 -06:00
colorscheme jinx
catch
2019-03-03 17:25:39 -06:00
colorscheme evening
endtry
2018-08-18 15:16:42 -05:00
" change cursor shape for different editing modes, neovim does this by default
2018-07-15 00:11:15 -05:00
if !has('nvim')
2019-03-03 17:25:39 -06:00
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\e[5 q\<Esc>\\"
let &t_SR = "\<Esc>Ptmux;\<Esc>\e[4 q\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\e[2 q\<Esc>\\"
elseif $TERM ==# 'linux'
let &t_SI = "\e[?0c"
let &t_EI = "\e[?8c"
else
let &t_SI = "\e[6 q"
let &t_SR = "\e[4 q"
let &t_EI = "\e[2 q"
endif
endif
2018-08-18 15:16:42 -05:00
" ------ commands ------
command! D Explore
2019-03-03 17:25:39 -06:00
command! W exec 'silent w !sudo tee % >/dev/null'|edit!
2018-08-18 15:16:42 -05:00
2018-06-16 21:09:51 -05:00
" ------ basic maps ------
2018-05-13 17:21:50 -05:00
" alt defaults
nnoremap 0 ^
nnoremap Y y$
nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap <Tab> ==1j
2019-03-03 17:25:39 -06:00
vnoremap <Tab> ==
" gj/k but preserve numbered jumps ie: 12j or 45k
nmap <buffer><silent><expr>j v:count ? 'j' : 'gj'
nmap <buffer><silent><expr>k v:count ? 'k' : 'gk'
2019-03-03 17:25:39 -06:00
" toggle folding
nnoremap <leader>za :set foldenable!<CR>
" fix syntax highlighting issues
nnoremap U :syntax sync fromstart<CR>:redraw!<CR>
2018-06-16 21:09:51 -05:00
" ------ autocmd ------
2019-03-03 17:25:39 -06:00
" when quitting a file save the cursor position and reload if file changed
augroup load_changed_file
2019-03-03 17:25:39 -06:00
autocmd!
autocmd BufReadPost * call setpos(".", getpos("'\""))
autocmd FocusGained,BufEnter * if mode() !=? 'c' | checktime | endif
autocmd FileChangedShellPost * echo "Changes loaded from source file"
augroup END
2019-03-03 17:25:39 -06:00
" make the built-in terminal behave a bit better
if has('nvim')
augroup open_terminal
autocmd!
autocmd TermOpen * setlocal nonumber norelativenumber modifiable | startinsert
autocmd TermClose * buffer #
augroup END
elseif has('terminal')
augroup open_terminal
autocmd!
autocmd TerminalOpen * setlocal nonumber norelativenumber
augroup END
endif
2018-06-16 21:09:51 -05:00
2019-03-03 17:25:39 -06:00
" when not running in a linux console toggle some things when in insert mode
if $TERM !=# 'linux'
augroup active_cursorline
autocmd!
autocmd InsertEnter * setlocal cursorline listchars-=trail:•
autocmd InsertLeave * setlocal nocursorline listchars+=trail:•
augroup END
else
" otherwise disable cursorline
set nocursorline
2018-08-18 15:16:42 -05:00
endif