Added support for golang.

This commit is contained in:
Mariano Uvalle 2021-03-31 19:47:20 -04:00
parent ec7a5e8945
commit c3add5d12e
3 changed files with 84 additions and 15 deletions

View file

@ -167,7 +167,9 @@ Repeated invocations toggle between the two most recently open buffers."
(use-package key-chord
:config
(key-chord-mode 1)
(key-chord-define evil-insert-state-map "kj" 'evil-normal-state))
(key-chord-define evil-insert-state-map "kj" 'evil-normal-state)
:custom
(key-chord-two-keys-delay 0.3))
#+end_src
** Hydra
@ -638,7 +640,8 @@ Basic configuration for languages servers interactions.
"lgd" '(lsp-find-definition :which-key "go to definition")
"lgi" '(lsp-find-implementation :which-key "find implementation")
"lr" '(:ignore t :which-key "refactor")
"lrr" '(lsp-rename :which-key "rename"))
"lrr" '(lsp-rename :which-key "rename")
)
#+end_src
**** lsp ui
@ -739,7 +742,11 @@ Configuration for Python.
;; Use 4 spaces for the indent level.
(add-hook 'python-mode-hook (lambda ()
(setq python-indent-offset 4)))
(progn
(setq python-guess-indent nil)
(setq python-indent-guess-indent-offset nil)
(setq python-indent 4)
(setq python-indent-offset 4))))
;; If used withing a project that was a virtualenv, use a .dir-locals.el to set the proper interpreter.
;; ((python-mode . ((python-shell-interpreter . "~/dev/6502/eeprom_programmer/venv/bin/python")
@ -757,6 +764,25 @@ Mode package for YAML
(use-package yaml-mode
:mode "\\.yml\\'")
#+end_src
*** Golang
#+begin_src emacs-lisp
(use-package go-mode
:config
(setq gofmt-command (concat (getenv "GOPATH") "/bin/goimports"))
(add-hook 'before-save-hook 'gofmt-before-save))
#+end_src
*** Prisma
#+begin_src emacs-lisp
(load "~/.emacs.d/local-packages/emacs-prisma-mode/prisma-mode.el")
(require 'prisma-mode)
(setq auto-mode-alist
(cons '("\\.prisma$" . prisma-mode) auto-mode-alist))
(setq lsp-language-id-configuration
(cons '("\\.prisma$" . "prisma") lsp-language-id-configuration))
#+end_src
** Company mode
For this config, company mode will only be used with lsp mode. It provides a better workflow for code completion.
@ -777,8 +803,8 @@ For this config, company mode will only be used with lsp mode. It provides a bet
:hook (lsp-mode . company-mode) ;; Run whenever lsp-mode is active.
:bind (:map company-active-map
("<tab>" . 'mariano/company-select-first-and-complete)) ;; When pressing tab, insert the first candidate. Default is cycle.
;; :map (lsp-mode-map
;; ("<tab>" . company-indent-or-complete-common)) ;; Activate if I want common completions in empty line.
(:map lsp-mode-map
("<tab>" . company-indent-or-complete-common)) ;; Activate if I want common completions in empty line.
:custom (company-minimum-prefix-length 1)
(company-idle-delay 0.0))
@ -817,7 +843,8 @@ later use.
(mariano/leader-keys
"p" '(:ignore t :which-key "Projectile")
"pp" '(projectile-switch-project :which-key "switch project")
"pf" '(projectile-find-file :which-key "find file in project"))
"pf" '(projectile-find-file :which-key "find file in project")
"ps" '(projectile-ripgrep :which-key "search in whole project"))
;; Extra ivy actions for projectile commands.
(use-package counsel-projectile
@ -925,3 +952,16 @@ We use origami for folding, keybindings are automatically set by evil.
(mariano/leader-keys
"j" '(dired-jump :which-key "Open in dired"))
#+end_src
* Config files
Leader keys to go to config files.
#+begin_src emacs-lisp
(defun mariano/open-zshell-config ()
(interactive)
(find-file "~/.zshrc"))
(mariano/leader-keys
"c" '(:ignore t :which-key "config files")
"cz" '(mariano/open-zshell-config :which-key "zshell config"))
#+end_src

41
init.el
View file

@ -141,7 +141,9 @@ Repeated invocations toggle between the two most recently open buffers."
(use-package key-chord
:config
(key-chord-mode 1)
(key-chord-define evil-insert-state-map "kj" 'evil-normal-state))
(key-chord-define evil-insert-state-map "kj" 'evil-normal-state)
:custom
(key-chord-two-keys-delay 0.3))
;; Setup hydra.
(use-package hydra)
@ -462,7 +464,8 @@ Repeated invocations toggle between the two most recently open buffers."
"lgd" '(lsp-find-definition :which-key "go to definition")
"lgi" '(lsp-find-implementation :which-key "find implementation")
"lr" '(:ignore t :which-key "refactor")
"lrr" '(lsp-rename :which-key "rename"))
"lrr" '(lsp-rename :which-key "rename")
)
(use-package lsp-ui
:hook (lsp-mode . lsp-ui-mode)
@ -511,7 +514,11 @@ Repeated invocations toggle between the two most recently open buffers."
;; Use 4 spaces for the indent level.
(add-hook 'python-mode-hook (lambda ()
(setq python-indent-offset 4)))
(progn
(setq python-guess-indent nil)
(setq python-indent-guess-indent-offset nil)
(setq python-indent 4)
(setq python-indent-offset 4))))
;; If used withing a project that was a virtualenv, use a .dir-locals.el to set the proper interpreter.
;; ((python-mode . ((python-shell-interpreter . "~/dev/6502/eeprom_programmer/venv/bin/python")
@ -520,6 +527,19 @@ Repeated invocations toggle between the two most recently open buffers."
(use-package yaml-mode
:mode "\\.yml\\'")
(use-package go-mode
:config
(setq gofmt-command (concat (getenv "GOPATH") "/bin/goimports"))
(add-hook 'before-save-hook 'gofmt-before-save))
(load "~/.emacs.d/local-packages/emacs-prisma-mode/prisma-mode.el")
(require 'prisma-mode)
(setq auto-mode-alist
(cons '("\\.prisma$" . prisma-mode) auto-mode-alist))
(setq lsp-language-id-configuration
(cons '("\\.prisma$" . "prisma") lsp-language-id-configuration))
(defun mariano/company-select-first-and-complete ()
"Selects the appropriate candidate in the company mode list and completes it."
(interactive)
@ -535,8 +555,8 @@ Repeated invocations toggle between the two most recently open buffers."
:hook (lsp-mode . company-mode) ;; Run whenever lsp-mode is active.
:bind (:map company-active-map
("<tab>" . 'mariano/company-select-first-and-complete)) ;; When pressing tab, insert the first candidate. Default is cycle.
;; :map (lsp-mode-map
;; ("<tab>" . company-indent-or-complete-common)) ;; Activate if I want common completions in empty line.
(:map lsp-mode-map
("<tab>" . company-indent-or-complete-common)) ;; Activate if I want common completions in empty line.
:custom (company-minimum-prefix-length 1)
(company-idle-delay 0.0))
@ -563,7 +583,8 @@ Repeated invocations toggle between the two most recently open buffers."
(mariano/leader-keys
"p" '(:ignore t :which-key "Projectile")
"pp" '(projectile-switch-project :which-key "switch project")
"pf" '(projectile-find-file :which-key "find file in project"))
"pf" '(projectile-find-file :which-key "find file in project")
"ps" '(projectile-ripgrep :which-key "search in whole project"))
;; Extra ivy actions for projectile commands.
(use-package counsel-projectile
@ -633,3 +654,11 @@ Repeated invocations toggle between the two most recently open buffers."
;; Dired leader keys.
(mariano/leader-keys
"j" '(dired-jump :which-key "Open in dired"))
(defun mariano/open-zshell-config ()
(interactive)
(find-file "~/.zshrc"))
(mariano/leader-keys
"c" '(:ignore t :which-key "config files")
"cz" '(mariano/open-zshell-config :which-key "zshell config"))