-
-
Notifications
You must be signed in to change notification settings - Fork 916
fix: remove direct references to the node_modules directory #4333
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
Changes from 5 commits
4b7352e
e28e593
023fb54
9470afd
cdbb478
99b1a47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -790,20 +790,42 @@ name (e.g. `data' variable passed as `data' parameter)." | |
(when-let ((workspace (lsp-find-workspace 'ts-ls (buffer-file-name)))) | ||
(eq 'initialized (lsp--workspace-status workspace)))) | ||
|
||
(defun lsp-clients-typescript-project-ts-server-path () | ||
"Return the project local TS server path." | ||
(f-join (lsp-workspace-root) "node_modules" "typescript" "lib" "tsserver.js")) | ||
(defun lsp-clients-typescript-require-resolve (&optional dir) | ||
"Get the location of the typescript. | ||
Use Node.js require. | ||
The node_modules directory structure is suspect | ||
and should be trusted as little as possible. | ||
If you call require in Node.js, | ||
it should take into account the various hooks. | ||
For example, yarn PnP. | ||
|
||
Optional argument DIR specifies the working directory | ||
to run the command in." | ||
(let* ((default-directory (or dir default-directory)) | ||
(output | ||
(string-trim-right | ||
(shell-command-to-string | ||
"node -e \"console.log(require.resolve('typescript'))\"")))) | ||
(if (string-empty-p output) | ||
nil | ||
(f-parent output)))) | ||
jcs090218 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
(defun lsp-clients-typescript-package-path-direct () | ||
"`lsp-package-path' apply `'typescript' is modified. | ||
because the lsp server may not recognize the tsserver executable file, | ||
e.g., on Windows." | ||
(if (memq system-type '(cygwin windows-nt ms-dos)) | ||
(lsp-clients-typescript-require-resolve (f-parent (lsp-package-path 'typescript))) | ||
(lsp-package-path 'typescript))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need some clarification here. We were previously using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Until the following PR, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting thing is |
||
|
||
(defun lsp-clients-typescript-server-path () | ||
"Return the TS sever path base on settings." | ||
(cond | ||
((and lsp-clients-typescript-prefer-use-project-ts-server | ||
(f-exists? (lsp-clients-typescript-project-ts-server-path))) | ||
(lsp-clients-typescript-project-ts-server-path)) | ||
(t | ||
(if (memq system-type '(cygwin windows-nt ms-dos)) | ||
(f-join (f-parent (lsp-package-path 'typescript)) "node_modules" "typescript" "lib") | ||
(f-join (f-parent (f-parent (lsp-package-path 'typescript))) "lib" "node_modules" "typescript" "lib"))))) | ||
(if lsp-clients-typescript-prefer-use-project-ts-server | ||
(let ((server-path (lsp-clients-typescript-require-resolve))) | ||
(if (f-exists? server-path) | ||
server-path | ||
(lsp-clients-typescript-package-path-direct))) | ||
(lsp-clients-typescript-package-path-direct))) | ||
jcs090218 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
(lsp-register-client | ||
(make-lsp-client :new-connection (lsp-stdio-connection (lambda () | ||
|
Uh oh!
There was an error while loading. Please reload this page.