Closed LouieTian0209 closed 3 weeks ago
Different versions of NodeJS are installed on my system using nvm
To check this, I must install several Node copies using nvm. I guess this will pollute my notebook Ubuntu 22. and I don't know how to do it yet. so I cannot check this yet.
Different versions of NodeJS are installed on my system using nvm
To check this, I must install several Node copies using nvm. I guess this will pollute my notebook Ubuntu 22. and I don't know how to do it yet. so I cannot check this yet.
I don't think you need to install nvm and use it to install multiple NodeJS versions. (Since the typescript-language-server that works on my machine wasn't from any of them.)
Maybe you can try to install typescript-langauge-server from snap directly (with command sudo snap install typescript-language-server
)? That's the one being used on my machine that doesn't show any error message but also doesn't provide any feature either.
OK, to do for me.
Do you see some warnings/errors in the LSP panel in the bottom panel of Cud? click the 'LSP' icon on the bottom of Cud's sidebar, then look in all places of LSP bottom panel.
Do you see some warnings/errors in the LSP panel in the bottom panel of Cud? click the 'LSP' icon on the bottom of Cud's sidebar, then look in all places of LSP bottom panel.
Unfortunately no, the LSP panel is completely empty, with both Messages and Logs, as well as Error, Warning, Info and Log enabled. Screenshot reference below:
This page tells the location of 'tsserver.log' https://stackoverflow.com/questions/54475607/where-tsserver-logs-are-located but I can't find this file anywhere on my PC. does it mean TS server is not working from Snap?
version:
$ typescript-language-server --version
4.3.3
help:
Usage: typescript-language-server [options]
Options:
-V, --version output the version number
--stdio use stdio
--log-level <logLevel> A number indicating the log level (4 = log, 3 = info, 2 = warn, 1 = error). Defaults to `2`.
-h, --help display help for command
helps shows that --log-level 4
must be used, not --log-level=4
. tried it too.
I corrected "--log-level=4"
in config to 2 items: "--log-level", "4"
,
and corrected "ts" to "typescript" as I read the LSP error about "ts is unknown id".
here is my lsp_ts.json
{
"lexers": {
"TypeScript": "typescript"
},
"cmd_unix": [
"typescript-language-server",
"--stdio",
"--log-level", "4"
]
}
and now it works! autocompletion works for this example:
let message: string = 'Hello, World!';
console.log(message);
LSP panel has text.
I corrected the wiki page about TS-server soon.
I corrected
"--log-level=4"
in config to 2 items:"--log-level", "4"
, and corrected "ts" to "typescript" as I read the LSP error about "ts is unknown id". here is my lsp_ts.json{ "lexers": { "TypeScript": "typescript" }, "cmd_unix": [ "typescript-language-server", "--stdio", "--log-level", "4" ] }
and now it works! autocompletion works for this example:
let message: string = 'Hello, World!'; console.log(message);
LSP panel has text.
Thank you! I'll give it a try tomorrow. Cheers!
I corrected
"--log-level=4"
in config to 2 items:"--log-level", "4"
, and corrected "ts" to "typescript" as I read the LSP error about "ts is unknown id". here is my lsp_ts.json{ "lexers": { "TypeScript": "typescript" }, "cmd_unix": [ "typescript-language-server", "--stdio", "--log-level", "4" ] }
and now it works! autocompletion works for this example:
let message: string = 'Hello, World!'; console.log(message);
LSP panel has text.
Just tried with your config file. Now the right click "Go to definition" function works fine. However, autocompletion and hover information still don't work for me. Here's the output from LSP panel after starting the program:
[lspserver] Resolving TypeScript version from path "/snap/typescript-language-server/178/usr/local/share/.config/yarn/global/node_modules/typescript/lib/tsserver.js"...
[lspserver] Reading version from package.json at "/snap/typescript-language-server/178/usr/local/share/.config/yarn/global/node_modules/typescript/package.json"
[lspserver] Resolved TypeScript version to "5.4.5"
Using Typescript version (bundled) 5.4.5 from path "/snap/typescript-language-server/178/usr/local/share/.config/yarn/global/node_modules/typescript/lib/tsserver.js"
[lspserver] [tsclient] Starting tsserver
[lspserver] [tsclient] Starting tsserver
[lspserver] onInitialize result {
"capabilities": {
"textDocumentSync": 2,
"completionProvider": {
"triggerCharacters": [
".",
"\"",
"'",
"/",
"@",
"<"
],
"resolveProvider": true
},
"codeActionProvider": true,
"codeLensProvider": {
"resolveProvider": true
},
"definitionProvider": true,
"documentFormattingProvider": true,
"documentRangeFormattingProvider": true,
"documentHighlightProvider": true,
"documentSymbolProvider": true,
"executeCommandProvider": {
"commands": [
"_typescript.applyWorkspaceEdit",
"_typescript.applyCodeAction",
"_typescript.applyRefactoring",
"_typescript.configurePlugin",
"_typescript.organizeImports",
"_typescript.applyRenameFile",
"_typescript.goToSourceDefinition"
]
},
"hoverProvider": true,
"inlayHintProvider": true,
"linkedEditingRangeProvider": false,
"renameProvider": true,
"referencesProvider": true,
"selectionRangeProvider": true,
"signatureHelpProvider": {
"triggerCharacters": [
"(",
",",
"<"
],
"retriggerCharacters": [
")"
]
},
"workspaceSymbolProvider": true,
"implementationProvider": true,
"typeDefinitionProvider": true,
"foldingRangeProvider": true,
"semanticTokensProvider": {
"documentSelector": null,
"legend": {
"tokenTypes": [
"class",
"enum",
"interface",
"namespace",
"typeParameter",
"type",
"parameter",
"variable",
"enumMember",
"property",
"function",
"member"
],
"tokenModifiers": [
"declaration",
"static",
"async",
"readonly",
"defaultLibrary",
"local"
]
},
"full": true,
"range": true
},
"workspace": {
"fileOperations": {
"willRename": {
"filters": [
{
"scheme": "file",
"pattern": {
"glob": "**/*.{ts,js,jsx,tsx,mjs,mts,cjs,cts}",
"matches": "file"
}
},
{
"scheme": "file",
"pattern": {
"glob": "**",
"matches": "folder"
}
}
]
}
}
},
"callHierarchyProvider": true
}
}
Installed plugin 'Differ' and compared your log with mine. the same!
did you try autocompletion for me|ssage
or con|sole
here (|
is caret pos):
let message: string = 'Hello, World!';
console.log(message);
Installed plugin 'Differ' and compared your log with mine. the same! did you try autocompletion for
me<caret>ssage
here?let message: string = 'Hello, World!'; console.log(message);
hove-dialog works here too (for 'message' and 'console'). when I hold Ctrl and stop mouse over Id.
lexer 'TypeScript' must also be installed from addons.
Oops, didn't realize I gotta hold Ctrl to have the hover dialog show up. It's working for me too!
I also assigned a keymap for auto completion, and upon pressing the keymap in the middle of the text, the auto completion context menu indeed showed up.
However, having hover dialog and auto completion trigger attached to keymaps is still less productive than ideal and kind of defeat the purpose of those functions. Is there a way we can alter the behavior of those functions, so that hover dialog shows up automatically when mouse cursor is on top of a variable/object/function and auto completion context menu shows up automatically as you type?
auto completion context menu shows up automatically as you type?
Yes! option "autocomplete_autoshow_chars" , set it to 1 or 2. in user.json.
hover dialog shows up automatically when mouse cursor is on top of a variable/object/function
AFAIK it works only with Ctrl hold. I will look at the python code to find how to change it.
Hover w/out Ctrl hold:
open file py/cuda_lsp/lsp.py ('py' is here- https://wiki.freepascal.org/CudaText#Location_of_'settings',_'py',_'data'_folders )
and find def on_mouse_stop
. Comment these lines:
if app_proc(PROC_GET_KEYSTATE, '') != 'c':
return
Yes! option "autocomplete_autoshow_chars" , set it to 1 or 2.
Thank you! That's such a life saver!
open file py/cuda_lsp/lsp.py
This is interesting. I successfully located py
folder, but couldn't find the cuda_lsp
sub-folder in it. See the ls
output:
I don't know much about Python, but it would be excellent if this auto hover dialog config can be added to Settings config file for users to tweak.
I successfully located py folder,
It is folder in /usr/share, but you need another one-- https://wiki.freepascal.org/CudaText#Location_of_'settings',_'py',_'data'_folders
if app_proc(PROC_GET_KEYSTATE, '') != 'c':
Thanks for the tip! I found it in ~/.config/cudatext
and after commenting it out and restarting the program, hover dialog now will automatically show up on mouse hover!
I'm not sure whether you have the plan/interest in making this feature a setting config option, so I'll let you decide whether to close this issue now or after you add it into setting config.
Thanks again for the super prompt response and willingless for helping out. Really appreciate your effort!
I just updated the LSP Client plugin (update it using "Plugins / addons manager / update"). added the option "hover_with_ctrl" to plugin's config.
One interesting (and slightly annoying) observation is that after turning off hover_with_ctrl
for LSP Client, if the file currently being viewed in CudaText is in a language that LSP currently supports and configured, if I switch to another program (either by minimizing CudaText or brining another program to the top layer of foreground) then very often CudaText will just pop back up to the top most layer of active windows.
(Example: My CudaText LSP Client plugin is configured to work with TypeScript files, I open a TypeScript file in CudaText, then bring up my web browser to make it the active window. After a few seconds CudaText will pop up onto the screen from background and become the new active window, even when I'm not performing any action that would activate it.)
My guess is that maybe CudaText somehow ignores the z-index of active programs, so that even if the active window is a different program, it's still checking if mouse cursor is going to trigger hover dialog with consideration of only x and y axes on screen. If the mouse cursor is above something that can trigger hover dialog, then regardless of whether CudaText is in foreground or background, the hover dialog will be triggered either way, making it the new active window on desktop. But that's only my guess.
Currently the workaround for me is to switch the document view into a file that LSP doesn't work in, before switching to a different program. But obviously it's the best if the auto pop up behavior can be disabled altogether.
I confirm this issue.
This happens when I first show hover-dialog for some Id, then I alt+tab to maximized Firefox, and move mouse there -> Cud activates. but I cannot find how MY code activates app, or how plugin's timers activate app.... call-stack-window shows some OS message comes to activate app.. maybe it is related to LSP server / caused by LSP server.. cannot fix yet.
maybe it is related to LSP server / caused by LSP server..
Is there any other plugin that can show similar hover dialogs? If so, we can test that plugin as well to see if it's a LSP issue or a hover dialog issue. Maybe still won't be able to fix it but at least we can nail down what caused the problem with this method.
I found that one of ed.focus()
calls in plugin's dlg.py file is the reason.
added some checks there.
pls test from git:
I see it's fixed in most cases, but sometimes app still pops up..
I fixed it more. more securely. Updated in git again.
Seems solved, closing.
Can confirm it's fixed on my end. Thanks!
I'm trying to add LSP support for TypeScript in CudaText on my Ubuntu-based system, and I followed this guide to install LSP Client and add TypeScript config file. Different versions of NodeJS are installed on my system using
nvm
, but after I pointtsserver-path
to typescript-language-server installed in the default node version, it still complained about not being able to find it. So I installed typescript-language-server through snap and pointedtsserver-path
to this installation, and it was being recognized successfully. However, after restarting CudaText, the LSP service doesn't seem to work, even though in console it saysLSP: starting server - TypeScript;
with no error message, in actual TypeScript code files I still don't have auto completion, go to definition, function signature help or hover information. I'm not sure what I did wrong or what else I need to do in order to make LSP work properly. Here's a copy of mylsp_ts.json
file insettings
folder: