Skip to content

Commit

Permalink
good
Browse files Browse the repository at this point in the history
  • Loading branch information
weidaolee committed Feb 14, 2024
1 parent 93619e2 commit 4c052dd
Show file tree
Hide file tree
Showing 26 changed files with 332 additions and 75 deletions.
13 changes: 7 additions & 6 deletions doom.d/init.el
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
:emacs
(dired ; making dired pretty [functional]
+icons
+ranger)
+ranger
)
electric ; smarter, keyword-based electric-indent
;;ibuffer ; interactive buffer management
(undo +tree) ; persistent, smarter undo for your inevitable mistakes
Expand Down Expand Up @@ -217,7 +218,7 @@
;;(wanderlust +gmail)

:app
;;calendar
calendar
;;emms
;;everywhere ; *leave* Emacs!? You must be joking
;;irc ; how neckbeards socialize
Expand All @@ -244,21 +245,21 @@
evil
hungry-delete
drag-stuff
;; format

:private-emacs
dired

:private-lang
;; org
org
cc
go
python
sh
protobuf

:private-tools
conf
;; gpt
log
treemacs-icons

:private-term
vterm
Expand Down
2 changes: 2 additions & 0 deletions doom.d/key-bindings/roam.el
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
(:when (modulep! :editor evil +everywhere)
:map evil-motion-state-map
"C-e" nil
"n" #'evil-ex-search-next
"p" #'evil-ex-search-previous
"N" #'evil-ex-search-next
"P" #'evil-ex-search-previous))

Expand Down
1 change: 1 addition & 0 deletions doom.d/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@
;(unpin! pinned-package another-pinned-package)
;; ...Or *all* packages (NOT RECOMMENDED; will likely break things)
;(unpin! t)
(package! doom-snippets :ignore t)
3 changes: 1 addition & 2 deletions modules/editor/file-templates/templates/sh-mode/__
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/usr/bin/env `(format "%s" sh-shell)`

#!/bin/bash
$0
9 changes: 9 additions & 0 deletions modules/private-completion/company/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@
:after company
:map company-active-map
[tab] #'company-complete-selection)

(use-package! company-spell
:after company
:config
(setf company-spell-args "-a -S --guess --suggest --sug-mode=bad-spellers --size=90 soundslike "))

(after! text-mode
(set-company-backend! 'text-mode
'(:separate company-dabbrev company-yasnippet company-ispell :with company-spell)))
5 changes: 5 additions & 0 deletions modules/private-completion/company/packages.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
;;; -*- no-byte-compile: t; -*-
;;; private-completion/company/packages.el

(package! company-spell)

7 changes: 0 additions & 7 deletions modules/private-config/emacs/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,3 @@
;; allow expert features
(put 'narrow-to-region 'disabled nil)
(put 'set-goal-column 'disabled nil)

;; disable <C-m>
(define-key input-decode-map [?\C-m] [C-m])
(global-set-key (kbd "<C-m>") #'c-m)

;; disable M-<tab>
(map! "M-<tab>" #'doom/escape)
29 changes: 25 additions & 4 deletions modules/private-editor/default/config.el
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
;;; private-edtior/default/config.el -*- lexical-binding: t; -*-

(normal-erase-is-backspace-mode t)
(if (not (display-graphic-p))
(normal-erase-is-backspace-mode 0)
(normal-erase-is-backspace-mode 1))

(delete-selection-mode t)

;; disable <C-m>
(if (display-graphic-p)
;; Running in a windowed environment
(progn
;; Define the keybinding for graphical mode
(define-key input-decode-map [?\C-m] [C-m])
(global-set-key (kbd "<C-m>") #'c-m))
;; Running in a terminal
;; Define alternative keybindings or leave it unbound
;; (for example, to avoid conflicts, you can use a different keybinding)
)

;; disable M-<tab>
(map! "M-<tab>" #'doom/escape)


(map!
:map global-map
"C-k" nil
"C-j" nil
"C-t" nil)
"C-k" nil
"C-j" nil
"C-t" nil
"C-<return>" nil
"C-RET" nil)

(use-package! smart-tab
:when (modulep! :editor evil +everywhere)
Expand Down
27 changes: 25 additions & 2 deletions modules/private-editor/evil/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,26 @@
(when (modulep! :editor evil +everywhere)
(general-unbind '(normal)
"r" "R" "y" "Y" "u" "o" "O" "p" "P" "="
"a" "A" "d" "D" "J" "m"
"x" "X" "c" "C" "," "." "<" ">"))
"a" "A" "d" "D" "J" "C-RET" "C-<return>"
"x" "X" "c" "C" "m" "," "." "<" ">"))

(when (modulep! :editor evil +everywhere)
(general-unbind '(motion)
"B"))

(when (modulep! :editor evil +everywhere)
(define-key! evil-snipe-mode-map
"S" nil
"F" nil
"t" nil
"T" nil))

(when (modulep! :editor evil +everywhere)
(define-key! evil-snipe-local-mode-map
"S" nil
"F" nil
"t" nil
"T" nil))

(when (modulep! :editor evil +everywhere)
(define-key! evil-motion-state-map
Expand All @@ -21,3 +39,8 @@
[return] nil
[tab] nil
"TAB" nil))

(when (modulep! :editor evil +everywhere)
(define-key! evil-motion-state-map
"<" #'evil-jump-backward
">" #'evil-jump-forward))
6 changes: 6 additions & 0 deletions modules/private-emacs/dired/+map/ranger.el
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
:n "x" #'dired-do-flagged-delete-or-trash
)

(:after ranger
:map ranger-mode-map
"d" #'dired-flag-file-deletion
"t" #'dired-flag-file-to-trash-can
"x" #'dired-do-flagged-delete-or-trash)

(:after ranger
:map ranger-normal-mode-map
"d" #'dired-flag-file-deletion
Expand Down
2 changes: 1 addition & 1 deletion modules/private-emacs/dired/config.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; private-emacs/dired/config.el -*- lexical-binding: t; -*-

(after! dired
(after! ranger
(load! "+map/ranger.el"))

(after! ranger
Expand Down
36 changes: 34 additions & 2 deletions modules/private-lang/cc/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,38 @@
* Auto Fromat on Save
Add the following code to ~.dir-lcoals.el~:
#+begin_src elisp
((c++-mode . ((eval . (add-hook 'before-save-hook #'lsp-format-buffer nil t)))))
((c-mode . ((eval . (add-hook 'before-save-hook #'lsp-format-buffer nil t)))))
((c-mode . ((eval . (add-hook 'before-save-hook #'clang-format-buffer nil t)))))
((c++-mode . ((eval . (add-hook 'before-save-hook #'clang-format-buffer nil t)))))

((c-mode . ((c-basic-offset . 4)
(c-offsets-alist . ((access-label . -4)
(inclass . +)
(namespace-open . 0)
(namespace-close . 0)
(innamespace . 0)
(case-label . 0)
(statement-case-open . +)
(statement-case-intro . +) ; for case labels
(member-init-intro . ++))) ; for constructor initializer lists
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))))

((c++-mode . ((c-basic-offset . 4)
(c-offsets-alist . ((access-label . -4)
(inclass . +)
(namespace-open . 0)
(namespace-close . 0)
(innamespace . 0)
(case-label . 0)
(statement-case-open . +)
(statement-case-intro . +) ; for case labels
(member-init-intro . ++))) ; for constructor initializer lists
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))))
#+end_src
* Download clangd
Download [[https://github.com/clangd/clangd/releases][clangd-linux-xx.x.xzip]]
* Upgrade Clang format version
1. Uninstall ~clang-format~
2. Install ~clang-format-xx~
3. ~ln -s /usr/bin/clang-format /usr/bin/clang-format-xx~
110 changes: 81 additions & 29 deletions modules/private-lang/cc/config.el
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
;;; private-lang/config.el -*- lexical-binding: t; -*-

(add-to-list 'auto-mode-alist '(".clang-format\\'" . yaml-mode))

;;; Clang
(after! lsp-clangd
(setq lsp-clients-clangd-args
Expand All @@ -18,40 +20,90 @@
"--background-index-rebuild"
;; "--header-insertion-decorators=1"
;; "--suggest-missing-includes=1"

))
(set-lsp-priority! 'clangd 2))

;; (after! ccls
;; (setq ccls-initialization-options '(:index (:comments 2 :thread 8) :completion (:detailedLabel t)))
;; (setq lsp-ui-doc-enable nil)
;; (set-lsp-priority! 'ccls 2)) ; optional as ccls is the default in Doom
(after! cc-mode
;; Set basic indentation to 4 spaces
;; (setq-default c-basic-offset 4)

;; Customize indentation for specific syntactic elements
(setq-default c-offsets-alist
`((inexpr-class . +)
(inexpr-statement . +)
(lambda-intro-cont . +)
(template-args-cont c-lineup-template-args +)
(incomposition . +)
(inmodule . +)
(innamespace . +)
(inextern-lang . +)
(composition-close . 0)
(module-close . 0)
(namespace-close . 0)
(extern-lang-close . 0)
(composition-open . 0)
(module-open . 0)
(namespace-open . 0)
(extern-lang-open . 0)
(objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call +)
(objc-method-args-cont . c-lineup-ObjC-method-args)
(objc-method-intro . [0])
(friend . 0)
(cpp-define-intro c-lineup-cpp-define +)
(cpp-macro-cont . +)
(cpp-macro . [0])
(stream-op . c-lineup-streamop)
(arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist)
(arglist-cont c-lineup-gcc-asm-reg 0)
(comment-intro c-lineup-knr-region-comment c-lineup-comment)
(catch-clause . 0)
(else-clause . 0)
(do-while-closure . 0)
(substatement . +)
(statement-case-open . 0)
(statement-case-intro . +)
(statement-block-intro . +)
(statement . 0)
(brace-entry-open . 0)
(brace-list-entry . 0)
(brace-list-open . 0)
(block-close . 0)
(block-open . 0)
(inher-cont . c-lineup-multi-inher)
(inher-intro . +)
(member-init-cont . c-lineup-multi-inher)
(member-init-intro . +)
(annotation-var-cont . +)
(annotation-top-cont . 0)
(topmost-intro-cont . c-lineup-topmost-intro-cont)
(topmost-intro . -)
(knr-argdecl . 0)
(func-decl-cont . +)
(inline-close . 0)
(class-close . 0)
(class-open . 0)
(defun-block-intro . +)
(defun-close . 0)
(defun-open . 0)
(c . c-lineup-C-comments)
(string . c-lineup-dont-change)
(label . 0)
(inclass +cc-c++-lineup-inclass +)
(access-label . -)
(inlambda . 0)
(inline-open . 0)
(arglist-close +cc-lineup-arglist-close 0)
(arglist-intro . +)
(brace-list-close . -)
(brace-list-intro . 0)
(case-label . +)
(statement-cont . +)
(substatement-label . 0)
(substatement-open . 0)
(knr-argdecl-intro . 0))
)
)

;;; CC Style
(after! (:or c-mode c++-mode)
(c-add-style "default-cc-style"
'("k&r"
(indent-tabs-mode . nil)
(c-basic-offset . 4)
(c-offsets-alist
(innamespace . -)
(access-label . -))))
(add-to-list 'c-default-style '(c++-mode . "default-cc-style"))
(add-to-list 'c-default-style '(c-mode . "default-cc-style")))

(c-add-style "default-cc-style"
'("k&r"
(indent-tabs-mode . nil)
(c-basic-offset . 4)
(c-offsets-alist
(innamespace . -)
(access-label . -)
(inline-open . 0))))
(add-to-list 'c-default-style '(c++-mode . "default-cc-style"))
(add-to-list 'c-default-style '(c-mode . "default-cc-style"))
;;; reference:
;;; https://emacs-china.org/t/emacs/19319/7
;;; and check c-fallback-style variable

;; (add-hook! '(c-mode-hook c++-mode-hook) #'format-all-mode)
5 changes: 5 additions & 0 deletions modules/private-lang/cc/packages.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
;;; -*- no-byte-compile: t; -*-
;;; private-lang/cc/packages.el

;; (package! clang-format)
;; (package! clang-format+)
Loading

0 comments on commit 4c052dd

Please sign in to comment.