Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
92 lines (84 sloc) 2.8 KB
;;; private/my-cc/config.el -*- lexical-binding: t; -*-
(after! cc-mode
;; https://github.com/radare/radare2
(c-add-style
"radare2"
'((c-basic-offset . 4)
(indent-tabs-mode . t)
(c-auto-align-backslashes . nil)
(c-offsets-alist
(arglist-intro . ++)
(arglist-cont . ++)
(arglist-cont-nonempty . ++)
(statement-cont . ++)
)))
(c-add-style
"my-cc" '("user"
(c-basic-offset . 2)
(c-offsets-alist
. ((innamespace . 0)
(access-label . -)
(case-label . 0)
(member-init-intro . +)
(topmost-intro . 0)
(arglist-cont-nonempty . +)))))
(setq c-default-style "my-cc")
(add-hook 'c-mode-common-hook
(lambda ()
(modify-syntax-entry ?_ "w")
))
(add-to-list 'auto-mode-alist '("\\.inc\\'" . +cc-c-c++-objc-mode))
(map!
:map (c-mode-map c++-mode-map)
:n "C-h" (λ! (ccls-navigate "U"))
:n "C-j" (λ! (ccls-navigate "R"))
:n "C-k" (λ! (ccls-navigate "L"))
:n "C-l" (λ! (ccls-navigate "D"))
(:leader
:n "=" #'clang-format-region
)
(:localleader
:n "a" #'ccls/references-address
:n "f" #'ccls/references-not-call
:n "lp" #'ccls-preprocess-file
:n "lf" #'ccls-reload
:n "m" #'ccls/references-macro
:n "r" #'ccls/references-read
:n "w" #'ccls/references-write
:desc "breakpoint"
:n "db" (lambda ()
(interactive)
(evil-open-above 1)
(insert "volatile static int z=0;while(!z)asm(\"pause\");")
(evil-normal-state))))
)
(def-package! clang-format
:commands (clang-format-region)
)
(def-package! ccls
:load-path "~/Dev/Emacs/emacs-ccls"
:defer t
:init (add-hook! (c-mode c++-mode objc-mode) #'+ccls//enable)
:config
;; overlay is slow
;; Use https://github.com/emacs-mirror/emacs/commits/feature/noverlay
(setq ccls-sem-highlight-method 'font-lock)
(add-hook 'lsp-after-open-hook #'ccls-code-lens-mode)
(ccls-use-default-rainbow-sem-highlight)
;; https://github.com/maskray/ccls/blob/master/src/config.h
(setq
ccls-extra-init-params
`(:clang (:extraArgs ["--gcc-toolchain=/usr"]
:pathMappings ,+ccls-path-mappings)
:completion
(:include
(:blacklist
["^/usr/(local/)?include/c\\+\\+/[0-9\\.]+/(bits|tr1|tr2|profile|ext|debug)/"
"^/usr/(local/)?include/c\\+\\+/v1/"
]))
:index (:initialBlacklist ,+ccls-initial-blacklist :trackDependency 1)))
(with-eval-after-load 'projectile
(add-to-list 'projectile-globally-ignored-directories ".ccls-cache"))
(evil-set-initial-state 'ccls-tree-mode 'emacs)
(set-company-backend! '(c-mode c++-mode objc-mode) 'company-lsp)
)