Kavya G

Language Server Protocol

Language Server Protocol

What is it?

Why?

Why not?

Thank you LSP!

I was recently working on something related to language servers. To test stuff out and to get some idea of the working of language servers (Cquery), I decided to try it out with Emacs since:

;; In general wrt to lsp, autocompletion and snippets
(require 'lsp-mode)

(require 'lsp-ui)
(add-hook 'lsp-mode-hook 'lsp-ui-mode)

(require 'company-lsp)
(push 'company-lsp company-backends)
(setq company-transformers nil company-lsp-async t company-lsp-cache-candidates 'auto company-lsp-enable-snippet t)

(require 'yasnippet)
(yas-global-mode 1)

;; Specific to cquery
(require 'cquery)
(setq cquery-executable "/path/to/cquery/build/release/bin/cquery")
(setq cquery-sem-highlight-method 'font-lock)
(setq cquery-extra-init-params '(:index (:comments 2) :cacheFormat "msgpack"))
(cquery-use-default-rainbow-sem-highlight)

M-x lsp-cquery-enable
M-x company-mode

Guess that needs to be automated.