From 5e340d1451cf295edc900270c52daee5dbe4a166 Mon Sep 17 00:00:00 2001 From: TiagoRG Date: Tue, 5 Mar 2024 18:47:56 +0000 Subject: [PATCH] Setup update Signed-off-by: TiagoRG --- .config/nvim/data/colorscheme.txt | 2 +- .config/nvim/snippets/java.snippets | 297 ++++++++++++++++++++++++++++ setup.sh | 25 ++- 3 files changed, 316 insertions(+), 8 deletions(-) create mode 100644 .config/nvim/snippets/java.snippets diff --git a/.config/nvim/data/colorscheme.txt b/.config/nvim/data/colorscheme.txt index 8c32236..3b15296 100644 --- a/.config/nvim/data/colorscheme.txt +++ b/.config/nvim/data/colorscheme.txt @@ -1 +1 @@ -vscode \ No newline at end of file +onedark \ No newline at end of file diff --git a/.config/nvim/snippets/java.snippets b/.config/nvim/snippets/java.snippets new file mode 100644 index 0000000..d3e6968 --- /dev/null +++ b/.config/nvim/snippets/java.snippets @@ -0,0 +1,297 @@ +## Access Modifiers +snippet po + protected ${0} +snippet pu + public ${0} +snippet pr + private ${0} +## +## Annotations +snippet before + @Before + static void ${1:intercept}(${2:args}) { ${0} } +snippet mm + @ManyToMany + ${0} +snippet mo + @ManyToOne + ${0} +snippet om + @OneToMany${1:(cascade=CascadeType.ALL)} + ${0} +snippet oo + @OneToOne + ${1} +## +## Basic Java packages and import +snippet im + import ${0} +snippet j.b + java.beans. +snippet j.i + java.io. +snippet j.m + java.math. +snippet j.n + java.net. +snippet j.u + java.util. +## +## Class +snippet cl + class ${1:`vim_snippets#Filename("$1", "untitled")`} ${0} +snippet pcl + public class ${1:`vim_snippets#Filename("$1", "untitled")`} ${0} +snippet in + interface ${1:`vim_snippets#Filename("$1", "untitled")`} ${2:extends Parent} +snippet tc + public class ${1:`vim_snippets#Filename("$1")`} extends ${0:TestCase} +## +## Class Enhancements +snippet ext + extends ${0} +snippet imp + implements ${0} +## +## Comments +snippet /* + /* + * ${0} + */ +## +## Constants +snippet co + static public final ${1:String} ${2:var} = ${3}; +snippet cos + static public final String ${1:var} = "${2}"; +## +## Control Statements +snippet case + case ${1}: + ${0} +snippet def + default: + ${0} +snippet el + else +snippet eif + else if (${1}) ${0} +snippet if + if (${1}) ${0} +snippet sw + switch (${1}) { + ${0} + } +## +## Create a Method +snippet m + ${1:void} ${2:method}(${3}) ${4:throws } +## +## Create a Variable +snippet v + ${1:String} ${2:var}${3: = null}${4}; +## +## Declaration for ArrayList +snippet d.al + List<${1:Object}> ${2:list} = new ArrayList<$1>();${0} +## Declaration for HashMap +snippet d.hm + Map<${1:Object}, ${2:Object}> ${3:map} = new HashMap<$1, $2>();${0} +## Declaration for HashSet +snippet d.hs + Set<${1:Object}> ${2:set} = new HashSet<$1>();${0} +## Declaration for Stack +snippet d.st + Stack<${1:Object}> ${2:stack} = new Stack<$1>();${0} +## +## Singleton Pattern +snippet singlet + private static class Holder { + private static final ${1:`vim_snippets#Filename("$1")`} INSTANCE = new $1(); + } + + private $1() { } + + public static $1 getInstance() { + return Holder.INSTANCE; + } +## +## Enhancements to Methods, variables, classes, etc. +snippet ab + abstract ${0} +snippet fi + final ${0} +snippet st + static ${0} +snippet sy + synchronized ${0} +## +## Error Methods +snippet err + System.err.print("${0:Message}"); +snippet errf + System.err.printf("${1:Message}", ${0:exception}); +snippet errln + System.err.println("${0:Message}"); +## +## Exception Handling +snippet as + assert ${1:test} : "${2:Failure message}"; +snippet ae + assertEquals("${1:Failure message}", ${2:expected}, ${3:actual}); +snippet aae + assertArrayEquals("${1:Failure message}", ${2:expecteds}, ${3:actuals}); +snippet af + assertFalse("${1:Failure message}", $2); +snippet at + assertTrue("${1:Failure message}", $2); +snippet an + assertNull("${1:Failure message}", ${2:object}); +snippet ann + assertNotNull("${1:Failure message}", ${2:object}); +snippet ass + assertSame("${1:Failure message}", ${2:expected}, ${3:actual}); +snippet asns + assertNotSame("${1:Failure message}", ${2:expected}, ${3:actual}); +snippet fa + fail("${1:Failure message}"); +snippet ca + catch(${1:Exception} ${2:e}) ${0} +snippet thr + throw ${0} +snippet ths + throws ${0} +snippet try + try { + ${0:${VISUAL}} + } catch(${1:Exception} ${2:e}) { + } +snippet tryf + try { + ${0:${VISUAL}} + } catch(${1:Exception} ${2:e}) { + } finally { + } +## +## Find Methods +snippet findall + List<${1:listName}> ${2:items} = $1.findAll(); +snippet findbyid + ${1:var} ${2:item} = $1.findById(${3}); +## +## Javadocs +snippet /** + /** + * ${0} + */ +snippet @au + @author `system("grep \`id -un\` /etc/passwd | cut -d \":\" -f5 | cut -d \",\" -f1")` +snippet @br + @brief ${0:Description} +snippet @fi + @file ${0:`vim_snippets#Filename("$1")`}.java +snippet @pa + @param ${0:param} +snippet @re + @return ${0:param} +## +## Logger Methods +snippet debug + Logger.debug(${1:param}); +snippet error + Logger.error(${1:param}); +snippet info + Logger.info(${1:param}); +snippet warn + Logger.warn(${1:param}); +## +## Loops +snippet enfor + for (${1} : ${2}) ${0} +snippet for + for (${1}; ${2}; ${3}) ${0} +snippet wh + while (${1:true}) ${0} +snippet wht + while (true) ${0} +## +## Main method +snippet psvm + public static void main (String[] args) { + ${0} + } +snippet main + public static void main (String[] args) { + ${0} + } +## +## Print Methods +snippet sout + System.out.println(${0}); +snippet serr + System.err.println(${0}); +snippet print + System.out.print("${0:Message}"); +snippet printf + System.out.printf("${1:Message}", ${0:args}); +snippet println + System.out.println(${0}); +snippet printlna + System.out.println(Arrays.toString(${0})); +## +## Render Methods +snippet ren + render(${1:param}); +snippet rena + renderArgs.put("${1}", ${2}); +snippet renb + renderBinary(${1:param}); +snippet renj + renderJSON(${1:param}); +snippet renx + renderXml(${1:param}); +## +## Setter and Getter Methods +snippet set + ${1:public} void set${3:}(${2:String} ${0:}){ + this.$4 = $4; + } +snippet get + ${1:public} ${2:String} get${3:}(){ + return this.${0:}; + } +## +## Terminate Methods or Loops +snippet re + return ${0} +snippet br + break; +## +## Test Methods +snippet t + public void test${1:Name}() throws Exception { + ${0} + } +snippet test + @Test + public void test${1:Name}() throws Exception { + ${0} + } +## +## Utils +snippet Sc + Scanner +## +## Miscellaneous +snippet action + public static void ${1:index}(${2:args}) { ${0} } +snippet rnf + notFound(${1:param}); +snippet rnfin + notFoundIfNull(${1:param}); +snippet rr + redirect(${1:param}); +snippet ru + unauthorized(${1:param}); +snippet unless + (unless=${1:param}); diff --git a/setup.sh b/setup.sh index 1b61930..7ffbb02 100644 --- a/setup.sh +++ b/setup.sh @@ -1,15 +1,25 @@ #!/bin/bash +# Save current directory +ORIGIN_DIR=$(pwd) +cd "$HOME" || exit + +# Install yay +git clone https://aur.archlinux.org/yay.git /tmp/yay +cd /tmp/yay || exit +makepkg -si --noconfirm +sudo pacman -U yay-*.pkg.tar.zst --noconfirm +cd "$OLDPWD" || exit + # Install the required packages # print in green echo -e "\e[32m$1\e[0mInstalling the required packages" -sudo pacman -Sy stow vim neovim zsh git clang nodejs npm --noconfirm +sudo yay -S stow vim neovim zsh git clang nodejs npm zoxide pfetch --noconfirm # Clone the dotfiles if it's not the current directory if [ "$(pwd)" != "$HOME/.dotfiles" ]; then echo -e "\e[32m$1\e[0mCloning the dotfiles repository" git clone "https://github.com/TiagoRG/.dotfiles.git" "$HOME/.dotfiles" - cd "$HOME/.dotfiles" || exit fi # Setup Vim @@ -20,18 +30,16 @@ curl -fLo "$HOME/.dotfiles/.vim/autoload/onedark.vim" --create-dirs "https://raw echo -e "\e[32m$1\e[0mInstalling Copilot" git clone "https://github.com/github/copilot.vim.git" "$HOME/.dotfiles/.vim/pack/github/start/copilot.vim" echo -e "\e[32m$1\e[0mSetting up Copilot" -stow -d "$HOME/.dotfiles" "$HOME" +stow -d .dotfiles . /bin/vim -c 'Copilot setup' -c 'qa!' # Setup Neovim echo -e "\e[32m$1\e[0mSetting up Neovim" echo -e "\e[32m$1\e[0mInstalling Packer" git clone --depth 1 "https://github.com/wbthomason/packer.nvim" "$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim" -cd "$HOME/.dotfiles/.config/nvim" || exit +stow -d .dotfiles . echo -e "\e[32m$1\e[0mInstalling Plugins" -stow -d "$HOME/.dotfiles" "$HOME" -/bin/nvim --headless -c 'source lua/tiagorg/packer.lua' -c 'PackerSync' -c 'qa!' -cd "$OLDPWD" || exit +/bin/nvim --headless -c 'source /home/tiagorg/.dotfiles/.config/nvim/lua/tiagorg/packer.lua' -c 'PackerSync' -c 'qa!' # Setup zsh echo -e "\e[32m$1\e[0mSetting up zsh" @@ -41,3 +49,6 @@ git clone "https://github.com/zsh-users/zsh-autosuggestions.git" "$HOME/.dotfile echo -e "\e[32m$1\e[0mInstalling zsh-syntax-highlighting" git clone "https://github.com/zsh-users/zsh-syntax-highlighting.git" "$HOME/.dotfiles/.zsh/zsh-syntax-highlighting" +# Restore the original directory +cd "$ORIGIN_DIR" || exit +