Skip to content

Commit 8bcbeca

Browse files
committed
Add a generic method lsp-initialization-options and delete lsp-clients-go-* custom variables
1 parent 9da97e8 commit 8bcbeca

File tree

2 files changed

+6
-65
lines changed

2 files changed

+6
-65
lines changed

lsp-clients.el

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -382,73 +382,15 @@ finding the executable with `exec-path'."
382382
:type '(repeat string)
383383
:group 'lsp-clients-go)
384384

385-
(defcustom lsp-clients-go-func-snippet-enabled t
386-
"Enable the returning of argument snippets on `func' completions, eg.
387-
`func(foo string, arg2 bar)'. Requires code completion to be enabled."
388-
:type 'boolean
389-
:group 'lsp-clients-go)
390-
391-
(defcustom lsp-clients-go-gocode-completion-enabled t
392-
"Enable code completion feature (using gocode)."
393-
:type 'boolean
394-
:group 'lsp-clients-go)
395-
396-
(defcustom lsp-clients-go-format-tool "goimports"
397-
"The tool to be used for formatting documents. Defaults to `goimports' if nil."
398-
:type '(choice (const :tag "goimports" "goimports")
399-
(const :tag "gofmt" "gofmt"))
400-
:group 'lsp-clients-go)
401-
402-
(defcustom lsp-clients-go-imports-local-prefix ""
403-
"The local prefix (comma-separated string) that goimports will use."
404-
:type 'string
405-
:group 'lsp-clients-go)
406-
407-
(defcustom lsp-clients-go-max-parallelism nil
408-
"The maximum number of goroutines that should be used to fulfill requests.
409-
This is useful in editor environments where users do not want results ASAP,
410-
but rather just semi quickly without eating all of their CPU. When nil,
411-
defaults to half of your CPU cores."
412-
:type '(choice integer (const nil "Half of CPU cores."))
413-
:group 'lsp-clients-go)
414-
415-
(defcustom lsp-clients-go-use-binary-pkg-cache t
416-
"Whether or not $GOPATH/pkg binary .a files should be used."
417-
:type 'boolean
418-
:group 'lsp-clients-go)
419-
420-
(defcustom lsp-clients-go-diagnostics-enabled t
421-
"Whether diagnostics are enabled."
422-
:type 'boolean
423-
:group 'lsp-clients-go)
424-
425-
(defcustom lsp-clients-go-library-directories '("/usr")
426-
"List of directories which will be considered to be libraries."
427-
:group 'lsp-clients-go
428-
:risky t
429-
:type '(repeat string))
430-
431385
(define-inline lsp-clients-go--bool-to-json (val)
432386
(inline-quote (if ,val t :json-false)))
433387

434-
(defun lsp-clients-go--make-init-options ()
435-
"Init options for golang."
436-
`(:funcSnippetEnabled ,(lsp-clients-go--bool-to-json lsp-clients-go-func-snippet-enabled)
437-
:disableFuncSnippet ,(lsp-clients-go--bool-to-json (not lsp-clients-go-func-snippet-enabled))
438-
:gocodeCompletionEnabled ,(lsp-clients-go--bool-to-json lsp-clients-go-gocode-completion-enabled)
439-
:formatTool ,lsp-clients-go-format-tool
440-
:goimportsLocalPrefix ,lsp-clients-go-imports-local-prefix
441-
:maxParallelism ,lsp-clients-go-max-parallelism
442-
:useBinaryPkgCache ,lsp-clients-go-use-binary-pkg-cache
443-
:diagnosticsEnabled ,lsp-clients-go-diagnostics-enabled))
444-
445388
(lsp-register-client
446389
(make-lsp-client :new-connection (lsp-stdio-connection
447390
(lambda () (cons lsp-clients-go-server
448391
lsp-clients-go-server-args)))
449392
:major-modes '(go-mode)
450393
:priority -1
451-
:initialization-options 'lsp-clients-go--make-init-options
452394
:server-id 'go-bingo
453395
:library-folders-fn (lambda (_workspace)
454396
lsp-clients-go-library-directories)))
@@ -457,7 +399,6 @@ defaults to half of your CPU cores."
457399
(make-lsp-client :new-connection (lsp-stdio-connection "go-langserver")
458400
:major-modes '(go-mode)
459401
:priority -2
460-
:initialization-options 'lsp-clients-go--make-init-options
461402
:server-id 'go-ls
462403
:library-folders-fn (lambda (_workspace)
463404
lsp-clients-go-library-directories)))

lsp-mode.el

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,10 @@ must be used for handling a particular message.")
525525
(cl-defgeneric lsp-execute-command (server command arguments)
526526
"Ask SERVER to execute COMMAND with ARGUMENTS.")
527527

528+
(cl-defgeneric lsp-initialization-options (server)
529+
"JSON object to send under `initializationOptions'"
530+
(:method (_s) nil))
531+
528532
(defun lsp--info (format &rest args)
529533
"Display lsp info message with FORMAT with ARGS."
530534
(message "%s :: %s" (propertize "LSP" 'face 'success) (apply #'format format args)))
@@ -756,8 +760,6 @@ INHERIT-INPUT-METHOD will be proxied to `completing-read' without changes."
756760
(server-id)
757761
;; defines whether the client supports multi root workspaces.
758762
(multi-root)
759-
;; Initialization options or a function that returns initialization options.
760-
(initialization-options)
761763
;; Function which returns the folders that are considered to be not projects but library files.
762764
;; The function accepts one parameter currently active workspace.
763765
;; See: https://github.com/emacs-lsp/lsp-mode/issues/225.
@@ -3926,10 +3928,8 @@ remote machine and vice versa."
39263928
"Create initialization-options from SESSION and CLIENT.
39273929
Add workspace folders depending on server being multiroot and
39283930
session workspce folder configuration for the server."
3929-
(let* ((initialization-options-or-fn (lsp--client-initialization-options client))
3930-
(initialization-options (if (functionp initialization-options-or-fn)
3931-
(funcall initialization-options-or-fn)
3932-
initialization-options-or-fn)))
3931+
(let ((initialization-options
3932+
(lsp-initialization-options (lsp--client-server-id client))))
39333933
(if (lsp--client-multi-root client)
39343934
(or (-some->> session
39353935
(lsp-session-server-id->folders)

0 commit comments

Comments
 (0)