;;使用国内elpa源来加速插件安装(defunw-install(pkg);;wouldbeawrapperforpackage-install(require'package)(setqpackage-archives'(("gnu" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")("melpa"."http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))(package-initialize)(package-refresh-contents)(unless(package-installed-ppkg)(package-installpkg)));;辅助判断插件安装通用函数(defunensure-package-installed(&restpackages)"Assure every package was installed, ask for installation if it's not.alistofinstalledpackagesornilforeveryskippedpackage."(mapcar(lambda(package)(if(package-installed-ppackage)nil(if(y-or-n-p(format"Package %s is missing. Install it?"package))(w-installpackage)package)))packages));;clang-format在文件保存时格式化代码(ensure-package-installed'clang-format)(defunclang-format-on-save-hook()"Create a buffer local save hook."(add-hook'before-save-hook(lambda()(when(locate-dominating-file"."".clang-format")(clang-format-buffer));;Continuetosavenil)nil;;Bufferlocalhook.t));;Runthishookforc-mode-hookandc++-mode-hook(add-hook'c-mode-hook (lambda () (clang-format-on-save-hook)))(add-hook'c++-mode-hook (lambda () (clang-format-on-save-hook)));;createdefaultclang-formatfile;;https://releases.llvm.org/3.6.2/tools/docs/ClangFormatStyleOptions.html;;clang-format-style=llvm-dump-config>.clang-format;;另外,这里列出使用的lsp-language-server配置。;;服务端使用ccls,客户端则使用ccls.el。同时将ccls作为c-mode的hook运行;;https://github.com/MaskRay/ccls/wiki/Build;;setuplsp-modeforc/c++(ensure-package-installed'ccls)(use-packageccls:hook((c-modec++-modeobjc-modecuda-mode).(lambda()(require'ccls) (lsp))))