From 1865cbc805984c41dbece257452d6a2db5824785 Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Fri, 25 Sep 2020 00:33:51 -0700 Subject: [PATCH 1/4] C --- dotfiles/emacs.d/init.el | 6 ++++++ dotfiles/emacs.d/package.el | 1 + 2 files changed, 7 insertions(+) diff --git a/dotfiles/emacs.d/init.el b/dotfiles/emacs.d/init.el index 1c871ff..82ac890 100644 --- a/dotfiles/emacs.d/init.el +++ b/dotfiles/emacs.d/init.el @@ -272,6 +272,12 @@ There are two things you can do about this warning: ;; Python testing helpers (use-package python-pytest) + +;;;;;;;;;;; C/C++ + +(use-package clang-format+) +(add-hook 'c-mode-common-hook #'clang-format+-mode) + ;;-------------------------------------------------------------------------------------- ;; Save hooks ;;-------------------------------------------------------------------------------------- diff --git a/dotfiles/emacs.d/package.el b/dotfiles/emacs.d/package.el index 44ea251..1abc419 100644 --- a/dotfiles/emacs.d/package.el +++ b/dotfiles/emacs.d/package.el @@ -28,6 +28,7 @@ cmake-ide cmake-mode + clang-format+ ;;;;;;;;;;;;;;;;;;;;;;;; From e7a15c17f289cbb6cc2a75bb374c6836cbb9ed64 Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Fri, 25 Sep 2020 00:44:33 -0700 Subject: [PATCH 2/4] cool binds --- dotfiles/bash/bashrc | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/dotfiles/bash/bashrc b/dotfiles/bash/bashrc index cb60cab..6d2c71c 100644 --- a/dotfiles/bash/bashrc +++ b/dotfiles/bash/bashrc @@ -80,8 +80,6 @@ if [[ "$OS_TYPE" != "gnu-linux" ]]; then alias python='python3' fi -alias vim='nvim' - # rlwrap provides readline wrapping for programs. # This alias makes the SBCL REPL usable. alias sbcl='rlwrap sbcl' @@ -96,6 +94,29 @@ alias gitd='git diff' alias k8='kubectl' +# Good overrides + +# Don't nuke the computer +alias rm='rm -i' + +# Better ls - lists more information for each file +alias ll='ls -lh' + +# Human readable ls for the current directory +if [[ "$OS_TYPE" != "gnu-linux" ]]; then + # OS X lt + alias lt='du -sh * | sort -h' +else + alias lt='ls --human-readable --size -1 -S --classify' +fi + + +# Count files in the current directory +alias count='find . -type f | wc -l' + +# Generate sha1 hashes on the fly +alias sha1='openssl sha1' + # -------------- END ALIASES --------------# @@ -119,7 +140,7 @@ if which go > /dev/null; then export GOPATH=$HOME/projects/go; fi # ----------------------------------------- INITIALIZATIONS -------------------------------------- # -if which pyenv-virtualenv-init > /dev/null; then +if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" fi From c852c7531c87b24f5f5fbad21bec66b2ca015ab1 Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Fri, 25 Sep 2020 01:14:55 -0700 Subject: [PATCH 3/4] C stuff --- dotfiles/emacs.d/init.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dotfiles/emacs.d/init.el b/dotfiles/emacs.d/init.el index f16faeb..5f9d8d6 100644 --- a/dotfiles/emacs.d/init.el +++ b/dotfiles/emacs.d/init.el @@ -173,9 +173,6 @@ There are two things you can do about this warning: (add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode) (add-hook 'scheme-mode-hook #'enable-paredit-mode) -(add-hook 'c-mode-hook 'counsel-gtags-mode) -(add-hook 'c++-mode-hook 'counsel-gtags-mode) - (require 'rainbow-delimiters) (add-hook 'clojure-mode-hook 'rainbow-delimiters-mode) @@ -306,7 +303,14 @@ There are two things you can do about this warning: ;;;;;;;;;;; C/C++ (use-package clang-format+) +(use-package counsel-gtags) + (add-hook 'c-mode-common-hook #'clang-format+-mode) +(add-hook 'c-mode-hook 'counsel-gtags-mode) +(add-hook 'c++-mode-hook 'counsel-gtags-mode) + +;; 4 space offset for c +(setq-default c-basic-offset 4) ;;-------------------------------------------------------------------------------------- ;; Save hooks From f46d5370beeadc9debbbb8313765a1211f295f9c Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Fri, 25 Sep 2020 08:53:17 -0700 Subject: [PATCH 4/4] emacs config stuff --- dotfiles/bash/scripts/cgen.sh | 9 ++++----- dotfiles/bash/scripts/cgen_etc/clang_format_template | 19 +++++++++++-------- dotfiles/emacs.d/init.el | 11 ++++++----- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/dotfiles/bash/scripts/cgen.sh b/dotfiles/bash/scripts/cgen.sh index f10404d..a10f999 100755 --- a/dotfiles/bash/scripts/cgen.sh +++ b/dotfiles/bash/scripts/cgen.sh @@ -27,8 +27,8 @@ fi if [ -z $c_standard ] then - echo "No C Standard supplied...defaulting to 99" - c_standard="99" + echo "No C Standard supplied...defaulting to 11" + c_standard="11" fi mkdir $name @@ -51,8 +51,7 @@ echo "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \${CMAKE_BINARY_DIR}/bin)" >> $cmake_co echo "" >> $cmake_config echo "" >> $cmake_config echo "# The following lines enable compile_commands.json and dump it in the root of the project" >> $cmake_config -echo "# in order to allow YouCompleteMe to provide completion. You can delete these lines if your" >> $cmake_config -echo "# editor does not need/use \`compile_commands.json\`" >> $cmake_config +echo "# This is needed for clangd and lsp to work" >> $cmake_config echo "" >> $cmake_config echo "set(CMAKE_EXPORT_COMPILE_COMMANDS ON)" >> $cmake_config echo "" >> $cmake_config @@ -62,7 +61,7 @@ echo " \${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json echo " \${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json" >> $cmake_config echo " )" >> $cmake_config echo "endif()" >> $cmake_config -echo "#-------- END YOUCOMPLETEME SECTION --------#" >> $cmake_config +echo "#-------- END COMPILE_COMMANDS.JSON SECTION --------#" >> $cmake_config echo "" >> $cmake_config echo "" >> $cmake_config echo "file(GLOB SOURCE \${PROJECT_SOURCE_DIR}/src/*.c)" >> $cmake_config diff --git a/dotfiles/bash/scripts/cgen_etc/clang_format_template b/dotfiles/bash/scripts/cgen_etc/clang_format_template index 94ff769..db8218d 100644 --- a/dotfiles/bash/scripts/cgen_etc/clang_format_template +++ b/dotfiles/bash/scripts/cgen_etc/clang_format_template @@ -1,13 +1,16 @@ +AlignAfterOpenBracket: Align +AlignConsecutiveMacros: 'true' AlignConsecutiveAssignments: 'true' +AlignConsecutiveDeclarations: 'true' AlignTrailingComments: 'true' -AllowShortBlocksOnASingleLine: 'false' -AllowShortCaseLabelsOnASingleLine: 'false' -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: Never -AllowShortLoopsOnASingleLine: 'false' BreakBeforeBraces: Allman -ColumnLimit: '120' +IndentCaseLabels: 'true' IndentWidth: '4' +Language: Cpp PointerAlignment: Right -SortIncludes: 'false' - +SortIncludes: 'true' +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: 'true' +SpaceInEmptyParentheses: 'false' +UseTab: Never +ColumnLimit: 80 \ No newline at end of file diff --git a/dotfiles/emacs.d/init.el b/dotfiles/emacs.d/init.el index 5f9d8d6..f7d10d6 100644 --- a/dotfiles/emacs.d/init.el +++ b/dotfiles/emacs.d/init.el @@ -204,14 +204,15 @@ There are two things you can do about this warning: ;; LSP (use-package lsp-mode - :ensure t - :hook (python-mode . lsp-deferred) - :commands (lsp lsp-deferred)) + :ensure t + :hook ((python-mode . lsp-deferred) + (c-mode . lsp-deferred)) + :commands (lsp lsp-deferred)) (use-package lsp-ui - :ensure t - :hook (lsp-mode . lsp-ui-mode)) + :ensure t + :hook (lsp-mode . lsp-ui-mode)) ;;;;; PYTHON ;;;;;;;;;;;;;;;;;;