File tree Expand file tree Collapse file tree 2 files changed +28
-5
lines changed Expand file tree Collapse file tree 2 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,8 @@ available in your path to use. Otherwise the system will try to
165
165
find a suitable one. Set this variable before loading lsp."
166
166
:group 'lsp-clangd
167
167
:risky t
168
- :type 'file )
168
+ :type '(choice (file :tag " Path" )
169
+ (const :tag " Auto" nil )))
169
170
170
171
(defvar lsp-clients--clangd-default-executable nil
171
172
" Clang default executable full path when found.
@@ -181,10 +182,12 @@ This must be set only once after loading the clang client.")
181
182
" Generate the language server startup command."
182
183
(unless lsp-clients--clangd-default-executable
183
184
(setq lsp-clients--clangd-default-executable
184
- (-first #'executable-find
185
- (-map (lambda (version )
186
- (concat " clangd" version))
187
- '(" " " -12" " -11" " -10" " -9" " -8" " -7" " -6" )))))
185
+ (or (-first #'executable-find
186
+ (-map (lambda (version )
187
+ (concat " clangd" version))
188
+ '(" " " -12" " -11" " -10" " -9" " -8" " -7" " -6" )))
189
+ (lsp-clients-executable-find " xcodebuild" " -find-executable" " clangd" )
190
+ (lsp-clients-executable-find " xcrun" " --find" " clangd" ))))
188
191
189
192
`(,(or lsp-clients-clangd-executable lsp-clients--clangd-default-executable " clangd" )
190
193
,@lsp-clients-clangd-args ))
Original file line number Diff line number Diff line change @@ -1520,6 +1520,26 @@ BODY should never return `t' value."
1520
1520
download-in-progress?
1521
1521
buffers)
1522
1522
1523
+ (defun lsp-clients-executable-find (find-command &rest args)
1524
+ "Finds an executable by invoking a search command.
1525
+
1526
+ FIND-COMMAND is the executable finder that searches for the
1527
+ actual language server executable. ARGS is a list of arguments to
1528
+ give to FIND-COMMAND to find the language server. Returns the
1529
+ output of FIND-COMMAND if it exits successfully, nil otherwise.
1530
+
1531
+ Typical uses include finding an executable by invoking 'find' in
1532
+ a project, finding LLVM commands on macOS with 'xcrun', or
1533
+ looking up project-specific language servers for projects written
1534
+ in the various dynamic languages, e.g. 'nvm', 'pyenv' and 'rbenv'
1535
+ etc."
1536
+ (when-let* ((find-command-path (executable-find find-command))
1537
+ (executable-path
1538
+ (with-temp-buffer
1539
+ (when (zerop (apply 'call-process find-command-path nil t nil args))
1540
+ (buffer-substring-no-properties (point-min) (point-max))))))
1541
+ (string-trim executable-path)))
1542
+
1523
1543
(defvar lsp--already-widened nil)
1524
1544
1525
1545
(defmacro lsp-save-restriction-and-excursion (&rest form)
You can’t perform that action at this time.
0 commit comments