diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..25be2eb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dotfiles diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..aecbe4b --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +all: sync + +sync: build + ./dotfiles + +delete: build + ./dotfiles --delete + +build: + go build diff --git a/dotfiles.go b/dotfiles.go new file mode 100644 index 0000000..2139fb4 --- /dev/null +++ b/dotfiles.go @@ -0,0 +1,57 @@ +package main + +import ( + "bytes" + "flag" + "os" + "os/exec" + + log "github.com/sirupsen/logrus" +) + +func main() { + deleteFlag := flag.Bool("delete", false, "Deletes the symlinks") + + flag.Parse() + + folders, err := os.ReadDir(".") + if err != nil { + log.WithFields(log.Fields{ + "folder": ".", + "error": err, + }).Fatal("Error reading directory") + } + + for _, dirStat := range folders { + if dirStat.Name()[0] == '.' || !dirStat.IsDir() { + continue + } + + homeDir, err := os.UserHomeDir() + if err != nil { + log.WithFields(log.Fields{"error": err}).Fatal("Error getting home directory") + } + + stowCmd := exec.Command("stow", "--verbose", "--restow", "--target", homeDir, dirStat.Name()) + + if *deleteFlag { + stowCmd.Args = []string{"stow", "-D", "--verbose", "--target", homeDir, dirStat.Name()} + } + + var out bytes.Buffer + var out2 bytes.Buffer + + stowCmd.Stdout = &out + stowCmd.Stderr = &out2 + + if err := stowCmd.Run(); err != nil { + log.WithFields(log.Fields{ + "error": err, + "directory": dirStat.Name(), + "stdout": string(out.Bytes()), + "stderr": string(out2.Bytes()), + }).Fatal("Error stowing directory") + } + log.Info(string(out2.Bytes())) + } +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..6f13e3c --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module github.com/NickyBoy89/dotfiles + +go 1.17 + +require ( + github.com/sirupsen/logrus v1.8.1 // indirect + golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..58fa35a --- /dev/null +++ b/go.sum @@ -0,0 +1,7 @@ +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/nvim/.config/nvim/UltiSnips/java.snippets b/nvim/.config/nvim/UltiSnips/java.snippets new file mode 100644 index 0000000..e36bbe9 --- /dev/null +++ b/nvim/.config/nvim/UltiSnips/java.snippets @@ -0,0 +1,3 @@ +snippet sout "Sout" b +System.out.println($1); +endsnippet diff --git a/nvim/.config/nvim/UltiSnips/tex.snippets b/nvim/.config/nvim/UltiSnips/tex.snippets new file mode 100644 index 0000000..a310bad --- /dev/null +++ b/nvim/.config/nvim/UltiSnips/tex.snippets @@ -0,0 +1,54 @@ +snippet article "WriteArticle" +\documentclass{article} + +\title{$1} +\date{$2} +\author{Nicholas Novak} + +\begin{document} +\maketitle + +$3 + +\end{document} +endsnippet + +snippet box "Box" +`!p snip.rv = '┌' + '─' * (len(t[1]) + 2) + '┐'` +│ $1 │ +`!p snip.rv = '└' + '─' * (len(t[1]) + 2) + '┘'` +$0 +endsnippet + +snippet beg "Begin" b +\begin{$1} + $2 +\end{$1} +endsnippet + +snippet mk "InlineMath" wA +$${1}$`!p +if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']: + snip.rv = ' ' +else: + snip.rv = '' +`$2 +endsnippet + +snippet dm "BlockMath" wA +\[ + $1 +\]$0 +endsnippet + +snippet check "CheckMark" +\textcolor{ForestGreen}{\checkmark} +endsnippet + +snippet corr "Correct" +\textcolor{red}{$1} +endsnippet + +snippet pm "Parenthesied matrix" A +\begin{pmatrix}$1\end{pmatrix} +endsnippet diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim new file mode 100644 index 0000000..fd14e48 --- /dev/null +++ b/nvim/.config/nvim/init.vim @@ -0,0 +1,43 @@ +call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged') + +Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } + +Plug 'vim-python/python-syntax' + +Plug 'srcery-colors/srcery-vim' + +Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } + +" Latex +Plug 'lervag/vimtex' +Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' } + +call plug#end() + +set autowrite + +" Go configuration +let g:go_highlight_fields = 1 +let g:go_highlight_functions = 1 +let g:go_highlight_function_calls = 1 +let g:go_highlight_extra_types = 1 +let g:go_highlight_operators = 1 + +let g:go_auto_type_info = 1 + +" Python syntax config +let g:python_highlight_all = 1 + +" Vimtex configuration +let g:vimtex_view_method = 'zathura' +let g:vimtex_quickfix_mode=0 + +set cc=80 +set tw=792034 +set background=dark +set clipboard=unnamedplus +set expandtab +set tabstop=2 +set shiftwidth=2 +set mouse=a +colorscheme srcery