Browse Source

Initial commit

master
David Trudgian 2 months ago
commit
3dbf6736e5
  1. 56
      .gitignore
  2. 167
      elisp/base-extensions.el
  3. 17
      elisp/base-functions.el
  4. 17
      elisp/base-global-keys.el
  5. 24
      elisp/base-theme.el
  6. 90
      elisp/base.el
  7. 85
      elisp/lang-c.el
  8. 8
      elisp/lang-go.el
  9. 47
      elisp/lang-javascript.el
  10. 64
      elisp/lang-python.el
  11. 81
      elisp/lang-web.el
  12. 19
      init.el

56
.gitignore

@ -0,0 +1,56 @@
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
recentf
network-security.data
transient/
private/
.\#*
# Org-mode
.org-id-locations
*_archive
# flymake-mode
*_flymake.*
# eshell files
/eshell/history
/eshell/lastdir
# elpa packages
/elpa/
# reftex files
*.rel
# AUCTeX auto folder
/auto/
# cask packages
.cask/
dist/
# Flycheck
flycheck_*.el
# server auth directory
/server/
# projectiles files
.projectile
# directory configuration
.dir-locals.el
.cache
.custom.el
smex-items

167
elisp/base-extensions.el

@ -0,0 +1,167 @@
(use-package ace-jump-mode
:bind
("C-c SPC" . ace-jump-mode))
(use-package company
:config
(add-hook 'after-init-hook 'global-company-mode))
(use-package dashboard
:config
(dashboard-setup-startup-hook))
(use-package ediff
:config
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
(setq-default ediff-highlight-all-diffs 'nil)
(setq ediff-diff-options "-w"))
(use-package exec-path-from-shell
:config
(exec-path-from-shell-copy-env "GOPATH")
(exec-path-from-shell-copy-env "PYTHONPATH")
(exec-path-from-shell-initialize))
(use-package expand-region
:bind
("C-=" . er/expand-region))
(use-package ivy
:ensure t
:config
(ivy-mode)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
:bind
("C-s" . swiper-isearch)
("M-x" . counsel-M-x)
("C-x C-f" . counsel-find-file)
("M-y" . counsel-yank-pop)
("<f1> f" . counsel-describe-function)
("<f1> v" . counsel-describe-variable)
("<f1> l" . counsel-find-library)
("<f2> i" . counsel-info-lookup-symbol)
("<f2> u" . counsel-unicode-char)
("<f2> j" . counsel-set-variable)
("C-x b" . ivy-switch-buffer)
("C-c v" . ivy-push-view)
("C-c V" . ivy-pop-view)
("C-c c" . counsel-compile)
("C-c g" . counsel-git)
("C-c j" . counsel-git-grep)
("C-c L" . counsel-git-log)
("C-c k" . counsel-rg)
("C-c m" . counsel-linux-app)
("C-c n" . counsel-fzf)
("C-x l" . counsel-locate)
("C-c J" . counsel-file-jump)
("C-S-o" . counsel-rhythmbox)
("C-c w" . counsel-wmctrl)
("C-c C-r" . ivy-resume)
("C-c b" . counsel-bookmark)
("C-c d" . counsel-descbinds)
("C-c g" . counsel-git)
("C-c o" . counsel-outline)
("C-c t" . counsel-load-theme)
("C-c F" . counsel-org-file))
(use-package counsel
:ensure t)
(use-package linum
:config
(setq linum-format " %3d ")
(global-linum-mode nil))
(use-package magit
:config
:bind
;; Magic
("C-x g s" . magit-status)
("C-x g x" . magit-checkout)
("C-x g c" . magit-commit)
("C-x g p" . magit-push)
("C-x g u" . magit-pull)
("C-x g e" . magit-ediff-resolve)
("C-x g r" . magit-rebase-interactive))
(use-package magit-popup)
(use-package multiple-cursors
:bind
("C-S-c C-S-c" . mc/edit-lines)
("C->" . mc/mark-next-like-this)
("C-<" . mc/mark-previous-like-this)
("C-c C->" . mc/mark-all-like-this))
(use-package neotree
:config
(setq neo-theme 'arrow
neotree-smart-optn t
neo-window-fixed-size nil))
(use-package org
:config
(setq org-directory "~/Org"
org-default-notes-file (concat org-directory "/todo.org"))
:bind
("C-c l" . org-store-link)
("C-c a" . org-agenda))
(use-package org-bullets
:config
(setq org-hide-leading-stars t)
(add-hook 'org-mode-hook
(lambda ()
(org-bullets-mode t))))
(use-package page-break-lines)
(use-package projectile
:config
(setq projectile-known-projects-file
(expand-file-name "projectile-bookmarks.eld" temp-dir))
(projectile-global-mode))
(use-package recentf
:config
(setq recentf-save-file (recentf-expand-file-name "~/.emacs.d/private/cache/recentf"))
(recentf-mode 1))
(use-package smartparens)
(use-package undo-tree
:config
;; Remember undo history
(setq
undo-tree-auto-save-history nil
undo-tree-history-directory-alist `(("." . ,(concat temp-dir "/undo/"))))
(global-undo-tree-mode 1))
(use-package which-key
:config
(which-key-mode))
(use-package windmove
:bind
("C-x <up>" . windmove-up)
("C-x <down>" . windmove-down)
("C-x <left>" . windmove-left)
("C-x <right>" . windmove-right))
(use-package yasnippet
:config
(yas-global-mode 1))
(use-package dumb-jump
:config
(dumb-jump-mode))
(use-package restart-emacs
:ensure t)
(provide 'base-extensions)

17
elisp/base-functions.el

@ -0,0 +1,17 @@
;; Add your custom functions here
(defun dct/neotree-project-dir ()
"Open NeoTree at the git root."
(interactive)
(let ((project-dir (projectile-project-root))
(file-name (buffer-file-name)))
(neotree-toggle)
(if project-dir
(if (neo-global--window-exists-p)
(progn
(neotree-dir project-dir)
(neotree-find file-name)))
(message "Could not find git project root."))))
(provide 'base-functions)

17
elisp/base-global-keys.el

@ -0,0 +1,17 @@
;; Add your keys here, as such
;; Overrides
(global-set-key (kbd "C-x f") 'counsel-recentf)
;; General Custom Super Bindings
(global-set-key (kbd "s-k") 'kill-this-buffer)
(global-set-key (kbd "s-/") 'counsel-rg)
;; Projectile related
(global-set-key (kbd "C-x p n") 'dct/neotree-project-dir)
(global-set-key [f8] 'dct/neotree-project-dir)
(global-set-key (kbd "C-x p /") 'projectile-grep)
(provide 'base-global-keys)

24
elisp/base-theme.el

@ -0,0 +1,24 @@
(use-package all-the-icons
:ensure t)
(use-package doom-themes
:config
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
(load-theme 'doom-tomorrow-day t)
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
;; Enable custom neotree theme (all-the-icons must be installed!)
(doom-themes-neotree-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config))
(use-package doom-modeline
:ensure t
:init (doom-modeline-mode 1))
(provide 'base-theme)

90
elisp/base.el

@ -0,0 +1,90 @@
(package-initialize)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(when (not package-archive-contents)
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(defconst private-dir (expand-file-name "private" user-emacs-directory))
(defconst temp-dir (format "%s/cache" private-dir)
"Hostname-based elisp temp directories")
;; Core settings
;; UTF-8 please
(set-charset-priority 'unicode)
(setq locale-coding-system 'utf-8) ; pretty
(set-terminal-coding-system 'utf-8) ; pretty
(set-keyboard-coding-system 'utf-8) ; pretty
(set-selection-coding-system 'utf-8) ; please
(prefer-coding-system 'utf-8) ; with sugar on top
(setq default-process-coding-system '(utf-8-unix . utf-8-unix))
;; Emacs customizations
(setq confirm-kill-emacs 'y-or-n-p
confirm-nonexistent-file-or-buffer t
save-interprogram-paste-before-kill t
mouse-yank-at-point t
require-final-newline t
visible-bell nil
ring-bell-function 'ignore
custom-file "~/.emacs.d/.custom.el"
;; http://ergoemacs.org/emacs/emacs_stop_cursor_enter_prompt.html
minibuffer-prompt-properties
'(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt)
;; Disable non selected window highlight
cursor-in-non-selected-windows nil
highlight-nonselected-windows nil
;; PATH
exec-path (append exec-path '("/usr/local/bin/"))
indent-tabs-mode nil
inhibit-startup-message t
fringes-outside-margins t
x-select-enable-clipboard t
use-package-always-ensure t)
;; Bookmarks
(setq
;; persistent bookmarks
bookmark-save-flag t
bookmark-default-file (concat temp-dir "/bookmarks"))
;; Backups enabled, use nil to disable
(setq
history-length 1000
backup-inhibited nil
make-backup-files t
auto-save-default t
auto-save-list-file-name (concat temp-dir "/autosave")
create-lockfiles nil
backup-directory-alist `((".*" . ,(concat temp-dir "/backup/")))
auto-save-file-name-transforms `((".*" ,(concat temp-dir "/auto-save-list/") t)))
(unless (file-exists-p (concat temp-dir "/auto-save-list"))
(make-directory (concat temp-dir "/auto-save-list") :parents))
(fset 'yes-or-no-p 'y-or-n-p)
(global-auto-revert-mode t)
;; Disable toolbar & menubar
(menu-bar-mode -1)
(when (fboundp 'tool-bar-mode)
(tool-bar-mode -1))
(when ( fboundp 'scroll-bar-mode)
(scroll-bar-mode -1))
(show-paren-mode 1)
;; Need to load custom file to avoid being overwritten
;; more at https://www.gnu.org/software/emacs/manual/html_node/emacs/Saving-Customizations.html
(load custom-file)
;; Delete trailing whitespace before save
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(provide 'base)
;;; base ends here

85
elisp/lang-c.el

@ -0,0 +1,85 @@
;; C-IDE based on https://github.com/tuhdo/emacs-c-ide-demo
(use-package cc-mode
:config
;; Available C style:
;; "gnu": The default style for GNU projects
;; "k&r": What Kernighan and Ritchie, the authors of C used in their book
;; "bsd": What BSD developers use, aka "Allman style" after Eric Allman.
;; "whitesmith": Popularized by the examples that came with Whitesmiths C, an early commercial C compiler.
;; "stroustrup": What Stroustrup, the author of C++ used in his book
;; "ellemtel": Popular C++ coding standards as defined by "Programming in C++, Rules and Recommendations," Erik Nyquist and Mats Henricson, Ellemtel
;; "linux": What the Linux developers use for kernel development
;; "python": What Python developers use for extension modules
;; "java": The default style for java-mode (see below)
;; "user": When you want to define your own style
(setq c-default-style "k&r") ;; set style to "linux"
(setq gdb-many-windows t ;; use gdb-many-windows by default
gdb-show-main t))
(use-package semantic
:config
(global-semanticdb-minor-mode 1)
(global-semantic-idle-scheduler-mode 1)
(global-semantic-stickyfunc-mode 1)
(semantic-mode 1))
(use-package ede
:config
;; Enable EDE only in C/C++
(global-ede-mode))
(use-package ggtags
:config
(ggtags-mode 1)
(add-hook 'c-mode-common-hook
(lambda ()
(when (derived-mode-p 'c-mode 'c++-mode 'java-mode 'asm-mode)
(ggtags-mode 1))))
(dolist (map (list ggtags-mode-map))
(define-key map (kbd "C-c g s") 'ggtags-find-other-symbol)
(define-key map (kbd "C-c g h") 'ggtags-view-tag-history)
(define-key map (kbd "C-c g r") 'ggtags-find-reference)
(define-key map (kbd "C-c g f") 'ggtags-find-file)
(define-key map (kbd "C-c g c") 'ggtags-create-tags)
(define-key map (kbd "C-c g u") 'ggtags-update-tags)
(define-key map (kbd "M-.") 'ggtags-find-tag-dwim)
(define-key map (kbd "M-,") 'pop-tag-mark)
(define-key map (kbd "C-c <") 'ggtags-prev-mark)
(define-key map (kbd "C-c >") 'ggtags-next-mark)))
;; company-c-headers
(use-package company-c-headers
:init
(add-to-list 'company-backends 'company-c-headers))
(use-package cc-mode
:init
(define-key c-mode-map [(tab)] 'company-complete)
(define-key c++-mode-map [(tab)] 'company-complete))
;; git@github.com:syohex/emacs-counsel-gtags.git
;(use-package counsel-gtags
; :load-path "vendor/emacs-counsel-gtags/"
; :ensure nil
; :config
; (add-hook 'c-mode-hook 'counsel-gtags-mode)
; (add-hook 'c++-mode-hook counsel-gtags-mode)
;
; (with-eval-after-load 'counsel-gtags
; (define-key counsel-gtags-mode-map (kbd "M-t") 'counsel-gtags-find-definition)
; ;(define-key counsel-gtags-mode-map (kbd "M-r") 'counsel-gtags-find-reference)
; ;(define-key counsel-gtags-mode-map (kbd "M-s") 'counsel-gtags-find-symbol)
; (define-key counsel-gtags-mode-map (kbd "M-,") 'counsel-gtags-pop-stack)))
(defun alexott/cedet-hook ()
(local-set-key (kbd "C-c C-j") 'semantic-ia-fast-jump)
(local-set-key (kbd "C-c C-s") 'semantic-ia-show-summary))
;; hs-minor-mode for folding source code
(add-hook 'c-mode-common-hook 'hs-minor-mode)
(add-hook 'c-mode-common-hook 'alexott/cedet-hook)
(add-hook 'c-mode-hook 'alexott/cedet-hook)
(add-hook 'c++-mode-hook 'alexott/cedet-hook)
(provide 'lang-c)

8
elisp/lang-go.el

@ -0,0 +1,8 @@
(use-package go-mode
:ensure t)
(use-package eglot
:ensure t
:hook (go-mode . eglot))
(provide 'lang-go)

47
elisp/lang-javascript.el

@ -0,0 +1,47 @@
;; js2-mode
;; https://github.com/mooz/js2-mode
(use-package js2-mode
:bind (:map js2-mode-map
(("C-x C-e" . js-send-last-sexp)
("C-M-x" . js-send-last-sexp-and-go)
("C-c C-b" . js-send-buffer-and-go)
("C-c C-l" . js-load-file-and-go)))
:mode
("\\.js$" . js2-mode)
("\\.json$" . js2-jsx-mode)
:config
(custom-set-variables '(js2-strict-inconsistent-return-warning nil))
(custom-set-variables '(js2-strict-missing-semi-warning nil))
(setq js-indent-level 2)
(setq js2-indent-level 2)
(setq js2-basic-offset 2))
;; tern :- IDE like features for javascript and completion
;; http://ternjs.net/doc/manual.html#emacs
(use-package tern
:if
(executable-find "tern")
:config
(defun my-js-mode-hook ()
"Hook for `js-mode'."
(set (make-local-variable 'company-backends)
'((company-tern company-files))))
(add-hook 'js2-mode-hook 'my-js-mode-hook)
(add-hook 'js2-mode-hook 'company-mode)
(add-hook 'js2-mode-hook 'tern-mode))
;; Run a JavaScript interpreter in an inferior process window
;; https://github.com/redguardtoo/js-comint
(use-package js-comint
:config
(setq inferior-js-program-command "node"))
;; js2-refactor :- refactoring options for emacs
;; https://github.com/magnars/js2-refactor.el
(use-package js2-refactor :defer t
:diminish js2-refactor-mode
:config
(js2r-add-keybindings-with-prefix "C-c j r")
(add-hook 'js2-mode-hook 'js2-refactor-mode))
(provide 'lang-javascript)

64
elisp/lang-python.el

@ -0,0 +1,64 @@
;;; package --- python configs
;;; Commentary:
;;; Contains my python configs
;;; Code:
(use-package python
:mode ("\\.py" . python-mode)
:config
(use-package elpy
:init
(add-to-list 'auto-mode-alist '("\\.py$" . python-mode))
:config
(setq elpy-rpc-backend "jedi")
;; (add-hook 'python-mode-hook 'py-autopep8-enable-on-save)
;;flycheck-python-flake8-executable "/usr/local/bin/flake8"
:bind (:map elpy-mode-map
("M-." . elpy-goto-definition)
("M-," . pop-tag-mark)))
(elpy-enable))
(use-package pip-requirements
:config
(add-hook 'pip-requirements-mode-hook #'pip-requirements-auto-complete-setup))
(use-package py-autopep8)
(use-package pyenv-mode
:if
(executable-find "pyenv")
:init
(add-to-list 'exec-path "~/.pyenv/shims")
(setenv "WORKON_HOME" "~/.pyenv/versions/")
:config
(pyenv-mode)
:bind
("C-x p e" . pyenv-activate-current-project))
(defun pyenv-init()
(setq global-pyenv (replace-regexp-in-string "\n" "" (shell-command-to-string "pyenv global")))
(message (concat "Setting pyenv version to " global-pyenv))
(pyenv-mode-set global-pyenv)
(defvar pyenv-current-version nil global-pyenv))
(defun pyenv-activate-current-project ()
"Automatically activates pyenv version if .python-version file exists."
(interactive)
(f-traverse-upwards
(lambda (path)
(message path)
(let ((pyenv-version-path (f-expand ".python-version" path)))
(if (f-exists? pyenv-version-path)
(progn
(setq pyenv-current-version (s-trim (f-read-text pyenv-version-path 'utf-8)))
(pyenv-mode-set pyenv-current-version)
(pyvenv-workon pyenv-current-version)
(message (concat "Setting virtualenv to " pyenv-current-version))))))))
(add-hook 'after-init-hook 'pyenv-init)
(add-hook 'projectile-after-switch-project-hook 'pyenv-activate-current-project)
(provide 'lang-python)
;;; base-python.el ends here

81
elisp/lang-web.el

@ -0,0 +1,81 @@
(use-package web-mode
:bind (("C-c ]" . emmet-next-edit-point)
("C-c [" . emmet-prev-edit-point))
:mode
(("\\.js\\'" . web-mode)
("\\.html?\\'" . web-mode)
("\\.phtml?\\'" . web-mode)
("\\.tpl\\.php\\'" . web-mode)
("\\.[agj]sp\\'" . web-mode)
("\\.as[cp]x\\'" . web-mode)
("\\.erb\\'" . web-mode)
("\\.mustache\\'" . web-mode)
("\\.djhtml\\'" . web-mode)
("\\.jsx$" . web-mode))
:config
(setq web-mode-markup-indent-offset 2
web-mode-css-indent-offset 2
web-mode-code-indent-offset 2)
(add-hook 'web-mode-hook 'jsx-flycheck)
;; highlight enclosing tags of the element under cursor
(setq web-mode-enable-current-element-highlight t)
(defadvice web-mode-highlight-part (around tweak-jsx activate)
(if (equal web-mode-content-type "jsx")
(let ((web-mode-enable-part-face nil))
ad-do-it)
ad-do-it))
(defun jsx-flycheck ()
(when (equal web-mode-content-type "jsx")
;; enable flycheck
(flycheck-select-checker 'jsxhint-checker)
(flycheck-mode)))
;; editing enhancements for web-mode
;; https://github.com/jtkDvlp/web-mode-edit-element
(use-package web-mode-edit-element
:config (add-hook 'web-mode-hook 'web-mode-edit-element-minor-mode))
;; snippets for HTML
;; https://github.com/smihica/emmet-mode
(use-package emmet-mode
:init (setq emmet-move-cursor-between-quotes t) ;; default nil
:diminish (emmet-mode . " e"))
(add-hook 'web-mode-hook 'emmet-mode)
(defun my-web-mode-hook ()
"Hook for `web-mode' config for company-backends."
(set (make-local-variable 'company-backends)
'((company-css company-web-html company-files))))
(add-hook 'web-mode-hook 'my-web-mode-hook)
;; to get completion data for angularJS
(use-package ac-html-angular :defer t)
;; to get completion for twitter bootstrap
(use-package ac-html-bootstrap :defer t)
;; to get completion for HTML stuff
;; https://github.com/osv/company-web
(use-package company-web)
(add-hook 'web-mode-hook 'company-mode))
;; configure CSS mode company backends
(use-package css-mode
:config
(defun my-css-mode-hook ()
(set (make-local-variable 'company-backends)
'((company-css company-dabbrev-code company-files))))
(add-hook 'css-mode-hook 'my-css-mode-hook)
(add-hook 'css-mode-hook 'company-mode))
;; impatient mode - Live refresh of web pages
;; https://github.com/skeeto/impatient-mode
(use-package impatient-mode
:diminish (impatient-mode . " i")
:commands (impatient-mode))
(provide 'lang-web)

19
init.el

@ -0,0 +1,19 @@
;;; package --- Main init file
;;; Commentary:
;;; This is my init file
;;; Code:
(add-to-list 'load-path (concat user-emacs-directory "elisp"))
(require 'base)
(require 'base-theme)
(require 'base-extensions)
(require 'base-functions)
(require 'base-global-keys)
(require 'lang-python)
(require 'lang-go)
(require 'lang-javascript)
(require 'lang-web)
(require 'lang-c)
Loading…
Cancel
Save