From 9e00e0ac306ce7fc9da726b5e22db4aa3218a152 Mon Sep 17 00:00:00 2001 From: bd Date: Thu, 3 Apr 2025 23:35:53 -0400 Subject: Show-paren, eglot changes --- .config/emacs/modules/bd--devel.el | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/.config/emacs/modules/bd--devel.el b/.config/emacs/modules/bd--devel.el index a8e0d1e..e3a05f4 100644 --- a/.config/emacs/modules/bd--devel.el +++ b/.config/emacs/modules/bd--devel.el @@ -58,9 +58,31 @@ '(tramp-own-remote-path "~/.guix-profile/bin" "~/.guix-profile/sbin")))) -(use-package autoformat +(use-package vc + :bind (("C-x v B" . #'bd/vc-browse-remote)) :config - (setopt autoformat-mode t)) + (defun bd/vc-browse-remote (&optional current-line) + "Open the repository's remote URL in the browser. +If CURRENT-LINE is non-nil, point to the current branch, file, and line. +Otherwise, open the repository's main page." + (interactive "P") + (let* ((remote-url (string-trim (vc-git--run-command-string nil "config" "--get" "remote.origin.url"))) + (branch (string-trim (vc-git--run-command-string nil "rev-parse" "--abbrev-ref" "HEAD"))) + (file (string-trim (file-relative-name (buffer-file-name) (vc-root-dir)))) + (line (line-number-at-pos))) + (message "Opening remote on browser: %s" remote-url) + (if (and remote-url (string-match "\\(?:git@\\|https://\\)\\([^:/]+\\)[:/]\\(.+?\\)\\(?:\\.git\\)?$" remote-url)) + (let ((host (match-string 1 remote-url)) + (path (match-string 2 remote-url))) + ;; Convert SSH URLs to HTTPS (e.g., git@github.com:user/repo.git -> https://github.com/user/repo) + (when (string-prefix-p "git@" host) + (setq host (replace-regexp-in-string "^git@" "" host))) + ;; Construct the appropriate URL based on CURRENT-LINE + (browse-url + (if current-line + (format "https://%s/%s/blob/%s/%s#L%d" host path branch file line) + (format "https://%s/%s" host path)))) + (message "Could not determine repository URL"))))) (use-package hl-line :hook @@ -73,7 +95,8 @@ :config (setopt compilation-always-kill t compilation-scroll-output 'first-error - compilation-ask-about-save nil) + compilation-ask-about-save nil + ansi-color-for-compilation-mode t) (defun bd/compile-dwim (f) (let ((default-directory (bd/get-directory-dwim))) (call-interactively f))) @@ -157,6 +180,9 @@ display for opening with browser." ("C-c C-f" . eglot-format) ("C-c C-e" . eglot-rename)) :config + (setopt eglot-autoshutdown t + eglot-prefer-plaintext t + jsonrpc-event-hook nil) (add-to-list 'eglot-server-programs '(c-mode . ("ccls" "--init={\"clang\": {\"extraArgs\": [\"-std=c++20\"]}}")))) @@ -178,6 +204,7 @@ display for opening with browser." (use-package paren :config (setopt show-paren-delay 0 + show-paren-style 'mixed show-paren-highlight-openparen t show-paren-context-when-offscreen t show-paren-when-point-in-periphery t -- cgit v1.2.3