Created
January 25, 2020 14:55
-
-
Save amirrajan/5991a34a2e096387926997f9388e827e to your computer and use it in GitHub Desktop.
My init.el for .Net dev on Windows
This file contains 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
;; This is a import that ships with emacs. | |
(load "~/.emacs.d/railscasts-theme/railscasts-theme.el" nil t) | |
;; (toggle-frame-fullscreen) | |
(toggle-frame-maximized) | |
(toggle-scroll-bar -1) | |
(menu-bar-mode -1) | |
(tool-bar-mode -1) | |
(defun display-startup-echo-area-message () (message "")) | |
(add-hook 'dired-mode-hook 'dired-hide-details-mode) | |
(set-cursor-color "#ffffff") | |
(setq frame-title-format '("Visual Studio 2020 Insider Preview")) | |
;; package is Emacs's package manager. | |
(require 'package) | |
;; After the repositories have been set, initialize the package | |
;; manager. | |
(package-initialize) | |
(setq inferior-fsharp-program "\"C:\\Program Files (x86)\\Microsoft SDKs\\F#\\4.1\\Framework\\v4.0\\fsi.exe\"") | |
(require 'editorconfig) | |
;; Emacs has an official repository of packages and a more current | |
;; unofficial one. Melpa is the 'unoffical one' (which in this | |
;; case translates to more up to date, newer, and by extension, | |
;; a bit more volatile). The official repo is called org. This | |
;; repo is slow changing and extremely stable (but doesn't have | |
;; all the cool/cutting edge packages that are being used). | |
(push '("melpa" . "http://melpa.org/packages/") package-archives) | |
(push '("org" . "http://orgmode.org/elpa/") package-archives) | |
(push '("melpa-stable" . "https://stable.melpa.org/packages/") package-archives) | |
(defun mfc () | |
(interactive) | |
(make-frame-command) | |
(toggle-frame-maximized)) | |
(defun amir-reinstall-packages-core () | |
;; Emacs keeps a cache of the package list locally. We'll | |
;; initialize this cache once. If you ever go to install a package | |
;; and it cant be found, just rerun (package-reresh-contents). | |
(unless package-archive-contents (package-refresh-contents)) | |
;; Here is our big bad package list. Whenever you want to | |
;; install a new package, just add it to this list. | |
(setq bootstrap-list | |
'(use-package)) | |
(dolist (package bootstrap-list) | |
(unless (package-installed-p package) | |
(package-install package)))) | |
(defun amir-reinstall-packages () | |
(interactive) (amir-reinstall-packages-core)) | |
(amir-reinstall-packages-core) | |
(defun amir-copy-file-path () | |
"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 clipboard." filename)))) | |
(use-package editorconfig | |
:ensure t | |
:config | |
(visual-line-mode) | |
(editorconfig-mode 1) | |
(define-key global-map (kbd "RET") 'newline-and-indent) | |
(display-line-numbers-mode) | |
(setq visible-bell 1) | |
(setq backup-directory-alist '(("." . "~/.emacs.d/backups"))) | |
(setq delete-old-versions -1) | |
(setq version-control t) | |
(setq vc-make-backup-files t) | |
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t))) | |
(setq large-file-warning-threshold 20000000) | |
(setq-default indent-tabs-mode nil) | |
;; (global-display-line-numbers-mode) | |
(allout-mode 0) | |
;;(add-hook 'after-init-hook 'allout-widgets-mode-off) | |
(add-to-list 'auto-mode-alist '("\\.ino$" . c-mode)) | |
(add-hook 'c-mode-hook #'(lambda () (modify-syntax-entry ?_ "w"))) | |
(add-hook 'c++-mode-hook #'(lambda () (modify-syntax-entry ?_ "w"))) | |
(add-hook 'lua-mode-hook #'(lambda () (modify-syntax-entry ?_ "w"))) | |
(add-to-list 'auto-mode-alist '("\\.log\\'" . auto-revert-mode)) | |
(electric-pair-mode 1) | |
(org-babel-do-load-languages | |
'org-babel-load-languages | |
'((ruby . t))) | |
(setq org-src-tab-acts-natively t) | |
(setq org-src-fontify-natively t) | |
(defun amir-turn-on-show-trailing-whitespace () | |
(interactive) | |
(setq show-trailing-whitespace t)) | |
(defun sudo-edit (&optional arg) | |
"Edit currently visited file as root. | |
With a prefix ARG prompt for a file to visit. | |
Will also prompt for a file to visit if current | |
buffer is not visiting a file." | |
(interactive "P") | |
(if (or arg (not buffer-file-name)) | |
(find-file (concat "/sudo:root@localhost:" | |
(ido-read-file-name "Find file(as root): "))) | |
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name)))) | |
(add-hook 'before-save-hook 'delete-trailing-whitespace) | |
(add-hook 'prog-mode-hook 'amir-turn-on-show-trailing-whitespace)) | |
(use-package dashboard | |
:ensure t | |
:config | |
(setq dashboard-startup-banner "~/.emacs.d/logo.png") | |
(setq dashboard-banner-logo-title "Microsoft Visual Studio 2020 Insider Preview") | |
(setq dashboard-items '()) | |
(setq dashboard-set-footer nil) | |
(setq dashboard-init-info "") | |
(setq dashboard-show-shortcuts nil) | |
(dashboard-setup-startup-hook) | |
) | |
(use-package evil | |
:ensure t | |
:init | |
(setq evil-want-C-i-jump nil) | |
:config | |
(evil-mode 1) | |
;; wire up emacs so that I can spam the escape key and | |
;; exit whatever ridiculous window/buffer it has me in. | |
(defun minibuffer-keyboard-quit () | |
(interactive) | |
(if (and delete-selection-mode transient-mark-mode mark-active) | |
(setq deactivate-mark t) | |
(when (get-buffer "*Completions*") (delete-windows-on "*Completions*")) | |
(abort-recursive-edit))) | |
(define-key evil-normal-state-map [escape] 'keyboard-quit) | |
(define-key evil-visual-state-map [escape] 'keyboard-quit) | |
(define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit) | |
(define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit) | |
(define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit) | |
(define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit) | |
(define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit) | |
(global-set-key [escape] 'evil-exit-emacs-state) | |
(eval-after-load 'dired | |
'(progn | |
(define-key dired-mode-map (kbd "n") nil) | |
(define-key dired-mode-map (kbd "g") nil) | |
(define-key dired-mode-map (kbd "G") nil) | |
(define-key dired-mode-map (kbd "C-r") 'revert-buffer)))) | |
(use-package avy | |
:ensure t | |
:config | |
(setq avy-styles-alist '((avy-goto-word-0 . at-full) (avy-goto-line . at-full))) | |
(setq avy-all-windows nil)) | |
(use-package ivy | |
:ensure t | |
:config | |
(ivy-mode 1) | |
(setq ivy-use-virtual-buffers t) | |
(setq enable-recursive-minibuffers t) | |
(setq ivy-count-format "(%d/%d) ") | |
(setq ivy-re-builders-alist | |
'((t . ivy--regex-fuzzy))) | |
(defun my-action-1 (x) | |
"action one was invoked") | |
(defun my-action-2 (x) | |
(message "action-2: %s" x)) | |
(defun my-action-3 (x) | |
(message "action-3: %s" x)) | |
;; This is a sample function that shows the power of | |
;; Ivy. This method can be invoked via M-x / :. | |
;; Once invoked, it will present an auto complete list | |
;; with three values: foo bar baz. | |
;; On selecting a value, the respective `action(x)` callback | |
;; will be invoked with the string value they entered. | |
(defun my-command-with-3-actions () | |
(interactive) | |
(ivy-read "test: " | |
'("foo" "bar" "baz") | |
:action | |
(lambda (x) | |
(cond | |
((string= x "foo") (message "foo was called")) | |
((string= x "bar") (message "bar was called")) | |
((string= x "baz") (message "baz was called")) | |
(t (message "no match"))))))) | |
(use-package counsel-etags :ensure t) | |
(use-package company | |
:ensure t | |
:config | |
(add-hook 'after-init-hook 'global-company-mode) | |
(add-hook 'org-mode-hook (lambda () (company-mode 0))) | |
;;dont auto complete numbers or things with special characters in it | |
(push (apply-partially | |
#'cl-remove-if | |
(lambda (c) | |
(or (string-match-p "[^\x00-\x7F]+" c) | |
(string-match-p "[0-9]+" c) | |
(if (equal major-mode "org") | |
(>= (length c) 15))))) | |
company-transformers) | |
(setq company-idle-delay 0.03) | |
(setq company-minimum-prefix-length 2) | |
(setq company-show-numbers 't) | |
(setq gc-cons-threshold 20000000) | |
;(setq company-dabbrev-downcase 'nil) | |
(defun amir-company-complete-equal-sign () | |
(interactive) | |
(progn | |
(company-complete-selection) | |
(insert " ="))) | |
(defun amir-company-complete-paren () | |
(interactive) | |
(progn | |
(company-complete-selection) | |
(insert "("))) | |
(defun amir-company-complete-end-paren () | |
(interactive) | |
(progn | |
(company-complete-selection) | |
(insert ")"))) | |
(defun amir-company-complete-. () | |
(interactive) | |
(progn | |
(company-complete-selection) | |
(insert "."))) | |
(defun amir-company-complete-comma () | |
(interactive) | |
(progn | |
(company-complete-selection) | |
(insert ","))) | |
(defun amir-company-complete-end-curly () | |
(interactive) | |
(progn | |
(company-complete-selection) | |
(insert "}"))) | |
;; Make autocomplete insert text if code based keys are pressed | |
(eval-after-load 'company | |
'(progn | |
(define-key company-active-map (kbd "C-n") 'company-abort) | |
(define-key company-active-map (kbd ">") 'company-abort) | |
(define-key company-active-map (kbd "C-k") 'company-select-previous) | |
(define-key company-active-map (kbd "C-j") 'company-select-next) | |
(define-key company-active-map (kbd "<backtab>") 'company-select-previous) | |
(define-key company-active-map (kbd "TAB") 'company-select-next) | |
(define-key company-active-map (kbd "<tab>") 'company-select-next) | |
;; (define-key company-active-map (kbd ".") 'amir-company-complete-.) | |
;; (define-key company-active-map (kbd ",") 'amir-company-complete-comma) | |
;; (define-key company-active-map (kbd "=") 'amir-company-complete-equal-sign) | |
;; (define-key company-active-map (kbd "}") 'amir-company-complete-end-curly) | |
;; (define-key company-active-map (kbd ")") 'amir-company-complete-end-paren) | |
;; (define-key company-active-map (kbd "(") 'amir-company-complete-paren) | |
))) | |
(use-package ruby-mode | |
:ensure t | |
:config | |
(add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode)) | |
(add-hook 'ruby-mode-hook #'(lambda () (modify-syntax-entry ?_ "w"))) | |
(setq ruby-deep-indent-paren nil)) | |
(use-package evil-escape :ensure t) | |
(use-package evil-leader | |
:ensure t | |
:config | |
(defun amir-hsplit-and-find () | |
"Opens a new split window and brings up projectile so I can search for a file." | |
(interactive) | |
(evil-window-split) | |
(projectile-find-file)) | |
(defun amir-split-and-find () | |
"Opens a new split window and brings up dired so I can ." | |
(interactive) | |
(evil-window-vsplit) | |
(projectile-find-file)) | |
(defun amir-hsplit-and-dired () | |
"Opens a new split window and brings up dired so I can navigate a directory." | |
(interactive) | |
(evil-window-split) | |
(ido-dired)) | |
(defun amir-eval-dwim () | |
"Send the current selected \"stuff\" to the repl." | |
(interactive) | |
(pcase major-mode | |
(`clojure-mode (cider-eval-defun-at-point)) | |
(`clojurescript-mode (cider-eval-defun-at-point)) | |
(`fsharp-mode | |
(progn | |
(fsharp-eval-phrase) | |
(evil-next-line 1))) | |
(_ (eval-last-sexp nil)))) | |
(defun amir-zoom-buffer () | |
(interactive) | |
(progn | |
(evil-window-set-width (frame-width)) | |
(evil-window-set-height (frame-height)) | |
(redraw-display))) | |
(defun amir-resize-equal () | |
(interactive) | |
(balance-windows) | |
(redraw-display)) | |
(defun amir-resize-window-dwim () | |
(interactive) | |
(let ((maximize (< (window-width) (/ (frame-width) 2)))) | |
(cond ((< (window-width) 80) (evil-window-set-width 80)) | |
(maximize | |
(progn | |
(evil-window-set-width (frame-width)) | |
(evil-window-set-height (frame-height)) | |
(redraw-display))) | |
((not maximize) (evil-window-set-width 80))))) | |
(defun amir-resize-window-vertical+ () | |
(interactive) | |
(evil-window-set-height (+ (window-height) 10))) | |
(defun amir-resize-window-vertical- () | |
(interactive) | |
(evil-window-set-height (- (window-height) 10))) | |
(defun amir-resize-window-horizontal+ () | |
(interactive) | |
(evil-window-set-width (+ (window-width) 10))) | |
(defun amir-resize-window-horizontal- () | |
(interactive) | |
(evil-window-set-width (- (window-width) 10))) | |
(defun amir-touch () | |
"Run touch command on current file." | |
(interactive) | |
(when buffer-file-name | |
(shell-command (concat "touch " (shell-quote-argument buffer-file-name))) | |
(clear-visited-file-modtime))) | |
(defun amir-split-and-dired () | |
"Opens a new split window and brings up dired so I can navigate a directory." | |
(interactive) | |
(evil-window-vsplit) | |
(ido-dired)) | |
(defun amir-next-frame () | |
(interactive) | |
(other-frame 1) | |
(set-cursor-color "#ffffff")) | |
(defun amir-dos-codepoint () | |
(interactive) | |
(revert-buffer-with-coding-system 'dos)) | |
(global-evil-leader-mode) | |
(evil-leader/set-leader ",") | |
(evil-leader/set-key | |
"V" 'ismyhc-hello-world | |
"a" 'yafolding-toggle-element | |
"A" 'yafolding-toggle-all | |
"v" 'counsel-git-grep | |
"c" 'comment-dwim | |
"e" 'amir-eval-dwim | |
"E" 'fsharp-eval-region | |
"x" 'eval-expression | |
"j" 'avy-goto-line | |
"J" 'toggle-truncate-lines | |
"w" 'avy-goto-word-0 | |
"m" 'amir-split-and-find | |
"M" 'amir-hsplit-and-find | |
"g" 'projectile-find-file | |
"r" 'amir-cider-send-to-repl | |
"t" 'amir-touch | |
"f" 'next-error | |
"F" 'make-frame-command | |
"d" 'previous-error | |
"D" 'amir-dos-codepoint | |
"b" 'ido-switch-buffer | |
"." 'ido-dired | |
"o" 'org-open-at-point | |
"," 'amir-split-and-dired | |
"<" 'amir-hsplit-and-dired | |
"s" 'magit-status | |
"h" 'vc-print-log | |
")" 'next-buffer | |
"0" 'next-buffer | |
"(" 'previous-buffer | |
"9" 'previous-buffer | |
"`" 'amir-resize-window-dwim | |
"TAB" 'amir-resize-equal | |
"2" 'amir-resize-window-vertical+ | |
"3" 'amir-resize-window-vertical- | |
"1" 'amir-resize-window-horizontal- | |
"4" 'amir-resize-window-horizontal+ | |
"z" 'amir-zoom-buffer)) | |
(use-package evil-matchit | |
:ensure t | |
:config | |
(global-evil-matchit-mode 1)) | |
(use-package evil-surround | |
:ensure t | |
:config | |
(global-evil-surround-mode 1)) | |
(use-package color-theme-modern | |
:ensure t) | |
(load "~/.emacs.d/windows-navigator/windows-navigator.el" nil t) | |
(require 'navigate) | |
(use-package magit | |
:ensure t | |
:config | |
(setq magit-last-seen-setup-instructions "1.4.0") | |
(setq tags-add-tables nil)) | |
(use-package evil-magit :ensure t) | |
(use-package evil-org :ensure t) | |
(use-package projectile | |
:ensure t | |
:config | |
(projectile-global-mode)) | |
(use-package ido | |
:ensure t | |
:config | |
(ido-mode 1) | |
(ido-everywhere 1) | |
(defun vim-like-ido-keys () | |
"Add vim like keybindings for ido." | |
(define-key ido-completion-map (kbd "<down>") 'ido-next-match) | |
(define-key ido-completion-map (kbd "C-n") 'ido-next-match) | |
(define-key ido-completion-map (kbd "C-j") 'ido-next-match) | |
(define-key ido-completion-map (kbd "C-p") 'ido-prev-match) | |
(define-key ido-completion-map (kbd "C-k") 'ido-prev-match) | |
(define-key ido-completion-map (kbd "<up>") 'ido-prev-match)) | |
(add-hook 'ido-setup-hook 'vim-like-ido-keys)) | |
(use-package ido-vertical-mode | |
:ensure t | |
:config | |
(ido-vertical-mode 1)) | |
(use-package powershell :ensure t) | |
(use-package flx-ido | |
:ensure t | |
:config | |
(flx-ido-mode 1) | |
(setq ido-enable-flex-matching t) | |
(setq ido-use-faces t) | |
(setq ido-enable-flex-matching t)) | |
(use-package magit | |
:ensure t | |
:config | |
(setq magit-last-seen-setup-instructions "1.4.0") | |
(setq tags-add-tables nil)) | |
(use-package flycheck :ensure t | |
:config | |
(fringe-mode '(20 . 20)) | |
(define-fringe-bitmap 'flycheck-fringe-bitmap-double-arrow | |
(vector #b00000000 | |
#b00000000 | |
#b00000000 | |
#b00000000 | |
#b00000000 | |
#b10011000 | |
#b01101100 | |
#b00110110 | |
#b00011011 | |
#b00110110 | |
#b01101100 | |
#b10011000 | |
#b00000000 | |
#b00000000 | |
#b00000000 | |
#b00000000 | |
#b00000000))) | |
(use-package paredit :ensure t) | |
(use-package csharp-mode | |
:ensure t | |
:config | |
(evil-define-key 'normal csharp-mode-map (kbd "g o") 'evil-goto-definition)) | |
(custom-set-variables | |
;; custom-set-variables was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
'(avy-all-windows (quote all-frames)) | |
'(company-auto-complete-chars (quote (32 40 41 46))) | |
'(company-idle-delay 0.03) | |
'(company-minimum-prefix-length 2) | |
'(company-show-numbers t)) | |
(custom-set-faces | |
;; custom-set-faces was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
'(default ((t (:inherit nil :stipple nil :background "#232323" :foreground "#E6E1DC" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 120 :width normal :foundry "outline" :family "Dank Mono")))) | |
'(company-echo-common ((t (:foreground "black")))) | |
'(company-preview ((t (:background "slate gray" :foreground "azure")))) | |
'(company-preview-common ((t (:inherit company-preview :foreground "black")))) | |
'(company-scrollbar-bg ((t (:background "slate gray")))) | |
'(company-scrollbar-fg ((t (:background "dim gray")))) | |
'(company-tooltip ((t (:background "slate gray" :foreground "azure")))) | |
'(company-tooltip-common ((t (:foreground "black")))) | |
'(company-tooltip-common-selection ((t (:inherit nil :foreground "black")))) | |
'(company-tooltip-selection ((t (:background "dim gray")))) | |
'(custom-button ((t (:background "dark slate gray" :foreground "gainsboro" :box nil)))) | |
'(dashboard-banner-logo-title ((t (:inherit default :height 1.1)))) | |
'(flycheck-info ((t (:underline "dim gray")))) | |
'(fringe ((t (:background " #232323")))) | |
'(link ((t (:foreground "pale turquoise" :underline t)))) | |
'(smerge-refined-added ((t nil))) | |
'(smerge-refined-removed ((t (:foreground "rosy brown")))) | |
'(smerge-upper ((t (:foreground "indian red")))) | |
'(success ((t (:foreground "medium sea green" :weight bold)))) | |
'(avy-lead-face ((t (:background "slate gray" :foreground "white"))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment