(setq lsp-bridge-get-multi-lang-server-by-project #'my/bridge-multi-server-detect)
(defun my/bridge-multi-server-detect (project-path filepath)
"Detect right server config for multi servers.."
(save-excursion
;; detect for web dev
(let* ((tailwindcss-p (directory-files
project-path
'full
"tailwind\\.config\\.\\(j\\|cj\\|mj\\|t\\)s\\'"))
(ext (file-name-extension filepath))
(jsx-p (or (string= ext "jsx")
(memq major-mode '(jtsx-jsx-mode js-jsx-mode))))
(tsx-p (or (string= ext "tsx")
(memq major-mode '(jtsx-tsx-mode
jtsx-typescript-mode
tsx-ts-mode))))
(html-p
(or (memq ext '("htm" "html"))
(memq major-mode '(mhtml-mode html-mode html-ts-mode web-mode))))
(css-p
(or (memq ext '("css"))
(memq major-mode '(css-mode css-ts-mode less-css-mode scss-mode)))))
(cond
((and tailwindcss-p jsx-p) "jsreact_tailwindcss")
((and tailwindcss-p tsx-p) "tsreact_tailwindcss")
((and tailwindcss-p html-p) "html_emmet_tailwindcss")
;; ((and tailwindcss-p html-p) "html_tailwindcss")
(html-p "html_emmet")
((and tailwindcss-p css-p) "css_emmet_tailwindcss")
;; ((and tailwindcss-p css-p) "css_tailwindcss")
(css-p "css_emmet")))))
我自定义的detect函数没问题啊,我git init之后就能正常使用了。