Last active
March 3, 2022 09:51
-
-
Save vang1ong7ang/696d5d79b2946bd7436650fa3735ac64 to your computer and use it in GitHub Desktop.
.emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; package --- Summary | |
;; todo | |
;;; Commentary: | |
;; todo | |
;;; Code: | |
;; todo | |
(add-to-list 'package-archives '("mepla" . "https://melpa.org/packages/") t) | |
(setq package-selected-packages '(gist exwm go-mode csharp-mode smex flycheck company treemacs multi-term lsp-mode)) | |
(package-initialize) | |
(require 'lsp-mode) | |
(require 'exwm) | |
(require 'treemacs) | |
(require 'multi-term) | |
(require 'lsp-pylsp) | |
(setq make-backup-files nil) | |
(setq auto-save-default nil) | |
(setq confirm-kill-processes nil) | |
(add-to-list 'display-buffer-alist '("*Help*" display-buffer-same-window)) | |
(add-hook 'after-init-hook 'global-company-mode) | |
(add-hook 'c-mode-hook 'lsp) | |
(add-hook 'c++-mode-hook 'lsp) | |
(add-hook 'python-mode-hook 'lsp) | |
(add-hook 'go-mode-hook 'lsp) | |
(add-hook 'csharp-mode-hook 'lsp) | |
(add-hook 'js-mode-hook 'lsp) | |
(ido-mode t) | |
(menu-bar-mode 0) | |
(tool-bar-mode -1) | |
(scroll-bar-mode -1) | |
(fringe-mode 1) | |
(global-flycheck-mode t) | |
(treemacs-define-RET-action 'file-node-open 'treemacs-visit-node-no-split) | |
(treemacs-define-RET-action 'file-node-closed 'treemacs-visit-node-no-split) | |
(add-to-list 'default-frame-alist '(foreground-color . "white")) | |
(add-to-list 'default-frame-alist '(background-color . "black")) | |
(setq multi-term-dedicated-skip-other-window-p t) | |
(setq lsp-pylsp-plugins-autopep8-enabled t) | |
(global-set-key (kbd "C-c q") (lambda () "format and save" (interactive) (ignore-errors (lsp-organize-imports))(ignore-errors (lsp-format-buffer))(save-buffer))) | |
(global-set-key (kbd "C-c e") 'eval-expression) | |
(global-set-key (kbd "C-c E") 'eval-region) | |
(global-set-key (kbd "C-c r") 'smex) | |
(global-set-key (kbd "C-c t") (lambda () "toggle multi-term" (interactive) (let ((multi-term-dedicated-select-after-open-p t)) (multi-term-dedicated-toggle)))) | |
(global-set-key (kbd "C-c T") 'multi-term-next) | |
(global-set-key (kbd "C-c f") 'treemacs) | |
(global-set-key (kbd "C-c g") 'lsp-find-definition) | |
(global-set-key (kbd "C-c x") (lambda (command) (interactive (list (read-shell-command "$ "))) (start-process-shell-command command nil command))) | |
(global-set-key (kbd "C-c w") 'windmove-up) | |
(global-set-key (kbd "C-c W") 'windmove-swap-states-up) | |
(global-set-key (kbd "C-c s") 'windmove-down) | |
(global-set-key (kbd "C-c S") 'windmove-swap-states-down) | |
(global-set-key (kbd "C-c a") 'windmove-left) | |
(global-set-key (kbd "C-c A") 'windmove-swap-states-left) | |
(global-set-key (kbd "C-c d") 'windmove-right) | |
(global-set-key (kbd "C-c D") 'windmove-swap-states-right) | |
(mapc (lambda (x) (define-key key-translation-map (vector (+ ?\s-a (- x ?a))) (vector ?\C-c x))) (number-sequence ?a ?z)) | |
(mapc (lambda (x) (define-key key-translation-map (vector (+ ?\s-A (- x ?A))) (vector ?\C-c x))) (number-sequence ?A ?Z)) | |
(when (string-equal window-system "x") (setq exwm-input-global-keys '(([s-up] . (lambda (x) "mouse-up" (interactive "p") (let ((p (mouse-absolute-pixel-position))) (set-mouse-absolute-pixel-position (car p) (- (cdr p) (/ (display-pixel-width) (* #x10 (expt 2 x)))))))) ([s-down] . (lambda (x) "mouse-down" (interactive "p") (let ((p (mouse-absolute-pixel-position))) (set-mouse-absolute-pixel-position (car p) (+ (cdr p) (/ (display-pixel-width) (* #x10 (expt 2 x)))))))) ([s-left] . (lambda (x) "mouse-left" (interactive "p") (let ((p (mouse-absolute-pixel-position))) (set-mouse-absolute-pixel-position (- (car p) (/ (display-pixel-width) (* #x10 (expt 2 x)))) (cdr p))))) ([s-right] . (lambda (x) "mouse-right" (interactive "p") (let ((p (mouse-absolute-pixel-position))) (set-mouse-absolute-pixel-position (+ (car p) (/ (display-pixel-width) (* #x10 (expt 2 x)))) (cdr p))))) ([?\s-[] . (lambda () "mouse click" (interactive) (shell-command "xdotool click 1"))) ([?\s-]] . (lambda () "mouse click" (interactive) (shell-command "xdotool click 3"))) ([s-prior] . (lambda () "mouse scroll" (interactive) (shell-command "xdotool click 4"))) ([s-next] . (lambda () "mouse scroll" (interactive) (shell-command "xdotool click 5"))) ([s-escape] . (lambda () "lock screen" (interactive) (shell-command "slock"))))) (exwm-enable) (add-to-list 'default-frame-alist '(font . "-DAMA-UbuntuMono Nerd Font-bold-normal-normal-*-27-*-*-*-m-0-iso10646-1"))) | |
;; todo | |
;; todo: multi cursor | |
;; todo: cut/copy/paste line | |
;; undo tree | |
(provide '.emacs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment