1;;; package --- 编程语言配置2;;; Commentary:34;;; Code:5;; Python6(use-package python7 :if (executable-find "python")8 :mode ("SCon\(struct\|script\)$" . python-mode)9 :config10 (setq lsp-diagnostic-package :none11 python-indent-offset 4)12 :hook13 (flycheck-add-next-checker 'python-flake8 'lsp)14 :interpreter ("python[0-9.]*" . python-mode))1516(use-package py-autopep817 :config18 (setq py-autopep8-options '("--max-line-length=130" "--aggressive"))19 :hook ((python-mode) . py-autopep8-mode))2021;; Golang22(use-package go-mode23 :if (executable-find "go")24 :mode (("\\.go\\'" . go-mode))25 :config26 (setq gofmt-command "goimports"27 godoc-command "go doc -all"))2829(use-package ob-go)3031;; C32(use-package cc-mode33 :hook ((c-mode . (lambda () (indent-tabs-mode 1)))34 (c++-mode . (lambda () (indent-tabs-mode 1))))35 :config36 ;; fix completion for c-mode37 (when (equal tab-always-indent 'complete)38 (define-key c-mode-base-map [remap c-indent-line-or-region] #'completion-at-point))39 :bind40 (:map c++-mode-map41 ("TAB" . indent-for-tab-command))42 (:map c-mode-map43 ("TAB" . indent-for-tab-command)))4445(use-package meson-mode)4647;; Zig48(use-package zig-mode49 :if (executable-find "zig")50 :mode (("\\.zig\\'" . zig-mode))51 :config52 (setq zig-format-on-save nil)53 :hook ((zig-mode . (lambda () (indent-tabs-mode -1)))))5455(use-package vue-mode56 :mode (("\\.vue\\'" . vue-mode))57 :hook ((vue-mode . (lambda () (indent-tabs-mode -1)))))5859(use-package sh-script60 :mode(("\\.sh\\'" . sh-mode)61 ("APKBUILD" . sh-mode))62 :config (setq sh-basic-offset 8)6364 :hook ((sh-mode . 'indent-tabs-mode))65 (after-save . (lambda () (executable-make-buffer-file-executable-if-script-p))))6667(use-package geiser-mit)68(use-package geiser-guile69 :config70 (setq geiser-default-implementation 'guile))7172(use-package emacs73 :config74 (setq which-func-modes '(prog-mode))75 :hook ((prog-mode . (lambda () (which-function-mode 1)))76 (prog-mode . (lambda () (hs-minor-mode 1)))))77(use-package hideshow78 :config79 (defun hs-cycle (&optional level)80 (interactive "p")81 (let (message-log-max82 (inhibit-message t))83 (if (= level 1)84 (pcase last-command85 ('hs-cycle86 (hs-hide-level 1)87 (setq this-command 'hs-cycle-children))88 ('hs-cycle-children89 ;; TODO: Fix this case. `hs-show-block' needs to be90 ;; called twice to open all folds of the parent91 ;; block.92 (save-excursion (hs-show-block))93 (hs-show-block)94 (setq this-command 'hs-cycle-subtree))95 ('hs-cycle-subtree96 (hs-hide-block))97 (_98 (if (not (hs-already-hidden-p))99 (hs-hide-block)100 (hs-hide-level 1)101 (setq this-command 'hs-cycle-children))))102 (hs-hide-level level)103 (setq this-command 'hs-hide-level))))104 (defun hs-global-cycle ()105 (interactive)106 (pcase last-command107 ('hs-global-cycle108 (save-excursion (hs-show-all))109 (setq this-command 'hs-global-show))110 (_ (hs-hide-all))))111 :bind112 (:map hs-minor-mode-map113 ("C-<tab>" . hs-cycle)114 ("<backtab>" . hs-global-cycle)))115116(use-package compile117 :config118 (require 'ansi-color)119 :hook ((compilation-filter . ansi-color-compilation-filter)))120121(use-package compile-multi122 :config123 (setq compile-multi-config '(((file-exists-p "Makefile")124 ("make:build" . "make build")125 ("make:test" . "make test")126 ("make:all" . "make all"))127 ((file-exists-p "meson.build")128 ("meson:test" . "meson test -C build --print-errorlogs")129 ("meson:compile" . "meson compile -C build")130 ("meson:setup" . "meson setup build"))131 ((file-exists-p "APKBUILD")132 ("apk:all" . "abuild -r")133 ("apk:build-depends" . "abuild deps")134 ("apk:prepare-source" . "abuild clean && abuild fetch && abuild unpack && abuild prepare")135 ("apk:build" . "abuild build")136 ("apk:check" . "abuild check")137 ("apk:clean" . "abuild clean"))))138 :bind139 ("C-c C-e" . compile-multi))140141(provide 'init-programing)142;;; init-programing.el ends here