Last active
December 17, 2017 13:06
-
-
Save jackgris/8570156 to your computer and use it in GitHub Desktop.
Possible settings for Emacs, with support for the Go language and more
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
;; ;;(add-to-list 'auto-mode-alist '("\\.jsx\\'" . web-mode)) | |
;; ;;(add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode)) | |
;; ;;(setq web-mode-content-types-alist '(("jsx" . "*\\.js[x]?\\'")) | |
;; ; Para que el demonio de emacs cargue nuestro archivo de configuración, | |
;; ; el comando de inicio debería ser algo así: | |
;; ;; emacs -u usuario --daemon -l ~/.emacs | |
(require 'package) | |
(package-initialize) | |
;; habilitamos los servidores | |
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") | |
("marmalade" . "http://marmalade-repo.org/packages/") | |
("melpa" . "http://melpa.milkbox.net/packages/") | |
("elpa" . "http://elpa.gnu.org/packages/") | |
("elpy" . "http://jorgenschaefer.github.io/packages/") | |
("org" . "http://orgmode.org/elpa/"))) | |
;; Cargamos el thema | |
;; (load-theme 'solarized-dark t) | |
;; (load-theme 'afternoon t) | |
(if (daemonp) | |
(add-hook 'after-make-frame-functions | |
'(lambda (f) | |
(with-selected-frame f | |
(when (window-system f) (load-theme 'afternoon t))))) | |
(load-theme 'afternoon t)) | |
(setq explicit-shell-file-name "/bin/bash") | |
;; vamos a configurar esta tecla para que sirva como la tecla comun de borrar | |
(global-set-key (kbd "C-z") 'delete-char) | |
(global-set-key (kbd "¬") 'advertised-undo) | |
;; añadimos el elpy para python | |
(elpy-enable) | |
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; ;; Esta es la configuracion de Emacs para el lenguaje Go ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; ;; http://tleyden.github.io/blog/2014/05/22/configure-emacs-as-a-go-editor-from-scratch/ ;; | |
;; ;; http://tleyden.github.io/blog/2014/05/27/configure-emacs-as-a-go-editor-from-scratch-part-2/;; | |
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(setenv "PATH" "/home/jackgris/GoProjects/bin/") | |
(setenv "GOPATH" "/home/jackgris/GoProjects") | |
;; Trabajar con emacs y el lenguaje go | |
(add-to-list 'load-path "~/.emacs.d/go/") | |
(require 'go-mode) | |
;;(setq exec-path (cons "/usr/local/go/bin" exec-path)) | |
(setq exec-path (append exec-path '("/usr/local/go/bin"))) | |
(add-to-list 'exec-path "/home/jackgris/GoProjects/bin") | |
(require 'go-autocomplete) | |
(require 'auto-complete-config) | |
(ac-config-default) | |
;; agregamos lint para go | |
(add-to-list 'load-path | |
(concat (getenv "GOPATH") "/src/github.com/golang/lint/misc/emacs")) | |
(require 'golint) | |
; Go Oracle | |
;; (load-file "$GOPATH/src/golang.org/x/tools/cmd/oracle/oracle.el") | |
;; Debemos configurar el proyecto sobre el que vamos a trabajar con el siguiente | |
;; comando: M-x go-oracle-set-scope (debemos pasarle el PATH del proyecto al | |
;; estilo de los import, no el PATH absoluto) | |
;; Luego si nos colocamos por encima de una funcion, podemos usar la funcion: | |
;; M-x go-oracle-callers | |
;; Para que nos muestre en que lugares es llamada la misma | |
(require 'go-guru) | |
(add-hook 'go-mode-hook #'go-guru-hl-identifier-mode) | |
(defun my-go-mode-hook () | |
; Use goimports instead of go-fmt | |
(setq gofmt-command "goimports") | |
; Call Gofmt before saving | |
(add-hook 'before-save-hook 'gofmt-before-save) | |
; Customize compile command to run go build | |
(if (not (string-match "go" compile-command)) | |
(set (make-local-variable 'compile-command) | |
"go build -v ;and go test -v ;and go vet")) | |
; Godef jump key binding | |
(local-set-key (kbd "M-.") 'godef-jump)) | |
; Gracias a esto, vamos a poder ir a la definicion de la funcion precionando | |
; M-. y vamos a poder volver donde estabamos presionando M-* | |
; Si no funcion M-* para volver, este es la otra opción para ello C-x <LEFT> | |
; Básicamente con esto volvemos al anterior buffer | |
; Go Oracle | |
;(go-oracle-mode) | |
(add-hook 'go-mode-hook 'my-go-mode-hook) | |
(require 'go-eldoc) | |
(add-hook 'go-mode-hook 'go-eldoc-setup) | |
(add-to-list 'load-path "~/GoProjects/src/github.com/dougm/goflymake") | |
(require 'go-flymake) | |
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; cargamos la sesion anterior cuando abrimos emacs | |
(require 'desktop) | |
;; (setq desktop-path (list "/home/jackgris/.emacs-server")) | |
(desktop-save-mode 1) | |
(defun my-desktop-save () | |
(interactive) | |
;; Don't call desktop-save-in-desktop-dir, as it prints a message. | |
(if (eq (desktop-owner) (emacs-pid)) | |
(desktop-save desktop-dirname))) | |
(add-hook 'auto-save-hook 'my-desktop-save) | |
(require 'ido) | |
(ido-mode t) | |
;; store all backup and autosave files in the tmp dir | |
(setq backup-directory-alist | |
`((".*" . ,temporary-file-directory))) | |
(setq auto-save-file-name-transforms | |
`((".*" ,temporary-file-directory t))) | |
;; cambiamos la identacion del tab a 4 espacios | |
(setq-default indent-tabs-mode nil) | |
(setq-default tab-width 4) | |
(setq indent-line-function 'insert-tab) | |
;; con esto configuramos para que nos muestre los numeros de linea | |
;; (setq linum-format "%d ") | |
(setq linum-format "%4d \u2502 ") | |
(require 'linum) ;; you miss this line | |
(global-linum-mode 1) | |
;; muestra el numero de columna | |
(setq column-number-mode t) | |
(global-auto-complete-mode t) | |
(auto-complete-mode) | |
;; Vamos a mostrar el nombre de la funcion donde nos encontramos | |
(which-function-mode) | |
;; Este es el texto que se va a mostrar cuando no se conoce el nombre | |
;; de la funcion | |
(setq which-func-unknown "no se conoce nombre funcion") | |
;; Vamos a mostrar el nombre de la funcion en la parte superior | |
(which-function-mode) | |
(setq-default header-line-format | |
'((which-func-mode ("" which-func-format " ")))) | |
(setq mode-line-misc-info | |
;; Vamos a remover el texto de la funcion de la "mode line" | |
(assq-delete-all 'which-func-mode mode-line-misc-info)) | |
;; configuramos una linea indicadora de la columna 80 | |
(add-to-list 'load-path "~/.emacs.d/fill-column-indicator.el") | |
(require 'fill-column-indicator) | |
(define-globalized-minor-mode | |
global-fci-mode fci-mode (lambda () (fci-mode 1) (set-fill-column 80))) | |
(global-fci-mode t) | |
;; Configuramos nuestro aspell como nuestro spellchecker | |
(setq ispell-program-name "aspell") | |
(setq ispell-list-command "list") | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Vamos a configurar el lenguaje Haskell | |
;; activa la identacion con el haskell mode | |
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) | |
(add-hook 'haskell-mode-hook 'turn-on-hi2) | |
;; manejo de import con el haskell mode usando la tecla F8 | |
(eval-after-load 'haskell-mode | |
'(define-key haskell-mode-map [f8] 'haskell-navigate-imports)) | |
(setenv "PATH" (concat "~/.cabal/bin:" (getenv "PATH"))) | |
(add-to-list 'exec-path "~/.cabal/bin") | |
;; Algunas combinaciones de comandos utiles el el mode haskell | |
(eval-after-load 'haskell-mode '(progn | |
(define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-or-reload) | |
(define-key haskell-mode-map (kbd "C-c C-z") 'haskell-interactive-switch) | |
(define-key haskell-mode-map (kbd "C-c C-n C-t") 'haskell-process-do-type) | |
(define-key haskell-mode-map (kbd "C-c C-n C-i") 'haskell-process-do-info) | |
(define-key haskell-mode-map (kbd "C-c C-n C-c") 'haskell-process-cabal-build) | |
(define-key haskell-mode-map (kbd "C-c C-n c") 'haskell-process-cabal) | |
(define-key haskell-mode-map (kbd "SPC") 'haskell-mode-contextual-space))) | |
(eval-after-load 'haskell-cabal '(progn | |
(define-key haskell-cabal-mode-map (kbd "C-c C-z") 'haskell-interactive-switch) | |
(define-key haskell-cabal-mode-map (kbd "C-c C-k") 'haskell-interactive-mode-clear) | |
(define-key haskell-cabal-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build) | |
(define-key haskell-cabal-mode-map (kbd "C-c c") 'haskell-process-cabal))) | |
;; Compilar | |
(eval-after-load 'haskell-mode | |
'(define-key haskell-mode-map (kbd "C-c C-o") 'haskell-compile)) | |
(eval-after-load 'haskell-cabal | |
'(define-key haskell-cabal-mode-map (kbd "C-c C-o") 'haskell-compile)) | |
(autoload 'ghc-init "ghc" nil t) | |
(autoload 'ghc-debug "ghc" nil t) | |
(add-hook 'haskell-mode-hook (lambda () (ghc-init))) | |
;; Autocompletado | |
(require 'company) | |
(add-hook 'haskell-mode-hook 'company-mode) | |
(add-to-list 'company-backends 'company-ghc) | |
;; Estructurar el codigo fuente | |
(add-hook 'haskell-mode-hook 'structured-haskell-mode) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Configuramos Aspell como nuestro corrector ortográfico | |
(setq ispell-program-name "aspell" | |
ispell-extra-args '("--sug-mode=ultra")) | |
;; Cambiar el tamaño de los paneles en emacs | |
(global-set-key (kbd "<C-S-up>") 'shrink-window) | |
(global-set-key (kbd "<C-S-down>") 'enlarge-window) | |
(global-set-key (kbd "<C-S-left>") 'shrink-window-horizontally) | |
(global-set-key (kbd "<C-S-right>") 'enlarge-window-horizontally) | |
(require 'go-direx) ;; Don't need to require, if you install by package.el | |
(define-key go-mode-map (kbd "C-c C-j") 'go-direx-pop-to-buffer) | |
(require 'popwin) | |
(setq display-buffer-function 'popwin:display-buffer) | |
;; (push '("^\*go-direx:" :regexp t :position left :width 0.4 :dedicated t :stick t) | |
;; popwin:special-display-config) | |
(push '("^\*go-direx:" :regexp t :position right :width 0.4 :dedicated t :stick t) | |
popwin:special-display-config) | |
(global-set-key "\C-ca" 'org-agenda) | |
(require 'org-agenda) | |
(setq org-directory "~/Dropbox/org") | |
(global-set-key "\C-cc" 'org-capture) | |
(setq org-capture-templates | |
(quote ( | |
("n" "note" entry (file+datetree "~/Dropbox/org/reference.org") | |
"* %?\nEntered on %U\n %i")))) | |
(setq org-tag-alist (quote (("BIO" . ?b) | |
("COMP" . ?c) | |
("EMACS" . ?e) | |
("GOLANG" . ?g) | |
("FOOD" . ?f)))) | |
(require 'iy-go-to-char) | |
(global-set-key (kbd "M-m") 'iy-go-to-char) | |
(require 'multiple-cursors) | |
(global-set-key (kbd "C-c >") 'mc/mark-next-like-this) | |
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) | |
(global-set-key (kbd "C-c <") 'mc/mark-all-like-this) | |
(require 'expand-region) | |
(global-set-key (kbd "C-@") 'er/expand-region) | |
;; Not sound with C-g | |
(setq visible-bell 1) | |
;; Ace jump mode major function | |
(add-to-list 'load-path "~/.emacs.d/ace-jump-mode/") | |
(autoload | |
'ace-jump-mode | |
"ace-jump-mode" | |
"Emacs quick move minor mode" | |
t) | |
;; you can select the key you prefer to | |
(define-key global-map (kbd "C-c ø") 'ace-jump-mode) | |
;; enable a more powerful jump back function from ace jump mode | |
(autoload | |
'ace-jump-mode-pop-mark | |
"ace-jump-mode" | |
"Ace jump back:-)" | |
t) | |
(eval-after-load "ace-jump-mode" | |
'(ace-jump-mode-enable-mark-sync)) | |
(define-key global-map (kbd "C-c Ø") 'ace-jump-mode-pop-mark) | |
(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. | |
'(custom-safe-themes | |
(quote | |
("28ec8ccf6190f6a73812df9bc91df54ce1d6132f18b4c8fcc85d45298569eb53" "b51c2dda65e8e7e66ab1b06bc10b59e61c153b0cf928f296efab5a7574779fb6" "d677ef584c6dfc0697901a44b885cc18e206f05114c8a3b7fde674fce6180879" "8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" default))) | |
'(js2-highlight-level 3) | |
'(package-selected-packages | |
(quote | |
(neotree magit elixir-mode use-package auto-complete go-mode afternoon-theme kooten-theme go-errcheck go-rename tide less-css-mode jsx-mode js2-mode elm-mode company company-racer flycheck flycheck-rust racer rust-mode php-mode solarized-theme popwin multiple-cursors iy-go-to-char golint go-eldoc go-direx go-autocomplete fill-column-indicator expand-region elpy)))) | |
(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. | |
) | |
(require 'yasnippet) | |
(yas-global-mode 1) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Rust mode | |
;; Reduce the time after which the company auto completion popup opens | |
(setq company-idle-delay 0.2) | |
;; Reduce the number of characters before company kicks in | |
(setq company-minimum-prefix-length 1) | |
;; Set path to racer binary | |
(setq racer-cmd "/usr/local/bin/racer") | |
;; Set path to rust src directory | |
(setq racer-rust-src-path "/home/jackgris/.rust/src/") | |
;; Load rust-mode when you open `.rs` files | |
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode)) | |
;; Setting up configurations when you load rust-mode | |
(add-hook 'rust-mode-hook | |
'(lambda () | |
;; Enable racer | |
(racer-activate) | |
;; Hook in racer with eldoc to provide documentation | |
(racer-turn-on-eldoc) | |
;; Use flycheck-rust in rust-mode | |
(add-hook 'flycheck-mode-hook #'flycheck-rust-setup) | |
;; Use company-racer in rust mode | |
(set (make-local-variable 'company-backends) '(company-racer)) | |
;; Key binding to jump to method definition | |
(local-set-key (kbd "M-.") #'racer-find-definition) | |
;; Key binding to auto complete and indent | |
(local-set-key (kbd "TAB") #'racer-complete-or-indent))) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(require 'js2-mode) | |
(add-to-list 'auto-mode-alist `(,(rx ".js" string-end) . js2-jsx-mode)) | |
(add-to-list 'auto-mode-alist `(,(rx ".jsx" string-end) . js2-jsx-mode)) | |
(require 'json-mode) | |
;; Read file again in the buffer | |
(defun revert-buffer-no-confirm () | |
"Revert buffer without confirmation." | |
(interactive) | |
(revert-buffer :ignore-auto :noconfirm)) | |
;; set a default font | |
(when (member "Go" (font-family-list)) | |
(set-face-attribute 'default nil :font "Go")) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;; Typescript config | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(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) | |
;; format options | |
(setq tide-format-options '(:insertSpaceAfterFunctionKeywordForAnonymousFunctions t :placeOpenBraceOnNewLineForFunctions nil)) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;; Erlang Mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(require 'whitespace) | |
(unless (member 'whitespace-mode prog-mode-hook) | |
(add-hook 'prog-mode-hook 'whitespace-mode)) | |
(global-set-key (kbd "C-c w") 'whitespace-cleanup) | |
(set-default 'indicate-empty-lines t) | |
(set-default 'indent-tabs-mode nil) | |
(setq whitespace-style '(face trailing lines-tail tabs) | |
whitespace-line-column 80) | |
(defun seancribbs/turn-on-hl-line-mode () | |
(when (> (display-color-cells) 8) | |
(hl-line-mode t))) | |
(defun seancribbs/add-watchwords () | |
(font-lock-add-keywords | |
nil '(("\\<\\(FIX\\(ME\\)?\\|TODO\\|HACK\\|REFACTOR\\|NOCOMMIT\\)" | |
1 font-lock-warning-face t)))) | |
(add-hook 'prog-mode-hook 'seancribbs/turn-on-hl-line-mode) | |
(add-hook 'prog-mode-hook 'seancribbs/add-watchwords) | |
(show-paren-mode t) | |
(defun comment-or-uncomment-region-or-line () | |
"Comments or uncomments the region or the current line if there's no active region." | |
(interactive) | |
(let (beg end) | |
(if (region-active-p) | |
(setq beg (region-beginning) end (region-end)) | |
(setq beg (line-beginning-position) end (line-end-position))) | |
(comment-or-uncomment-region beg end))) | |
(global-set-key (kbd "M-/") 'comment-or-uncomment-region-or-line) | |
(global-set-key (kbd "M-\\") 'dabbrev-expand) | |
(defun seancribbs/flymake-keys () | |
"Adds keys for navigating between errors found by Flymake." | |
(local-set-key (kbd "C-c C-n") 'flymake-goto-next-error) | |
(local-set-key (kbd "C-c C-p") 'flymake-goto-prev-error)) | |
(add-hook 'flymake-mode-hook 'seancribbs/flymake-keys) | |
(setq load-path (cons "/usr/lib/erlang/lib/tools-2.10/emacs" load-path)) | |
(setq erlang-root-dir "/usr/lib/erlang/") | |
(setq exec-path (cons "/usr/lib/erlang/bin" exec-path)) | |
(require 'erlang-start) | |
(add-hook 'erlang-mode-hook 'seancribbs/add-watchwords) | |
(add-hook 'erlang-mode-hook 'seancribbs/turn-on-hl-line-mode) | |
(add-hook 'erlang-mode-hook 'whitespace-mode) | |
(add-to-list 'auto-mode-alist '("rebar.config" . erlang-mode)) ;; rebar | |
(add-to-list 'auto-mode-alist '("rebar.config.script" . erlang-mode)) ;; rebar | |
(add-to-list 'auto-mode-alist '("app.config" . erlang-mode)) ;; embedded node/riak | |
;;(add-to-list 'auto-mode-alist '(".riak_test.config" . erlang-mode)) | |
(add-to-list 'auto-mode-alist '("\\.erlang$" . erlang-mode)) ;; User customizations file | |
(require 'erlang-flymake) | |
(defun rebar3/erlang-flymake-get-include-dirs () | |
(append | |
(erlang-flymake-get-include-dirs) | |
(file-expand-wildcards (concat (erlang-flymake-get-app-dir) "_build/*/lib"))) | |
) | |
(setq erlang-flymake-get-include-dirs-function 'rebar3/erlang-flymake-get-include-dirs) | |
(defun rebar3/erlang-flymake-get-code-path-dirs () | |
(append | |
(erlang-flymake-get-code-path-dirs) | |
(file-expand-wildcards (concat (erlang-flymake-get-app-dir) "_build/*/lib/*/ebin")))) | |
(setq erlang-flymake-get-code-path-dirs-function 'rebar3/erlang-flymake-get-code-path-dirs) | |
(require 'neotree) | |
(global-set-key [f8] 'neotree-toggle) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment