summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/#org-custom.el#64
-rw-r--r--lisp/add-node-modules-path.el76
-rw-r--r--lisp/cpp.el9
-rw-r--r--lisp/general.el200
-rw-r--r--lisp/js-mode-custom.el37
-rw-r--r--lisp/markdown.el14
-rw-r--r--lisp/org-custom.el7
-rw-r--r--lisp/text.el14
-rw-r--r--lisp/ts-custom.el34
-rw-r--r--lisp/web.el53
10 files changed, 268 insertions, 240 deletions
diff --git a/lisp/#org-custom.el# b/lisp/#org-custom.el#
deleted file mode 100644
index 8fbc6a0..0000000
--- a/lisp/#org-custom.el#
+++ /dev/null
@@ -1,64 +0,0 @@
-;; https://zzamboni.org/post/beautifying-org-mode-in-emacs/
-
-(defun org-custom-hook()
- (setq org-hide-emphasis-markers t)
- (font-lock-add-keywords 'org-mode
- '(("^ *\\([-]\\) "
- (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))
-
- (let* ((variable-tuple
- (cond ((x-list-fonts "ETBembo") '(:font "ETBembo"))
- ((x-list-fonts "Source Sans Pro") '(:font "Source Sans Pro"))
- ((x-list-fonts "Lucida Grande") '(:font "Lucida Grande"))
- ((x-list-fonts "Verdana") '(:font "Verdana"))
- ((x-family-fonts "Sans Serif") '(:family "Sans Serif"))
- (nil (warn "Cannot find a Sans Serif Font. Install Source Sans Pro."))))
- (base-font-color (face-foreground 'default nil 'default))
- (headline `(:inherit default :weight bold :foreground ,base-font-color)))
-
- (custom-theme-set-faces
- 'user
- `(org-level-8 ((t (,@headline ,@variable-tuple))))
- `(org-level-7 ((t (,@headline ,@variable-tuple))))
- `(org-level-6 ((t (,@headline ,@variable-tuple))))
- `(org-level-5 ((t (,@headline ,@variable-tuple))))
- `(org-level-4 ((t (,@headline ,@variable-tuple :height 0.8))))
- `(org-level-3 ((t (,@headline ,@variable-tuple :height 0.9))))
- `(org-level-2 ((t (,@headline ,@variable-tuple :height 1.0))))
- `(org-level-1 ((t (,@headline ,@variable-tuple :height 1.25))))
- `(org-document-title ((t (,@headline ,@variable-tuple :height 1.5 :underline nil))))))
-
- (custom-theme-set-faces
- 'user
- '(org-block ((t (:inherit fixed-pitch))))
- '(org-code ((t (:inherit (shadow fixed-pitch)))))
- '(org-document-info ((t (:foreground "dark orange"))))
- '(org-document-info-keyword ((t (:inherit (shadow fixed-pitch)))))
- '(org-indent ((t (:inherit (org-hide fixed-pitch)))))
- '(org-link ((t (:foreground "royal blue" :underline t))))
- '(org-meta-line ((t (:inherit (font-lock-comment-face fixed-pitch)))))
- '(org-property-value ((t (:inherit fixed-pitch))) t)
- '(org-special-keyword ((t (:inherit (font-lock-comment-face fixed-pitch)))))
- '(org-table ((t (:inherit fixed-pitch :foreground "#83a598"))))
- '(org-tag ((t (:inherit (shadow fixed-pitch) :weight bold :height 0.8))))
- '(org-verbatim ((t (:inherit (shadow fixed-pitch))))))
-
- (variable-pitch-mode)
- (visual-line-mode)
-
- (require 'org-bullets)
- (org-bullets-mode 1)
-
- (setq org-blank-before-new-entry (quote ((heading . nil)
- (plain-list-item . nil))))
-)
-
-(custom-set-variables
- '(org-directory "~/Documents/org")
- '(org-agenda-files (list org-directory)))
-
-(setq org-todo-keywords
- '((sequence "TODO" "PROGRESS" "VERIFY" "|" "DONE" "ABANDONED")))
-
-(provide 'org-custom)
-
diff --git a/lisp/add-node-modules-path.el b/lisp/add-node-modules-path.el
new file mode 100644
index 0000000..9789c23
--- /dev/null
+++ b/lisp/add-node-modules-path.el
@@ -0,0 +1,76 @@
+;;; add-node-modules-path.el --- Add node_modules to your exec-path
+
+;; Copyright (C) 2016 Neri Marschik
+;; This package uses the MIT License.
+;; See the LICENSE file.
+
+;; Author: Neri Marschik <marschik_neri@cyberagent.co.jp>
+;; Version: 1.0
+;; Package-Requires: ((s "1.12.0"))
+;; Keywords: javascript, node, node_modules, eslint
+;; URL: https://github.com/codesuki/add-node-modules-path
+
+;;; Commentary:
+;;
+;; This file provides `add-node-modules-path', which runs `npm bin` and
+;; and adds the path to the buffer local `exec-path'.
+;; This allows Emacs to find project based installs of e.g. eslint.
+;;
+;; Usage:
+;; M-x add-node-modules-path
+;;
+;; To automatically run it when opening a new buffer:
+;; (Choose depending on your favorite mode.)
+;;
+;; (eval-after-load 'js-mode
+;; '(add-hook 'js-mode-hook #'add-node-modules-path))
+;;
+;; (eval-after-load 'js2-mode
+;; '(add-hook 'js2-mode-hook #'add-node-modules-path))
+
+;;; Code:
+
+(require 's)
+
+(defgroup add-node-modules-path nil
+ "Put node_modules binaries into `exec-path'."
+ :prefix "add-node-modules-path-"
+ :group 'environment)
+
+;;;###autoload
+(defcustom add-node-modules-path-command "npm bin"
+ "Command to find the bin path."
+ :type 'string)
+
+;;;###autoload
+(defcustom add-node-modules-path-debug nil
+ "Enable verbose output when non nil."
+ :type 'boolean
+ :group 'add-node-modules-path)
+
+;;;###autoload
+(defun add-node-modules-path ()
+ "Run `npm bin` command and add the path to the `exec-path`.
+If `npm` command fails, it does nothing."
+ (interactive)
+
+ (let* ((res (s-chomp (shell-command-to-string add-node-modules-path-command)))
+ (exists (file-exists-p res))
+ )
+ (cond
+ (exists
+ (make-local-variable 'exec-path)
+ (add-to-list 'exec-path res)
+ (when add-node-modules-path-debug
+ (message "Added to `exec-path`: %s" res))
+ )
+ (t
+ (when add-node-modules-path-debug
+ (message "Failed to run `%s':\n %s" add-node-modules-path-command res))
+ ))
+ )
+ )
+
+(provide 'add-node-modules-path)
+
+;;; add-node-modules-path.el ends here
diff --git a/lisp/cpp.el b/lisp/cpp.el
index 2a44fba..3565a16 100644
--- a/lisp/cpp.el
+++ b/lisp/cpp.el
@@ -1,7 +1,7 @@
-;;; package --- Summary
;;; Code:
(defun setup-c()
+ "Set up c common mode."
(setq c++-tab-always-indent 0)
(setq c-basic-offset 4) ;; Default is 2
(setq c-indent-level 4) ;; Default is 2
@@ -12,7 +12,7 @@
;; (electric-indent-mode 0)
)
-; == irony-mode ==
+;; Irony mode.
(use-package irony
:ensure t
:defer t
@@ -34,5 +34,8 @@
(require 'cmake-ide)
(cmake-ide-setup)
-(provide 'cpp)
+(add-hook 'c-mode-common-hook 'setup-c)
+
+(provide 'cpp)
+;;; cpp.el ends here
diff --git a/lisp/general.el b/lisp/general.el
index cedc5fa..dc3af36 100644
--- a/lisp/general.el
+++ b/lisp/general.el
@@ -1,95 +1,109 @@
-(defun setup-general()
- ;; menu bars
- (menu-bar-mode -1)
- (toggle-scroll-bar -1)
- (tool-bar-mode -1)
- (setq mac-shift-modifier 'meta)
-
- ;; Default Values
- ;(setq-default indent-tabs-mode t) ; use spaces only if nil
- (setq-default tab-width 4) ; Assuming you want your tabs to be four spaces wide
- (set-face-attribute 'default nil :font "Droid Sans Mono-12")
- (set-fontset-font t nil "Courier New" nil 'append)
- (set-fontset-font t '(?😊 . ?😎) "Segoe UI Emoji")
-
- ;;(set-face-attribute 'default nil :height 110 :family "Consolas")
- (set-language-environment "UTF-8")
- (set-default-coding-systems 'utf-8)
-
- ;; Cursor
- (setq-default cursor-type 'bar)
- (blink-cursor-mode 1)
-
- ;; Margin
- (global-linum-mode 1)
- ;;(require 'minimap)
- ;;(minimap-mode 1)
- (require 'perfect-margin)
- (perfect-margin-mode 1)
-
- ;; Initialization screen
- (setq inhibit-splash-screen t)
- (setq initial-scratch-message "")
- (setq initial-major-mode 'text-mode)
- ;(desktop-save-mode 1)
-
- ;; Projectile for projects
- (require 'projectile)
- (projectile-mode +1)
- (define-key projectile-mode-map (kbd "s-q") 'projectile-command-map)
- (define-key projectile-mode-map [?\s-t] 'projectile-switch-project)
- (define-key projectile-mode-map [?\s-p] 'projectile-find-file)
-
- ;; Tree
- (require 'neotree)
- (global-set-key [f8] 'neotree-toggle)
- (setq neo-smart-open t)
- ;;(setq projectile-switch-project-action 'neotree-projectile-action)
- (setq neo-theme (if (display-graphic-p) 'icons 'arrow))
-
- ;; Smooth scroll
- (setq redisplay-dont-pause t
- scroll-margin 1
- scroll-step 1
- scroll-conservatively 10000
- scroll-preserve-screen-position 1)
-
- ;; Show flycheck always and after save
- (use-package flycheck :ensure t)
- (global-flycheck-mode)
- (add-hook 'after-init-hook #'global-flycheck-mode)
-
- ;; Emojis
- (use-package emojify
- :config
- (when (member "Segoe UI Emoji" (font-family-list))
- (set-fontset-font
- t 'symbol (font-spec :family "Segoe UI Emoji") nil 'prepend))
- (setq emojify-display-style 'unicode)
- (setq emojify-emoji-styles '(unicode))
- (bind-key* (kbd "C-c e") #'emojify-insert-emoji)) ; override binding in any mode
-
- ;; == company-mode ==
- (use-package company
- :ensure t
- :defer t
- :init (add-hook 'after-init-hook 'global-company-mode)
- :config
- (use-package company-irony :ensure t :defer t)
- (setq company-idle-delay 0
- company-minimum-prefix-length 2
- company-show-numbers t
- company-tooltip-limit 20
- company-dabbrev-downcase nil
- company-backends '((company-irony company-gtags))
- company-vscode-light-icons-margin 1
- )
- :bind ("C-;" . company-complete-common)
- )
-
- ;; Flycheck
- (eval-after-load 'flycheck
- '(add-hook 'flycheck-mode-hook #'flycheck-irony-setup))
-)
+
+;;; Code:
+
+;; Backup files
+(setq backup-directory-alist `(("." . "~/.emacs_saves")))
+(setq backup-by-copying t)
+(setq delete-old-versions t
+ kept-new-versions 6
+ kept-old-versions 2
+ version-control t)
+
+;; menu bars
+(menu-bar-mode -1)
+(toggle-scroll-bar -1)
+(tool-bar-mode -1)
+(setq mac-shift-modifier 'meta)
+
+;; Default Values
+ ;(setq-default indent-tabs-mode t) ; use spaces only if nil
+(setq-default tab-width 4) ; Assuming you want your tabs to be four spaces wide
+(set-face-attribute 'default nil :font "Droid Sans Mono-12")
+(set-fontset-font t nil "Courier New" nil 'append)
+(set-fontset-font t '(?😊 . ?😎) "Segoe UI Emoji")
+
+;;(set-face-attribute 'default nil :height 110 :family "Consolas")
+(set-language-environment "UTF-8")
+(set-default-coding-systems 'utf-8)
+
+;; Cursor
+(setq-default cursor-type 'bar)
+(blink-cursor-mode 1)
+
+;; Margin
+(global-linum-mode 1)
+;;(require 'minimap)
+;;(minimap-mode 1)
+(require 'perfect-margin)
+(perfect-margin-mode 1)
+
+;; Initialization screen
+(setq inhibit-splash-screen t)
+(setq initial-scratch-message "")
+(setq initial-major-mode 'text-mode)
+ ;(desktop-save-mode 1)
+
+;; Projectile for projects
+(require 'projectile)
+(projectile-mode +1)
+(define-key projectile-mode-map (kbd "s-q") 'projectile-command-map)
+(define-key projectile-mode-map [?\s-t] 'projectile-switch-project)
+(define-key projectile-mode-map [?\s-p] 'projectile-find-file)
+
+;; Tree
+(require 'neotree)
+(global-set-key [f8] 'neotree-toggle)
+(setq neo-smart-open t)
+;;(setq projectile-switch-project-action 'neotree-projectile-action)
+(setq neo-theme (if (display-graphic-p) 'icons 'arrow))
+
+;; Smooth scroll
+(setq redisplay-dont-pause t
+ scroll-margin 1
+ scroll-step 1
+ scroll-conservatively 10000
+ scroll-preserve-screen-position 1)
+
+
+;; Line highlighting
+(global-hl-line-mode 1)
+(set-face-background 'hl-line "gray97")
+
+;; Show flycheck always and after save
+(use-package flycheck :ensure t)
+(global-flycheck-mode)
+(add-hook 'after-init-hook #'global-flycheck-mode)
+
+;; Emojis
+(use-package emojify
+ :config
+ (when (member "Segoe UI Emoji" (font-family-list))
+ (set-fontset-font
+ t 'symbol (font-spec :family "Segoe UI Emoji") nil 'prepend))
+ (setq emojify-display-style 'unicode)
+ (setq emojify-emoji-styles '(unicode))
+ (bind-key* (kbd "C-c e") #'emojify-insert-emoji)) ; override binding in any mode
+
+;; Company mode
+(use-package company
+ :ensure t
+ :defer t
+ :init (add-hook 'after-init-hook 'global-company-mode)
+ :config
+ (use-package company-irony :ensure t :defer t)
+ (setq company-idle-delay 0
+ company-minimum-prefix-length 2
+ company-show-numbers t
+ company-tooltip-limit 20
+ company-dabbrev-downcase nil
+ company-backends '((company-irony company-gtags))
+ company-vscode-light-icons-margin 1
+ )
+ :bind ("C-;" . company-complete-common)
+ )
+
+;; Flycheck
+(eval-after-load 'flycheck '(add-hook 'flycheck-mode-hook #'flycheck-irony-setup))
(provide 'general)
+;;; general.el ends here
diff --git a/lisp/js-mode-custom.el b/lisp/js-mode-custom.el
deleted file mode 100644
index 5c687f3..0000000
--- a/lisp/js-mode-custom.el
+++ /dev/null
@@ -1,37 +0,0 @@
-(defun setup-js()
- (setq js-indent-level 2)
- (hl-line-mode 1)
- (set-face-background hl-line-face "#EFEFEF")
- )
-
-(add-to-list 'auto-mode-alist '("\\.jsx$" . web-mode))
-(require 'js2-mode)
-(require 'js2-refactor)
-(require 'js2-highlight-vars)
-(require 'company)
-(require 'flycheck)
-(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
-(add-hook 'js2-mode-hook #'js2-imenu-extras-mode)
-(add-hook 'js2-mode-hook 'ac-js2-mode)
-(add-hook 'js2-mode-hook 'js2-refactor-mode)
-(add-hook 'js2-mode-hook 'js2-highlight-vars-mode)
-(add-hook 'js2-mode-hook 'setup-js)
-(js2r-add-keybindings-with-prefix "C-c C-r")
-(add-hook 'js2-mode-hook 'ac-js2-mode)
-(add-to-list 'company-backends 'ac-js2-company)
-
-(defun my/use-eslint-from-node-modules ()
- (let* ((root (locate-dominating-file
- (or (buffer-file-name) default-directory)
- "node_modules"))
- (eslint (and root
- (expand-file-name "node_modules/eslint/bin/eslint.js"
- root))))
- (when (and eslint (file-executable-p eslint))
- (setq-local flycheck-javascript-eslint-executable eslint))))
-(add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)
-(flycheck-add-mode 'javascript-eslint 'web-mode)
-
-
-(provide 'js-mode-custom)
-;; js-mode-custom.el ends here
diff --git a/lisp/markdown.el b/lisp/markdown.el
new file mode 100644
index 0000000..97e5b92
--- /dev/null
+++ b/lisp/markdown.el
@@ -0,0 +1,14 @@
+
+;;; Code:
+(autoload 'markdown-mode "markdown-mode"
+ "Use the markdown-mode package to provide 'markdown-mode on-demand."
+ t)
+(use-package markdown-mode
+ :commands (markdown-mode gfm-mode)
+ :mode (("README\\.md\\'" . gfm-mode)
+ ("\\.md\\'" . markdown-mode)
+ ("\\.markdown\\'" . markdown-mode))
+ :init (setq markdown-command "multimarkdown"))
+
+(provide 'markdown)
+;;; markdown.el ends here
diff --git a/lisp/org-custom.el b/lisp/org-custom.el
index 8d7e42e..584d0fc 100644
--- a/lisp/org-custom.el
+++ b/lisp/org-custom.el
@@ -1,6 +1,8 @@
-;; https://zzamboni.org/post/beautifying-org-mode-in-emacs/
+
+;;; Code:
(defun org-custom-hook()
+ "Custom org mode hook."
(setq org-hide-emphasis-markers t)
(font-lock-add-keywords 'org-mode
'(("^ *\\([-]\\) "
@@ -69,4 +71,7 @@
'(org-agenda-files (list org-directory))
'(org-directory "~/Documents/org")
+(add-hook 'org-mode-hook 'org-custom-hook)
+
(provide 'org-custom)
+;;; org-custom.el ends here
diff --git a/lisp/text.el b/lisp/text.el
index 4e1f8bf..4e7c410 100644
--- a/lisp/text.el
+++ b/lisp/text.el
@@ -1,12 +1,10 @@
-;; Text file section
+
+;;; Code:
(defun setup-text-mode ()
+ "Disable word wrap in text mode."
(setq word-wrap t)
- (global-hl-line-mode 0)
- )
-
-;;(require 'flyspell)
-;;(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
-;;(add-hook 'text-mode flyspell-mode)
-
+)
+(add-hook 'text-mode-hook 'setup-text-mode)
(provide 'text)
+;; text.el ends here
diff --git a/lisp/ts-custom.el b/lisp/ts-custom.el
deleted file mode 100644
index 3054102..0000000
--- a/lisp/ts-custom.el
+++ /dev/null
@@ -1,34 +0,0 @@
-(defun setup-ts()
-
- (use-package tide :ensure t)
- (use-package company :ensure t)
- (use-package flycheck :ensure t)
- (defun setup-tide-mode()
- (interactive)
- (tide-setup)
- (flycheck-mode +1)
- (setq web-mode-enable-auto-quoting nil)
- (setq web-mode-markup-indent-offset 2)
- (setq web-mode-code-indent-offset 2)
- (setq web-mode-attr-indent-offset 2)
- (setq web-mode-attr-value-indent-offset 2)
- (setq flycheck-check-syntax-automatically '(save-mode-enabled))
- (eldoc-mode +1)
- (tide-hl-identifier-mode +1)
- (company-mode +1)
- (setq flycheck-check-syntax-automatically '(mode-enabled save)))
-
- (add-hook 'typescript-mode-hook #'setup-tide-mode)
- (add-hook 'before-save-hook 'tide-format-before-save)
- (require 'web-mode)
-
- (add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
- (add-hook 'web-mode-hook
- (lambda ()
- (when (string-equal "tsx" (file-name-extension buffer-file-name))
- (setup-tide-mode))))
-
- ;; enable typescript - tslint checker
- (flycheck-add-mode 'typescript-tslint 'web-mode))
-
-(provide 'ts-custom)
diff --git a/lisp/web.el b/lisp/web.el
new file mode 100644
index 0000000..ae8f96c
--- /dev/null
+++ b/lisp/web.el
@@ -0,0 +1,53 @@
+
+;;; Code:
+;; web mode
+(use-package web-mode
+ :mode ("\\.html\\'" . web-mode)
+ :config (setq
+ web-mode-markup-indent-offset 2
+ web-mode-code-indent-offset 2
+ web-mode-enable-current-element-highlight t
+ web-mode-enable-current-column-highlight t
+ ))
+(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
+(add-to-list 'auto-mode-alist '("\\.css\\'" . web-mode))
+(add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode))
+(add-to-list 'auto-mode-alist '("\\.php\\'" . web-mode))
+(defun my-web-mode-hook ()
+ "Hooks for Web mode."
+ (setq web-mode-markup-indent-offset 2)
+ (setq web-mode-css-indent-offset 2)
+ (setq web-mode-code-indent-offset 2)
+)
+(add-hook 'web-mode-hook 'my-web-mode-hook)
+
+
+(require 'eglot)
+
+;; JavaScript
+(require 'js2-mode)
+(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
+(add-hook 'js2-mode-hook #'js2-imenu-extras-mode)
+
+(defun my-js2-mode-hook()
+ "Hooks for Javscript 2 Mode."
+ (setq js-indent-level 2)
+ (company-mode t)
+ (company-quickhelp-mode t)
+)
+(add-hook 'js2-mode-hook 'my-js2-mode-hook)
+(add-hook 'js2-mode-hook 'eglot-ensure)
+(push '("\\.js[x]?\\'" . js2-mode) auto-mode-alist)
+
+;; JS2-Refactor
+(use-package js2-refactor)
+(add-hook 'js2-mode-hook #'js2-refactor-mode)
+(js2r-add-keybindings-with-prefix "C-c C-r")
+
+;; Web goodies
+(autoload 'json-mode "json-mode"
+ "Use the json-mode package to provide 'json-mode on-demand."
+ t)
+
+(provide 'web)
+;;; web.el ends here