Skip to content

Instantly share code, notes, and snippets.

@jstaursky
Last active October 6, 2021 22:59
Show Gist options
  • Save jstaursky/020e3ccc2f836e09dc1822ffc477a2ac to your computer and use it in GitHub Desktop.
Save jstaursky/020e3ccc2f836e09dc1822ffc477a2ac to your computer and use it in GitHub Desktop.
;-----------------------------------------------------------
; LAYERS
(c-c++ :variables
c-c++-backend 'lsp-ccls
c-c++-adopt-subprojects t)
(lsp :variables
lsp-ui-peek-enable nil
lsp-use-lsp-ui nil
lsp-headerline-breadcrumb-enable nil
lsp-remap-xref-keybindings t
lsp-navigation 'simple
lsp-ui-sideline-enable nil
lsp-ui-doc-enable nil)
;-----------------------------------------------------------
(use-package evil
:config
(setq evil-jmp-list '(xref-goto-xref
xref-quit-and-goto-xref evil-scroll-page-down
evil-scroll-page-up jump-to-register switch-to-buffer
previous-buffer helm-gtags-find-tag
spacemacs/c-c++-lsp-ccls-find-callers spacemacs/c-c++-lsp-ccls-find-callees
spacemacs/c-c++-lsp-ccls-find-refs-read spacemacs/c-c++-lsp-ccls-find-refs-write))
(dolist (jumper evil-jmp-list)
(evil-add-command-properties jumper :jump t))
)
;; HACK
;; currently only way to disable lsp from auto formatting pasted text.
(dolist (func '(yank yank-pop evil-paste-before evil-paste-after))
(advice-remove func #'spacemacs//yank-indent-region))
;; Favorite Keybinding
(global-set-key (kbd "M-i") 'indent-relative)
(setq-default tab-width 4
indent-tabs-mode nil ; use space to indent by default
truncate-lines t) ; Don't fold long lines
(setq c-default-style "linux"
c-basic-offset tab-width)
(c-set-offset 'inline-open '0)
(use-package cc-mode
:config
(use-package dumb-jump
:commands (dumb-jump-go))
;; Preserve jump list in evil
(defun evil-set-jump-args (&rest ns) (evil-set-jump))
(advice-add 'dumb-jump-goto-file-line :before #'evil-set-jump-args)
(spacemacs/set-leader-keys-for-major-mode 'c++-mode "." 'dumb-jump-go)
(spacemacs/set-leader-keys-for-major-mode 'c-mode "." 'dumb-jump-go)
)
(use-package ccls
:after projectile
:config
(setq projectile-project-root-files-top-down-recurring
(append '("compile_commands.json" ".ccls")
projectile-project-root-files-top-down-recurring))
:config (push ".ccls-cache" projectile-globally-ignored-directories))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment