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 :hook ((before-save . gofmt-before-save))26 :config27 (setq gofmt-command "goimports"28 godoc-command "go doc -all"))2930(use-package ob-go)3132;; C33(use-package cc-mode34 :hook ((c-mode . (lambda () (indent-tabs-mode 1)))35 (c++-mode . (lambda () (indent-tabs-mode 1))))36 :config37 ;; fix completion for c-mode38 (when (equal tab-always-indent 'complete)39 (define-key c-mode-base-map [remap c-indent-line-or-region] #'completion-at-point))40 :bind41 (:map c++-mode-map42 ("TAB" . indent-for-tab-command))43 (:map c-mode-map44 ("TAB" . indent-for-tab-command)))4546(use-package clang-format47 :init48 (setq clang-format-style '"file")49 (setq clang-format-fallback-style '"LLVM")50 :hook ((c-mode . clang-format-on-save-mode)51 (c++-mode . clang-format-on-save-mode)))5253;; Zig54(use-package zig-mode55 :if (executable-find "zig")56 :mode (("\\.zig\\'" . zig-mode))57 :config58 (setq zig-format-on-save nil)59 :hook ((zig-mode . (lambda () (indent-tabs-mode -1)))))6061(use-package vue-mode62 :mode (("\\.vue\\'" . vue-mode))63 :hook ((vue-mode . (lambda () (indent-tabs-mode -1)))))6465(use-package sh-script66 :mode(("\\.sh\\'" . sh-mode)67 ("APKBUILD" . sh-mode))68 :config (setq sh-basic-offset 8)6970 :hook ((sh-mode . 'indent-tabs-mode))71 (after-save . (lambda () (executable-make-buffer-file-executable-if-script-p))))7273(use-package emacs74 :config75 (setq which-func-modes '(prog-mode))76 :hook ((prog-mode . (lambda () (which-function-mode 1)))77 (prog-mode . (lambda () (hs-minor-mode 1)))))78(use-package hideshow79 :config80 (defun hs-cycle (&optional level)81 (interactive "p")82 (let (message-log-max83 (inhibit-message t))84 (if (= level 1)85 (pcase last-command86 ('hs-cycle87 (hs-hide-level 1)88 (setq this-command 'hs-cycle-children))89 ('hs-cycle-children90 ;; TODO: Fix this case. `hs-show-block' needs to be91 ;; called twice to open all folds of the parent92 ;; block.93 (save-excursion (hs-show-block))94 (hs-show-block)95 (setq this-command 'hs-cycle-subtree))96 ('hs-cycle-subtree97 (hs-hide-block))98 (_99 (if (not (hs-already-hidden-p))100 (hs-hide-block)101 (hs-hide-level 1)102 (setq this-command 'hs-cycle-children))))103 (hs-hide-level level)104 (setq this-command 'hs-hide-level))))105 (defun hs-global-cycle ()106 (interactive)107 (pcase last-command108 ('hs-global-cycle109 (save-excursion (hs-show-all))110 (setq this-command 'hs-global-show))111 (_ (hs-hide-all))))112 :bind113 (:map hs-minor-mode-map114 ("C-<tab>" . hs-cycle)115 ("<backtab>" . hs-global-cycle)))116117(use-package compile118 :config119 (require 'ansi-color)120 :hook ((compilation-filter . ansi-color-compilation-filter)))121122(use-package compile-multi123 :config124 (setq compile-multi-config '(((file-exists-p "Makefile")125 ("make:build" . "make build")126 ("make:test" . "make test")127 ("make:all" . "make all"))128 ((file-exists-p "meson.build")129 ("meson:test" . "meson test -C build")130 ("meson:compile" . "meson compile -C build")131 ("meson:setup" . "meson setup build"))132 ((file-exists-p "APKBUILD")133 ("apk:all" . "abuild -r")134 ("apk:build-depends" . "abuild deps")135 ("apk:prepare-source" . "abuild clean && abuild fetch && abuild unpack && abuild prepare")136 ("apk:build" . "abuild build")137 ("apk:check" . "abuild check")138 ("apk:clean" . "abuild clean"))))139 :bind140 ("C-c C-e" . compile-multi))141142(provide 'init-programing)143;;; init-programing.el ends here