Skip to content

Instantly share code, notes, and snippets.

@ji6czd
Created July 31, 2024 19:42
Show Gist options
  • Save ji6czd/1c43ee63c81637bc98a2e82adb8d7daa to your computer and use it in GitHub Desktop.
Save ji6czd/1c43ee63c81637bc98a2e82adb8d7daa to your computer and use it in GitHub Desktop.
My Emacs init file.
;(load-file "~/src/emacspeak/lisp/emacspeak-setup.el")
(blink-cursor-mode 0)
;; Emacs startup initialization
(set-language-environment 'Japanese)
(setq default-buffer-file-coding-system 'utf-8)
(setq default-process-coding-system '(utf-8 . utf-8))
(setq default-file-name-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-default-coding-systems 'utf-8) ; utf-8 にする
(prefer-coding-system 'utf-8)
(setq gc-cons-threshold (* 100 1024 1024))
(setq read-process-output-max (* 1024 1024))
;; Set backup directory
(setq backup-directory-alist
(cons (cons ".*" (expand-file-name "~/.emacs.d/backup"))
backup-directory-alist))
(setq auto-save-file-name-transforms
`((".*", (expand-file-name "~/.emacs.d/backup/") t)))
;; xterm-mouse-mode
(xterm-mouse-mode t)
(require 'mouse)
;; ウィンドーが横に分割されるのを防ぐ
(setq split-width-threshold nil)
(setq visible-cursor nil)
;; Sharing clipboard
(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))))
(setq interprogram-cut-function 'paste-to-osx)
(setq interprogram-paste-function 'copy-from-osx)
;; Package system
(setq package-archives
'(("melpa" . "http://melpa.org/packages/")
("gnu" . "http://elpa.gnu.org/packages/")
("org" . "http://orgmode.org/elpa/")
))
(package-initialize)
;;; use-package
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
;;; custom-file
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
(load custom-file))
;; w3m
(use-package w3m
:ensure t
:defer t
:bind
(:map w3m-mode-map
("<left>" . left-char)
("<right>" . right-char)
("<up>" . previous-line)
("<down>" . next-line))
)
;; flycheck
(use-package flycheck
:ensure t
:defer t
:init
(global-flycheck-mode t)
)
;; lsp-mode
(use-package lsp-mode
:ensure t
:defer t
:custom ((lsp-prefer-capf t)
(lsp-enable-snippet t)
(lsp-lens-enable nil)
(lsp-enable-indentation nil)
(lsp-prefer-flymake nil)
(lsp-document-sync-method 2)
(lsp-inhibit-message t)
(lsp-message-project-root-warning t)
(create-lockfiles nil)
(lsp-rust-server 'rust-analyzer)
(lsp-clients-clangd-executable "/usr/local/opt/llvm/bin/clangd"))
:init
(add-hook 'c++-mode-hook 'lsp)
(add-hook 'c-mode-hook 'lsp)
(unbind-key "C-l")
:bind
(("C-l C-l" . lsp)
("C-l h" . lsp-describe-session)
("C-l t" . lsp-goto-type-definition)
("C-l r" . lsp-rename)
("C-l <f5>" . lsp-restart-workspace)
("C-l l" . lsp-lens-mode))
:hook
(rust-mode . lsp)
(prog-major-mode . lsp-prog-major-mode-enable)
)
;; company
(use-package company
:ensure t
:defer t
:custom
(company-clang-executable "/usr/local/opt/llvm/bin/clang")
(company-transformers '(company-sort-by-backend-importance))
(company-idle-delay 0)
(company-echo-delay 0)
(company-minimum-prefix-length 2)
(company-selection-wrap-around t)
(completion-ignore-case t)
:bind
(("C-M-<tab>" . company-complete))
(:map company-active-map
("C-n" . company-select-next)
("C-p" . company-select-previous)
("C-s" . company-filter-candidates)
("C-i" . company-complete-selection)
([tab] . company-complete-selection))
(:map company-search-map
("C-n" . company-select-next)
("C-p" . company-select-previous))
:init
(global-company-mode t)
;; yasnippetとの連携
(defvar company-mode/enable-yas t)
(defun company-mode/backend-with-yas (backend)
(if (or (not company-mode/enable-yas) (and (listp backend) (member 'company-yasnippet backend)))
backend
(append (if (consp backend) backend (list backend))
'(:with company-yasnippet))))
(setq company-backends (mapcar #'company-mode/backend-with-yas company-backends)))
;; yasnippet
(use-package yasnippet
:ensure t
:bind
(:map yas-minor-mode-map
("C-x i n" . yas-new-snippet)
("C-x i v" . yas-visit-snippet-file)
("C-M-i" . yas-insert-snippet))
(:map yas-keymap
("<tab>" . nil)) ;; because of avoiding conflict with company keymap
:init
(yas-global-mode t))
;; CMake
(use-package cmake-mode
:ensure t
)
(use-package flycheck-google-cpplint
:ensure t
)
(use-package rust-mode
:ensure t
:custom rust-format-on-save t)
;; Flutter & Dart
(use-package dart-mode
:ensure t
:custom
(dart-format-on-save t)
(dart-sdk-path "~/flutter/bin/cache/dart-sdk"))
(use-package lsp-dart
:ensure t
:hook (dart-mode . lsp)
:custom
(lsp-dart-suggest-from-unimported-libraries nil)
(lsp-dart-main-code-lens nil)
(lsp-dart-closing-labels nil)
(lsp-dart-flutter-widget-guides nil)
)
;; Java
(use-package lsp-java
:hook
(java-mode . lsp)
)
;; Golang
(use-package go-mode
:ensure t
:hook
(go-mode . lsp)
)
(use-package swift-mode
:ensure t
)
(use-package lsp-sourcekit
:ensure t
)
;; Mew
(use-package mew
:ensure t
:custom
(mew-name "切明政憲 \(KIRIAKE Masanori\)")
(mew-user "seiken")
(mew-mail-domain "lab.rd01.net")
(mew-proto "%")
(mew-smtp-server "lab.rd01.net")
(mew-smtp-port "submission")
(mew-smtp-ssl-port "submission")
(mew-smtp-user "seiken")
(mew-smtp-ssl t)
(mew-imap-server "lab.rd01.net")
(mew-imap-ssl t)
(mew-imap-delete nil)
(mew-imap-size 0)
:config
(setq mew-ssl-verify-level 0)
(setq mew-use-smtp-auth t)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment