142 lines
5.5 KiB
EmacsLisp
142 lines
5.5 KiB
EmacsLisp
![]() |
;;; ../../../../mnt/c/Users/SmithEvar/.doom.d/config-dev.el -*- lexical-binding: t; -*-
|
||
|
|
||
|
;; ink mode
|
||
|
;; (require 'ink-mode)
|
||
|
;; (add-hook 'ink-mode-hook 'flymake-mode) ;; error reporting
|
||
|
;; (defvar my/inklecate-exe (if IS-WINDOWS "C:\dev\engines\inklecate"))
|
||
|
;; (setq ink-inklecate-path my/inklecate-exe)
|
||
|
|
||
|
;; terraform ls using
|
||
|
;; https://github.com/hashicorp/terraform-ls
|
||
|
|
||
|
(setq terraform-path (executable-find "terraform"))
|
||
|
(setq terraform-ls-path (executable-find "terraform-ls"))
|
||
|
(setq HAS-TERRAFORM-LS (and terraform-path terraform-ls-path))
|
||
|
|
||
|
(when HAS-TERRAFORM-LS
|
||
|
(after! lsp-mode
|
||
|
(lsp-register-client
|
||
|
(make-lsp-client :new-connection (lsp-stdio-connection (list terraform-ls-path "serve"))
|
||
|
:major-modes '(terraform-mode)
|
||
|
:server-id 'terraform-ls)))
|
||
|
|
||
|
(add-hook 'terraform-mode-hook #'terraform-format-on-save-mode)
|
||
|
(add-hook 'terraform-mode-hook #'lsp))
|
||
|
|
||
|
;; copilot config
|
||
|
(use-package! copilot
|
||
|
:hook (prog-mode . copilot-mode)
|
||
|
:bind (:map copilot-completion-map
|
||
|
("<tab>" . 'copilot-accept-completion)
|
||
|
("TAB" . 'copilot-accept-completion)
|
||
|
("C-TAB" . 'copilot-accept-completion-by-word)
|
||
|
("C-<tab>" . 'copilot-accept-completion-by-word)))
|
||
|
|
||
|
;; (use-package! kubernetes)
|
||
|
|
||
|
;; suppress godot lsp errors per
|
||
|
;; https://github.com/godotengine/emacs-gdscript-mode
|
||
|
(defun lsp--gdscript-ignore-errors (original-function &rest args)
|
||
|
"Ignore the error message resulting from Godot not replying to the `JSONRPC' request."
|
||
|
(if (string-equal major-mode "gdscript-mode")
|
||
|
(let ((json-data (nth 0 args)))
|
||
|
(if (and (string= (gethash "jsonrpc" json-data "") "2.0")
|
||
|
(not (gethash "id" json-data nil))
|
||
|
(not (gethash "method" json-data nil)))
|
||
|
nil ; (message "Method not found")
|
||
|
(apply original-function args)))
|
||
|
(apply original-function args)))
|
||
|
;; Runs the function `lsp--gdscript-ignore-errors` around `lsp--get-message-type` to suppress unknown notification errors.
|
||
|
(advice-add #'lsp--get-message-type :around #'lsp--gdscript-ignore-errors)
|
||
|
|
||
|
;; Web mode for razor files
|
||
|
(add-to-list 'auto-mode-alist '("\\.razor\\'" . web-mode))
|
||
|
|
||
|
;; Projectile project for terraform
|
||
|
(after! projectile
|
||
|
(projectile-register-project-type 'terraform '(".terraform")
|
||
|
:compile "terraform init"
|
||
|
:run "terraform apply"))
|
||
|
|
||
|
|
||
|
; TODO: Eventually make a thing
|
||
|
; to execute org babel src blocks with type
|
||
|
; vterm in a new vterm popup
|
||
|
|
||
|
; In a nutshell, I want to be able to get streaming results from
|
||
|
; org babel. There's a thing that someone made that I copied to my
|
||
|
; private config here from
|
||
|
;
|
||
|
; https://github.com/whacked/ob-shstream
|
||
|
;
|
||
|
; .. and subsequently
|
||
|
;
|
||
|
; https://github.com/excalamus/ob-shstream
|
||
|
;
|
||
|
; since the former was very outdated and couldn't successfully run.
|
||
|
|
||
|
; I configured it with the block below
|
||
|
;
|
||
|
;; ob shstream
|
||
|
;;
|
||
|
;; (load! "modules/tools/ob-shstream")
|
||
|
;; (org-babel-do-load-languages
|
||
|
;; 'org-babel-load-languages
|
||
|
;; '(...
|
||
|
;; (shstream . t)
|
||
|
;; ...))
|
||
|
;
|
||
|
; Which... sort of worked. I didn't like how it felt to use. I thought
|
||
|
; it would just be fine to use vterm, so I did some googling, and found this
|
||
|
;
|
||
|
; https://www.reddit.com/r/emacs/comments/op4fcm/send_command_to_vterm_and_execute_it/
|
||
|
;
|
||
|
; Which, after some hacking together with the source of +vterm/toggle, I
|
||
|
; came to something that's a happy medium.
|
||
|
;
|
||
|
; Might be an idea to get it working with org babel so that I could do something like
|
||
|
;
|
||
|
; #+BEGIN_SRC vterm
|
||
|
; git status
|
||
|
; #+END_SRC
|
||
|
;
|
||
|
; Maybe one weekend.
|
||
|
; Here's that hacked together function below
|
||
|
|
||
|
(defun my/vterm-execute-region-or-current-line ()
|
||
|
"Insert text of current line in vterm and execute."
|
||
|
(interactive)
|
||
|
(require 'vterm)
|
||
|
(eval-when-compile (require 'subr-x))
|
||
|
; grab the command
|
||
|
(let ((command (if (region-active-p)
|
||
|
(string-trim (buffer-substring (save-excursion
|
||
|
(region-beginning))
|
||
|
(save-excursion
|
||
|
(region-end))))
|
||
|
(string-trim (buffer-substring (save-excursion
|
||
|
(beginning-of-line)
|
||
|
(point))
|
||
|
(save-excursion
|
||
|
(end-of-line)
|
||
|
(point)))))))
|
||
|
; find vterm buffer, either switch to it or make a new one
|
||
|
(let ((return-buffer (current-buffer))
|
||
|
(vterm-popup-buffer-name (format "*doom:vterm-popup:%s*"
|
||
|
(if (bound-and-true-p persp-mode)
|
||
|
(safe-persp-name (get-current-persp))
|
||
|
"main"))))
|
||
|
(if-let (existing-buffer (cl-loop for buf in (doom-buffers-in-mode 'vterm-mode)
|
||
|
if (equal (buffer-local-value '+vterm--id buf)
|
||
|
vterm-popup-buffer-name)
|
||
|
return buf))
|
||
|
(pop-to-buffer existing-buffer)
|
||
|
(+vterm/toggle nil))
|
||
|
; send the command
|
||
|
(vterm--goto-line -1)
|
||
|
; (message command) ; uncomment if i want messages
|
||
|
(vterm-send-string command)
|
||
|
(vterm-send-return)
|
||
|
; switch back to where we were
|
||
|
(switch-to-buffer-other-window return-buffer))))
|