diff options
| author | Craig Jennings <c@cjennings.net> | 2025-10-20 16:17:30 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-10-20 16:17:30 -0500 |
| commit | df4469f231e86877b7d055bf989220a5fbc0a763 (patch) | |
| tree | ea3ef00d10a7a7c1366213d493ea4e2546b9d783 /modules/prog-go.el | |
| parent | ce8477e80e0a837ac462b97c1a4b5d834838d6d3 (diff) | |
feat:programming: Enhance language-specific keybindings and setup
Add language-specific keybindings and configurations for C, Go,
Python, and shell scripting panels. Introduce system utility
function declarations and improve keybinding consistency across
languages. Implement keybindings for debug, format, and static
analysis tools tailored to each programming language, enhancing the
developer experience and workflow efficiency.
Diffstat (limited to 'modules/prog-go.el')
| -rw-r--r-- | modules/prog-go.el | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/modules/prog-go.el b/modules/prog-go.el index 1526698e..465cbf14 100644 --- a/modules/prog-go.el +++ b/modules/prog-go.el @@ -27,6 +27,10 @@ This is where tools like goimports and staticcheck are installed.") "Path to gopls (Go language server). Install with: go install golang.org/x/tools/gopls@latest") +(defvar dlv-path "dlv" + "Path to Delve debugger. +Install with: go install github.com/go-delve/delve/cmd/dlv@latest") + (defvar go-ts-mode-map) (defvar go-mod-ts-mode-map) @@ -38,6 +42,7 @@ Install with: go install golang.org/x/tools/gopls@latest") ;; Forward declarations for external packages (declare-function company-mode "company") +(declare-function cj/disabled "system-defaults") (defvar gofmt-command) ;; ---------------------------------- Go Setup --------------------------------- @@ -68,16 +73,35 @@ Install with: go install golang.org/x/tools/gopls@latest") (message "staticcheck not found at %s. Install with: go install honnef.co/go/tools/cmd/staticcheck@latest" staticcheck-bin)))) +(defun cj/go-debug () + "Start Delve debugger for the current Go package." + (interactive) + (let* ((dlv-bin (expand-file-name dlv-path go-bin-path)) + (default-directory (if buffer-file-name + (file-name-directory buffer-file-name) + default-directory))) + (if (or (executable-find dlv-path) + (file-executable-p dlv-bin)) + (gud-gdb (format "%s debug" (or (executable-find dlv-path) dlv-bin))) + (message "Delve not found. Install with: go install github.com/go-delve/delve/cmd/dlv@latest")))) + +(defun cj/go-mode-keybindings () + "Set up keybindings for Go programming. +Overrides default prog-mode keybindings with Go-specific commands." + ;; S-f5: Run staticcheck (static analysis) + (local-set-key (kbd "S-<f5>") #'cj/go-staticcheck) + + ;; S-f6: Debug with Delve + (local-set-key (kbd "S-<f6>") #'cj/go-debug)) + ;; ---------------------------------- Go Mode ---------------------------------- ;; go-ts-mode configuration (treesit-based Go editing) (use-package go-mode - :hook (go-ts-mode . cj/go-setup) + :hook ((go-ts-mode . cj/go-setup) + (go-ts-mode . cj/go-mode-keybindings)) :bind (:map go-ts-mode-map - ("<f6>" . gofmt) - ("C-c 6" . gofmt) - ("<f4>" . cj/go-staticcheck) - ("C-c 4" . cj/go-staticcheck)) + ("C-; f" . gofmt)) ;; Override global formatter with gofmt/goimports :mode (("\\.go\\'" . go-ts-mode) ;; .go files use go-ts-mode ("go\\.mod\\'" . go-mod-ts-mode)) ;; go.mod uses go-mod-ts-mode :config |
