86 lines
2.7 KiB
EmacsLisp
86 lines
2.7 KiB
EmacsLisp
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
|
|
;;
|
|
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
|
|
;;
|
|
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
|
;; URL: https://devheroes.codes/FG42/FG42
|
|
;; Version: 3.0.0
|
|
;;
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
;; it under the terms of the GNU General Public License as published by
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
;; (at your option) any later version.
|
|
;;
|
|
;; This program is distributed in the hope that it will be useful,
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
;; GNU General Public License for more details.
|
|
;;
|
|
;; You should have received a copy of the GNU General Public License
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
;;
|
|
;;; Commentary:
|
|
;;; Code:
|
|
(eval-when-compile
|
|
(require 'fpkg))
|
|
|
|
(defvar fg42/clangd-args
|
|
(list
|
|
(format "-j=%s" (- (num-processors) 2))
|
|
"--clang-tidy"
|
|
"--header-insertion=iwyu"
|
|
"--pch-storage=memory"
|
|
"--background-index"
|
|
"--cross-file-rename"
|
|
"--completion-style=detailed"
|
|
"--malloc-trim"
|
|
)
|
|
"Arguments to pass to clangd.")
|
|
|
|
(use! cmake-ts-mode
|
|
"Enable cmake-ts-mode instead of the non-TS version.")
|
|
|
|
(use! eldoc-cmake
|
|
"ElDoc and cmake integration"
|
|
:hook (cmake-ts-mode . eldoc-cmake-enable))
|
|
|
|
|
|
(use! ninja-mode
|
|
"This cube enables Ninja integration with FG42. For more info checkout:
|
|
https://github.com/ninja-build/ninja/blob/master/misc/ninja-mode.el")
|
|
|
|
|
|
(defun fg42/c-ts-mode-setup ()
|
|
"A hook handler to setup cpp related configurations."
|
|
(message "[FG42][C/C++]: Make sure to setup clangd to fit your needs. For more info: https://clangd.llvm.org/config")
|
|
(setq-local company-backends
|
|
'((company-capf :with company-yasnippet) :separate
|
|
(company-keywords company-dabbrev company-ispell) :separate
|
|
company-files)))
|
|
|
|
|
|
(use! c-ts-mode
|
|
"C++ setup. We're using treesitter version of c++ mode."
|
|
:init
|
|
;; Remap the standard C/C++ modes
|
|
(add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode))
|
|
(add-to-list 'major-mode-remap-alist '(c++-mode . c++-ts-mode))
|
|
(add-to-list 'major-mode-remap-alist '(c-or-c++-mode . c-or-c++-ts-mode))
|
|
|
|
:config
|
|
;; Set the default lang server for C/C++ to clangd
|
|
(with-eval-after-load 'eglot
|
|
(add-to-list
|
|
'eglot-server-programs
|
|
`(c-mode c++-mode c-ts-mode c++-ts-mode . ("clangd" ,@fg42/clangd-args))))
|
|
|
|
:hook
|
|
(c++-ts-mode . eglot-ensure)
|
|
(c++-ts-mode . company-mode)
|
|
(c++-ts-mode . fg42/c-ts-mode-setup)
|
|
(c++-ts-mode . flyspell-prog-mode))
|
|
|
|
|
|
(provide 'fg42/langs/cpp)
|
|
;;; cpp.el ends here
|