From ba571b66dba9a0a592aaeb8f816c0867ab2c3f5c Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Sat, 5 Nov 2022 12:53:26 -0400 Subject: [PATCH] feat: NVIM common config and setup --- README.md | 1 + extras.vim | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup | 23 +++++++++++++++++--- 3 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 extras.vim diff --git a/README.md b/README.md index 8dd6320..8d96d94 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ env/ setup # Adds bootstrap block to your shell's config file. source/ ... # Anything here is sourced on shell-start + extras.vim # Common config for NVIM ``` Adding files to `source/` will add code that gets executed on shell-start. Files are discovered by globbing in the diff --git a/extras.vim b/extras.vim new file mode 100644 index 0000000..715c00d --- /dev/null +++ b/extras.vim @@ -0,0 +1,61 @@ +" Shared configuration for NVIM. + +"""""""""" +" Misc " +"""""""""" + +set number +syntax on +set tabstop=4 +set shiftwidth=4 +set expandtab +set ignorecase +set cursorline +set cursorcolumn +set textwidth=120 +set wrap linebreak +set termguicolors + +""""""""""" +" Plugins " +""""""""""" + +call plug#begin('~/.vim/plugged') +" Style +Plug 'joshdick/onedark.vim' + +" Language support +Plug 'maxmellon/vim-jsx-pretty' +Plug 'leafgarland/typescript-vim' + +" Git things +Plug 'airblade/vim-gitgutter' +Plug 'nvim-lua/plenary.nvim' +Plug 'vim-airline/vim-airline' + +Plug 'HerringtonDarkholme/yats.vim' +Plug 'tpope/vim-fugitive' + +" Search +Plug 'nvim-telescope/telescope.nvim' +Plug 'nvim-telescope/telescope-symbols.nvim' + +" Patched for support Yarn Berry. +Plug 'mcataford/ale' + +Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} + +call plug#end() + +"""""""""""""""" +" Key bindings " +"""""""""""""""" + +let mapleader=" " + +nmap f Telescope live_grep +nmap F Telescope grep_string + +colorscheme onedark + + diff --git a/setup b/setup index 8419102..8731532 100644 --- a/setup +++ b/setup @@ -5,6 +5,8 @@ # block to its configuration to source extra files on shell-start. # +BLOCK_DELIMITER_PATTERN="mcataford/env-managed-block" + SHELL_CONFIG_PATH="" if [[ -n $(echo $SHELL | grep zsh) ]]; then @@ -13,8 +15,23 @@ else SHELL_CONFIG_PATH="$HOME/.bashrc" fi -if [[ -z $(cat $SHELL_CONFIG_PATH | grep 'mcataford/env-managed-block') ]]; then - echo '# mcataford/env-managed-block:start +if [[ -z $(cat $SHELL_CONFIG_PATH | grep $BLOCK_DELIMITER_PATTERN) ]]; then + echo "# $BLOCK_DELIMITER_PATTERN:start for f in ~/.env_goodies/source/*; do source $f; done -# mcataford/env-managed-block:end' >> $SHELL_CONFIG_PATH +# $BLOCK_DELIMITER_PATTERN:end" >> $SHELL_CONFIG_PATH +fi + +EDITOR_CONFIG=$HOME/.config/nvim +EDITOR_CONFIG_FILE=$EDITOR_CONFIG/init.vim + +if [[ -f $EDITOR_CONFIG_FILE ]]; then + if [[ -z $(cat $EDITOR_CONFIG_FILE | grep $BLOCK_DELIMITER_PATTERN) ]]; then + echo "\" $BLOCK_DELIMITER_PATTERN:start +source $HOME/.env_goodies/extras.vim +\" $BLOCK_DELIMITER_PATTERN:end\n\n" >> $EDITOR_CONFIG_FILE.new + cat $EDITOR_CONFIG_FILE >> $EDITOR_CONFIG_FILE.new + + mv $EDITOR_CONFIG_FILE $EDITOR_CONFIG_FILE.old + mv $EDITOR_CONFIG_FILE.new $EDITOR_CONFIG_FILE + fi fi