Emacs: Replace company-clang-version with my/clangd-version.

This commit is contained in:
tastytea 2020-01-26 07:01:04 +01:00
parent c42cb09db7
commit 1d029a4ff9
3 changed files with 12 additions and 6 deletions

View File

@ -1,6 +1,6 @@
;;; global-variables.el --- Set global variables. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-01-26T01:07:21+0100>
;; Time-stamp: <2020-01-26T06:59:34+0100>
;;; Commentary:
;; * Set `slow-computer'.
@ -54,6 +54,11 @@
(defalias 'yes-or-no-p 'y-or-n-p) ; Just type y/n instead of yes/no.
(savehist-mode t) ; Save minibuffer history.
(global-auto-revert-mode t) ; Auto-revert file if changed on disk.
(defun my/clangd-version ()
"Returns the version of clangd as float."
(string-to-number
(nth 2 (split-string (shell-command-to-string "clangd --version")))))
)
(provide 'basics/global-variables)

View File

@ -1,6 +1,6 @@
;;; c++.el --- C++ settings. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-01-26T02:35:47+0100>
;; Time-stamp: <2020-01-26T06:58:53+0100>
;;; Commentary:
@ -15,7 +15,8 @@
:after (flycheck projectile lsp-ui)
:if (executable-find "clang-tidy")
;; clang-tidy is built into clangd >= 9.
:if (< (cdr (company-clang-version)) 9.0)
:if (< (my/clangd-version) 9.0)
:config
(defun my/clang-tidy-off ()
"Disable c/c++-clang-tidy."

View File

@ -1,6 +1,6 @@
;;; common.el --- Common programming settings. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-01-26T01:58:12+0100>
;; Time-stamp: <2020-01-26T07:00:14+0100>
;;; Commentary:
@ -316,7 +316,7 @@ purpose or not wide enough."
;; Client for Language Server Protocol servers.
(use-package lsp-mode
:if (executable-find "clangd")
:after (whitespace company)
:after (whitespace)
:defines (lsp-clients-clangd-args)
:custom
@ -327,7 +327,7 @@ purpose or not wide enough."
:config
(setq lsp-clients-clangd-args '("-compile-commands-dir=build"))
;; Add “-clang-tidy” to clangd args if the version supports it.
(if (>= (cdr (company-clang-version)) 9.0)
(if (>= (my/clangd-version) 9.0)
(add-to-list 'lsp-clients-clangd-args "-clang-tidy" t))
(defun my/lsp-ws-toggle ()