File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -97,13 +97,9 @@ finding the executable with variable `exec-path'."
97
97
:risky t
98
98
:type '(repeat string))
99
99
100
- (defun lsp-typescript-javascript-tsx-jsx-activate-p (filename mode )
101
- " Check if the javascript-typescript language server should be enabled
102
- based on FILE-NAME and MAJOR-MODE"
103
- (or (member mode '(typescript-mode typescript-tsx-mode js-mode js-jsx-mode js2-mode js2-jsx-mode rjsx-mode))
104
- (and (eq major-mode 'web-mode )
105
- (or (string-suffix-p " .tsx" filename t )
106
- (string-suffix-p " .jsx" filename t )))))
100
+ (defun lsp-typescript-javascript-tsx-jsx-activate-p (filename &optional _ )
101
+ " Check if the javascript-typescript language server should be enabled based on FILENAME."
102
+ (string-match-p (rx (one-or-more char) " ." (or " ts" " js" ) (opt " x" ) string-end) filename))
107
103
108
104
(lsp-register-client
109
105
(make-lsp-client :new-connection (lsp-stdio-connection (lambda ()
Original file line number Diff line number Diff line change 75
75
(let ((major-mode 'js-mode ))
76
76
(should (not (lsp-clients-flow-activate-p (concat test-location " fixtures/SampleTypeScriptProject/src/sample.ts" ) nil )))))
77
77
78
+ (ert-deftest lsp-typescript-javascript-activates-based-on-file-extension ()
79
+ (should (lsp-typescript-javascript-tsx-jsx-activate-p " abc.js" ))
80
+ (should (lsp-typescript-javascript-tsx-jsx-activate-p " abc.jsx" ))
81
+ (should (lsp-typescript-javascript-tsx-jsx-activate-p " abc.ts" ))
82
+ (should (lsp-typescript-javascript-tsx-jsx-activate-p " abc.tsx" ))
83
+ (should (lsp-typescript-javascript-tsx-jsx-activate-p " a1.ts" ))
84
+ (should (lsp-typescript-javascript-tsx-jsx-activate-p " a1.d.ts" ))
85
+ (should (not (lsp-typescript-javascript-tsx-jsx-activate-p " abc.tsxx" )))
86
+ (should (not (lsp-typescript-javascript-tsx-jsx-activate-p " abc.jss" ))))
87
+
78
88
; ;; lsp-clients-test.el ends here
You can’t perform that action at this time.
0 commit comments