Enhanced comments and enabled company mode with eglot

This commit is contained in:
Louis Lacoste 2023-02-24 17:38:11 +01:00
parent 2054d46570
commit bd8d701dcf
2 changed files with 68 additions and 28 deletions

View file

@ -87,13 +87,8 @@
(dired-directory dired-directory "%b")))) (dired-directory dired-directory "%b"))))
(global-font-lock-mode t) (global-font-lock-mode t)
(custom-set-faces
(custom-set-faces '(flyspell-incorrect ((t (:inverse-video t)))))
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(flyspell-incorrect ((t (:inverse-video t)))))
(line-number-mode 1) (line-number-mode 1)
(column-number-mode 1) (column-number-mode 1)
@ -320,12 +315,15 @@ A->B
(setq python-shell-completion-native-enable nil) (setq python-shell-completion-native-enable nil)
;;; Beginning of my customisations
(let* ((wanted-packages (let* ((wanted-packages
'(flycheck ; grammar '(flycheck ; grammar
flycheck-grammalecte ; grammar flycheck-grammalecte ; grammar
company ; auto-complete company ; auto-complete
org-appear ; org emphasis appear org-appear ; org emphasis appear
org-fragtog ; see latex fragment in org org-fragtog ; see latex fragment in org
org-bullets ; Nicer bullets
use-package use-package
eglot ; LSP client eglot ; LSP client
counsel ; ivy autocomplete for M-x counsel ; ivy autocomplete for M-x
@ -343,15 +341,22 @@ flycheck-grammalecte ; grammar
(require 'powerline) (require 'powerline)
(powerline-default-theme) (powerline-default-theme)
;; Below we modify Org Mode behavior
;; When loading org-mode turns off auto-fill-mode ;; When loading org-mode turns off auto-fill-mode
(add-hook 'org-mode-hook 'turn-off-auto-fill) (add-hook 'org-mode-hook 'turn-off-auto-fill)
;; Emphasis markers now appear when hovering
(add-hook 'org-mode-hook 'org-appear-mode) (add-hook 'org-mode-hook 'org-appear-mode)
(global-visual-line-mode 1) ; 1 for on & 0 for off ;; Nicer org bullets
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
;; Auto-toggle LaTeX fragments
(add-hook 'org-mode-hook 'org-fragtog-mode) (add-hook 'org-mode-hook 'org-fragtog-mode)
(global-visual-line-mode 1) ; 1 for on & 0 for off
(global-company-mode) (global-company-mode)
(ivy-mode 1) (ivy-mode 1)
@ -359,7 +364,8 @@ flycheck-grammalecte ; grammar
(setq ivy-use-virtual-buffers t) (setq ivy-use-virtual-buffers t)
(setq ivy-count-format "(%d/%d) ") (setq ivy-count-format "(%d/%d) ")
; Enables LSP for the provided languages ;;; LSP features
;; Enables LSP for the provided languages
(require 'use-package) (require 'use-package)
(use-package eglot (use-package eglot
@ -368,22 +374,26 @@ flycheck-grammalecte ; grammar
:hook :hook
((ess-mode . eglot-ensure)) ((ess-mode . eglot-ensure))
:config :config
(setq eglot-stay-out-of '(company)) ;(setq eglot-stay-out-of '(company))
;(add-to-list 'eglot-server-programs '((c-mode c++-mode) "clangd-10")) ;(add-to-list 'eglot-server-programs '((c-mode c++-mode) "clangd-10"))
) )
;; Forcing the ESS mode to work
(with-eval-after-load 'eglot (with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs (add-to-list 'eglot-server-programs
'(ess-mode . ("R" "--slave" "-e" "languageserver::run()")))) '(ess-mode . ("R" "--slave" "-e" "languageserver::run()"))))
;; Activating eldoc-box to have a popup with the doc
(require 'eldoc-box) (require 'eldoc-box)
(add-hook 'eglot-managed-mode-hook #'eldoc-box-hover-mode t) (add-hook 'eglot-managed-mode-hook #'eldoc-box-hover-mode t)
(load-theme 'leuven t) ;; Workaround to disable the popup when we open the buffer
(custom-set-variables (defun quit-eldoc-box-frame-before-doc-buffer (orig-fun &rest _arg)
;; custom-set-variables was added by Custom. (eldoc-box-quit-frame)
;; If you edit it by hand, you could mess it up, so be careful. (funcall orig-fun t))
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right. (advice-add 'eldoc-doc-buffer
'(package-selected-packages :around 'quit-eldoc-box-frame-before-doc-buffer)
'(powerline cmake-mode use-package treemacs-tab-bar treemacs-projectile treemacs-persp treemacs-magit treemacs-icons-dired treemacs-evil org-fragtog org-appear lsp-pyright htmlize helm flycheck-grammalecte ess eldoc-box eglot counsel company auctex)))
(load-theme 'wombat t)

View file

@ -1,4 +1,3 @@
# -*- mode: org -*- # -*- mode: org -*-
#+TITLE: Emacs init file written in org-mode #+TITLE: Emacs init file written in org-mode
#+AUTHOR: Arnaud Legrand, Konrad Hinsen #+AUTHOR: Arnaud Legrand, Konrad Hinsen
@ -506,6 +505,9 @@ This often fails, yielding an ugly warning, and isn't of any use in Org-mode any
(setq python-shell-completion-native-enable nil) (setq python-shell-completion-native-enable nil)
#+end_src #+end_src
* Custom Louis :LOUIS: * Custom Louis :LOUIS:
#+begin_src emacs-lisp :tangle init.el
;;; Beginning of my customisations
#+end_src
** Installing wanted packages ** Installing wanted packages
#+begin_src emacs-lisp :tangle init.el #+begin_src emacs-lisp :tangle init.el
(let* ((wanted-packages (let* ((wanted-packages
@ -514,6 +516,7 @@ flycheck-grammalecte ; grammar
company ; auto-complete company ; auto-complete
org-appear ; org emphasis appear org-appear ; org emphasis appear
org-fragtog ; see latex fragment in org org-fragtog ; see latex fragment in org
org-bullets ; Nicer bullets
use-package use-package
eglot ; LSP client eglot ; LSP client
counsel ; ivy autocomplete for M-x counsel ; ivy autocomplete for M-x
@ -550,25 +553,36 @@ flycheck-grammalecte ; grammar
(require 'powerline) (require 'powerline)
(powerline-default-theme) (powerline-default-theme)
#+end_src #+end_src
** Disabling auto-fill-mode when using org ** Org modifications
#+begin_src emacs-lisp :tangle init.el
;; Below we modify Org Mode behavior
#+end_src
*** Disabling auto-fill-mode when using org
This snippet disables the auto-fill-mode which wraps the line when it exceeds a certain length This snippet disables the auto-fill-mode which wraps the line when it exceeds a certain length
#+begin_src emacs-lisp :tangle init.el #+begin_src emacs-lisp :tangle init.el
;; When loading org-mode turns off auto-fill-mode ;; When loading org-mode turns off auto-fill-mode
(add-hook 'org-mode-hook 'turn-off-auto-fill) (add-hook 'org-mode-hook 'turn-off-auto-fill)
#+end_src #+end_src
** Activating org-appear minor mode *** Activating org-appear minor mode
This mode makes the emphasis markers appear when the cursor is on it This mode makes the emphasis markers appear when the cursor is on it
#+begin_src emacs-lisp :tangle init.el #+begin_src emacs-lisp :tangle init.el
;; Emphasis markers now appear when hovering
(add-hook 'org-mode-hook 'org-appear-mode) (add-hook 'org-mode-hook 'org-appear-mode)
#+end_src #+end_src
*** Nicer Org bullets
#+begin_src emacs-lisp :tangle init.el
;; Nicer org bullets
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
#+end_src
*** Auto toggle the preview of LaTeX fragments
#+begin_src emacs-lisp :tangle init.el
;; Auto-toggle LaTeX fragments
(add-hook 'org-mode-hook 'org-fragtog-mode)
#+end_src
** Visual line mode activated on startup ** Visual line mode activated on startup
#+begin_src emacs-lisp :tangle init.el #+begin_src emacs-lisp :tangle init.el
(global-visual-line-mode 1) ; 1 for on & 0 for off (global-visual-line-mode 1) ; 1 for on & 0 for off
#+end_src #+end_src
** Auto toggle the preview of LaTeX fragments
#+begin_src emacs-lisp :tangle init.el
(add-hook 'org-mode-hook 'org-fragtog-mode)
#+end_src
** Remote image display :disabled: ** Remote image display :disabled:
This code was taken from https://emacs.stackexchange.com/questions/42281/org-mode-is-it-possible-to-display-online-images and makes use of the =org-yt= package. This code was taken from https://emacs.stackexchange.com/questions/42281/org-mode-is-it-possible-to-display-online-images and makes use of the =org-yt= package.
@ -610,7 +624,8 @@ This code was taken from https://emacs.stackexchange.com/questions/42281/org-mod
*** Enabling eglot and adding ess-mode lsp *** Enabling eglot and adding ess-mode lsp
Language Server Protocol (LSP) provides intellisense completion and other nice features of VS Code. Language Server Protocol (LSP) provides intellisense completion and other nice features of VS Code.
#+begin_src emacs-lisp :tangle init.el #+begin_src emacs-lisp :tangle init.el
; Enables LSP for the provided languages ;;; LSP features
;; Enables LSP for the provided languages
(require 'use-package) (require 'use-package)
(use-package eglot (use-package eglot
@ -619,10 +634,12 @@ Language Server Protocol (LSP) provides intellisense completion and other nice f
:hook :hook
((ess-mode . eglot-ensure)) ((ess-mode . eglot-ensure))
:config :config
(setq eglot-stay-out-of '(company)) ;(setq eglot-stay-out-of '(company))
;(add-to-list 'eglot-server-programs '((c-mode c++-mode) "clangd-10")) ;(add-to-list 'eglot-server-programs '((c-mode c++-mode) "clangd-10"))
) )
;; Forcing the ESS mode to work
(with-eval-after-load 'eglot (with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs (add-to-list 'eglot-server-programs
'(ess-mode . ("R" "--slave" "-e" "languageserver::run()")))) '(ess-mode . ("R" "--slave" "-e" "languageserver::run()"))))
@ -630,8 +647,18 @@ Language Server Protocol (LSP) provides intellisense completion and other nice f
#+end_src #+end_src
*** Floating pop-up for eldoc *** Floating pop-up for eldoc
#+begin_src emacs-lisp :tangle init.el #+begin_src emacs-lisp :tangle init.el
;; Activating eldoc-box to have a popup with the doc
(require 'eldoc-box) (require 'eldoc-box)
(add-hook 'eglot-managed-mode-hook #'eldoc-box-hover-mode t) (add-hook 'eglot-managed-mode-hook #'eldoc-box-hover-mode t)
;; Workaround to disable the popup when we open the buffer
(defun quit-eldoc-box-frame-before-doc-buffer (orig-fun &rest _arg)
(eldoc-box-quit-frame)
(funcall orig-fun t))
(advice-add 'eldoc-doc-buffer
:around 'quit-eldoc-box-frame-before-doc-buffer)
#+end_src #+end_src
** Treemacs :disabled: ** Treemacs :disabled:
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -754,5 +781,8 @@ Language Server Protocol (LSP) provides intellisense completion and other nice f
* Theme * Theme
** Activation du thème ** Activation du thème
#+begin_src emacs-lisp :tangle init.el #+begin_src emacs-lisp :tangle init.el
(load-theme 'leuven t) (load-theme 'wombat t)
#+end_src #+end_src
#+RESULTS:
: t