Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation of section synchronization #3167

Merged
merged 1 commit into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions clients/lsp-ada.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,29 @@
:tag "Language Server"
:package-version '(lsp-mode . "6.2"))

(defcustom lsp-ada-project-file "default.gpr"
(defcustom-lsp lsp-ada-project-file "default.gpr"
"Set the project file full path to configure the language server with.
The ~ prefix (for the user home directory) is supported.
See https://github.com/AdaCore/ada_language_server for a per-project
configuration example."
:type 'string
:group 'lsp-ada
:package-version '(lsp-mode . "6.2"))
:package-version '(lsp-mode . "6.2")
:lsp-path "ada.projectFile")

(defcustom lsp-ada-option-charset "UTF-8"
(defcustom-lsp lsp-ada-option-charset "UTF-8"
"The charset to use by the Ada Language server. Defaults to 'UTF-8'."
:type 'string
:group 'lsp-ada
:package-version '(lsp-mode . "6.2"))
:package-version '(lsp-mode . "6.2")
:lsp-path "ada.defaultCharset")

(defcustom lsp-ada-enable-diagnostics t
(defcustom-lsp lsp-ada-enable-diagnostics t
"A boolean to disable diagnostics. Defaults to true."
:type 'boolean
:group 'lsp-ada
:package-version '(lsp-mode . "6.2"))

(lsp-register-custom-settings
'(("ada.projectFile" lsp-ada-project-file)
("ada.enableDiagnostics" lsp-ada-enable-diagnostics)
("ada.defaultCharset" lsp-ada-option-charset)))
:package-version '(lsp-mode . "6.2")
:lsp-path "ada.enableDiagnostics")

(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection '("ada_language_server"))
Expand All @@ -66,7 +64,8 @@
(with-lsp-workspace workspace
(lsp--set-configuration
(lsp-configuration-section "ada"))))
:server-id 'ada-ls))
:server-id 'ada-ls
:synchronize-sections '("ada")))

(lsp-consistency-check lsp-ada)

Expand Down
29 changes: 28 additions & 1 deletion lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,8 @@ return value of `body' or nil if interrupted."
(async-request-handlers (make-hash-table :test 'equal))
download-server-fn
download-in-progress?
buffers)
buffers
synchronize-sections)

(defun lsp-clients-executable-find (find-command &rest args)
"Finds an executable by invoking a search command.
Expand Down Expand Up @@ -7840,6 +7841,31 @@ TBL - a hash table, PATHS is the path to the nested VALUE."
(ht-set! tbl path temp-tbl)
temp-tbl))))
(lsp-ht-set nested-tbl rst value)))))

;; sections

(defmacro defcustom-lsp (symbol standard doc &rest args)
"Defines `lsp-mode' server property."
(let ((path (plist-get args :lsp-path)))
(cl-remf args :lsp-path)
`(progn
(lsp-register-custom-settings
(quote ((,path ,symbol ,(equal ''boolean (plist-get args :type))))))

(defcustom ,symbol ,standard ,doc
:set (lambda (sym val)
(lsp--set-custom-property sym val ,path))
,@args))))

(defun lsp--set-custom-property (sym val path)
(set sym val)
(let ((section (cl-first (s-split "\\." path))))
(mapc (lambda (workspace)
(when (-contains? (lsp--client-synchronize-sections (lsp--workspace-client workspace))
section)
(with-lsp-workspace workspace
(lsp--set-configuration (lsp-configuration-section section)))))
(lsp--session-workspaces (lsp-session)))))

(defun lsp-configuration-section (section)
"Get settings for SECTION."
Expand All @@ -7857,6 +7883,7 @@ TBL - a hash table, PATHS is the path to the nested VALUE."
lsp-client-settings)
ret))


(defun lsp--start-connection (session client project-root)
"Initiates connection created from CLIENT for PROJECT-ROOT.
SESSION is the active session."
Expand Down