-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix LSP-enabled "Find Project File" command.
The Ada Language Server recently changed the response from the "als-project-file" command to return a URI instead of a file path. As a result, `ada-ts-mode` now supports either response format, converting to a file path, if needed.
- Loading branch information
Showing
1 changed file
with
21 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
;; Author: Troy Brown <[email protected]> | ||
;; Created: February 2023 | ||
;; Version: 0.7.2 | ||
;; Version: 0.7.3 | ||
;; Keywords: ada languages tree-sitter | ||
;; URL: https://github.com/brownts/ada-ts-mode | ||
;; Package-Requires: ((emacs "29.1")) | ||
|
@@ -801,15 +801,31 @@ When CLIENT is not nil, use it as the active LSP client." | |
;; project file) when it can't find the configured project file. In | ||
;; this situation we prefer the non-existent user configured project | ||
;; file over a non-existent Language Server project file. | ||
|
||
;; NOTE: Older versions of the Ada Language Server returned a file | ||
;; path for the als-project-file command, but newer versions return | ||
;; a URI instead. | ||
|
||
(when-let* | ||
((client (ada-ts-mode-lspclient-current)) | ||
(project-file | ||
(project-file-path-or-uri | ||
(or (ada-ts-mode-lspclient-workspace-configuration client "ada.projectFile") | ||
(let ((command "als-project-file")) | ||
(and (ada-ts-mode-lspclient-command-supported-p client command) | ||
(ada-ts-mode-lspclient-command-execute client command)))))) | ||
(let ((root (ada-ts-mode-lspclient-workspace-root client (buffer-file-name)))) | ||
(expand-file-name project-file root)))) | ||
(ada-ts-mode-lspclient-command-execute client command))))) | ||
(project-file | ||
(let* ((obj (url-generic-parse-url (url-unhex-string project-file-path-or-uri))) | ||
(type (url-type obj))) | ||
(if (and type (string-equal type "file")) | ||
(let ((path (url-filename obj))) | ||
(if (and (eq system-type 'windows-nt) | ||
(string-equal (substring path 0 1) "/")) | ||
(substring path 1) ; Strip leading separator on Windows | ||
path)) | ||
;; Doesn't appear to be a URI, treat as path | ||
project-file-path-or-uri))) | ||
(root (ada-ts-mode-lspclient-workspace-root client (buffer-file-name)))) | ||
(directory-file-name (expand-file-name project-file root)))) | ||
|
||
(defun ada-ts-mode--root-project-file () | ||
"Determine name of GNAT Project file, looking in root directory." | ||
|