@@ -63,36 +63,37 @@ Example: adding EmmyLua to [SublimeText](https://www.sublimetext.com/) with [Sub
6363```
6464
6565## Adding to Emacs
66+ you can use [ lsp-lua-emmy] ( https://github.com/phenix3443/lsp-lua-emmy ) as lsp client.
67+
6668add following code to your ` ~/.emacs ` or ` .emacs.d/init.el ` .
69+
6770``` emacs-lisp
6871(use-package lsp-mode
6972 :ensure t
7073 :commands lsp
7174 :hook ((lua-mode) . lsp)
7275 :config
73-
74- ;; register emmy-lua-lsp
75- (lsp-register-client
76- (make-lsp-client :new-connection
77- (lsp-stdio-connection
78- (list
79- "/usr/bin/java"
80- "-cp"
81- (expand-file-name "EmmyLua-LS-all.jar" user-emacs-directory)
82- "com.tang.vscode.MainKt"))
83- :major-modes '(lua-mode)
84- :server-id 'emmy-lua))
8576 )
8677
8778(use-package company-lsp
8879 :ensure t
8980 :after lsp-mode
9081 :config
9182 (setq company-lsp-enable-recompletion t)
83+ (setq lsp-auto-configure nil) ;该功能会自动执行(push company-lsp company-backends)
84+ )
85+
86+ (use-package lsp-lua-emmy
87+ :demand
88+ :ensure nil
89+ :load-path "~/github/lsp-lua-emmy"
90+ :hook (lua-mode . lsp)
91+ :config
92+ (setq lsp-lua-emmy-jar-path (expand-file-name "EmmyLua-LS-all.jar" user-emacs-directory))
9293 )
9394
94- (defun company-lua-mode-setup ()
95- "Create lua company backend."
95+ (defun set- company-backends-for-lua ()
96+ "Set lua company backend."
9697 (setq-local company-backends '(
9798 (
9899 company-lsp
@@ -104,15 +105,17 @@ add following code to your `~/.emacs` or `.emacs.d/init.el` .
104105 company-capf
105106 company-dabbrev-code
106107 company-files
107- )
108- ))
108+ )))
109109
110110(use-package lua-mode
111111 :ensure t
112112 :mode "\\.lua$"
113113 :interpreter "lua"
114- :hook (lua-mode . company-lua-mode-setup )
114+ :hook (lua-mode . set- company-backends-for-lua )
115115 :config
116+ (setq lua-indent-level 4)
117+ (setq lua-indent-string-contents t)
118+ (setq lua-prefix-key nil)
116119 )
117120
118121```
0 commit comments