Skip to content

Commit

Permalink
fix: remove obsoleted if/when-let and shadowed dynamic variable (#4612)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiennq authored Nov 19, 2024
1 parent 9509148 commit 620bbd7
Show file tree
Hide file tree
Showing 33 changed files with 127 additions and 121 deletions.
2 changes: 1 addition & 1 deletion clients/lsp-autotools.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
makefile-bsdmake-mode
makefile-imake-mode)
"List of major mode that work with Autotools."
:type 'list
:type '(list symbol)
:group 'lsp-autotools)

(defun lsp-autotools--download-server (_client callback error-callback update?)
Expand Down
2 changes: 1 addition & 1 deletion clients/lsp-awk.el
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Command to run the AWK language server."
:group 'lsp-awk
:risky t
:type 'list)
:type '(list string))

(lsp-register-client
(make-lsp-client
Expand Down
23 changes: 11 additions & 12 deletions clients/lsp-camel.el
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
;; Directory in which the servers will be installed. Lsp Server Install Dir: ~/.emacs.d/.cache/camells
(defcustom lsp-camel-jar-file (f-join lsp-server-install-dir "camells" lsp-camel-jar-name)
"Camel Language server jar command."
:type 'string
:group 'lsp-camel
:type 'file
:package-version '(lsp-mode . "9.0.0"))
Expand All @@ -36,7 +35,7 @@
'camells
'(:system lsp-camel-jar-file)
`(:download :url lsp-camel-jar-download-url
:store-path lsp-camel-jar-file))
:store-path lsp-camel-jar-file))

(defcustom lsp-camel-server-command `("java" "-jar" , lsp-camel-jar-file)
"Camel server command."
Expand All @@ -51,16 +50,16 @@

(lsp-register-client
(make-lsp-client :new-connection (lsp-camel--create-connection)
:activation-fn (lsp-activate-on "xml" "java")
:priority 0
:server-id 'camells
:add-on? t
:multi-root t
:initialized-fn (lambda (workspace)
(with-lsp-workspace workspace
(lsp--set-configuration (lsp-configuration-section "camel"))))
:download-server-fn (lambda (_client callback error-callback _update?)
(lsp-package-ensure 'camells callback error-callback))))
:activation-fn (lsp-activate-on "xml" "java")
:priority 0
:server-id 'camells
:add-on? t
:multi-root t
:initialized-fn (lambda (workspace)
(with-lsp-workspace workspace
(lsp--set-configuration (lsp-configuration-section "camel"))))
:download-server-fn (lambda (_client callback error-callback _update?)
(lsp-package-ensure 'camells callback error-callback))))

(lsp-consistency-check lsp-camel)

Expand Down
4 changes: 2 additions & 2 deletions clients/lsp-clangd.el
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Information comes from the clang.llvm.org website."
(url-retrieve (format
"https://clang.llvm.org/extra/clang-tidy/checks/%s.html" error-id)
(lambda (status)
(if-let ((error-status (plist-get status :error)))
(if-let* ((error-status (plist-get status :error)))
(lsp-cpp-flycheck-clang-tidy--explain-error
#'insert
(format
Expand All @@ -185,7 +185,7 @@ Information comes from the clang.llvm.org website."
"Explain a clang-tidy ERROR by scraping documentation from llvm.org."
(unless (fboundp 'libxml-parse-html-region)
(error "This function requires Emacs to be compiled with libxml2"))
(if-let ((clang-tidy-error-id (flycheck-error-id error)))
(if-let* ((clang-tidy-error-id (flycheck-error-id error)))
(condition-case err
(lsp-cpp-flycheck-clang-tidy--show-documentation clang-tidy-error-id)
(error
Expand Down
10 changes: 5 additions & 5 deletions clients/lsp-clojure.el
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
(expand-file-name "~/.gitlibs/libs"))
"LSP clojure dirs that should be considered library folders."
:group 'lsp-clojure
:type 'list)
:type '(list string))

(defcustom lsp-clojure-test-tree-position-params nil
"The optional test tree position params.
Expand Down Expand Up @@ -434,7 +434,7 @@ Focus on it if IGNORE-FOCUS? is nil."
NOTIFICATION is the test tree notification data received from server.
It updates the test tree view data."
(when (require 'lsp-treemacs nil t)
(when-let (buffer (find-buffer-visiting (lsp--uri-to-path uri)))
(when-let* ((buffer (find-buffer-visiting (lsp--uri-to-path uri))))
(with-current-buffer buffer
(setq lsp-clojure--test-tree-data notification)
(when (get-buffer-window lsp-clojure--test-tree-buffer-name)
Expand Down Expand Up @@ -593,16 +593,16 @@ Focus on it if IGNORE-FOCUS? is nil."
(let ((info (lsp-clojure-server-info-raw)))
(save-match-data
(when (functionp 'cider-connect-clj)
(when-let (port (and (string-match "\"port\":\\([0-9]+\\)" info)
(match-string 1 info)))
(when-let* ((port (and (string-match "\"port\":\\([0-9]+\\)" info)
(match-string 1 info))))
(cider-connect-clj `(:host "localhost"
:port ,port)))))))

;; Cider integration

(defun lsp-clojure-semantic-tokens-refresh (&rest _)
"Force refresh semantic tokens."
(when-let ((workspace (and lsp-semantic-tokens-enable
(when-let* ((workspace (and lsp-semantic-tokens-enable
(lsp-find-workspace 'clojure-lsp (buffer-file-name)))))
(--each (lsp--workspace-buffers workspace)
(when (lsp-buffer-live-p it)
Expand Down
2 changes: 1 addition & 1 deletion clients/lsp-cobol.el
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ This is only for development use."
(defun lsp-cobol-start-ls ()
"Start the COBOL language service."
(interactive)
(when-let ((exe (lsp-cobol--executable))
(when-let* ((exe (lsp-cobol--executable))
((lsp--port-available "localhost" lsp-cobol-port)))
(lsp-async-start-process #'ignore #'ignore exe)))

Expand Down
8 changes: 4 additions & 4 deletions clients/lsp-csharp.el
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Returns :elements from omnisharp:CodeStructureResponse."

(defun lsp-csharp--code-element-stack-on-l-c (l c elements)
"Return omnisharp:CodeElement stack at L (line) and C (column) in ELEMENTS tree."
(when-let ((matching-element (seq-find (lambda (el)
(when-let* ((matching-element (seq-find (lambda (el)
(-when-let* (((&omnisharp:CodeElement :ranges) el)
((&omnisharp:RangeList :full?) ranges))
(lsp-csharp--l-c-within-range l c full?)))
Expand Down Expand Up @@ -266,7 +266,7 @@ PRESENT-BUFFER will make the buffer be presented to the user."

(defun lsp-csharp--test-message (message)
"Emit a MESSAGE to lsp-csharp test run buffer."
(when-let ((existing-buffer (get-buffer lsp-csharp-test-run-buffer-name))
(when-let* ((existing-buffer (get-buffer lsp-csharp-test-run-buffer-name))
(inhibit-read-only t))
(with-current-buffer existing-buffer
(save-excursion
Expand Down Expand Up @@ -309,7 +309,7 @@ PRESENT-BUFFER will make the buffer be presented to the user."
(defun lsp-csharp-run-last-tests ()
"Re-run test(s) that were run last time."
(interactive)
(if-let ((last-test-method-framework (lsp-session-get-metadata "last-test-method-framework"))
(if-let* ((last-test-method-framework (lsp-session-get-metadata "last-test-method-framework"))
(last-test-method-names (lsp-session-get-metadata "last-test-method-names")))
(lsp-csharp--start-tests last-test-method-framework last-test-method-names)
(message "lsp-csharp: No test method(s) found to be ran previously on this workspace")))
Expand Down Expand Up @@ -430,7 +430,7 @@ See https://github.com/OmniSharp/omnisharp-roslyn/wiki/Configuration-Options"
(when lsp-csharp-solution-file
(list "-s" (expand-file-name lsp-csharp-solution-file)))))
#'(lambda ()
(when-let ((binary (lsp-csharp--language-server-path)))
(when-let* ((binary (lsp-csharp--language-server-path)))
(f-exists? binary))))
:activation-fn (lsp-activate-on "csharp")
:server-id 'omnisharp
Expand Down
2 changes: 1 addition & 1 deletion clients/lsp-cucumber.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ This is only for development use."
(defcustom lsp-cucumber-active-modes
'( feature-mode)
"List of major mode that work with Cucumber language server."
:type 'list
:type '(list symbol)
:group 'lsp-cucumber)

(lsp-defcustom lsp-cucumber-features
Expand Down
4 changes: 2 additions & 2 deletions clients/lsp-eslint.el
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ stored."

(defun lsp--find-eslint ()
(or
(when-let ((workspace-folder (lsp-find-session-folder (lsp-session) default-directory)))
(when-let* ((workspace-folder (lsp-find-session-folder (lsp-session) default-directory)))
(let ((eslint-local-path (f-join workspace-folder "node_modules" ".bin"
(if (eq system-type 'windows-nt) "eslint.cmd" "eslint"))))
(when (f-exists? eslint-local-path)
Expand Down Expand Up @@ -374,7 +374,7 @@ to allow or deny it.")
(setq lsp-eslint--stored-libraries (lsp--read-from-file lsp-eslint-library-choices-file)))

(lsp-defun lsp-eslint--confirm-local (_workspace (&eslint:ConfirmExecutionParams :library-path) callback)
(if-let ((option-alist '(("Always" 4 . t)
(if-let* ((option-alist '(("Always" 4 . t)
("Yes" 4 . nil)
("No" 1 . nil)
("Never" 1 . t)))
Expand Down
2 changes: 1 addition & 1 deletion clients/lsp-glsl.el
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Command to run the GLSL language server."
:group 'lsp-glsl
:risky t
:type 'list)
:type '(list string))

(lsp-register-client
(make-lsp-client
Expand Down
2 changes: 1 addition & 1 deletion clients/lsp-go.el
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ flake.nix file with:
(use-package nix-sandbox)
(defun my/nix--lsp-go-wrapper (args)
(if-let ((sandbox (nix-current-sandbox)))
(if-let* ((sandbox (nix-current-sandbox)))
(apply `nix-shell-command sandbox args)
args))
(setq lsp-go-server-path \"gopls\"
Expand Down
4 changes: 2 additions & 2 deletions clients/lsp-javascript.el
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ name (e.g. `data' variable passed as `data' parameter)."
(lsp--info "Renamed '%s' to '%s'." name (file-name-nondirectory new)))))

(defun lsp-javascript-initialized? ()
(when-let ((workspace (lsp-find-workspace 'ts-ls (buffer-file-name))))
(when-let* ((workspace (lsp-find-workspace 'ts-ls (buffer-file-name))))
(eq 'initialized (lsp--workspace-status workspace))))

(defun lsp-clients-typescript-require-resolve (&optional dir)
Expand Down Expand Up @@ -891,7 +891,7 @@ finding the executable with variable `exec-path'."
(defun lsp-clients-flow-tag-file-present-p (file-name)
"Check if the '// @flow' or `/* @flow */' tag is present in
the contents of FILE-NAME."
(if-let ((buffer (find-buffer-visiting file-name)))
(if-let* ((buffer (find-buffer-visiting file-name)))
(with-current-buffer buffer
(lsp-clients-flow-tag-string-present-p))
(with-temp-buffer
Expand Down
4 changes: 2 additions & 2 deletions clients/lsp-lisp.el
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
(defcustom lsp-lisp-active-modes
'( lisp-mode)
"List of major mode that work with lisp."
:type 'list
:type '(list symbol)
:group 'lsp-lisp)

(defcustom lsp-lisp-alive-port 8006
Expand All @@ -49,7 +49,7 @@
(defun lsp-lisp-alive-start-ls ()
"Start the alive-lsp."
(interactive)
(when-let ((exe (executable-find "sbcl"))
(when-let* ((exe (executable-find "sbcl"))
((lsp--port-available "localhost" lsp-lisp-alive-port)))
(lsp-async-start-process #'ignore #'ignore
exe
Expand Down
7 changes: 3 additions & 4 deletions clients/lsp-markdown.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

(defcustom lsp-markdown-server-command-args '("--parser=remark-parse" "--stdio")
"Command-line arguments for the markdown lsp server."
:type '(repeat 'string)
:type '(repeat string)
:group 'lsp-markdown
:package-version '(lsp-mode . "8.0.0"))

Expand All @@ -59,9 +59,8 @@ For a complete list of plugins, check:
For a complete list of plugins, check:
https://github.com/unifiedjs/unified-language-server/blob/main/CONFIGURATION.md#re-using-settings"
:type '(choice (
(const "retext-english")
(const "remark-parse")))
:type '(choice (const "retext-english")
(const "remark-parse"))
:group 'lsp-markdown
:package-version '(lsp-mode . "8.0.0"))

Expand Down
2 changes: 1 addition & 1 deletion clients/lsp-prolog.el
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"The prolog-lsp server command."
:group 'lsp-prolog
:risky t
:type 'list)
:type '(list string))

(lsp-register-client
(make-lsp-client
Expand Down
2 changes: 1 addition & 1 deletion clients/lsp-rf.el
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
(defcustom lsp-rf-language-server-start-command '("~/.nvm/versions/node/v9.11.2/bin/node" "~/.vscode/extensions/tomiturtiainen.rf-intellisense-2.8.0/server/server.js")
"Path to the server.js file of the rf-intellisense server.
Accepts a list of strings (path/to/interpreter path/to/server.js)"
:type 'list
:type '(list string)
:group 'lsp-rf)

(defcustom lsp-rf-language-server-include-paths []
Expand Down
4 changes: 2 additions & 2 deletions clients/lsp-roslyn.el
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ creates another process connecting to the named pipe it specifies."
(lsp-roslyn--make-named-pipe-process filter sentinel environment-fn process-name stderr-buf)))
(with-current-buffer (get-buffer parent-stderr-buf)
(special-mode))
(when-let ((stderr-buffer (get-buffer stderr-buf)))
(when-let* ((stderr-buffer (get-buffer stderr-buf)))
(with-current-buffer stderr-buffer
;; Make the *NAME::stderr* buffer buffer-read-only, q to bury, etc.
(special-mode))
Expand All @@ -187,7 +187,7 @@ creates another process connecting to the named pipe it specifies."
uri)))
(concat "#" target))))
(file-name (if (and type (not (string= type "file")))
(if-let ((handler (lsp--get-uri-handler type)))
(if-let* ((handler (lsp--get-uri-handler type)))
(funcall handler uri)
uri)
;; `url-generic-parse-url' is buggy on windows:
Expand Down
2 changes: 1 addition & 1 deletion clients/lsp-rust.el
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ such as imports and dyn traits."
:package-version '(lsp-mode . "9.0.0"))

(defun lsp-rust-analyzer-initialized? ()
(when-let ((workspace (lsp-find-workspace 'rust-analyzer (buffer-file-name))))
(when-let* ((workspace (lsp-find-workspace 'rust-analyzer (buffer-file-name))))
(eq 'initialized (lsp--workspace-status workspace))))

(defun lsp-rust-analyzer-expand-macro ()
Expand Down
2 changes: 1 addition & 1 deletion clients/lsp-sqls.el
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Depending on `lsp-sqls-workspace-config-path'."

(if lsp-sqls-connections
(lsp--set-configuration `(:sqls (:connections ,(apply #'vector lsp-sqls-connections))))
(when-let ((config-json-path (cond
(when-let* ((config-json-path (cond
((equal lsp-sqls-workspace-config-path "workspace")
".sqls/config.json")
((equal lsp-sqls-workspace-config-path "root")
Expand Down
4 changes: 2 additions & 2 deletions clients/lsp-typespec.el
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
(defun lsp-typespec--server-executable-path ()
"Return the typespec-lsp server command."
(or
(when-let ((workspace-folder (lsp-find-session-folder (lsp-session) default-directory)))
(when-let* ((workspace-folder (lsp-find-session-folder (lsp-session) default-directory)))
(let ((tsp-server-local-path (f-join workspace-folder "node_modules" ".bin"
(if (eq system-type 'windows-nt) "tsp-server.cmd" "tsp-server"))))
(when (f-exists? tsp-server-local-path)
Expand All @@ -70,7 +70,7 @@

(defun lsp-typespec-semantic-tokens-refresh (&rest _)
"Force refresh semantic tokens."
(when-let ((workspace (and lsp-semantic-tokens-enable
(when-let* ((workspace (and lsp-semantic-tokens-enable
(lsp-find-workspace 'typespec-lsp (buffer-file-name)))))
(--each (lsp--workspace-buffers workspace)
(when (lsp-buffer-live-p it)
Expand Down
6 changes: 3 additions & 3 deletions clients/lsp-volar.el
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
(defconst lsp-volar--is-windows (memq system-type '(cygwin windows-nt ms-dos)))
(defun lsp-volar-get-typescript-tsdk-path ()
"Get tsserver lib*.d.ts directory path."
(if-let ((package-path (lsp-package-path 'typescript))
(if-let* ((package-path (lsp-package-path 'typescript))
(system-tsdk-path (f-join (file-truename package-path)
(if lsp-volar--is-windows
"../node_modules/typescript/lib"
Expand All @@ -85,7 +85,7 @@
(lsp-register-custom-settings
'(("typescript.tsdk"
(lambda ()
(if-let ((project-root (lsp-workspace-root))
(if-let* ((project-root (lsp-workspace-root))
(tsdk-path (f-join project-root "node_modules/typescript/lib"))
((file-exists-p tsdk-path)))
tsdk-path
Expand All @@ -98,7 +98,7 @@
(defun lsp-volar--vue-project-p (workspace-root)
"Check if the `Vue' package is present in the package.json file
in the WORKSPACE-ROOT."
(if-let ((package-json (f-join workspace-root "package.json"))
(if-let* ((package-json (f-join workspace-root "package.json"))
(exist (f-file-p package-json))
(config (json-read-file package-json))
(dependencies (alist-get 'dependencies config)))
Expand Down
2 changes: 1 addition & 1 deletion clients/lsp-yaml.el
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Limited for performance reasons."
"User defined schemas that extend default schema store.
Used in `lsp-yaml--get-supported-schemas' to supplement schemas provided by
`lsp-yaml-schema-store-uri'."
:type 'list
:type '(list alist)
:group 'lsp-yaml
:package-version '(lsp-mode . "9.0.1"))

Expand Down
2 changes: 1 addition & 1 deletion docs/lsp-doc.el
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Make sure to make mkdocs.yml updated as well.")

(defun lsp-doc--add-feature-variables (group dest-file)
"Add FEATURE variables from GROUP to DEST-FILE."
(if-let ((variables (lsp-doc--variables group)))
(if-let* ((variables (lsp-doc--variables group)))
(--each variables
(with-temp-buffer
(insert-file-contents "../../template/lsp-var.md")
Expand Down
Loading

0 comments on commit 620bbd7

Please sign in to comment.