134 lines
3.8 KiB
VimL
134 lines
3.8 KiB
VimL
" Sane vim defaults for ArchLabs
|
||
|
||
scriptencoding utf8
|
||
|
||
" Arch defaults
|
||
runtime! archlinux.vim
|
||
|
||
" create the backup and undo directories
|
||
silent! call mkdir($HOME.'/.config/nvim/undo', 'p')
|
||
silent! call mkdir($HOME.'/.config/nvim/backup', 'p')
|
||
|
||
" leader key
|
||
let g:mapleader = "\<Space>"
|
||
|
||
syntax enable
|
||
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
|
||
set linebreak breakindent
|
||
set list listchars=tab:>>,trail:~
|
||
set wildignore+=*~,*.pyc,*/.git/*,*.so,*.swp,*.o,*.zip,*.zwc,*.png,*.jpg
|
||
set mouse=niv " use the terminal mouse in command mode (:)
|
||
|
||
if has('mouse_sgr') " sgr mouse is better but not every term supports it
|
||
set ttymouse=sgr
|
||
endif
|
||
|
||
let g:netrw_altv = 1
|
||
let g:netrw_liststyle = 3
|
||
let g:netrw_browse_split = 3
|
||
|
||
if $TERM !=? 'linux'
|
||
set termguicolors
|
||
if has('multi_byte') && $TERM !=? 'linux'
|
||
set list listchars=tab:▏\ ,extends:❯,precedes:❮
|
||
set fillchars=vert:┃ showbreak=↪
|
||
endif
|
||
endif
|
||
|
||
" set the colorscheme variant.. midnight, night, or day
|
||
let g:jinx_theme = 'midnight'
|
||
try
|
||
colorscheme jinx
|
||
catch
|
||
colorscheme evening
|
||
endtry
|
||
|
||
" change cursor shape for different editing modes, neovim does this by default
|
||
if !has('nvim')
|
||
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
|
||
|
||
" ------ commands ------
|
||
|
||
command! D Explore
|
||
command! W exec 'silent w !sudo tee % >/dev/null'|edit!
|
||
|
||
" ------ basic maps ------
|
||
|
||
" alt defaults
|
||
nnoremap 0 ^
|
||
nnoremap Y y$
|
||
nnoremap n nzzzv
|
||
nnoremap N Nzzzv
|
||
nnoremap <Tab> ==1j
|
||
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'
|
||
|
||
" toggle folding
|
||
nnoremap <leader>za :set foldenable!<CR>
|
||
|
||
" fix syntax highlighting issues
|
||
nnoremap U :syntax sync fromstart<CR>:redraw!<CR>
|
||
|
||
" ------ autocmd ------
|
||
|
||
" when quitting a file save the cursor position and reload if file changed
|
||
augroup load_changed_file
|
||
autocmd!
|
||
autocmd BufReadPost * call setpos(".", getpos("'\""))
|
||
autocmd FocusGained,BufEnter * if mode() !=? 'c' | checktime | endif
|
||
autocmd FileChangedShellPost * echo "Changes loaded from source file"
|
||
augroup END
|
||
|
||
" 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
|
||
|
||
" 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
|
||
endif
|