Skip to content

Commit 5106f66

Browse files
author
binwan
committed
update
1 parent 25496ab commit 5106f66

10 files changed

+307
-77
lines changed

config/init-eaf.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; :files ("*")))
44

55
(use-package eaf
6-
;; :load-path "~/.emacs.d/site-lisp/emacs-application-framework" ; Set to "/usr/share/emacs/site-lisp/eaf" if installed from AUR
6+
:load-path "~/.emacs.d/third/emacs-application-framework" ; Set to "/usr/share/emacs/site-lisp/eaf" if installed from AUR
77
:init
88
(use-package epc :defer t :ensure t)
99
(use-package ctable :defer t :ensure t)

config/init-elpa.el

+44-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
(require 'package)
22

3-
(setq package-archives '(("qinghua" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))
4-
;; ("gnu" . "http://elpa.emacs-china.org/gnu/")
5-
;; ("melpa" . "http://elpa.emacs-china.org/melpa/")
6-
3+
(setq package-archives '(("gnu" . "http://elpa.emacs-china.org/gnu/")
4+
("melpa" . "http://elpa.emacs-china.org/melpa/")
5+
("qinghua" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))
76

87
;;; Install into separate package dirs for each Emacs version, to prevent bytecode incompatibility
98
(let ((versioned-package-dir
@@ -14,27 +13,60 @@
1413

1514
;;; Standard package repositories
1615

17-
;;(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
18-
;; (not (gnutls-available-p))))
19-
;; (proto (if no-ssl "http" "https")))
16+
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
17+
(not (gnutls-available-p))))
18+
(proto (if no-ssl "http" "https")))
2019
;;(add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
2120
;; Official MELPA Mirror, in case necessary.
22-
;; (add-to-list 'package-archives (cons "melpa-mirror" (concat proto "://elpa.emacs-china.org/melpa/")) t)
23-
;; (if (< emacs-major-version 24)
21+
(add-to-list 'package-archives (cons "melpa-mirror" (concat proto "://elpa.emacs-china.org/melpa/")) t)
22+
(if (< emacs-major-version 24)
2423
;; For important compatibility libraries like cl-lib
25-
;; (add-to-list 'package-archives '("gnu" . (concat proto "://elpa.emacs-china.org/gnu/")))
26-
;; (unless no-ssl
24+
(add-to-list 'package-archives '("gnu" . (concat proto "://elpa.emacs-china.org/gnu/")))
25+
(unless no-ssl
2726
;; Force SSL for GNU ELPA
28-
;; (setcdr (assoc "gnu" package-archives) "http://elpa.emacs-china.org/gnu/"))))
27+
(setcdr (assoc "gnu" package-archives) "http://elpa.emacs-china.org/gnu/"))))
2928

3029
;; We include the org repository for completeness, but don't normally
3130
;; use it.
3231
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
3332

33+
34+
;;; On-demand installation of packages
35+
36+
(defun require-package (package &optional min-version no-refresh)
37+
"Install given PACKAGE, optionally requiring MIN-VERSION.
38+
If NO-REFRESH is non-nil, the available package lists will not be
39+
re-downloaded in order to locate PACKAGE."
40+
(if (package-installed-p package min-version)
41+
t
42+
(if (or (assoc package package-archive-contents) no-refresh)
43+
(if (boundp 'package-selected-packages)
44+
;; Record this as a package the user installed explicitly
45+
(package-install package nil)
46+
(package-install package))
47+
(progn
48+
(package-refresh-contents)
49+
(require-package package min-version t)))))
50+
51+
52+
(defun maybe-require-package (package &optional min-version no-refresh)
53+
"Try to install PACKAGE, and return non-nil if successful.
54+
In the event of failure, return nil and print a warning message.
55+
Optionally require MIN-VERSION. If NO-REFRESH is non-nil, the
56+
available package lists will not be re-downloaded in order to
57+
locate PACKAGE."
58+
(condition-case err
59+
(require-package package min-version no-refresh)
60+
(error
61+
(message "Couldn't install optional package `%s': %S" package err)
62+
nil)))
63+
3464
;;; Fire up package.el
3565

3666
(setq package-enable-at-startup nil)
3767
(package-initialize)
3868

69+
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
70+
3971

4072
(provide 'init-elpa)

config/init-font.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(let ((emacs-font-size 16)
1+
(let ((emacs-font-size 14)
22
emacs-font-name)
33
(setq emacs-font-name "Fira Code")
44
(when (display-grayscale-p)

config/init-go.el

+12-46
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,14 @@
11
(require-package 'go-projectile)
2-
(require-package 'lsp-mode)
3-
(require-package 'lsp-ui)
2+
(require-package 'go-mode)
43

5-
;; Prefer goimports to gofmt if installed
6-
(let ((goimports (executable-find "goimports")))
7-
(when goimports
8-
(setq gofmt-command goimports)))
9-
10-
(add-hook 'before-save-hook 'gofmt-before-save nil t)
11-
;; (whitespace-toggle-options '(tabs))
12-
;; (set (make-local-variable 'company-backends) '(company-go))
13-
14-
(use-package lsp-mode
15-
:ensure t
16-
:commands (lsp lsp-deferred)
17-
:hook (go-mode . lsp-deferred))
18-
19-
;; Optional - provides fancier overlays.
20-
(use-package lsp-ui
21-
:ensure t
22-
:commands lsp-ui-mode)
23-
24-
25-
;; Company mode is a standard completion package that works well with lsp-mode.
26-
(use-package company
4+
(use-package go-mode
275
:ensure t
286
:config
29-
;; Optionally enable completion-as-you-type behavior.
30-
(setq company-idle-delay 0)
31-
(setq company-minimum-prefix-length 1))
7+
(setq gofmt-command "goimports")
8+
(local-set-key (kbd "C-c t") 'go-test-current-file)
9+
(local-set-key (kbd "C-c s r") 'my-kill-go-server-fun)
10+
(add-hook 'before-save-hook 'gofmt-before-save)
11+
:hook (go-mode . lsp))
3212

3313
;; Optional - provides snippet support.
3414
(use-package yasnippet
@@ -37,20 +17,6 @@
3717
:hook (go-mode . yas-minor-mode))
3818

3919

40-
(defun go-mode-defaults ()
41-
(interactive)
42-
(local-set-key (kbd "C-c C-b") 'pop-tag-mark)
43-
(local-set-key (kbd "C-c t") 'go-test-current-file)
44-
(local-set-key (kbd "C-c C-j") 'lsp-find-definition)
45-
(local-set-key (kbd "C-c s s") 'lsp-restart-workspace)
46-
(local-set-key (kbd "C-c s r") 'my-kill-go-server-fun)
47-
(local-set-key (kbd "C-c C-c") 'lsp-find-references)
48-
(add-hook 'before-save-hook #'lsp-format-buffer t t)
49-
(add-hook 'before-save-hook #'lsp-organize-imports t t)
50-
(setq tab-width 4))
51-
52-
(add-hook 'go-mode-hook 'go-mode-defaults)
53-
5420
;; ;; (require-package 'protobuf-mode)
5521
;; ;; (defconst protobuf-style
5622
;; ;; '((c-basic-offset . 2)
@@ -59,11 +25,11 @@
5925
;; ;; (add-hook 'protobuf-mode-hook
6026
;; ;; (lambda () (c-add-style "my-style" protobuf-style t)))
6127

62-
(defun my-kill-go-server-fun ()
63-
(interactive)
64-
(deferred:process-shell '"kill -9 `ps aux|grep gopls|grep -v grep |awk '{print $2}'`")
65-
(sleep-for 0.2)
66-
(lsp-restart-workspace))
28+
;; (defun my-kill-go-server-fun ()
29+
;; (interactive)
30+
;; (deferred:process-shell '"kill -9 `ps aux|grep gopls|grep -v grep |awk '{print $2}'`")
31+
;; (sleep-for 0.2)
32+
;; (lsp-restart-workspace))
6733

6834

6935
(provide 'init-go)

config/init-lspmode.el

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
(require-package 'lsp-ui)
21
(require-package 'py-autopep8)
2+
(require-package 'lsp-ui)
33

44
(use-package lsp-ui
55
:hook (lsp-mode . lsp-ui-mode))
66

77
(use-package lsp-mode
88
;; :init
99
;; (setq lsp-file-watch-threshold 102400)
10-
:bind (("C-c j" . lsp-find-definition)))
11-
12-
;; (use-package lsp-python-ms
13-
;; :ensure t
14-
;; :init (setq lsp-python-ms-auto-install-server t)
15-
;; :hook
16-
;; (python-mode . (lambda ()
17-
;; (require 'lsp-python-ms)
18-
;; (lsp)))) ; or lsp-deferred
10+
:config
11+
(setq tab-width 4)
12+
(setq indent-tabs-mode 4)
13+
(setq company-idle-delay 0)
14+
(setq company-minimum-prefix-length 1)
15+
;; (add-hook 'before-save-hook #'lsp-format-buffer t t)
16+
(add-hook 'before-save-hook #'lsp-organize-imports t t)
17+
:bind (("C-c C-j" . lsp-find-definition)
18+
("C-c C-b" . pop-tag-mark)
19+
("C-c s s" . lsp-restart-workspace)
20+
("C-c C-c" . lsp-find-references)
21+
("C-." . lsp-execute-code-action)))
1922

2023
(use-package py-autopep8
2124
:hook (python-mode . py-autopep8-enable-on-save))

config/init-rainbow.el

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
(require-package 'rainbow-mode)
2-
(require-package 'rainbow-delimiters)
1+
;; (require-package 'rainbow-mode)
2+
;; (require-package 'rainbow-delimiters)
33

4-
(use-package rainbow-mode
5-
:ensure t
6-
:hook (prog-mode . rainbow-delimiters-mode))
4+
;; (use-package rainbow-mode
5+
;; :ensure t
6+
;; :hook (prog-mode . rainbow-delimiters-mode))
77

88
(provide 'init-rainbow)

0 commit comments

Comments
 (0)