Moved LSP server config to separate file

This commit is contained in:
Random936 2023-09-19 21:47:43 -07:00
parent 3058833332
commit dec032575e
2 changed files with 129 additions and 122 deletions

View File

@ -776,122 +776,6 @@ Company is a package that automatically finds completions instead of making the
:init (global-flycheck-mode))
#+end_src
** Language Servers
This will include any language server packages and configuration.
*** HTML
#+begin_src emacs-lisp
(use-package web-mode
:mode "\\.html\\'"
:hook (web-mode . lsp-deferred))
#+end_src
*** JavaScript/Typescript
#+begin_src emacs-lisp
(use-package typescript-mode
:mode ("\\.ts\\'" "\\.js\\'")
:hook (typescript-mode . lsp-deferred))
#+end_src
Install the ~typescript-language-server~ through npm.
#+begin_src sh
npm install -g typescript-language-server
#+end_src
*** Python
#+begin_src emacs-lisp
(use-package python-mode
:mode ("\\.py\\'")
:hook (python-mode . lsp-deferred))
#+end_src
Install the ~python-lsp-server~ though pip.
#+begin_src sh
pip install python-lsp-server
#+end_src
*** C/C++
#+begin_src emacs-lisp
(use-package ccls
:hook ((c-mode cc-mode c++-mode objc-mode cuda-mode) .
(lambda () (require 'ccls) (lsp)))
:config
(setq ccls-executable "/usr/bin/ccls"))
#+end_src
Install ~ccls~ with homebrew using the following command.
#+begin_src sh
sudo apt install ccls
#+end_src
*** Golang
#+begin_src emacs-lisp
(use-package go-mode
:hook (go-mode . lsp-deferred))
#+end_src
*** Rust
#+begin_src emacs-lisp
(use-package rustic
:hook (rust-mode . lsp-deferred))
#+end_src
*** C#
#+begin_src emacs-lisp
(use-package csharp-mode
:hook (csharp-mode . lsp-deferred))
#+end_src
*** JSON
#+begin_src emacs-lisp
(use-package json-mode
:hook (json-mode . lsp-deferred))
#+end_src
*** Yaml
#+begin_src emacs-lisp
(use-package yaml-mode
:hook (yaml-mode . lsp-deferred))
#+end_src
*** Yara
To install the corresponding LSP, you need to install ~yls~. Using the command ~pip install -U yls-yara~. Keep in mind that ~yls~ is dependent on an up to date version of ~yara-python~.
#+begin_src emacs-lisp
(use-package yara-mode
:hook (yara-mode . lsp-deferred)
:config
(with-eval-after-load 'lsp-mode
(add-to-list 'lsp-language-id-configuration
'(yara-mode . "yara"))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection "yls")
:activation-fn (lsp-activate-on "yara")
:server-id 'yls))))
#+end_src
*** R
#+begin_src emacs-lisp
(use-package ess
:hook (R-mode . lsp-deferred))
#+end_src
* Terminal
Emacs also has the functionality to run a terminal environment. While many other terminals will try to have similar capabilities with keybindings, nothing matches just integrating your terminal in emacs.
@ -940,13 +824,21 @@ When using zsh with powerlevel10k, the ~MesloLGS NF~ font is required to make th
This is the section to include imports from other files.
#+begin_src emacs-lisp
;; Load org file contianing EXWM config.
(defun jm/load-config-if-exists (file-path)
(when (file-exists-p file_path)
(org-babel-load-file file_path)))
;; Load LSP (Language Server Protocol) configuration.
(jm/load-config-if-exists "~/.emacs.d/lsp.org")
;; Load custom functions from org file.
(jm/load-config-if-exists "~/.emacs.d/functions.org")
;; Load emacs email client configuration
(jm/load-config-if-exists "~/.emacs.d/lsp.org")
;; Load EXWM configuration if environment variable set.
(let ((exwm-org-file "~/.emacs.d/exwm.org"))
(when (and (file-exists-p exwm-org-file) (getenv "USING_EXWM"))
(org-babel-load-file exwm-org-file)))
;; Load org file containing custom Elisp functions.
(let ((functions-file "~/.emacs.d/functions.org"))
(when (file-exists-p functions-file)
(org-babel-load-file functions-file)))
#+end_src

115
.emacs.d/lsp.org Normal file
View File

@ -0,0 +1,115 @@
* Language Servers
This will include any language server packages and configuration.
** HTML
#+begin_src emacs-lisp
(use-package web-mode
:mode "\\.html\\'"
:hook (web-mode . lsp-deferred))
#+end_src
** JavaScript/Typescript
#+begin_src emacs-lisp
(use-package typescript-mode
:mode ("\\.ts\\'" "\\.js\\'")
:hook (typescript-mode . lsp-deferred))
#+end_src
Install the ~typescript-language-server~ through npm.
#+begin_src sh
npm install -g typescript-language-server
#+end_src
** Python
#+begin_src emacs-lisp
(use-package python-mode
:mode ("\\.py\\'")
:hook (python-mode . lsp-deferred))
#+end_src
Install the ~python-lsp-server~ though pip.
#+begin_src sh
pip install python-lsp-server
#+end_src
** C/C++
#+begin_src emacs-lisp
(use-package ccls
:hook ((c-mode cc-mode c++-mode objc-mode cuda-mode) .
(lambda () (require 'ccls) (lsp)))
:config
(setq ccls-executable "/usr/bin/ccls"))
#+end_src
Install ~ccls~ with homebrew using the following command.
#+begin_src sh
sudo apt install ccls
#+end_src
** Golang
#+begin_src emacs-lisp
(use-package go-mode
:hook (go-mode . lsp-deferred))
#+end_src
** Rust
#+begin_src emacs-lisp
(use-package rustic
:hook (rust-mode . lsp-deferred))
#+end_src
** C#
#+begin_src emacs-lisp
(use-package csharp-mode
:hook (csharp-mode . lsp-deferred))
#+end_src
** JSON
#+begin_src emacs-lisp
(use-package json-mode
:hook (json-mode . lsp-deferred))
#+end_src
** Yaml
#+begin_src emacs-lisp
(use-package yaml-mode
:hook (yaml-mode . lsp-deferred))
#+end_src
** Yara
To install the corresponding LSP, you need to install ~yls~. Using the command ~pip install -U yls-yara~. Keep in mind that ~yls~ is dependent on an up to date version of ~yara-python~.
#+begin_src emacs-lisp
(use-package yara-mode
:hook (yara-mode . lsp-deferred)
:config
(with-eval-after-load 'lsp-mode
(add-to-list 'lsp-language-id-configuration
'(yara-mode . "yara"))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection "yls")
:activation-fn (lsp-activate-on "yara")
:server-id 'yls))))
#+end_src
** R
#+begin_src emacs-lisp
(use-package ess
:hook (R-mode . lsp-deferred))
#+end_src