Replace old C integration with lsp-mode config
This commit is contained in:
parent
cd21a6cf2c
commit
a4740069c6
74
config.org
74
config.org
@ -299,52 +299,40 @@
|
|||||||
(setq-default indent-tabs-mode nil)
|
(setq-default indent-tabs-mode nil)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
*** Language Server Protocol
|
||||||
|
LSP seems to be the way forward in terms of IDE-like features in
|
||||||
|
Emacs; grab =lsp-mode= and enable =lsp-deferred=:
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(use-package lsp-mode
|
||||||
|
:init (setq lsp-keymap-prefix "C-c l")
|
||||||
|
:commands (lsp lsp-deferred))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
=lsp-deferred= means that the LSP server will only be started once
|
||||||
|
a buffer is actually opened, which makes more sense to me.
|
||||||
|
|
||||||
|
Also going to give =lsp-ui= a shot, which displays a bunch of
|
||||||
|
information from the language server in the buffer. It looks like
|
||||||
|
it could be a bit much but we'll see.
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(use-package lsp-ui :commands lsp-ui-mode)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
Finally, to enable Ido integration:
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(require 'lsp-ido)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
** C
|
** C
|
||||||
For C, I like to indent with tabs and align with spaces: this
|
For C there is =clangd= implementing LSP. Assuming that's installed
|
||||||
behaviour is provided by =smart-tabs-mode=.
|
and on the =PATH=, we can just hook =lsp-mode= into the default
|
||||||
|
mode and there will be much rejoicing.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package smart-tabs-mode)
|
(add-hook 'c-mode-hook #'lsp-deferred)
|
||||||
(smart-tabs-insinuate 'c)
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
I'll generally format my code in BSD style but I also use
|
|
||||||
=clang-format= a lot, so I have a keybinding to run that.
|
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(setq c-default-style "bsd")
|
|
||||||
(setq c-basic-offset 4)
|
|
||||||
|
|
||||||
(use-package clang-format)
|
|
||||||
(add-hook 'c-mode-hook
|
|
||||||
(lambda ()
|
|
||||||
(define-key c-mode-map (kbd "C-M-f")
|
|
||||||
'clang-format-buffer)))
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
Meson is my build system of choice for C, but I also use CMake a lot.
|
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(use-package meson-mode)
|
|
||||||
(use-package cmake-mode)
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
*** Code Navigation
|
|
||||||
Using GNU Global for now, so hook =ggtags-mode= into =c-mode=:
|
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(use-package ggtags
|
|
||||||
:config
|
|
||||||
(add-hook 'c-mode-common-hook
|
|
||||||
(lambda () (ggtags-mode 1))))
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
And, of course, add some keybindings
|
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(define-key ggtags-mode-map (kbd "C-c g r") 'ggtags-find-reference)
|
|
||||||
(define-key ggtags-mode-map (kbd "C-c g d") 'ggtags-find-definition)
|
|
||||||
(define-key ggtags-mode-map (kbd "C-c g u") 'ggtags-update-tags)
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Haskell
|
** Haskell
|
||||||
|
Loading…
x
Reference in New Issue
Block a user