diff --git a/.gitignore b/.gitignore index 8110c28..93de918 100644 --- a/.gitignore +++ b/.gitignore @@ -53,4 +53,4 @@ flycheck_*.el /network-security.data -# End of https://www.toptal.com/developers/gitignore/api/emacs \ No newline at end of file +# End of https://www.toptal.com/developers/gitignore/api/emacs diff --git a/Config.org b/Config.org index b32486e..905390e 100644 --- a/Config.org +++ b/Config.org @@ -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 @@ -738,8 +741,12 @@ Configuration for Python. (python-black-on-save-mode))) ;; Use 4 spaces for the indent level. -(add-hook 'python-mode-hook (lambda () - (setq python-indent-offset 4))) +(add-hook 'python-mode-hook (lambda () + (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 ("" . 'mariano/company-select-first-and-complete)) ;; When pressing tab, insert the first candidate. Default is cycle. - ;; :map (lsp-mode-map - ;; ("" . company-indent-or-complete-common)) ;; Activate if I want common completions in empty line. + (:map lsp-mode-map + ("" . 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 diff --git a/init.el b/init.el index 9a1b90c..207c069 100644 --- a/init.el +++ b/init.el @@ -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) @@ -510,8 +513,12 @@ Repeated invocations toggle between the two most recently open buffers." (python-black-on-save-mode))) ;; Use 4 spaces for the indent level. -(add-hook 'python-mode-hook (lambda () - (setq python-indent-offset 4))) +(add-hook 'python-mode-hook (lambda () + (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 ("" . 'mariano/company-select-first-and-complete)) ;; When pressing tab, insert the first candidate. Default is cycle. - ;; :map (lsp-mode-map - ;; ("" . company-indent-or-complete-common)) ;; Activate if I want common completions in empty line. + (:map lsp-mode-map + ("" . 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"))