fixing c++ and eglot systems
This commit is contained in:
parent
81012a9d4a
commit
6c20cda022
33
README.org
33
README.org
|
@ -2002,7 +2002,36 @@ I'm gonna try this to speed up emacs and make it nicer
|
|||
*** C++
|
||||
In c++ I just want to make sure lsp is called when enter c++-mode
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(add-hook 'c++-mode-hook 'eglot)
|
||||
(defun astyle-this-buffer ()
|
||||
"Use astyle command to auto format c/c++ code."
|
||||
(interactive "r")
|
||||
(let* ((original-point (point))) ;; save original point before processing, thanks to @Scony
|
||||
(progn
|
||||
(if (executable-find "astyle")
|
||||
(shell-command-on-region
|
||||
(point-min) (point-max)
|
||||
(concat
|
||||
"astyle"
|
||||
" --style=" cc-mode-code-style
|
||||
" --indent=spaces=" (number-to-string c-basic-offset)
|
||||
" --pad-oper"
|
||||
" --pad-header"
|
||||
" --break-blocks"
|
||||
" --delete-empty-lines"
|
||||
" --align-pointer=type"
|
||||
" --align-reference=name")
|
||||
(current-buffer) t
|
||||
(get-buffer-create "*Astyle Errors*") t)
|
||||
(message "Cannot find binary \"astyle\", please install first."))
|
||||
(goto-char original-point)))) ;; restore original point
|
||||
|
||||
(defun astyle-before-save ()
|
||||
"Auto styling before saving."
|
||||
(interactive)
|
||||
(when (member major-mode '(cc-mode c++-mode c-mode))
|
||||
(astyle-this-buffer)))
|
||||
|
||||
(add-hook 'c-mode-common-hook (lambda () (add-hook 'before-save-hook 'astyle-before-save)))
|
||||
#+END_SRC
|
||||
|
||||
*** Web
|
||||
|
@ -2094,7 +2123,7 @@ Let's give eglot a try.
|
|||
(use-package eglot
|
||||
:commands eglot
|
||||
:hook
|
||||
(c++-mode . eglot))
|
||||
(c++-mode . eglot-ensure))
|
||||
#+end_src
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
|
|
33
init.el
33
init.el
|
@ -1374,7 +1374,36 @@ targets."
|
|||
)
|
||||
(use-package tree-sitter-langs)
|
||||
|
||||
(add-hook 'c++-mode-hook 'eglot)
|
||||
(defun astyle-this-buffer ()
|
||||
"Use astyle command to auto format c/c++ code."
|
||||
(interactive "r")
|
||||
(let* ((original-point (point))) ;; save original point before processing, thanks to @Scony
|
||||
(progn
|
||||
(if (executable-find "astyle")
|
||||
(shell-command-on-region
|
||||
(point-min) (point-max)
|
||||
(concat
|
||||
"astyle"
|
||||
" --style=" cc-mode-code-style
|
||||
" --indent=spaces=" (number-to-string c-basic-offset)
|
||||
" --pad-oper"
|
||||
" --pad-header"
|
||||
" --break-blocks"
|
||||
" --delete-empty-lines"
|
||||
" --align-pointer=type"
|
||||
" --align-reference=name")
|
||||
(current-buffer) t
|
||||
(get-buffer-create "*Astyle Errors*") t)
|
||||
(message "Cannot find binary \"astyle\", please install first."))
|
||||
(goto-char original-point)))) ;; restore original point
|
||||
|
||||
(defun astyle-before-save ()
|
||||
"Auto styling before saving."
|
||||
(interactive)
|
||||
(when (member major-mode '(cc-mode c++-mode c-mode))
|
||||
(astyle-this-buffer)))
|
||||
|
||||
(add-hook 'c-mode-common-hook (lambda () (add-hook 'before-save-hook 'astyle-before-save)))
|
||||
|
||||
(use-package web-mode
|
||||
:config
|
||||
|
@ -1408,7 +1437,7 @@ targets."
|
|||
(use-package eglot
|
||||
:commands eglot
|
||||
:hook
|
||||
(c++-mode . eglot))
|
||||
(c++-mode . eglot-ensure))
|
||||
|
||||
(use-package consult-eglot)
|
||||
|
||||
|
|
Loading…
Reference in a new issue