feat(dev-workflow): add Perl/Python/Go/Ansible/Terraform/Podman config
- cperl-mode with perltidy formatter and LSP - Python with ruff formatter and pyright LSP - Go with gopls and goimports - Ansible/YAML with ansible-lint - Terraform with terraform-ls LSP - Dockerfile/Podman with hadolint - SPC m f/r/t/b/d keybindings per language
This commit is contained in:
127
config.el
127
config.el
@@ -1570,3 +1570,130 @@ current frame."
|
||||
(after! forge
|
||||
(add-to-list 'forge-alist
|
||||
'("git.apps.sukany.cz" "git.apps.sukany.cz/api/v1" "git.apps.sukany.cz" forge-gitea-repository)))
|
||||
|
||||
|
||||
;;; ============================================================
|
||||
;;; DEVELOPER WORKFLOW
|
||||
;;; ============================================================
|
||||
;; Language-specific configs for Perl, Python, Go, Ansible, Terraform, Podman.
|
||||
;; Each language gets SPC m f (format), SPC m r (run), and additional bindings.
|
||||
|
||||
;;; --- Perl (cperl-mode) ---
|
||||
|
||||
;; Prefer cperl-mode over perl-mode for all Perl files
|
||||
(add-to-list 'auto-mode-alist '("\\.pl\\'" . cperl-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.pm\\'" . cperl-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.t\\'" . cperl-mode))
|
||||
|
||||
(after! cperl-mode
|
||||
(setq cperl-indent-level 4
|
||||
cperl-close-paren-offset -4
|
||||
cperl-continued-statement-offset 4
|
||||
cperl-indent-parens-as-block t
|
||||
cperl-tab-always-indent t))
|
||||
|
||||
;; Perltidy formatter via reformatter
|
||||
(use-package! reformatter
|
||||
:config
|
||||
(reformatter-define perl-tidy
|
||||
:program "perltidy"
|
||||
:args '("-st" "-se" "--quiet")))
|
||||
|
||||
(after! cperl-mode
|
||||
(map! :map cperl-mode-map
|
||||
:localleader
|
||||
:desc "Format (perltidy)" "f" #'perl-tidy-buffer
|
||||
:desc "Run file" "r" (cmd! (compile (concat "perl " (buffer-file-name))))
|
||||
:desc "Debug (perldb)" "d" #'perldb)
|
||||
|
||||
;; Flycheck: use perl checker
|
||||
(add-hook 'cperl-mode-hook
|
||||
(lambda ()
|
||||
(when (fboundp 'flycheck-select-checker)
|
||||
(flycheck-select-checker 'perl)))))
|
||||
|
||||
;;; --- Python ---
|
||||
|
||||
(after! python
|
||||
(setq python-shell-interpreter "python3")
|
||||
|
||||
(map! :map python-mode-map
|
||||
:localleader
|
||||
:desc "Format (ruff)" "f" (cmd! (compile (concat "ruff format " (buffer-file-name))
|
||||
(revert-buffer t t t)))
|
||||
:desc "Run file" "r" (cmd! (compile (concat "python3 " (buffer-file-name))))))
|
||||
|
||||
;;; --- Go ---
|
||||
|
||||
(after! go-mode
|
||||
(setq gofmt-command "goimports")
|
||||
|
||||
;; Auto-format on save
|
||||
(add-hook 'go-mode-hook
|
||||
(lambda ()
|
||||
(add-hook 'before-save-hook #'gofmt-before-save nil t)))
|
||||
|
||||
(map! :map go-mode-map
|
||||
:localleader
|
||||
:desc "Format (goimports)" "f" #'gofmt
|
||||
:desc "Run file" "r" (cmd! (compile (concat "go run " (buffer-file-name))))
|
||||
:desc "Test" "t" (cmd! (compile "go test ./..."))
|
||||
:desc "Build" "b" (cmd! (compile "go build ./..."))))
|
||||
|
||||
;;; --- Ansible / YAML ---
|
||||
|
||||
(after! yaml-mode
|
||||
(map! :map yaml-mode-map
|
||||
:localleader
|
||||
:desc "Run playbook" "r" (cmd! (compile (concat "ansible-playbook " (buffer-file-name))))))
|
||||
|
||||
;; Ansible-lint via flycheck for YAML files in ansible-ish directories
|
||||
(after! flycheck
|
||||
(flycheck-define-checker yaml-ansible-lint
|
||||
"Ansible linter."
|
||||
:command ("ansible-lint" "--parseable" source)
|
||||
:error-patterns
|
||||
((warning line-start (file-name) ":" line ": " (message) line-end))
|
||||
:modes (yaml-mode))
|
||||
(add-to-list 'flycheck-checkers 'yaml-ansible-lint t))
|
||||
|
||||
;;; --- Terraform ---
|
||||
|
||||
(after! terraform-mode
|
||||
(map! :map terraform-mode-map
|
||||
:localleader
|
||||
:desc "Format (terraform fmt)" "f" (cmd! (compile "terraform fmt" t)
|
||||
(revert-buffer t t t))
|
||||
:desc "Init" "i" (cmd! (compile "terraform init"))
|
||||
:desc "Plan" "p" (cmd! (compile "terraform plan"))))
|
||||
|
||||
;;; --- Dockerfile / Podman ---
|
||||
|
||||
(after! dockerfile-mode
|
||||
(map! :map dockerfile-mode-map
|
||||
:localleader
|
||||
:desc "Build (podman)" "b" (cmd! (let ((tag (read-string "Image tag: " "myapp:latest")))
|
||||
(compile (format "podman build -t %s -f %s ."
|
||||
tag (buffer-file-name)))))
|
||||
:desc "Run (podman)" "r" (cmd! (let ((img (read-string "Image name: " "myapp:latest")))
|
||||
(compile (format "podman run --rm %s" img))))))
|
||||
|
||||
;; Hadolint via flycheck for Dockerfiles
|
||||
(after! flycheck
|
||||
(when (executable-find "hadolint")
|
||||
(flycheck-define-checker dockerfile-hadolint
|
||||
"Dockerfile linter using hadolint."
|
||||
:command ("hadolint" "--no-color" "-")
|
||||
:standard-input t
|
||||
:error-patterns
|
||||
((info line-start (one-or-more not-newline) ":" line " " (id (one-or-more not-newline)) " " (message) line-end)
|
||||
(warning line-start (one-or-more not-newline) ":" line " " (id (one-or-more not-newline)) " " (message) line-end)
|
||||
(error line-start (one-or-more not-newline) ":" line " " (id (one-or-more not-newline)) " " (message) line-end))
|
||||
:modes (dockerfile-mode))
|
||||
(add-to-list 'flycheck-checkers 'dockerfile-hadolint t)))
|
||||
|
||||
;;; --- Common project settings ---
|
||||
|
||||
(after! projectile
|
||||
(dolist (dir '("node_modules" "__pycache__" ".terraform" "vendor"))
|
||||
(add-to-list 'projectile-globally-ignored-directories dir)))
|
||||
|
||||
Reference in New Issue
Block a user