manateelazycat / lsp-bridge

A blazingly fast LSP client for Emacs
GNU General Public License v3.0
1.35k stars 197 forks source link

Dynamically set up `lsp-bridge-get-single-lang-server-by-project` #943

Open rezaamashi opened 1 month ago

rezaamashi commented 1 month ago

As exampled in #471, I reckon the way to set up lsp-bridge-get-single-lang-server-by-project is by statically setting it in init.el. I personally use .dir-locals.el for my project specific set up. Is there a way to dynamically set it specifically per project through .dir-locals.el? perhaps like:

((nil . ((eval . (setq lsp-bridge-get-single-lang-server-by-project
                              (lambda (project-path filepath)
                                (when (string-equal project-path (file-name-directory buffer-file-name)) 
                                ;; instead of having it statically set up like "~/.local/ansible/"
                                  (ansible-language-server))))))))

Thanks

PS: Also to note I am still currently unable to set up lsp-bridge-get-single-lang-server-by-project properly. Even if I statically set project-path manually. In above case any yaml file still calls yaml-language-server instead of ansible-language-server

manateelazycat commented 1 month ago

lsp-bridge support git or .dir-locals.el, I can't understand what your mean.

rezaamashi commented 1 month ago

Hello.

From what I understand lsp-bridge-get-single-lang-server-by-project is set up through the user's init.el. My questions were:

  1. Is there a way to set up lsp-bridge-get-single-lang-server-by-project in project-by-project basis through .dir-locals.el? Instead of having it set up in user's init.el.
  2. Furthermore, by "dynamically" I meant that instead of having the directory or a file location being pointed out statically ( by writing the string for the file or project directory ), just pick the current directory for the project.
manateelazycat commented 1 month ago

I see, but I haven't use .dir-locals.el

You can try to change code of lsp-bridge--get-project-path-func, PR are welcome