From 5cfaf54de348bd36e3f35d0847f26c321cba298f Mon Sep 17 00:00:00 2001 From: Arthur BARRAUX Date: Mon, 21 Oct 2024 14:40:56 +0200 Subject: [PATCH] lsp --- README.md | 4 ++-- config.org | 69 ++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 64 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 73ace49..1e3b1ff 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,11 @@ Then you will have to put this only line in your `init.el` file: Obviously, you need to change the path to your config file. Now the configuration should be great and you can make any changs you want on the org file. -** Key bindings +## Key bindings | Keybind | Action | |:--------|:----------------------------------------| | `ù` | Insert the dereference arrow in C `->`. | -| `C-c r` | Reload the config file (**init.el**) | +| `C-c r` | Reload the config file (*init.el*) | | `C-c c` | Open the org config file. | | `C-x é` | Split window vertically. | | `C-x "` | Split window horizontaly. | diff --git a/config.org b/config.org index 12eab3d..2021bcf 100644 --- a/config.org +++ b/config.org @@ -44,19 +44,74 @@ (company-mode 1) #+END_SRC +** Smart parenthesis +#+begin_src emacs-lisp + (use-package smartparens + :ensure smartparens ;; install the package + :hook (prog-mode text-mode markdown-mode) ;; add `smartparens-mode` to these hooks + :config + ;; load default config + (require 'smartparens-config)) +#+end_src + +** LSP +#+begin_src emacs-lisp +(setq package-selected-packages '(lsp-mode yasnippet lsp-treemacs helm-lsp + projectile hydra flycheck company avy which-key helm-xref dap-mode)) + +(when (cl-find-if-not #'package-installed-p package-selected-packages) + (package-refresh-contents) + (mapc #'package-install package-selected-packages)) + +;; sample `helm' configuration use https://github.com/emacs-helm/helm/ for details +(helm-mode) +(require 'helm-xref) +(define-key global-map [remap find-file] #'helm-find-files) +(define-key global-map [remap execute-extended-command] #'helm-M-x) +(define-key global-map [remap switch-to-buffer] #'helm-mini) + +(which-key-mode) +(add-hook 'c-mode-hook 'lsp) +(add-hook 'c++-mode-hook 'lsp) + +(setq gc-cons-threshold (* 100 1024 1024) + read-process-output-max (* 1024 1024) + treemacs-space-between-root-nodes nil + company-idle-delay 0.0 + company-minimum-prefix-length 1 + lsp-idle-delay 0.1) ;; clangd is fast + +(with-eval-after-load 'lsp-mode + (add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration) + (require 'dap-cpptools) + (yas-global-mode)) + +#+end_src * Key-binds -** Dereference arrow +** C +*** Dereference arrow #+BEGIN_SRC emacs-lisp -(defun print-arrow () - (interactive) - (with-current-buffer (buffer-name); - (insert "->"))) - -(keymap-global-set "ù" 'print-arrow) + (defun print-arrow () + (interactive) + (if (eq major-mode 'c-mode) + (with-current-buffer (buffer-name); + (insert "->")) + (with-current-buffer (buffer-name); + (insert "ù")) + )) + (keymap-global-set "ù" 'print-arrow) #+END_SRC +*** Jump to def +#+begin_src emacs-lisp + (defun go-to-definition () + if (eq major-mode 'c-mode) + ('ff-find-other-file)) + (keymap-local-set "C-" 'go-to-definition) +#+end_src + ** Reload config #+BEGIN_SRC emacs-lisp