summaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ravi-init-cpp.el70
-rw-r--r--lisp/ravi-init-lsp.el62
2 files changed, 82 insertions, 50 deletions
diff --git a/lisp/ravi-init-cpp.el b/lisp/ravi-init-cpp.el
index 4b4ad91..89836a7 100644
--- a/lisp/ravi-init-cpp.el
+++ b/lisp/ravi-init-cpp.el
@@ -438,61 +438,31 @@ this to 3 makes header-protection define KIG_MISC_NEWTYPE_H for a file named
(add-to-list 'company-backends 'company-rtags)))))
;; Choices of different LSP backends
- (setq ravi/use-cpp-lsp-backends '(ravi/use-cpp-cquery ravi/use-cpp-ccls ravi/use-cpp-none))
+ (setq ravi/use-cpp-lsp-backends '(ravi/use-cpp-ccls ravi/use-cpp-none))
(setq ravi/use-cpp-lsp-backend 'ravi/use-cpp-ccls)
(unless (memq ravi/use-cpp-lsp-backend ravi/use-cpp-lsp-backends)
(message "Invalid value for C++ LSP backend")
(setq ravi/use-cpp-lsp-backend 'ravi/use-cpp-none))
- (unless (eq ravi/use-cpp-lsp-backend 'ravi/use-cpp-none)
- (setq lsp-enable-completion-at-point nil)
- (setq lsp-enable-indentation nil) ; conflicts with other indentation commands
- (use-package company-lsp
- :commands company-lsp
- :config
- (progn
- (bind-key "H-<tab>" 'company-rtags c-mode-base-map)
- (setq company-lsp-async t)
- (setq company-lsp-cache-candidates nil)))
- (use-package lsp-mode
- :commands lsp)
- (use-package lsp-ui
- :commands lsp-ui-mode))
-
- (when (eq ravi/use-cpp-lsp-backend 'ravi/use-cpp-ccls)
- (use-package ccls
- :init
- (progn
- (defun ravi/ccls-enable ()
- (unless (file-remote-p default-directory)
- (condition-case nil
- (progn
- (require 'ccls)
- (lsp))
- (user-error nil))))
- (add-hook 'c-mode-common-hook #'ravi/ccls-enable))
- :config
- (setq ccls-executable (ravi/emacs-file "site-lisp/ccls/Release/ccls"))
- (setq ccls-args `(,(concat "--log-file=" (expand-file-name "ccls.log" (ravi/emacs-file "past"))))) ; to do: use relative path
- ))
-
- (when (eq ravi/use-cpp-lsp-backend 'ravi/use-cpp-cquery)
- (use-package cquery
- :commands lsp-cquery-enable
- :init
- (progn
- (defun ravi/cquery-enable ()
- (unless (file-remote-p default-directory)
- (condition-case nil
- (lsp-cquery-enable)
- (user-error nil))))
- (add-hook 'c-mode-common-hook #'ravi/cquery-enable))
- :config
- (progn
- (setq cquery-executable (ravi/emacs-file "site-lisp/cquery/build/cquery"))
- (setq cquery-extra-args `(,(concat "--log-file=" (expand-file-name "cq.log" (ravi/emacs-file "past"))))) ; to do: use relative path
- (setq cquery-cache-dir ".cquery_cached_index")
- (setq cquery-extra-init-params '(:index (:comments 2) :cacheFormat "msgpack" :completion (:detailedLabel t))))))
+ (use-package ccls
+ :if (eq ravi/use-cpp-lsp-backend 'ravi/use-cpp-ccls)
+ :init
+ (progn
+ (defun ravi/ccls-enable ()
+ (unless (file-remote-p default-directory)
+ (condition-case nil
+ (progn
+ (require 'ccls)
+ (lsp-deferred))
+ (user-error nil))))
+ (add-hook 'c-mode-common-hook #'ravi/ccls-enable))
+ :config
+ (setq ccls-executable (ravi/emacs-file "site-lisp/ccls/Release/ccls"))
+ (setq ccls-args `(,(concat "--log-file="
+ (expand-file-name
+ (format "ccls-%s.log" (system-name))
+ (ravi/emacs-file "past"))))) ; to do: use relative path
+ )
(setq hide-ifdef-initially nil)
diff --git a/lisp/ravi-init-lsp.el b/lisp/ravi-init-lsp.el
new file mode 100644
index 0000000..dc40c9c
--- /dev/null
+++ b/lisp/ravi-init-lsp.el
@@ -0,0 +1,62 @@
+;;; ravi-init-lsp.el --- lsp-mode support -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Ravi Kiran
+
+;; Author: Ravi Kiran <ravi@cramer>
+;; Keywords:
+
+;; 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 <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; LSP mode support
+
+;;; Code:
+
+;; 4k is too low; use 1MB minimum for interprocess communication
+(setq read-process-output-max (* 1024 1024))
+
+(use-package lsp-mode
+ :init
+ (setq lsp-keymap-prefix "H-l")
+ :hook ((c-mode . lsp-deferred)
+ (c++-mode . lsp-deferred)
+ ;; (python-mode . lsp-deferred)
+ (lsp-mode . lsp-enable-which-key-integration))
+ :commands (lsp lsp-deferred)
+ :bind (:map lsp-mode-map
+ ("M-<RET>" . lsp-execute-code-action)) ; perhaps helm-lsp-code-actions?
+ :config
+ (setq lsp-enable-file-watchers nil) ; Most of my repos are too large
+ (setq lsp-enable-indentation nil) ; I'll handle indentation myself
+ (use-package helm-lsp
+ :commands helm-lsp-workspace-symbol)
+ (use-package lsp-ui
+ :commands lsp-ui-mode
+ :hook (lsp-mode . lsp-ui-mode)
+ :bind (:map lsp-ui-mode-map
+ ("C-c i" . lsp-ui-imenu))
+ :config
+ (setq lsp-ui-doc-enable t)
+ (setq lsp-ui-peek-show-directory t)
+ (setq lsp-ui-peek-enable t)))
+
+(use-package dap-mode
+ :defer t
+ :after lsp-mode
+ :config
+ (dap-auto-configure-mode))
+
+(provide 'ravi-init-lsp)
+;;; ravi-init-lsp.el ends here