|
#!/usr/bin/env bash |
|
[ "$USER" == "root" ] && HOME=/root |
|
|
|
function _command_exists { |
|
type -p "$1" &>/dev/null |
|
} |
|
|
|
function _install { |
|
_command_exists "$1" || ( |
|
# Debian, Ubuntu, etc |
|
_command_exists apt && sudo apt update && sudo apt install -y "$1" |
|
# Fedora, RHEL, etc |
|
_command_exists dnf && sudo dnf install -y "$1" |
|
) |
|
} |
|
|
|
function _install_plug { |
|
git clone --depth 1 "https://github.com/$1/$2" "$plugins/$2" |
|
vim -u NONE -c "helptags $plugins/$2/doc" -c q |
|
} |
|
|
|
# Install requirements |
|
_install vim |
|
_install git |
|
_install fzf |
|
_install bat |
|
|
|
# Determine if we need to use the Pathogen package manager |
|
vim --version | grep --quiet --fixed-strings +packages || use_pathogen='yes' |
|
|
|
# Cleanup previous settings |
|
rm -rf ~/.vim* |
|
|
|
# Install Pathogen (if required) |
|
if [ "$use_pathogen" ]; then |
|
mkdir -p ~/.vim/autoload |
|
wget -P ~/.vim/autoload https://raw.githubusercontent.com/tpope/vim-pathogen/master/autoload/pathogen.vim |
|
plugins=~/.vim/bundle |
|
else |
|
plugins=~/.vim/pack/plugins/start |
|
fi |
|
|
|
# Install VIM plugins |
|
mkdir -p "$plugins" |
|
_install_plug tpope vim-sensible |
|
_install_plug tpope vim-sleuth |
|
_install_plug tpope vim-vinegar |
|
_install_plug itchyny lightline.vim |
|
_install_plug mengelbrecht lightline-bufferline |
|
_install_plug Yggdroot indentLine |
|
_install_plug zigford vim-powershell |
|
_install_plug bfrg vim-cpp-modern |
|
_install_plug vim-python python-syntax |
|
_install_plug ErichDonGubler vim-sublime-monokai |
|
_command_exists fzf && ( |
|
_install_plug junegunn fzf |
|
_install_plug junegunn fzf.vim |
|
) |
|
|
|
# Configure vim |
|
if [ "$use_pathogen" ]; then |
|
echo -e '" Load plugins\nexecute pathogen#infect()\n' >~/.vimrc |
|
fi |
|
|
|
cat >>~/.vimrc <<'EOF' |
|
" Personal preferences |
|
set number |
|
set cursorline |
|
set showcmd |
|
|
|
try |
|
" Use 24-bit truecolor (https://github.com/termstandard/colors) |
|
set termguicolors |
|
catch |
|
set t_Co=256 |
|
endtry |
|
|
|
" Color scheme |
|
let g:sublimemonokai_term_italic = 1 |
|
colorscheme sublimemonokai |
|
|
|
" Spell check settings |
|
set spell |
|
set spelllang=en |
|
try |
|
let &t_Cs = "\e[4:3m" |
|
let &t_Ce = "\e[4:0m" |
|
hi SpellBad guisp=red gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl ctermul=red |
|
hi SpellCap guisp=yellow gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl ctermul=yellow |
|
catch |
|
hi SpellBad guisp=red gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl |
|
hi SpellCap guisp=yellow gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl |
|
endtry |
|
|
|
" Plugin settings |
|
let java_comment_strings=1 |
|
let java_highlight_functions=1 |
|
let java_highlight_java_lang_ids=1 |
|
let g:cpp_attributes_highlight = 1 |
|
let g:cpp_member_highlight = 1 |
|
let g:cpp_simple_highlight = 1 |
|
let g:python_highlight_all = 1 |
|
let g:indentLine_char = '▏' |
|
|
|
set showtabline=2 |
|
let g:lightline#bufferline#show_number = 1 |
|
let g:lightline#bufferline#shorten_path = 0 |
|
let g:lightline#bufferline#unnamed = '[No Name]' |
|
let g:lightline = { |
|
\ 'active': { |
|
\ 'left': [ [ 'mode', 'paste' ], [ 'readonly', 'filename', 'modified' ] ] |
|
\ }, |
|
\ 'tabline': { |
|
\ 'left': [ ['buffers'] ], |
|
\ 'right': [ ['close'] ] |
|
\ }, |
|
\ 'component_expand': { |
|
\ 'buffers': 'lightline#bufferline#buffers' |
|
\ }, |
|
\ 'component_type': { |
|
\ 'buffers': 'tabsel' |
|
\ } |
|
\ } |
|
EOF |