Emacs: Rust improvements, ob-rust race condition, TS with ansi codes compilation
This commit is contained in:
		
							parent
							
								
									38232c81ab
								
							
						
					
					
						commit
						6703a9fece
					
				| @ -714,6 +714,7 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun | ||||
|         "^\\*lsp-help\\*" lsp-help-mode | ||||
|         "^\\*ert\\*" ert-results-mode | ||||
|         "^\\*cargo-test\\*" cargo-test-mode | ||||
|         "^\\*cargo-run\\*" cargo-run-mode | ||||
|         "^\\*rustic-compilation\\*" rustic-compilation-mode | ||||
|         ;; "^\\*ansi-term\\*$" term-mode | ||||
|         ("^\\*Warnings\\*$" . hide) | ||||
| @ -1140,50 +1141,8 @@ targets." | ||||
|     (message "Opening %s done" file))) | ||||
| 
 | ||||
| #+end_src | ||||
| ** Org Mode | ||||
| 
 | ||||
| #+begin_src emacs-lisp | ||||
| (straight-use-package 'org-bullets) | ||||
| 
 | ||||
| (defun joe/org-init () | ||||
|   (setq org-todo-keywords '((sequence "TODO" "IN-PROGRESS" "|" "DONE" "BACKLOG"))) | ||||
|   (setq org-agenda-files '("~/todo.org")) | ||||
| 
 | ||||
|   (org-babel-do-load-languages | ||||
|    'org-babel-load-languages | ||||
|    '((emacs-lisp . t) | ||||
|      (makefile . t) | ||||
|      (ocaml . t) | ||||
|      (python . t) | ||||
|      (C . t) | ||||
|      (haskell . t) | ||||
|      (rust . t) | ||||
|      (shell . t))) | ||||
| 
 | ||||
|   (require 'org-tempo) | ||||
|   (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) | ||||
|   (add-to-list 'org-structure-template-alist '("ml" . "src ocaml")) | ||||
|   (add-to-list 'org-structure-template-alist '("rs" . "src rust")) | ||||
|   (add-to-list 'org-structure-template-alist '("py" . "src python")) | ||||
|   (add-to-list 'org-structure-template-alist '("hs" . "src haskell")) | ||||
|   (add-to-list 'org-structure-template-alist '("cc" . "src C :includes stdio.h stdlib.h")) | ||||
|   (setq org-edit-src-content-indentation 0)) | ||||
| (with-eval-after-load 'org (joe/org-init)) | ||||
| 
 | ||||
| (setq org-blank-before-new-entry | ||||
|       '((heading . nil) | ||||
|         (plain-list-item . nil))) | ||||
| (setq org-cycle-separator-lines 1) | ||||
| (setq org-hide-emphasis-markers t) | ||||
| (setq org-src-window-setup 'current-window) | ||||
| 
 | ||||
| (defun joe/org-hook () | ||||
|   (local-set-key (kbd "C-. C-i") 'consult-org-heading) | ||||
|   (org-bullets-mode) | ||||
|   (org-indent-mode)) | ||||
| (add-hook 'org-mode-hook 'joe/org-hook) | ||||
| 
 | ||||
| (straight-use-package 'org-kanban) | ||||
| #+end_src | ||||
| ** Avy | ||||
| 
 | ||||
| @ -1497,6 +1456,25 @@ println!("Hello world"); | ||||
| ;; (define-key global-map (kbd "C-x C-s) #'save-buffer) | ||||
| (define-key global-map (kbd "<f9>") #'joe/save-then-recompile) | ||||
| (define-key global-map (kbd "<f10>") #'compile) | ||||
| 
 | ||||
| (defun joe/colorize-compilation-buffer () | ||||
|   (ansi-color-apply-on-region compilation-filter-start (point))) | ||||
| (add-hook 'compilation-filter-hook 'joe/colorize-compilation-buffer) | ||||
| 
 | ||||
| (defun joe/close-compilation-if-no-warn-err (buffer string) | ||||
|   "Bury a compilation buffer if succeeded without warnings " | ||||
|   (if (and | ||||
|        (string-match "compilation" (buffer-name buffer)) | ||||
|        (string-match "finished" string) | ||||
|        (not | ||||
|         (with-current-buffer (current-buffer) | ||||
|           (search-forward "warning" nil t)))) | ||||
|       (run-with-timer 1.5 nil | ||||
|                       (lambda () | ||||
|                         (and (eq (point) 1) | ||||
|                              (string-match "compilation" (buffer-name (current-buffer))) | ||||
|                              (popper-close-latest)))))) | ||||
| (add-hook 'compilation-finish-functions 'joe/close-compilation-if-no-warn-err) | ||||
| #+end_src | ||||
| ** Debugging | ||||
| *** DAP | ||||
| @ -1539,7 +1517,8 @@ println!("Hello world"); | ||||
| *** Rust | ||||
| #+begin_src emacs-lisp | ||||
| (straight-use-package 'rustic) | ||||
| (straight-use-package 'ob-rust) ;; Org-Babel | ||||
| (straight-use-package 'ob-rust) | ||||
| ;; Org-Babel | ||||
| ;; Disabling until we figure out how to get it working | ||||
| ;; (straight-use-package 'parsec) ;; Required by evcxr-mode | ||||
| 
 | ||||
| @ -1559,6 +1538,7 @@ println!("Hello world"); | ||||
| (with-eval-after-load 'rustic | ||||
|   ;; Don't autostart | ||||
|   (setq rustic-lsp-setup-p nil) | ||||
|   (define-key rustic-mode-map (kbd "<f9>") #'rustic-cargo-run) | ||||
| 
 | ||||
|   (setq lsp-rust-analyzer-server-display-inlay-hints t) | ||||
|   (setq lsp-rust-analyzer-display-lifetime-elision-hints-enable "always") | ||||
| @ -1573,6 +1553,11 @@ println!("Hello world"); | ||||
| #+begin_src emacs-lisp | ||||
| (global-set-key (kbd "C-x C-r") 'eval-region) | ||||
| #+end_src | ||||
| *** Web | ||||
| #+begin_src emacs-lisp | ||||
| (straight-use-package 'typescript-mode) | ||||
| (setq typescript-indent-level 2) | ||||
| #+end_src | ||||
| *** C | ||||
| 
 | ||||
| Design some basic functions for compiling. There's also a hook to close the popper window if there | ||||
| @ -1588,21 +1573,6 @@ it doesn't close it. | ||||
|   (electric-pair-local-mode t) | ||||
|   (c-toggle-comment-style -1)) | ||||
| (add-hook 'c-mode-hook #'joe/c-mode-hook) | ||||
| 
 | ||||
| (defun joe/close-compilation-if-no-warn-err (buffer string) | ||||
|   "Bury a compilation buffer if succeeded without warnings " | ||||
|   (if (and | ||||
|        (string-match "compilation" (buffer-name buffer)) | ||||
|        (string-match "finished" string) | ||||
|        (not | ||||
|         (with-current-buffer (current-buffer) | ||||
|           (search-forward "warning" nil t)))) | ||||
|       (run-with-timer 1.5 nil | ||||
|                       (lambda () | ||||
|                         (and (eq (point) 1) | ||||
|                              (string-match "compilation" (buffer-name (current-buffer))) | ||||
|                              (popper-close-latest)))))) | ||||
| (add-hook 'compilation-finish-functions 'joe/close-compilation-if-no-warn-err) | ||||
| #+end_src | ||||
| *** Haskell | ||||
| #+begin_src emacs-lisp | ||||
| @ -1619,7 +1589,7 @@ it doesn't close it. | ||||
| (setq cider-show-error-buffer 'only-in-repl) | ||||
| #+end_src | ||||
| *** OCaml | ||||
| #+begin_src emacs-lisp | ||||
| #+begin_src emacs-lisp :tangle no | ||||
| (straight-use-package 'tuareg) | ||||
| (straight-use-package 'dune) | ||||
| (straight-use-package 'utop) | ||||
| @ -1646,7 +1616,7 @@ it doesn't close it. | ||||
| We won't use the LSP server but rather directly talk to Merlin, since I guess LSP just wraps Merlin | ||||
| and there's no need for a middle-man when it's already been implemented. | ||||
| 
 | ||||
| #+begin_src emacs-lisp | ||||
| #+begin_src emacs-lisp :tangle no | ||||
| 
 | ||||
| ;; (require 'utop) | ||||
| ;; Use the opam installed utop | ||||
| @ -1680,6 +1650,51 @@ and there's no need for a middle-man when it's already been implemented. | ||||
| (straight-use-package 'json) | ||||
| (straight-use-package 'markdown-mode) | ||||
| #+end_src | ||||
| ** Org Mode | ||||
| 
 | ||||
| #+begin_src emacs-lisp | ||||
| (straight-use-package 'org-bullets) | ||||
| 
 | ||||
| (defun joe/org-init () | ||||
|   (setq org-todo-keywords '((sequence "TODO" "IN-PROGRESS" "|" "DONE" "BACKLOG"))) | ||||
|   (setq org-agenda-files '("~/todo.org")) | ||||
| 
 | ||||
|   (org-babel-do-load-languages | ||||
|    'org-babel-load-languages | ||||
|    '((emacs-lisp . t) | ||||
|      (makefile . t) | ||||
|      (ocaml . t) | ||||
|      (python . t) | ||||
|      (C . t) | ||||
|      (haskell . t) | ||||
|      (rust . t) | ||||
|      (shell . t))) | ||||
| 
 | ||||
|   (require 'org-tempo) | ||||
|   (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) | ||||
|   (add-to-list 'org-structure-template-alist '("ml" . "src ocaml")) | ||||
|   (add-to-list 'org-structure-template-alist '("rs" . "src rust")) | ||||
|   (add-to-list 'org-structure-template-alist '("py" . "src python")) | ||||
|   (add-to-list 'org-structure-template-alist '("hs" . "src haskell")) | ||||
|   (add-to-list 'org-structure-template-alist '("cc" . "src C :includes stdio.h stdlib.h")) | ||||
|   (setq org-edit-src-content-indentation 0)) | ||||
| (with-eval-after-load 'org (joe/org-init)) | ||||
| 
 | ||||
| (setq org-blank-before-new-entry | ||||
|       '((heading . nil) | ||||
|         (plain-list-item . nil))) | ||||
| (setq org-cycle-separator-lines 1) | ||||
| (setq org-hide-emphasis-markers t) | ||||
| (setq org-src-window-setup 'current-window) | ||||
| 
 | ||||
| (defun joe/org-hook () | ||||
|   (local-set-key (kbd "C-. C-i") 'consult-org-heading) | ||||
|   (org-bullets-mode) | ||||
|   (org-indent-mode)) | ||||
| (add-hook 'org-mode-hook 'joe/org-hook) | ||||
| 
 | ||||
| (straight-use-package 'org-kanban) | ||||
| #+end_src | ||||
| ** Magit | ||||
| 
 | ||||
| The best git porcelain/client I've ever used. Also kill stray magit buffers left over as explained [[https://manueluberti.eu/emacs/2018/02/17/magit-bury-buffer/][here]] | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user