Skip to content

Commit 52de586

Browse files
authored
lsp-graphql: add new defcustom lsp-graphql-target-file-extensions (#4575)
1 parent 2e51473 commit 52de586

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

clients/lsp-graphql.el

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,18 @@
4343
:risky t
4444
:group 'lsp-graphql)
4545

46+
(defcustom lsp-graphql-target-file-extensions '("ts" "js" "jsx" "tsx" "vue" "graphql" "graphqls" "gql")
47+
"List of target file extensions for the GraphQL language server."
48+
:type '(repeat string)
49+
:group 'lsp-graphql)
50+
4651
(defun lsp-graphql-activate-p (filename &optional _)
4752
"Check if the GraphQL language server should be enabled based on FILENAME."
48-
(or (string-match-p (rx (one-or-more anything) "."
49-
(or "ts" "js" "jsx" "tsx" "vue" "graphql" "gql")eos)
50-
filename)
51-
(and (derived-mode-p 'js-mode 'js2-mode 'typescript-mode 'typescript-ts-mode)
52-
(not (derived-mode-p 'json-mode)))))
53+
(let ((target-extensions (mapconcat 'identity lsp-graphql-target-file-extensions "\\|")))
54+
(or (string-match-p (format "\\.%s\\'" target-extensions) filename)
55+
(and (derived-mode-p 'js-mode 'js2-mode 'typescript-mode 'typescript-ts-mode)
56+
(not (derived-mode-p 'json-mode))))))
57+
5358

5459
(lsp-register-client
5560
(make-lsp-client :new-connection (lsp-stdio-connection (lambda()

0 commit comments

Comments
 (0)