From b7f9724436c81154997f6737d0cc4896dc119332 Mon Sep 17 00:00:00 2001 From: Max Richter Date: Sat, 7 Nov 2020 16:40:23 +0100 Subject: [PATCH] feat: add install script for remote exec --- .bashrc | 5 + .zshrc | 8 +- install.sh | 28 +++++ install/nvim-config.sh | 2 + nvim/init.vim | 239 +++++++++++++++++++++++++++++++++++++++++ nvim/install-config.sh | 45 ++++++++ setup.sh | 17 ++- 7 files changed, 339 insertions(+), 5 deletions(-) create mode 100644 install.sh create mode 100644 install/nvim-config.sh create mode 100644 nvim/init.vim create mode 100644 nvim/install-config.sh diff --git a/.bashrc b/.bashrc index 09500f5..89b93b7 100644 --- a/.bashrc +++ b/.bashrc @@ -115,3 +115,8 @@ fi export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +alias vim='nvim' +alias vim='nvim' +alias vim='nvim' +alias vim='nvim' +alias vim='nvim' diff --git a/.zshrc b/.zshrc index d4dff3d..d343294 100644 --- a/.zshrc +++ b/.zshrc @@ -37,7 +37,7 @@ export PATH="$PATH:$HOME/go/bin" eval "$(direnv hook zsh)" -#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!! +#Java version manager export SDKMAN_DIR="$HOME/.sdkman" [[ -s "$HOME/jim/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh" @@ -45,4 +45,8 @@ export SDKMAN_DIR="$HOME/.sdkman" [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh # Go version manager -[[ -s "/$HOME/.gvm/scripts/gvm" ]] && source "/$HOME/.gvm/scripts/gvm" \ No newline at end of file +[[ -s "/$HOME/.gvm/scripts/gvm" ]] && source "/$HOME/.gvm/scripts/gvm" + +# Node Version manager +export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..d607b4f --- /dev/null +++ b/install.sh @@ -0,0 +1,28 @@ +function isInstalled(){ + if [ "$(which $1)" != "" ]; then + return 0; + fi + return 1; +} + +function install { + # Check if program is already installed + if isInstalled $1; then + echo " - $1 is already installed" + else + echo " - installing $1 ..." + apt-get install $1 -y > /dev/null + echo " - finished" + fi +} + +#Prerequesits +echo "-- Installing prerequisites --" +install git + +echo "-- Cloning repo --" +git clone git@github.com:jim-fx/.dotfiles.git ~/.dotfiles + +echo "-- starting script --" +chmod +x ~/.dotfiles/setup.sh +~/.dotfiles/setup.sh \ No newline at end of file diff --git a/install/nvim-config.sh b/install/nvim-config.sh new file mode 100644 index 0000000..2146ccd --- /dev/null +++ b/install/nvim-config.sh @@ -0,0 +1,2 @@ +echo " - cloning github.com/rafi/vim-config.git to /temp/nvim-config/" +git clone --quiet git@github.com:Optixal/neovim-init.vim.git ~/.config/nvim \ No newline at end of file diff --git a/nvim/init.vim b/nvim/init.vim new file mode 100644 index 0000000..8c4671e --- /dev/null +++ b/nvim/init.vim @@ -0,0 +1,239 @@ +""" Optixal's Neovim Init.vim + +""" Vim-Plug +call plug#begin() + +" Aesthetics - Main +Plug 'dracula/vim', { 'commit': '147f389f4275cec4ef43ebc25e2011c57b45cc00' } +Plug 'vim-airline/vim-airline' +Plug 'vim-airline/vim-airline-themes' +Plug 'ryanoasis/vim-devicons' +Plug 'junegunn/goyo.vim' +Plug 'junegunn/limelight.vim' +Plug 'junegunn/seoul256.vim' +Plug 'junegunn/vim-journal' +Plug 'junegunn/rainbow_parentheses.vim' +Plug 'nightsense/forgotten' +Plug 'zaki/zazen' + +" Aethetics - Additional +Plug 'nightsense/nemo' +Plug 'yuttie/hydrangea-vim' +Plug 'chriskempson/tomorrow-theme', { 'rtp': 'vim' } +Plug 'rhysd/vim-color-spring-night' + +" Functionalities +Plug 'tpope/vim-fugitive' +Plug 'tpope/vim-sensible' +Plug 'tpope/vim-surround' +Plug 'majutsushi/tagbar' +Plug 'scrooloose/nerdtree' +Plug 'scrooloose/nerdcommenter' +Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } +Plug 'deoplete-plugins/deoplete-jedi' +Plug 'ervandew/supertab' +Plug 'jiangmiao/auto-pairs' +Plug 'junegunn/vim-easy-align' +Plug 'alvan/vim-closetag' +Plug 'tpope/vim-abolish' +Plug 'Yggdroot/indentLine' +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf.vim' +Plug 'sheerun/vim-polyglot' +Plug 'chrisbra/Colorizer' +Plug 'KabbAmine/vCoolor.vim' +Plug 'heavenshell/vim-pydocstring', { 'do': 'make install' } +Plug 'vim-scripts/loremipsum' +Plug 'SirVer/ultisnips' +Plug 'honza/vim-snippets' +Plug 'metakirby5/codi.vim' +Plug 'dkarter/bullets.vim' + +" Entertainment +"Plug 'ryanss/vim-hackernews' + +call plug#end() + +""" Python3 VirtualEnv +let g:python3_host_prog = '/usr/bin/python3' + +""" Coloring +syntax on +color dracula +highlight Pmenu guibg=white guifg=black gui=bold +highlight Comment gui=bold +highlight Normal gui=none +highlight NonText guibg=none + +" Opaque Background (Comment out to use terminal's profile) +set termguicolors + +" Transparent Background (For i3 and compton) +highlight Normal guibg=NONE ctermbg=NONE +highlight LineNr guibg=NONE ctermbg=NONE + +""" Other Configurations +filetype plugin indent on +set tabstop=4 softtabstop=4 shiftwidth=4 expandtab smarttab autoindent +set incsearch ignorecase smartcase hlsearch +set ruler laststatus=2 showcmd showmode +set list listchars=trail:»,tab:»- +set fillchars+=vert:\ +set wrap breakindent +set encoding=utf-8 +set number +set title + +""" Plugin Configurations + +" NERDTree +let NERDTreeShowHidden=1 +let g:NERDTreeDirArrowExpandable = '↠' +let g:NERDTreeDirArrowCollapsible = '↡' + +" Airline +let g:airline_powerline_fonts = 1 +let g:airline_section_z = ' %{strftime("%-I:%M %p")}' +let g:airline_section_warning = '' +"let g:airline#extensions#tabline#enabled = 1 + +" Neovim :Terminal +tmap +tmap +"tmap :q +autocmd BufWinEnter,WinEnter term://* startinsert +autocmd BufLeave term://* stopinsert + +" Deoplete +let g:deoplete#enable_at_startup = 1 +" Disable documentation window +set completeopt-=preview + +" vim-pydocstring +let g:pydocstring_doq_path = '~/.config/nvim/env/bin/doq' + +" Supertab +let g:SuperTabDefaultCompletionType = "" + +" Ultisnips +let g:UltiSnipsExpandTrigger="" +let g:UltiSnipsJumpForwardTrigger="" +let g:UltiSnipsJumpBackwardTrigger="" + +" EasyAlign +xmap ga (EasyAlign) +nmap ga (EasyAlign) + +" indentLine +let g:indentLine_char = '▏' +let g:indentLine_color_gui = '#363949' + +" TagBar +let g:tagbar_width = 30 +let g:tagbar_iconchars = ['↠', '↡'] + +" fzf-vim +let g:fzf_action = { + \ 'ctrl-t': 'tab split', + \ 'ctrl-s': 'split', + \ 'ctrl-v': 'vsplit' } +let g:fzf_colors = +\ { 'fg': ['fg', 'Normal'], + \ 'bg': ['bg', 'Normal'], + \ 'hl': ['fg', 'Comment'], + \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], + \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], + \ 'hl+': ['fg', 'Statement'], + \ 'info': ['fg', 'Type'], + \ 'border': ['fg', 'Ignore'], + \ 'prompt': ['fg', 'Character'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'] } + +""" Filetype-Specific Configurations + +" HTML, XML, Jinja +autocmd FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2 +autocmd FileType css setlocal shiftwidth=2 tabstop=2 softtabstop=2 +autocmd FileType xml setlocal shiftwidth=2 tabstop=2 softtabstop=2 +autocmd FileType htmldjango setlocal shiftwidth=2 tabstop=2 softtabstop=2 +autocmd FileType htmldjango inoremap {{ {{ }} +autocmd FileType htmldjango inoremap {% {% %} +autocmd FileType htmldjango inoremap {# {# #} + +" Markdown and Journal +autocmd FileType markdown setlocal shiftwidth=2 tabstop=2 softtabstop=2 +autocmd FileType journal setlocal shiftwidth=2 tabstop=2 softtabstop=2 + +""" Custom Functions + +" Trim Whitespaces +function! TrimWhitespace() + let l:save = winsaveview() + %s/\\\@q :NERDTreeToggle +nmap \ q +nmap w :TagbarToggle +nmap ee :Colors +nmap ea :AirlineTheme +nmap e1 :call ColorDracula() +nmap e2 :call ColorSeoul256() +nmap e3 :call ColorForgotten() +nmap e4 :call ColorZazen() +nmap r :so ~/.config/nvim/init.vim +nmap t :call TrimWhitespace() +xmap a gaip* +nmap a gaip* +nmap s sj:terminal +nmap vs vl:terminal +nmap d (pydocstring) +nmap f :Files +nmap g :Goyo +nmap h :RainbowParentheses!! +nmap j :set filetype=journal +nmap k :ColorToggle +nmap l :Limelight!! +xmap l :Limelight!! +autocmd FileType python nmap x :0,$!~/.config/nvim/env/bin/python -m yapf +"nmap n :HackerNews bestJ +nmap :noh +nmap :bnext +nmap :bprevious diff --git a/nvim/install-config.sh b/nvim/install-config.sh new file mode 100644 index 0000000..6b8ee67 --- /dev/null +++ b/nvim/install-config.sh @@ -0,0 +1,45 @@ +#!/bin/bash -e +cd "$(dirname "$0")" + +# Make config directory for Neovim's init.vim +echo '[*] Preparing Neovim config directory ...' +mkdir -p ~/.config/nvim + +# Install nvim (and its dependencies: pip3, git), Python 3 and ctags (for tagbar) +echo '[*] App installing Neovim and its dependencies (Python 3 and git), and dependencies for tagbar (exuberant-ctags) ...' +sudo apt update +sudo apt install neovim python3 python3-pip python3-venv git curl exuberant-ctags -y + +# Install virtualenv to containerize dependencies +echo '[*] Pip installing venv to containerize Neovim dependencies (instead of installing them onto your system) ...' +python3 -m venv ~/.config/nvim/env + +# Install pip modules for Neovim within the virtual environment created +echo '[*] Activating virtualenv and pip installing Neovim (for Python plugin support), libraries for async autocompletion support (jedi, psutil, setproctitle), and library for pep8-style formatting (yapf) ...' +source ~/.config/nvim/env/bin/activate +pip install pynvim jedi psutil setproctitle yapf doq # run `pip uninstall neovim pynvim` if still using old neovim module +deactivate + +# Install vim-plug plugin manager +echo '[*] Downloading vim-plug, the best minimalistic vim plugin manager ...' +curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + +# (Optional but recommended) Install a nerd font for icons and a beautiful airline bar (https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts) (I'll be using Iosevka for Powerline) +echo "[*] Downloading patch font into ~/.local/share/fonts ..." +curl -fLo ~/.fonts/Iosevka\ Term\ Nerd\ Font\ Complete.ttf --create-dirs https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/Iosevka/Regular/complete/Iosevka%20Term%20Nerd%20Font%20Complete.ttf + +# (Optional) Alias vim -> nvim +echo '[*] Aliasing vim -> nvim, remember to source ~/.bashrc ...' +echo "alias vim='nvim'" >> ~/.bashrc + +# Enter Neovim and install plugins using a temporary init.vim, which avoids warnings about missing colorschemes, functions, etc +echo -e '[*] Running :PlugInstall within nvim ...' +sed '/call plug#end/q' init.vim > ~/.config/nvim/init.vim +nvim -c ':PlugInstall' -c ':UpdateRemotePlugins' -c ':qall' +rm ~/.config/nvim/init.vim + +# Copy init.vim in current working directory to nvim's config location ... +echo '[*] Linking init.vim -> ~/.config/nvim/init.vim' +cp init.vim ~/.config/nvim/ + +echo -e "[+] Done, welcome to \033[1m\033[92mNeoVim\033[0m! Try it by running: nvim/vim. Want to customize it? Modify ~/.config/nvim/init.vim" diff --git a/setup.sh b/setup.sh index f6d9f83..57cc237 100755 --- a/setup.sh +++ b/setup.sh @@ -52,6 +52,7 @@ function linkFile { echo "-- Installing prerequisites --" install git install curl +install neovim echo "-- Linking .dotfiles --" linkFile .bashrc @@ -70,7 +71,17 @@ zsh $(pwd)/install/p10k.sh install direnv +echo "-- Configuring Optixal's Neovim (https://github.com/Optixal/neovim-init.vim) --" +sh $(pwd)/nvim/install-config.sh + echo "-- Applying .zshrc --" -chsh -s $(which zsh) -export SHELL=$(which zsh) -zsh \ No newline at end of file + +if [ $SHELL != $(which zsh) ]; then + echo "- changing default shell" + chsh -s $(which zsh) + export SHELL=$(which zsh) +fi + +zsh + +cd \ No newline at end of file