(setq user-full-name "kelvin"
user-mail-address "[email protected]")
(setq gc-cons-threshold 100000000)
(setq large-file-warning-threshold 200000000)
;; Always load newest byte code
(setq load-prefer-newer t)
;; (require 'cl) を見逃す
(setq byte-compile-warnings '(not cl-functions obsolete))
;; MacでGUIの時、optionをmeta
(if window-system (progn
(when (equal system-type 'darwin)
(setq mac-option-modifier 'meta))
))
(require 'server)
(if (not (server-running-p)) (server-start))
(require 'package)
(setq package-enable-at-startup nil)
(defun @-setup-package-repos ()
(progn
(defun @-set-repo-when-missing (name repo)
(unless (assoc-default name package-archives)
(add-to-list 'package-archives (cons name repo))))
(let ((repos
'(("melpa" . "https://melpa.org/packages/")
("melpa-stable" . "https://stable.melpa.org/packages/")
("elpy" . "https://jorgenschaefer.github.io/packages/")
("org" . "https://orgmode.org/elpa/")
("melpa-mirror" . "https://www.mirrorservice.org/sites/melpa.org/packages/")
("ublt" . "https://elpa.ubolonton.org/packages/")
("gnu" . "https://elpa.emacs-china.org/gnu/")))
_)
(dolist (pair repos _)
(progn
(@-set-repo-when-missing (car pair) (cdr pair))
)))
(package-initialize)
))
(defun @-setup-package-installer ()
(progn
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
(setq use-package-verbose t
use-package-always-ensure t
warning-minimum-level :emergency)
;; Enable defer and ensure by default for use-package
;; Keep auto-save/backup files separate from source code: https://github.com/scalameta/metals/issues/1027
(setq use-package-always-defer t
use-package-always-ensure t
;;backup-directory-alist `((".*" . ,temporary-file-directory))
;;auto-save-file-name-transforms `((".*" ,temporary-file-directory t))
)
;; Version control
(defvar backup-directory "~/emacs-backup")
(if (not (file-exists-p backup-directory))
(make-directory backup-directory t))
(setq
make-backup-files t
;; Set the backup directory path.
backup-directory-alist `((".*" . ,backup-directory)) ;; save backup files in ~/.backups
;; Copy all files, don't rename them.
backup-by-copying t
;; Use version numbers for backups.
version-control t
;; Don't ask to delete excess backup versions.
delete-old-versions t
;; Number of oldest versions to keep.
kept-old-versions 6
;; Number of newest versions to keep.
kept-new-versions 9
auto-save-default t
auto-save-timeout 20
auto-save-interval 200
vc-make-backup-files t
auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t)))
;;Backups
;;(setq backup-directory-alist
;; `((".*" . ,temporary-file-directory)))
;;(setq auto-save-file-name-transforms
;; `((".*" ,temporary-file-directory t)))
))
(defun @-setup-macos-hack ()
(cond ((string-equal system-type "darwin")
(progn
;; batter copy and paste support for mac os x
(defun @-copy-from-osx ()
(shell-command-to-string "pbpaste"))
(defun @-paste-to-osx (text &optional push)
(let ((process-connection-type nil))
(let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
(process-send-string proc text)
(process-send-eof proc))))
;; modify option and command key
(setq mac-command-modifier 'control)
(setq mac-option-modifier 'meta)
(setq interprogram-cut-function '@-paste-to-osx)
(setq interprogram-paste-function '@-copy-from-osx)
(use-package exec-path-from-shell)
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize))
(message "Wellcome To Mac OS X, Have A Nice Day!!!")))))
(defun @-setup-global-mode ()
(progn
(display-time-mode 1)
;;(show-paren-mode nil)
(display-battery-mode 1)
;;(global-auto-revert-mode t)
;;(toggle-frame-fullscreen)
(toggle-scroll-bar -1)
(blink-cursor-mode -1)
;;(global-hl-line-mode nil)
(global-hl-line-mode +1)
;;(line-number-mode +1)
;;(global-display-line-numbers-mode 1)
;;(column-number-mode t)
(size-indication-mode t)
(setq inhibit-startup-message t)
(tool-bar-mode -1)
(set-window-fringes nil 0 0)
(menu-bar-mode -1)
(scroll-bar-mode -1)
;;
(setq org-src-fontify-natively t)
;;(show-paren-mode)
;;Ease of life
(fset 'yes-or-no-p 'y-or-n-p) ; Accept 'y' in lieu of 'yes'.
(fset 'jdent
[return return ?\C-p tab])
;; No need to see GNU agitprop.
;;(setq inhibit-startup-screen nil)
(setq inhibit-startup-screen t
org-startup-folded nil
ring-bell-function 'ignore
scroll-conservatively 1000
show-paren-delay 0)
(setq tab-width 4
inhibit-splash-screen t
;; No need to remind me what a scratch buffer is.
initial-scratch-message nil
;; Double-spaces after periods is morally wrong.
sentence-end-double-space nil
;; Never ding at me, ever.
;;ring-bell-function 'ignore
;; Prompts should go in the minibuffer, not in a GUI.
use-dialog-box nil
;; Fix undo in commands affecting the mark.
mark-even-if-inactive nil
;; Let C-k delete the whole line.
kill-whole-line t
;; search should be case-sensitive by default
case-fold-search nil
create-lockfiles nil)
;; Never mix tabs and spaces. Never use tabs, period.
;; We need the setq-default here because this becomes
;; a buffer-local variable when set.
(setq-default indent-tabs-mode nil)
;;(defalias 'yes-or-no-p 'y-or-n-p) ; Accept 'y' in lieu of 'yes'.
(setq frame-title-format
'((:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
"%b"))))
(setq scroll-margin 0
;;scroll-conservatively 100000
scroll-preserve-screen-position 1)
(set-frame-font "Hack 12" nil t)
(global-auto-revert-mode t)
(setq-default tab-width 4
indent-tabs-mode nil)
(add-hook 'before-save-hook 'whitespace-cleanup)
(savehist-mode 1)
(setq savehist-file "~/.emacs.d/.savehist")
(setq history-length t)
(setq history-delete-duplicates t)
(setq savehist-save-minibuffer-history 1)
(setq savehist-additional-variables
'(kill-ring
search-ring
regexp-search-ring))
)
)
(defun @-setup-vendor-package ()
(progn
(add-to-list 'load-path (expand-file-name "~/.emacs.d/vendor"))
(require 'gcmh)
;; gc magic hack
(require 'lang-js)))
(@-setup-vendor-package)
(@-setup-package-repos)
(@-setup-package-installer)
(@-setup-macos-hack)
(@-setup-global-mode)
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-charset-priority 'unicode)
(set-selection-coding-system 'utf-8)
(setq default-process-coding-system '(utf-8-unix . utf-8-unix))
(setq locale-coding-system 'utf-8)
;;(setq make-backup-files nil)
;;(setq auto-save-default t)
(defun @-setup-editor-theme ()
(progn
(setq custom-safe-themes t)
(if (display-graphic-p)
(progn
(use-package doom-themes
:config
(setq doom-themes-enable-bold t
doom-themes-enable-italic t)
(doom-themes-visual-bell-config))
(if (string-equal system-type "darwin")
(load-theme 'doom-dracula)
(load-theme 'doom-nord)))
(progn
(use-package darkokai-theme)
(load-theme 'darkokai))
)
))
(defun @-setup-editor-face ()
(progn
(let ((display-table (or standard-display-table (make-display-table))))
(set-display-table-slot display-table 'vertical-border (make-glyph-code ?│)) ; or ┃ │
(setq standard-display-table display-table))
(set-face-background 'vertical-border (face-background 'default))
(set-face-foreground 'vertical-border "color-237")
))
(use-package rainbow-mode
:init
(defun @-enable-rainbow ()
(rainbow-mode t))
:hook ((prog-mode-hook . @-enable-reainbow))
)
(use-package rainbow-delimiters
:init
(defun @-enable-rainbow-delimiters ()
(rainbow-delimiters-mode t))
:hook ((prog-mode-hook . @-enable-rainbow-delimiters))
)
(use-package doom-modeline
:ensure t
:init
(set-face-background 'mode-line nil)
:hook (after-init . doom-modeline-mode))
(@-setup-editor-theme)
(@-setup-editor-face)
;; Notes in *scratch* v. 0.2
;; Copyright (c) 2006 by Michal Nazarewicz (mina86/AT/mina86.com)
;; Released under GNU GPL
(defconst scratch-file (expand-file-name "~/.emacs.d/scratch")
"File where content of *scratch* buffer will be read from and saved to.")
(defconst scratch-file-autosave (concat scratch-file ".autosave")
"File where to autosave content of *scratch* buffer.")
(save-excursion
(set-buffer (get-buffer-create "*scratch*"))
(if (file-readable-p scratch-file)
(if (and (file-readable-p scratch-file-autosave)
(file-newer-than-file-p scratch-file-autosave scratch-file)t)
(insert-file-contents scratch-file-autosave nil nil nil t)
(insert-file-contents scratch-file nil nil nil t)
(set-buffer-modified-p nil)))
(auto-save-mode 1)
(setq buffer-auto-save-file-name scratch-file-autosave)
; (setq revert-buffer-function 'scratch-revert)
(fundamental-mode))
(add-hook 'kill-buffer-query-functions 'kill-scratch-buffer)
(add-hook 'kill-emacs-hook 'kill-emacs-scratch-save)
(defun scratch-revert (ignore-auto noconfirm)
(when (file-readable-p scratch-file)
(insert-file-contents scratch-file nil nil nil t)
(set-buffer-modified-p nil)))
(defun kill-scratch-buffer ()
(not (when (string-equal (buffer-name (current-buffer)) "*scratch*")
(delete-region (point-min) (point-max))
(set-buffer-modified-p nil)
(next-buffer)
t)))
(defun kill-emacs-scratch-save ()
(let ((buffer (get-buffer-create "*scratch*")))
(if buffer
(save-excursion
(set-buffer buffer)
(write-region nil nil scratch-file)
(unless (string-equal scratch-file buffer-auto-save-file-name)
(delete-auto-save-file-if-necessary t))))))
;; Update packages
(use-package auto-package-update
:ensure t
:init
(setq auto-package-update-delete-old-versions t
auto-package-update-interval 4)
(auto-package-update-maybe))
(use-package diminish
:ensure t
:config
(with-eval-after-load 'company
(diminish 'company-mode))
(with-eval-after-load 'magit
(diminish 'magit-mode))
(with-eval-after-load 'git-gutter+
(diminish 'git-gutter+-mode))
;;(with-eval-after-load 'smartparens
;; (diminish 'smartparens-mode))
(with-eval-after-load 'expand-region
(diminish 'expand-region-mode))
(with-eval-after-load 'flycheck
(diminish 'flycheck-mode))
(with-eval-after-load 'avy
(diminish 'avy-mode))
(with-eval-after-load 'rainbow
(diminish 'rainbow-mode))
(with-eval-after-load 'yasnippet
(diminish 'yasnippet-mode))
)
;;:config (diminish 'eldoc-mode))
(use-package gnu-elpa-keyring-update)
(use-package smart-mode-line-powerline-theme
:ensure t)
(use-package smart-mode-line
:ensure t
:config
(setq sml/theme 'powerline)
(add-hook 'after-init-hook 'sml/setup))
(use-package smartparens
:ensure t
:config
(progn
(require 'smartparens-config)
(smartparens-global-mode 1)
(show-paren-mode t)))
(use-package expand-region
:ensure t
:config
:bind ("M-m" . er/expand-region))
(use-package avy
:ensure t
:bind
("C-=" . avy-goto-char-2)
:config
(setq avy-background t))
(use-package crux
:ensure t
:config
;;:bind
;;("C-k" . crux-smart-kill-line)
;;("C-c n" . crux-cleanup-buffer-or-region)
;;("C-c f" . crux-recentf-find-file)
;;("C-a" . crux-move-beginning-of-line)
:bind (("C-c o" . crux-open-with)
("M-o" . crux-smart-open-line)
("C-c n" . crux-cleanup-buffer-or-region)
("C-c f" . crux-recentf-find-file)
("C-M-z" . crux-indent-defun)
("C-c u" . crux-view-url)
("C-c e" . crux-eval-and-replace)
("C-c w" . crux-swap-windows)
("C-c D" . crux-delete-file-and-buffer)
("C-c r" . crux-rename-buffer-and-file)
("C-c t" . crux-visit-term-buffer)
("C-c k" . crux-kill-other-buffers)
("C-c TAB" . crux-indent-rigidly-and-copy-to-clipboard)
("C-c I" . crux-find-user-init-file)
("C-c S" . crux-find-shell-init-file)
("s-r" . crux-recentf-find-file)
("s-j" . crux-top-join-line)
("C-^" . crux-top-join-line)
("s-k" . crux-kill-whole-line)
("C-<backspace>" . crux-kill-line-backwards)
("s-o" . crux-smart-open-line-above)
([remap move-beginning-of-line] . crux-move-beginning-of-line)
([(shift return)] . crux-smart-open-line)
([(control shift return)] . crux-smart-open-line-above)
([remap kill-whole-line] . crux-kill-whole-line)
("C-c s" . crux-ispell-word-then-abbrev))
)
(use-package flycheck
:ensure t
:config
(add-hook 'after-init-hook #'global-flycheck-mode))
(use-package yasnippet
:ensure t
:diminish yasnippet-mode
:config
(yas-global-mode 1)
(add-hook 'term-mode-hook (lambda()
(setq yas-dont-activate t)))
)
(use-package helm-swoop
:ensure t
:after helm)
(use-package helm
:ensure t
:defer 2
:bind
;; First using helm for M-x so we get a live filter
;; of options, and don't need to keep tab completing.
("M-x" . helm-M-x)
;; Also use helm for buffers. I can never remember the
;; buffers I have open.
("C-x C-b" . helm-buffers-list)
;; Finding files can also be a pain, so use helm
;; to locate and open files
("C-x C-f" . helm-find-files)
("M-y" . helm-show-kill-ring)
;;("C-x b" . helm-mini)
:config
(require 'helm-config)
(helm-mode 1)
(setq helm-split-window-inside-p t
helm-move-to-line-cycle-in-source t)
(setq helm-autoresize-max-height 0)
(setq helm-autoresize-min-height 20)
(setq helm-boring-buffer-regexp-list (list
(rx "*magit-")
(rx "*magit: ")
(rx "magit-")
(rx "magit: ")
(rx "*helm ")
(rx "*Minibuf-")
(rx "*Echo Area")
(rx "*Backtrace*")
(rx "*code-converting-work*")
(rx "*code-conversion-work*")
(rx "*elpy")
(rx "*Compile-Log*")
(rx "*Completions*")
(rx "*groovy*")
(rx "*Help*")
(rx "*Messages*")
(rx "*NeoTree*")
(rx "*scratch*")
(rx "*server*")
(rx "*Shell Command Output*")
))
(helm-autoresize-mode 1)
;;:bind
;;(("C-c s" . helm-swoop)
;;("C-x C-f" . helm-find-files)
;;("C-x b" . helm-buffers-list)
;;("M-y" . helm-show-kill-ring)
;;("M-x" . helm-M-x))
)
(use-package ido-completing-read+)
(defun @-insert-src-block (src-code-type)
"Insert a `SRC-CODE-TYPE' type source code block in org-mode."
(interactive
(let ((src-code-types
'("emacs-lisp" "python" "C" "sh" "java" "js" "clojure" "C++" "css"
"calc" "asymptote" "dot" "gnuplot" "ledger" "lilypond" "mscgen"
"octave" "oz" "plantuml" "R" "sass" "screen" "sql" "awk" "ditaa"
"haskell" "latex" "lisp" "matlab" "ocaml" "org" "perl" "ruby"
"scheme" "sqlite" "html" "go")))
(list (ido-completing-read+ "Source code type: " src-code-types))))
(progn
(newline-and-indent)
(insert (format "\n#+BEGIN_SRC %s\n" src-code-type))
(newline-and-indent)
(insert "#+END_SRC\n")
(previous-line 2)
(org-edit-src-code)))
(use-package undo-tree
:ensure t
:config
;; autosave the undo-tree history
(setq undo-tree-history-directory-alist
`((".*" . ,temporary-file-directory)))
(setq undo-tree-auto-save-history t)
(global-undo-tree-mode +1)
;;(global-undo-tree-mode)
(setq undo-tree-visualizer-timestamps t)
(setq undo-tree-visualizer-diff t)
)
(use-package company
:ensure t
:defer 2
:config
;;(global-company-mode)
(add-hook 'after-init-hook #'global-company-mode)
(add-hook 'go-mode-hook 'company-mode)
;; Optionally enable completion-as-you-type behavior.
(setq company-idle-delay 0)
;;(setq company-minimum-prefix-length 4)
(setq company-minimum-prefix-length 1
company-idle-delay 0.200)
(setq company-dabbrev-downcase nil)
(setq company-selection-wrap-around t))
(with-eval-after-load 'company
(define-key company-active-map (kbd "SPC") #'company-abort)
(define-key company-active-map (kbd "M-n") nil)
(define-key company-active-map (kbd "M-p") nil)
(define-key company-active-map (kbd "C-n") #'company-select-next)
(define-key company-active-map (kbd "C-p") #'company-select-previous)
)
(add-hook 'after-init-hook 'global-company-mode)
(use-package which-key
:ensure t
:config
;;(which-key-mode)
(which-key-mode +1)
(which-key-setup-side-window-bottom))
(use-package recentf
:ensure t
:config
(setq recentf-max-saved-items 200
recentf-max-menu-items 15)
:bind ("<f3>" . helm-recentf)
:hook ((after-init-hook . recentf-mode)))
;;(use-package linum
;; :ensure t
;; :config
;; (global-linum-mode t)
;; (setq linum-format "%4d ")
;; (set-face-background 'linum nil))
(use-package autopair
:ensure t
:config
(autopair-global-mode))
(use-package neotree
:custom
(neo-theme 'nerd2)
:config
(require 'neotree)
(setq neo-smart-open t)
(setq neo-theme (if (display-graphic-p) 'icons 'nerd))
(setq-default neo-show-hidden-files nil)
(setq neo-show-hidden-files t)
(setq neo-window-fixed-size nil)
(setq neo-window-width 35)
;; (setq neo-autorefresh t) ;; setting to t will cause neotree to change root after opening a file
(setq neo-force-change-root t)
(global-set-key [f2] 'neotree-toggle)
(global-set-key [f8] 'neotree-dir)
(add-hook 'after-init-hook #'neotree-toggle)
)
(use-package magit
:ensure t
:bind (("C-M-g" . magit-status)))
(use-package git-gutter+
:ensure t
:config
(global-git-gutter+-mode))
(use-package smart-tab
:hook ((prog-mode-hook . smart-tab-mode)))
(use-package mwim
:bind
("C-a" . mwim-beginning-of-code-or-line)
("C-e" . mwim-end-of-code-or-line))
(use-package guru-mode
:config
(guru-global-mode +1))
(use-package projectile
:ensure t
;;:diminish (projectile-mode . "Ⓟ")
:bind
(("C-c p f" . helm-projectile-find-file)
("C-c p p" . helm-projectile-switch-project)
("C-c p s" . projectile-save-project-buffers))
;;:init
;;(setq projectile-keymap-prefix (kbd "C-c p")
;; projectile-require-project-root nil)
:config
(projectile-mode +1)
;;(projectile-global-mode)
)
;; helm-projectile-switch-project
;; workaround for laggy projectile, more info: https://github.com/bbatsov/projectile/issues/1183
(setq projectile-mode-line
'(:eval (format " Projectile[%s]"
(projectile-project-name))))
(use-package helm-projectile
:ensure t
:after (helm projectile)
:init
(setq projectile-completion-system 'helm)
:config
(helm-projectile-on))
(use-package helm-projectile
:ensure t
:after (helm projectile)
:init
(setq projectile-completion-system 'helm)
:config
(helm-projectile-on))
(use-package projectile-ripgrep
:ensure t
:commands projectile-ripgrep)
(use-package helm-rg
:ensure t
:defer t
:after helm)
(use-package lsp-mode
;;:requires hydra helm helm-lsp
:requires hydra helm helm-lsp
:commands (lsp lsp-deferred)
:ensure t
:custom
(
;; try to disable automatic-doc-help in echo erea
;; when it is enabled, lsp will send requests to lsp-server
;; when cursor is moved, which may block the editor
;; https://github.com/emacs-lsp/lsp-mode/issues/1223
(lsp-log-io nil)
;; debug
(lsp-print-io nil)
(lsp-trace nil)
(lsp-print-performance t)
(lsp-response-timeout 20)
;;(lsp-prefer-flymake t) ; t(flymake), nil(lsp-ui), or :none
(lsp-signature-auto-activate nil)
(lsp-signature-render-documentation nil)
(lsp-enable-snippet t)
(lsp-enable-indentation nil)
(lsp-keep-workspace-alive t)
(lsp-enable-xref t)
(lsp-enable-imenu t)
(lsp-enable-completion-at-point nil)
(lsp-enable-file-watchers nil)
(lsp-diagnostic-package :flymake)
(lsp-prefer-capf t)
(lsp-auto-guess-root t)
;;(lsp-document-sync-method 2)
(lsp-document-sync-method 'incremental) ; none, full, incremental, or nil
(lsp-inhibit-message t)
(lsp-message-project-root-warning t)
;;(create-lockfiles nil)
(read-process-output-max (* 1024 1024))
;; Python
(lsp-pyls-configuration-sources ["flake8"])
)
:hook ((lsp-mode . lsp-enable-which-key-integration)
(c++-mode . lsp-deferred)
(c-mode . lsp-deferred)
(go-mode . lsp-deferred)
(python-mode . lsp-deferred)
(rust-mode . lsp-deferred)
(html-mode . lsp-deferred)
(js-mode . lsp-deferred)
(web-mode . lsp-deferred)
(typescript-mode . lsp-deferred)
(rust-mode . lsp-deferred)
(typescript-mode . lsp-deferred)
(json-mode . lsp-deferred)
(yaml-mode . lsp-deferred)
(dockerfile-mode . lsp-deferred)
(shell-mode . lsp-deferred)
(css-mode . lsp-deferred)
(prog-major-mode . lsp-prog-major-mode-enable)
(clojure-mode . lsp-deferred)
(clojurec-mode . lsp-deferred)
(clojurescript-mode . lsp-deferred))
:config
(progn
(require 'lsp-clients)
(setq lsp-message-project-root-warning t
lsp-prefer-flymake nil
lsp-restart 'ignore
lsp-eldoc-hook nil
lsp-eldoc-enable-hover nil
lsp-auto-configure nil
lsp-enable-symbol-highlighting nil)
(dolist (m '(clojure-mode
clojurec-mode
clojurescript-mode
clojurex-mode))
(add-to-list 'lsp-language-id-configuration `(,m . "clojure")))
;;(require 'lsp-clients)
;;(lsp-register-client
;;(make-lsp-client :new-connection (lsp-stdio-connection "gopls")
;; :major-modes '(go-mode)
;; :server-id 'gopls))
;;(lsp-define-stdio-client lsp-python "python"
;; #'projectile-project-root
;; '("pyls"))
)
(use-package company-lsp
:ensure t
:commands company-lsp
:config (push 'company-lsp company-backends)
(setq company-lsp-async t
company-lsp-cache-candidates 'auto
company-lsp-match-candidate-predicate #'company-lsp-match-candidate-flex
)
)
(use-package lsp-ui
:commands lsp-ui-mode
:after lsp-mode
:custom
;; lsp-ui-doc
(lsp-ui-doc-enable t)
(lsp-ui-doc-header t)
(lsp-ui-doc-include-signature t)
(lsp-ui-sideline-enable nil)
(lsp-ui-doc-position 'top)
(lsp-ui-doc-max-width 60)
(lsp-ui-doc-max-height 20)
(lsp-ui-doc-use-childframe t)
(lsp-ui-doc-use-webkit nil)
;; lsp-ui-flycheck
(lsp-ui-flycheck-enable t)
(lsp-ui-flycheck-list-position 'right)
(lsp-ui-flycheck-live-reporting t)
;; lsp-ui-sideline
(lsp-ui-sideline-enable t)
(lsp-ui-sideline-ignore-duplicate t)
(lsp-ui-sideline-show-symbol t)
(lsp-ui-sideline-show-hover t)
(lsp-ui-sideline-show-diagnostics t)
(lsp-ui-sideline-show-code-actions t)
(lsp-ui-sideline-code-actions-prefix "")
;; lsp-ui-imenu
(lsp-ui-imenu-enable nil)
(lsp-ui-imenu-kind-position 'top)
;; lsp-ui-peek
(lsp-ui-peek-enable t)
(lsp-ui-peek-always-show t)
(lsp-ui-peek-peek-height 25)
(lsp-ui-peek-list-width 60)
;;(lsp-ui-peek-fontify 'always)
(lsp-ui-peek-fontify 'on-demand) ; never, on-demand, or always
:preface
(defun ladicle/toggle-lsp-ui-doc ()
(interactive)
(if lsp-ui-doc-mode
(progn
(lsp-ui-doc-mode -1)
(lsp-ui-doc--hide-frame))
(lsp-ui-doc-mode 1)))
:bind
(:map lsp-mode-map
("C-c C-r" . lsp-ui-peek-find-references)
("C-c C-j" . lsp-ui-peek-find-definitions)
("C-c i" . lsp-ui-peek-find-implementation)
("C-c m" . lsp-ui-imenu)
("C-c s" . lsp-ui-sideline-mode)
("C-c d" . ladicle/toggle-lsp-ui-doc))
:hook
(lsp-mode . lsp-ui-mode)
)
(use-package helm-lsp
:commands helm-lsp-workspace-symbol helm-lsp-global-workspace-symbol)
(use-package dap-mode
:init
(defun @-dap-hydra-hook ()
(call-interactively #'dap-hydra))
:config
(dap-mode 1)
(dap-ui-mode 1)
(dap-tooltip-mode 1)
(tooltip-mode 1)
:hook ((dap-stopped-hook . @-dap-hydra-hook)))
(use-package go-mode
:mode "\\.go\\'"
:init
(setq gofmt-command "goimports")
(defun @-gofmat-when-save ()
(if (equal major-mode 'go-mode)
(gofmt-before-save)))
:config
(when (memq window-system '(mac ns))
(use-package exec-path-from-shell)
(exec-path-from-shell-initialize)
(exec-path-from-shell-copy-env "GOPATH"))
(add-hook 'before-save-hook '@-gofmat-when-save)
:hook ((go-mode . lsp)))
(use-package go-eldoc
:hook ((gp-mode-hook . go-eldoc-setup)))
(use-package go-guru
:hook (go-mode . go-guru-hl-identifier-mode))
(use-package go-dlv)
go get -u -v golang.org/x/tools/cmd/...
go get -u -v github.com/rogpeppe/godef
go get -u -v golang.org/x/tools/cmd/goimports
go get -u -v golang.org/x/tools/gopls
go get -u -v github.com/mdempsky/gocode
(use-package py-isort)
(use-package python
:init
(defun @-python-code-format()
(if (equal major-mode 'python-mode)
(progn
(python-black-buffer)
(py-isort-buffer)
)))
:mode ("\\.py" . python-mode)
:hook ((python-mode . lsp)
(before-save-hook . @-pythoncode-format))
:config
(add-hook 'before-save-hook #'@-python-code-format)
:ensure t)
;; (use-package jedi
;; :config
;; (add-hook 'python-mode-hook 'jedi:setup))
;; (use-package lsp-python-ms
;; :ensure t
;; :hook (python-mode . (lambda ()
;; (require 'lsp-python-ms)
;; (lsp)))
;; :init
;; (setq lsp-python-ms-executable (concat EMACS_ROOT "lsp/python-language-server/output/bin/Release/osx-x64/publish/Microsoft.Python.LanguageServer")))
(use-package pyvenv)
(use-package python-black
:demand t
:after python
:config
(python-black-on-save-mode))
(use-package pyenv-mode
:init
;;(add-to-list 'exec-path "~/.pyenv/shims")
;;(setenv "WORKON_HOME" "~/.pyenv/versions/")
(add-to-list 'exec-path "~/.anyenv/envs/pyenv/shims/")
(setenv "WORKON_HOME" "~/.anyenv/envs/pyenv/versions/")
:config
(pyenv-mode))
(use-package ccls
:ensure t
:config
(setq ccls-executable "ccls")
(setq lsp-prefer-flymake nil)
(setq-default flycheck-disabled-checkers '(c/c++-clang c/c++-cppcheck c/c++-gcc))
:hook ((c-mode c++-mode objc-mode) .
(lambda () (require 'ccls) (lsp))))
(use-package emmet-mode)
(use-package web-beautify)
;; typescirpt tide
(use-package typescript-mode)
(use-package web-mode)
(use-package js2-mode
:ensure t
:mode (("\\.js\\'" . js2-mode)
("\\.json\\'" . javascript-mode))
:init
(setq-default js2-basic-offset 2)
(setq-default js2-global-externs '("module" "require" "assert" "setInterval" "console" "__dirname__") )
)
(defun @-setup-tide-mode ()
(interactive)
(tide-setup)
(flycheck-mode +1)
(setq flycheck-check-syntax-automatically '(save mode-enabled))
(eldoc-mode +1)
(tide-hl-identifier-mode +1)
;; company is an optional dependency. You have to
;; install it separately via package-install
;; `M-x package-install [ret] company`
(company-mode +1))
;; aligns annotation to the right hand side
(setq company-tooltip-align-annotations t)
;; formats the buffer before saving
(add-hook 'before-save-hook 'tide-format-before-save)
(add-hook 'typescript-mode-hook #'@-setup-tide-mode)
(add-hook 'js2-mode-hook #'setup-tide-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))))
(use-package tide
:ensure t
:after (typescript-mode company flycheck)
:hook ((typescript-mode . tide-setup)
(typescript-mode . tide-hl-identifier-mode)
(before-save . tide-format-before-save)))
(use-package prettier-js
:ensure t
:hook ((js2-mode . prettier-js-mode))
:config
(setq prettier-js-args '(
"--trailing-comma" "all"
"--bracket-spacing" "false"
))
)
(use-package plantuml-mode
:custom
(plantuml-jar-path (concat EMACS_ROOT "plantuml.jar"))
:mode "\\.uml\\'")
(use-package json-mode
:hook ((json-mode . lsp)))
(use-package yaml-mode
:hook ((yaml-mode . lsp)))
(use-package dockerfile-mode
:hook ((dockerfile-mode . lsp)))
(use-package protobuf-mode
:hook ((protobuf-mode . lsp)))
(use-package flyspell
:config
(flyspell-mode +1))
;;(add-hook 'before-save-hook (lambda () (flyspell-buffer)))
(add-hook 'text-mode-hook 'flyspell-mode)
(add-hook 'prog-mode-hook 'flyspell-prog-mode)
(defun @-close-all-buffers ()
(interactive)
(mapc 'kill-buffer (buffer-list)))
(defun @-minify-buffer-contents()
(interactive)
(mark-whole-buffer)
(goto-char (point-min))
(while (search-forward-regexp "[\s\n]*" nil t) (replace-match "" nil t)))
(defun @-copy-file-name-to-clipboard ()
"Copy the current buffer file name to the clipboard."
(interactive)
(let ((filename (if (equal major-mode 'dired-mode)
default-directory
(buffer-file-name))))
(when filename
(kill-new filename)
(message "Copied buffer file name '%s' to the clipboard." filename))))
(global-set-key (kbd "C-\\") 'comment-line)
;; F1 for tmux
;; F2 neotree toggle
;;(global-set-key (kbd "<f3>") 'helm-recentf)
(global-set-key (kbd "<f4>") 'fiplr-find-file)
(global-set-key (kbd "<f5>") 'grep-find)
(global-set-key (kbd "<f6>") 'goto-line)
;; F8 neotree-dir
(global-set-key (kbd "<f9>") 'bookmark-jump)
;;(global-set-key (kbd "<f10>") 'helm-M-x)
;;(global-set-key (kbd "<f12>") 'helm-projectile-find-file)
(global-set-key (kbd "M-0") 'next-multiframe-window)
(global-set-key (kbd "M-9") 'previous-multiframe-window)
(global-set-key (kbd "C-x k") 'kill-this-buffer)
(global-set-key "\C-h" 'delete-backward-char)
(global-set-key (kbd "M-g f") 'avy-goto-line)
(global-set-key (kbd "C-j") nil)
(global-set-key (kbd "C-j") 'jdent)
;;(global-set-key [f8] 'menu-bar-mode)