Skip to content

Commit

Permalink
Fix a number of warnings (#4373)
Browse files Browse the repository at this point in the history
* lsp-javascript.el: fix incorrect default value in defcustom choices

Fixes a warning:

      lsp-javascript.el:488:12: Warning: in defcustom for ‘lsp-typescript-locale’: ‘nil’ is not a valid type

* lsp-mode.el: don't use let* for a single binding

`let*` vs `let` are only different in the order of binding the
variables, however it doesn't matter when there's just one variable.

* lsp-mode.el: remove duplicated `nil` choice in lsp-document-sync-method

Worth noting that the two descriptions contradict each other. In the
code, the only place where the variable is handled is in
`lsp-on-change` function. Specifically, if the variable is nil, it
calls `(lsp--workspace-sync-method workspace)` which presumably
implies that the description "use method recommended by the
lang-server" is the correct one. So remove the other.

And while at it, remove the `lsp--sync-none` which was never used.

Fixes:
    lsp-mode.el:489:19: Warning: in defcustom for ‘lsp-document-sync-method’:
        duplicated value in ‘choice’: ‘nil’

* lsp-mode.el: swap order of :tag and value in defcustom

Fixes warning:

    lsp-mode.el:2150:25: Warning: in defcustom for ‘lsp-progress-function’:
        misplaced :tag keyword in ‘const’ type

* lsp-mode.el: don't quote condition-case handlers

And while at it, replace an unused condition-case binding to _err with
nil.

Fixes warnings:

    lsp-mode.el:1995:19: Warning: ‘condition-case’ condition should not be quoted:
        'quit

    lsp-mode.el:8686:7: Warning: ‘condition-case’ condition should not be quoted:
        'error

    In lsp--find-root-interactively:
    lsp-mode.el:8990:7: Warning: ‘condition-case’ condition should not be quoted:
        'quit

* lsp-diagnostics.el: declare arguments to a `list` in defcustom :type

Fixes a warning:
    lsp-diagnostics.el:68:10: Warning: in defcustom for
        ‘lsp-diagnostics-attributes’: ‘list’ without arguments
  • Loading branch information
Hi-Angel authored Mar 16, 2024
1 parent 802e256 commit 13f400b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion clients/lsp-javascript.el
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ TypeScript 2.6.1 or newer in the workspace."
(const "ru")
(const "zh-CN")
(const "zh-TW")
nil)
(const :tag "default" nil))
:package-version '(lsp-mode . "6.1"))

(defcustom lsp-javascript-suggestion-actions-enabled t
Expand Down
2 changes: 1 addition & 1 deletion lsp-diagnostics.el
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
List containing (tag attributes) where tag is the LSP diagnostic tag and
attributes is a `plist' containing face attributes which will be applied
on top the flycheck face for that error level."
:type '(repeat list)
:type '(repeat (list symbol plist))
:group 'lsp-diagnostics)

(defcustom lsp-diagnostics-disabled-modes nil
Expand Down
22 changes: 10 additions & 12 deletions lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ level or at a root of an lsp workspace."
:group 'lsp-mode
:package-version '(lsp-mode . "6.3"))

(defconst lsp--sync-none 0)
(defconst lsp--sync-full 1)
(defconst lsp--sync-incremental 2)

Expand All @@ -483,8 +482,7 @@ This flag affects only servers which do not support incremental updates."

(defcustom lsp-document-sync-method nil
"How to sync the document with the language server."
:type '(choice (const :tag "Documents should not be synced at all." nil)
(const :tag "Documents are synced by always sending the full content of the document." lsp--sync-full)
:type '(choice (const :tag "Documents are synced by always sending the full content of the document." lsp--sync-full)
(const :tag "Documents are synced by always sending incremental changes to the document." lsp--sync-incremental)
(const :tag "Use the method recommended by the language server." nil))
:group 'lsp-mode)
Expand Down Expand Up @@ -1992,9 +1990,9 @@ regex in IGNORED-FILES."
(let ((number-of-directories (length dirs-to-watch)))
(or
(< number-of-directories lsp-file-watch-threshold)
(condition-case _err
(condition-case nil
(lsp--ask-about-watching-big-repo number-of-directories dir)
('quit)))))
(quit)))))
(dolist (current-dir dirs-to-watch)
(condition-case err
(progn
Expand Down Expand Up @@ -2149,7 +2147,7 @@ PARAMS - the data sent from WORKSPACE."
(const :tag "Use modeline" lsp-on-progress-modeline)
(const :tag "Legacy(uses either `progress-reporter' or `spinner' based on `lsp-progress-via-spinner')"
lsp-on-progress-legacy)
(const ignore :tag "Ignore")
(const :tag "Ignore" ignore)
(function :tag "Other function"))
:package-version '(lsp-mode . "8.0.0"))

Expand Down Expand Up @@ -4724,9 +4722,9 @@ Added to `before-change-functions'."
(setq lsp--delayed-requests nil)))))

(defun lsp--workspace-sync-method (workspace)
(let* ((sync (-> workspace
(lsp--workspace-server-capabilities)
(lsp:server-capabilities-text-document-sync?))))
(let ((sync (-> workspace
(lsp--workspace-server-capabilities)
(lsp:server-capabilities-text-document-sync?))))
(if (lsp-text-document-sync-options? sync)
(lsp:text-document-sync-options-change? sync)
sync)))
Expand Down Expand Up @@ -8685,8 +8683,8 @@ When ALL is t, erase all log buffers of the running session."
(cl-defmethod lsp-process-send ((process process) message)
(condition-case err
(process-send-string process (lsp--make-message message))
('error (lsp--error "Sending to process failed with the following error: %s"
(error-message-string err)))))
(error (lsp--error "Sending to process failed with the following error: %s"
(error-message-string err)))))

(cl-defmethod lsp-process-cleanup (process)
;; Kill standard error buffer only if the process exited normally.
Expand Down Expand Up @@ -8989,7 +8987,7 @@ Select action: "
(lsp--persist-session session)
nil)
(t nil)))
('quit)))
(quit)))

(declare-function tramp-file-name-host "ext:tramp" (file) t)
(declare-function tramp-dissect-file-name "ext:tramp" (file &optional nodefault))
Expand Down

0 comments on commit 13f400b

Please sign in to comment.