Skip to content

Commit

Permalink
lsp-graphql: add new defcustom lsp-graphql-target-file-extensions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki authored Oct 3, 2024
1 parent 2e51473 commit 52de586
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions clients/lsp-graphql.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,18 @@
:risky t
:group 'lsp-graphql)

(defcustom lsp-graphql-target-file-extensions '("ts" "js" "jsx" "tsx" "vue" "graphql" "graphqls" "gql")
"List of target file extensions for the GraphQL language server."
:type '(repeat string)
:group 'lsp-graphql)

(defun lsp-graphql-activate-p (filename &optional _)
"Check if the GraphQL language server should be enabled based on FILENAME."
(or (string-match-p (rx (one-or-more anything) "."
(or "ts" "js" "jsx" "tsx" "vue" "graphql" "gql")eos)
filename)
(and (derived-mode-p 'js-mode 'js2-mode 'typescript-mode 'typescript-ts-mode)
(not (derived-mode-p 'json-mode)))))
(let ((target-extensions (mapconcat 'identity lsp-graphql-target-file-extensions "\\|")))
(or (string-match-p (format "\\.%s\\'" target-extensions) filename)
(and (derived-mode-p 'js-mode 'js2-mode 'typescript-mode 'typescript-ts-mode)
(not (derived-mode-p 'json-mode))))))


(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection (lambda()
Expand Down

0 comments on commit 52de586

Please sign in to comment.