I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.5 KiB

  1. #+TITLE: Language Server Protocol
  2. #+AUTHOR: Christopher James Hayward
  3. #+EMAIL: chris@chrishayward.xyz
  4. #+PROPERTY: header-args:emacs-lisp :tangle lsp.el :comments org
  5. #+PROPERTY: header-args:shell :tangle no
  6. #+PROPERTY: header-args :results silent :eval no-export :comments org
  7. #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  8. #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  9. The Language Server Protocol (LSP) defines the protocol used between an editor, or IDE, and a language server that provides language features like auto-complete, go-to-definition, find-all-references, etc[fn:1]
  10. * Config
  11. Support for the Language Server Protocol[fn:1] is available through the ~lsp-mode~[fn:2] package. Configure an immutable delay of =.5= to ensure it doesn't attack the current language server and overload it with requests.
  12. #+begin_src emacs-lisp
  13. (use-package lsp-mode
  14. :commands (lsp lsp-deferred)
  15. :custom (lsp-idle-delay 0.5)
  16. (lsp-prefer-flymake t))
  17. #+end_src
  18. ** Code snippets
  19. Download ~yasnippet~[fn:4], used by a number of ~lsp-mode~[fn:2] extensions to provide smart completion functionality.
  20. #+begin_src emacs-lisp
  21. (use-package yasnippet
  22. :ensure t)
  23. #+end_src
  24. ** UI integration
  25. Download ~lsp-ui~[fn:3] to provide user interface improvements for ~lsp-mode~[fn:2] over the defaults.
  26. #+begin_src emacs-lisp
  27. (use-package lsp-ui
  28. :after lsp
  29. :custom (lsp-ui-doc-position 'at-point)
  30. (lsp-ui-doc-delay 0.500))
  31. #+end_src
  32. ** Code completion
  33. Text completion provided by ~company~[fn:5], AKA Complete Anything. Make sure it's integrated with ~lsp-mode~[fn:2] to provide completion candidates through the Language Server Protocol[fn:1].
  34. #+begin_src emacs-lisp
  35. (use-package company
  36. :after lsp)
  37. #+end_src
  38. Specify the repository for ~company-lsp~ using straight to make sure we're getting the most recent version from GitHub, instead of the typically outdated versions in the Emacs package repositories.
  39. #+begin_src emacs-lisp
  40. (use-package company-lsp
  41. :after (lsp company)
  42. :custom (company-lsp-async t)
  43. (company-backend 'company-lsp)
  44. :straight (company-lsp :type git
  45. :host github
  46. :repo "tigersoldier/company-lsp"))
  47. #+end_src
  48. * Footnotes
  49. [fn:1] https://microsoft.github.io/language-server-protocol/
  50. [fn:2] https://emacs-lsp.github.io/lsp-mode/
  51. [fn:3] https://emacs-lsp.github.io/lsp-ui/
  52. [fn:4] https://github.com/joaotavora/yasnippet
  53. [fn:5] https://company-mode.github.io/