Ekopalypse / NppLspClient

LSP client for Notepad++
MIT License
39 stars 3 forks source link

[Help request] there is no interaction between the NppLspClient and the clojure-lsp server #6

Open linpengcheng opened 2 years ago

linpengcheng commented 2 years ago

[Help request] there is no interaction between the NppLspClient and the clojure-lsp server

first, thank you for your excellent project!

I feel that there is no interaction between the NppLspClient and the clojure-lsp server, and the lsp client cannot obtain a list of symbols, and cannot goto definitions, declarations, implementation, and find references.


notepad++ lsp config file:

[lspservers.clojure]
# mode = "tcp"
# port = 12340
# host = "127.0.0.1"
mode = "io"
executable = 'x:\dev\cljc\clojure-lsp.bat'
# args = '--check-parent-process --log-file D:\log.txt -vvv'
auto_start_server = false

lsp out console info:

on_file_opened:: clojure: x:\tmp\t.clj
on_file_opened: initialized=false
starting language server: clojure
checking language server status: clojure
  trying to start x:\dev\cljc\clojure-lsp.bat
  running
checking current lexer
checking language server status: clojure
  is already running
on_initialize: 10132
write_to_stdin: Content-Length: 2119

{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":10132,"clientInfo":{"name":"NppLspClient","version":"0.0.1"},"rootUri":"file:///x%3A/tmp","initializationOptions":{},"capabilities":{"workspace":{"applyEdit":false,"workspaceEdit":{"documentChanges":false},"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":false,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":false},"configuration":false,"workspaceFolders":false},"textDocument":{"publishDiagnostics":{"relatedInformation":false},"synchronization":{"dynamicRegistration":false,"willSave":false,"willSaveWaitUntil":false,"didSave":true},"completion":{"dynamicRegistration":false,"contextSupport":false,"completionItem":{"snippetSupport":false,"commitCharactersSupport":false,"documentationFormat":["plaintext"],"deprecatedSupport":false},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":false,"contentFormat":["plaintext"]},"signatureHelp":{"dynamicRegistration":false,"signatureInformation":{"documentationFormat":["plaintext"]}},"definition":{"dynamicRegistration":false},"references":{"dynamicRegistration":false},"documentHighlight":{"dynamicRegistration":false},"documentSymbol":{"dynamicRegistration":false,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"codeAction":{"dynamicRegistration":false},"codeLens":{"dynamicRegistration":false},"formatting":{"dynamicRegistration":false},"rangeFormatting":{"dynamicRegistration":false},"onTypeFormatting":{"dynamicRegistration":false},"rename":{"dynamicRegistration":false},"documentLink":{"dynamicRegistration":false},"typeDefinition":{"dynamicRegistration":false},"implementation":{"dynamicRegistration":false},"colorProvider":{"dynamicRegistration":false},"foldingRange":{"dynamicRegistration":false,"rangeLimit":100,"lineFoldingOnly":true}}},"trace":"off","workspaceFolders":null}}
on_message_received: 
on_message_received: x:\dev\Notepad++>#!/usr/bin/env bash 
'#!' ²»ʇĚ²¿»򍢲¿üÁҲ²»ʇ¿ɔːеij̐򍊻򅺴¦À펄¼þ¡£
on_message_received: 
'exec' ²»ʇĚ²¿»򍢲¿üÁҲ²»ʇ¿ɔːеij̐򍊻򅺴¦À펄¼þ¡£
on_message_received: x:\dev\Notepad++>exec java -Xmx2g -server -jar $0 "$@" 
on_message_received: Content-Length: 134

on_message_received: {"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"begin","title":"clojure-lsp","percentage":0}}}
on_message_received: Content-Length: 146

on_message_received: {"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"report","message":"Finding kondo config","percentage":5}}}Content-Length: 140

clojure-lsp server is like properly working.

~/.config/clojure-lsp/config.edn

{:log-path "x:/tmp/clojure-lsp.log"
 :use-metadata-for-privacy? true}

:log-path "x:/tmp/clojure-lsp.log"

2022-06-01T05:51:13.840Z  INFO [clojure-lsp.db:70] - [DB] Reading transit analysis cache from x:\tmp\.lsp\.cache\db.transit.json db took 29ms
2022-06-01T05:51:13.871Z  INFO [clojure-lsp.crawler:160] - [Startup] Using cached db for project root x:\tmp
2022-06-01T05:51:13.871Z  INFO [clojure-lsp.source-paths:216] - [Startup] Using default source-paths: #{"src" "test"}
2022-06-01T05:51:13.871Z  INFO [clojure-lsp.crawler:71] - Copying kondo configs from classpath to project if any...
2022-06-01T05:51:13.886Z  INFO [clojure-lsp.crawler:73] - Copied kondo configs, took 7ms secs.
2022-06-01T05:51:13.886Z  INFO [clojure-lsp.crawler:191] - [Startup] Analyzing source paths for project root x:\tmp
2022-06-01T05:51:13.918Z  INFO [clojure-lsp.kondo:157] - Linting whole project for unused-public-var took 3ms
2022-06-01T05:51:13.934Z  INFO [clojure-lsp.crawler:27] - [Startup] Project only paths analyzed, took 34ms
2022-06-01T05:51:13.934Z  INFO [clojure-lsp.handlers:93] - :initialize 156ms
2022-06-01T05:51:13.934Z  INFO [clojure-lsp.feature.clojuredocs:21] - [Clojuredocs] Refreshing clojuredocs cache...
2022-06-01T05:51:13.950Z  INFO [clojure-lsp.handlers:116] - [Startup] Analyzing test paths for project root file:///x%3A/tmp
2022-06-01T05:51:13.966Z  INFO [clojure-lsp.feature.java-interop:222] - [Java] JDK source already present on global LSP cache dir.
2022-06-01T05:51:14.218Z  INFO [clojure-lsp.db:70] - [DB] Reading transit analysis cache from C:\Users\user001\.cache\clojure-lsp\db.transit.json db took 259ms
2022-06-01T05:51:14.278Z  INFO [clojure-lsp.feature.java-interop:255] - [Java] JDK source cached loaded successfully.
2022-06-01T05:52:53.445Z  INFO [lsp4clj.core:317] - [Server] Initializing...
2022-06-01T05:52:53.460Z  INFO [clojure-lsp.db:70] - [DB] Reading transit analysis cache from x:\tmp\.lsp\.cache\db.transit.json db took 1ms
2022-06-01T05:52:53.460Z  INFO [clojure-lsp.crawler:160] - [Startup] Using cached db for project root x:\tmp
2022-06-01T05:52:53.460Z  INFO [clojure-lsp.source-paths:216] - [Startup] Using default source-paths: #{"src" "test"}
2022-06-01T05:52:53.460Z  INFO [clojure-lsp.crawler:71] - Copying kondo configs from classpath to project if any...
2022-06-01T05:52:53.460Z  INFO [clojure-lsp.crawler:73] - Copied kondo configs, took 3ms secs.
2022-06-01T05:52:53.476Z  INFO [clojure-lsp.crawler:191] - [Startup] Analyzing source paths for project root x:\tmp
2022-06-01T05:52:53.476Z  INFO [clojure-lsp.kondo:157] - Linting whole project for unused-public-var took 0ms
2022-06-01T05:52:53.476Z  INFO [clojure-lsp.crawler:27] - [Startup] Project only paths analyzed, took 10ms
2022-06-01T05:52:53.476Z  INFO [clojure-lsp.handlers:93] - :initialize 33ms
2022-06-01T05:52:53.491Z  INFO [clojure-lsp.feature.java-interop:222] - [Java] JDK source already present on global LSP cache dir.
2022-06-01T05:52:53.476Z  INFO [clojure-lsp.handlers:116] - [Startup] Analyzing test paths for project root file:///x%3A/tmp
2022-06-01T05:52:53.797Z  INFO [clojure-lsp.db:70] - [DB] Reading transit analysis cache from C:\Users\user001\.cache\clojure-lsp\db.transit.json db took 300ms
2022-06-01T05:52:53.885Z  INFO [clojure-lsp.feature.java-interop:255] - [Java] JDK source cached loaded successfully.
2022-06-01T05:53:22.853Z  ERROR [clojure-lsp.feature.clojuredocs:34] - [Clojuredocs] Error refreshing clojuredocs information. java.net.ConnectException: Connection timed out: connect
2022-06-01T05:53:22.853Z  INFO [clojure-lsp.feature.clojuredocs:23] - [Clojuredocs] Refreshing clojuredocs cache took 128904ms.
2022-06-01T05:54:20.935Z  INFO [lsp4clj.core:317] - [Server] Initializing...
2022-06-01T05:54:20.935Z  INFO [clojure-lsp.db:70] - [DB] Reading transit analysis cache from x:\tmp\.lsp\.cache\db.transit.json db took 1ms
2022-06-01T05:54:20.951Z  INFO [clojure-lsp.crawler:160] - [Startup] Using cached db for project root x:\tmp
2022-06-01T05:54:20.951Z  INFO [clojure-lsp.source-paths:216] - [Startup] Using default source-paths: #{"src" "test"}
2022-06-01T05:54:20.951Z  INFO [clojure-lsp.crawler:71] - Copying kondo configs from classpath to project if any...
2022-06-01T05:54:20.951Z  INFO [clojure-lsp.crawler:73] - Copied kondo configs, took 4ms secs.
2022-06-01T05:54:20.966Z  INFO [clojure-lsp.crawler:191] - [Startup] Analyzing source paths for project root x:\tmp
2022-06-01T05:54:20.966Z  INFO [clojure-lsp.kondo:157] - Linting whole project for unused-public-var took 0ms
2022-06-01T05:54:20.966Z  INFO [clojure-lsp.crawler:27] - [Startup] Project only paths analyzed, took 8ms
2022-06-01T05:54:20.984Z  INFO [clojure-lsp.feature.clojuredocs:21] - [Clojuredocs] Refreshing clojuredocs cache...
2022-06-01T05:54:20.987Z  INFO [clojure-lsp.feature.java-interop:222] - [Java] JDK source already present on global LSP cache dir.
2022-06-01T05:54:20.983Z  INFO [clojure-lsp.handlers:93] - :initialize 37ms
2022-06-01T05:54:20.982Z  INFO [clojure-lsp.handlers:116] - [Startup] Analyzing test paths for project root file:///x%3A/tmp
2022-06-01T05:54:21.193Z  INFO [clojure-lsp.db:70] - [DB] Reading transit analysis cache from C:\Users\user001\.cache\clojure-lsp\db.transit.json db took 200ms
2022-06-01T05:54:21.243Z  INFO [clojure-lsp.feature.java-interop:255] - [Java] JDK source cached loaded successfully.
2022-06-01T05:55:34.598Z  ERROR [clojure-lsp.feature.clojuredocs:34] - [Clojuredocs] Error refreshing clojuredocs information. java.net.ConnectException: Connection timed out: connect
2022-06-01T05:55:34.598Z  INFO [clojure-lsp.feature.clojuredocs:23] - [Clojuredocs] Refreshing clojuredocs cache took 73610ms.
Ekopalypse commented 2 years ago

Thank you for your interest in this plugin. May I ask you how you set up the Clojure language itself and the associated lsp?

I used the udl from here for the language and the lsp binary from here

and I do see communication from and to the clojure lsp

image

but I do see also exceptions from the clojure lsp like

Jun 05, 2022 3:05:53 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint logIssues
WARNING: Issue found in NotificationMessage: Message could not be parsed.
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 156 path $.params.contentChanges[0]
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:225)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.CollectionTypeAdapter.read(CollectionTypeAdapter.java:114)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.CollectionTypeAdapter.read(CollectionTypeAdapter.java:40)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:130)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:221)
    at com.google.gson.Gson.fromJson(Gson.java:991)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.fromJson(MessageTypeAdapter.java:329)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.parseParams(MessageTypeAdapter.java:249)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:119)
    at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:55)
    at com.google.gson.Gson.fromJson(Gson.java:991)
    at org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler.parseMessage(MessageJsonHandler.java:119)
    at org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler.parseMessage(MessageJsonHandler.java:114)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:193)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
    at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.lang.Thread.run(Thread.java:829)
    at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:596)
    at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 156 path $.params.contentChanges[0]
    at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:214)
    ... 22 more

So I'm not sure if I have my environment set up correctly and also, the latest code I am using is not yet published in the repo. I will push this today, at the latest tomorrow after some additional tests.

Ekopalypse commented 2 years ago

@linpengcheng the last pushes should solve some problems with the closure lsp server,

image

but it introduces a dirty hack because it looks like the json2 decoder has a problem decoding the double backslash inside a string.

linpengcheng commented 2 years ago

@Ekopalypse Thank you for your reply and work, I'm looking forward to the release of v.0.0.11-alpha!

Ekopalypse commented 2 years ago

@linpengcheng - has been published. Thanks in advance for testing.

linpengcheng commented 2 years ago

@Ekopalypse Thank you very much!

linpengcheng commented 2 years ago

@Ekopalypse

linpengcheng commented 2 years ago

@Ekopalypse

Ekopalypse commented 2 years ago

@linpengcheng

I tested it with Windows 10 from a VM and it seems to work now BUT on the very first startup it did not work. After using "Stop server for current language" followed by "Start server for current language" it worked and now it works even if I stop Notepad++ and restart. Strange. I saw similar behavior on Windows 7, but at the time I thought I was wrong about the configuration, now I'm not so sure. I'll definitely have to check this out further.

image

linpengcheng commented 2 years ago

@Ekopalypse

Tested:

Ekopalypse commented 2 years ago

@linpengcheng Strange, my test with Windows 10 was on C:. Can you restart Notepad++, do a test and then attach the output from the console? Maybe that will give us the necessary clue what is going on. The test sequence would be

Use the Console context menu to select and copy everything. The log does not contain any other potentially sensitive data, except for path and file names, and the actual code. You can make this information unrecognizable if necessary.

linpengcheng commented 2 years ago

@Ekopalypse

The three messages received at the end are different.


(+ 1 2)

(+ 4 6)

(def x 1)

(defn f123 [x]  1)

(zip x)

(zipmap)
(flatten)
(zipmap)
starting language server: clojure
checking language server status: clojure
  trying to start D:\npp\tools\clj\clojure-lsp.exe
  running
checking current lexer
checking language server status: clojure
  is already running
on_initialize: 9148
write_to_stdin: Content-Length: 2122

{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":9148,"clientInfo":{"name":"NppLspClient","version":"0.0.1"},"rootUri":"file:///D%3A/tmp/src","initializationOptions":{},"capabilities":{"workspace":{"applyEdit":false,"workspaceEdit":{"documentChanges":false},"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":false,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":false},"configuration":false,"workspaceFolders":false},"textDocument":{"publishDiagnostics":{"relatedInformation":false},"synchronization":{"dynamicRegistration":false,"willSave":false,"willSaveWaitUntil":false,"didSave":true},"completion":{"dynamicRegistration":false,"contextSupport":false,"completionItem":{"snippetSupport":false,"commitCharactersSupport":false,"documentationFormat":["plaintext"],"deprecatedSupport":false},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":false,"contentFormat":["plaintext"]},"signatureHelp":{"dynamicRegistration":false,"signatureInformation":{"documentationFormat":["plaintext"]}},"definition":{"dynamicRegistration":false},"references":{"dynamicRegistration":false},"documentHighlight":{"dynamicRegistration":false},"documentSymbol":{"dynamicRegistration":false,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"codeAction":{"dynamicRegistration":false},"codeLens":{"dynamicRegistration":false},"formatting":{"dynamicRegistration":false},"rangeFormatting":{"dynamicRegistration":false},"onTypeFormatting":{"dynamicRegistration":false},"rename":{"dynamicRegistration":false},"documentLink":{"dynamicRegistration":false},"typeDefinition":{"dynamicRegistration":false},"implementation":{"dynamicRegistration":false},"colorProvider":{"dynamicRegistration":false},"foldingRange":{"dynamicRegistration":false,"rangeLimit":100,"lineFoldingOnly":true}}},"trace":"off","workspaceFolders":null}}
on_message_received: Content-Length: 134

on_message_received: {"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"begin","title":"clojure-lsp","percentage":0}}}
progress_notification: lsp.ProgressParams{
    token: 'clojure-lsp'
    value: '{"kind":"begin","title":"clojure-lsp","percentage":0}'
}
on_message_received: Content-Length: 146

on_message_received: {"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"report","message":"Finding kondo config","percentage":5}}}Content-Length: 140

{"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"report","message":"Finding cache","percentage":10}}}
progress_notification: lsp.ProgressParams{
    token: 'clojure-lsp'
    value: '{"kind":"report","message":"Finding kondo config","percentage":5}'
}
progress_notification: lsp.ProgressParams{
    token: 'clojure-lsp'
    value: '{"kind":"report","message":"Finding cache","percentage":10}'
}
on_message_received: Content-Length: 148

on_message_received: {"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"report","message":"Copying kondo configs","percentage":15}}}
progress_notification: lsp.ProgressParams{
    token: 'clojure-lsp'
    value: '{"kind":"report","message":"Copying kondo configs","percentage":15}'
}
on_message_received: Content-Length: 149

{"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"report","message":"Resolving config paths","percentage":15}}}Content-Length: 150

{"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"report","message":"Analyzing project files","percentage":20}}}
progress_notification: lsp.ProgressParams{
    token: 'clojure-lsp'
    value: '{"kind":"report","message":"Resolving config paths","percentage":15}'
}
progress_notification: lsp.ProgressParams{
    token: 'clojure-lsp'
    value: '{"kind":"report","message":"Analyzing project files","percentage":20}'
}
on_message_received: Content-Length: 124

on_message_received: {"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"end","message":"Project analyzed"}}}
progress_notification: lsp.ProgressParams{
    token: 'clojure-lsp'
    value: '{"kind":"end","message":"Project analyzed"}'
}
on_message_received: Content-Length: 1887

on_message_received: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":1,"save":{"includeText":true}},"hoverProvider":true,"completionProvider":{"resolveProvider":true,"triggerCharacters":[":","/"]},"signatureHelpProvider":{"triggerCharacters":[]},"definitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]},"codeLensProvider":{"resolveProvider":true},"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"renameProvider":{"prepareProvider":true},"declarationProvider":true,"executeCommandProvider":{"commands":["add-missing-libspec","add-import-to-namespace","move-coll-entry-up","cycle-privacy","create-test","drag-backward","promote-fn","change-coll","thread-last-all","drag-forward","unwind-all","move-to-let","clean-ns","suppress-diagnostic","move-coll-entry-down","thread-last","resolve-macro-as","introduce-let","add-missing-import","move-form","sort-map","unwind-thread","thread-first-all","thread-first","inline-symbol","extract-function","demote-fn","cycle-coll","expand-let","create-function","add-require-suggestion"]},"workspace":{"fileOperations":{"willRename":{"filters":[{"pattern":{"glob":"**/*.{clj,cljs,cljc,cljd,edn,bb,clj_kondo}","matches":"file"},"scheme":"file"}]}}},"callHierarchyProvider":true,"linkedEditingRangeProvider":true,"semanticTokensProvider":{"legend":{"tokenTypes":["namespace","type","function","macro","keyword","class","variable","method","event"],"tokenModifiers":["definition","defaultLibrary","implementation"]},"range":true,"full":true},"experimental":{"testTree":true,"cursorInfo":true,"serverInfo":true,"clojuredocs":true}}}}
    initialized response received
write_to_stdin: Content-Length: 52

{"jsonrpc":"2.0","method":"initialized","params":{}}
on_file_opened:: clojure: D:\tmp\src\t.clj
on_file_opened: initialized=true
write_to_stdin: Content-Length: 258

{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///D%3A/tmp/src/t.clj","languageId":"clojure","version":0,"text":"\n(+ 1 2)\n\n(+ 4 6)\n\n(def x 1)\n\n(defn f123 [x]  1)\n\n(zip x)\n\n(zipmap)\n(flatten)\n(zipmap)\n"}}}
write_to_stdin: Content-Length: 126

{"jsonrpc":"2.0","id":1,"method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///D%3A/tmp/src/t.clj"}}}
on_message_received: Content-Length: 241

{"jsonrpc":"2.0","id":"1","method":"client/registerCapability","params":{"registrations":[{"id":"id","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"**/*.{clj,cljs,cljc,cljd,edn,bb,clj_kondo}"}]}}]}}
registerCapability: lsp.RegistrationParams{
    registrations: [lsp.Registration{
        id: 'id'
        method: 'workspace/didChangeWatchedFiles'
        register_options: '{"watchers":[{"globPattern":"**\/*.{clj,cljs,cljc,cljd,edn,bb,clj_kondo}"}]}'
    }]
}
write_to_stdin: Content-Length: 40

{"jsonrpc":"2.0","id":"1","result":null}
on_message_received: Content-Length: 631

on_message_received: {"jsonrpc":"2.0","id":1,"result":[{"name":"D:\\tmp\\src\\t.clj","kind":21,"range":{"start":{"line":0,"character":0},"end":{"line":999999,"character":999999}},"selectionRange":{"start":{"line":0,"character":0},"end":{"line":999999,"character":999999}},"children":[{"name":"x","kind":13,"range":{"start":{"line":5,"character":0},"end":{"line":5,"character":9}},"selectionRange":{"start":{"line":5,"character":5},"end":{"line":5,"character":6}}},{"name":"f123","kind":12,"range":{"start":{"line":7,"character":0},"end":{"line":7,"character":18}},"selectionRange":{"start":{"line":7,"character":6},"end":{"line":7,"character":10}}}]}]}
on_message_received: Content-Length: 1120

on_message_received: {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///D%3A/tmp/src/t.clj","diagnostics":[{"range":{"start":{"line":7,"character":12},"end":{"line":7,"character":13}},"severity":2,"code":"unused-binding","source":"clj-kondo","message":"unused binding x","tags":[1]},{"range":{"start":{"line":9,"character":1},"end":{"line":9,"character":4}},"severity":1,"code":"unresolved-symbol","source":"clj-kondo","message":"Unresolved symbol: zip","tags":[]},{"range":{"start":{"line":11,"character":0},"end":{"line":11,"character":8}},"severity":1,"code":"invalid-arity","source":"clj-kondo","message":"clojure.core/zipmap is called with 0 args but expects 2","tags":[]},{"range":{"start":{"line":12,"character":0},"end":{"line":12,"character":9}},"severity":1,"code":"invalid-arity","source":"clj-kondo","message":"clojure.core/flatten is called with 0 args but expects 1","tags":[]},{"range":{"start":{"line":13,"character":0},"end":{"line":13,"character":8}},"severity":1,"code":"invalid-arity","source":"clj-kondo","message":"clojure.core/zipmap is called with 0 args but expects 2","tags":[]}]}}

starting language server: clojure
checking language server status: clojure
  trying to start C:\dev\Notepad++\tools\clj\clojure-lsp.exe
  running
checking current lexer
checking language server status: clojure
  is already running
on_initialize: 12336
write_to_stdin: Content-Length: 2123

{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":12336,"clientInfo":{"name":"NppLspClient","version":"0.0.1"},"rootUri":"file:///D%3A/tmp/src","initializationOptions":{},"capabilities":{"workspace":{"applyEdit":false,"workspaceEdit":{"documentChanges":false},"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":false,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":false},"configuration":false,"workspaceFolders":false},"textDocument":{"publishDiagnostics":{"relatedInformation":false},"synchronization":{"dynamicRegistration":false,"willSave":false,"willSaveWaitUntil":false,"didSave":true},"completion":{"dynamicRegistration":false,"contextSupport":false,"completionItem":{"snippetSupport":false,"commitCharactersSupport":false,"documentationFormat":["plaintext"],"deprecatedSupport":false},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":false,"contentFormat":["plaintext"]},"signatureHelp":{"dynamicRegistration":false,"signatureInformation":{"documentationFormat":["plaintext"]}},"definition":{"dynamicRegistration":false},"references":{"dynamicRegistration":false},"documentHighlight":{"dynamicRegistration":false},"documentSymbol":{"dynamicRegistration":false,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"codeAction":{"dynamicRegistration":false},"codeLens":{"dynamicRegistration":false},"formatting":{"dynamicRegistration":false},"rangeFormatting":{"dynamicRegistration":false},"onTypeFormatting":{"dynamicRegistration":false},"rename":{"dynamicRegistration":false},"documentLink":{"dynamicRegistration":false},"typeDefinition":{"dynamicRegistration":false},"implementation":{"dynamicRegistration":false},"colorProvider":{"dynamicRegistration":false},"foldingRange":{"dynamicRegistration":false,"rangeLimit":100,"lineFoldingOnly":true}}},"trace":"off","workspaceFolders":null}}
on_message_received: Content-Length: 134

on_message_received: {"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"begin","title":"clojure-lsp","percentage":0}}}
progress_notification: lsp.ProgressParams{
    token: 'clojure-lsp'
    value: '{"kind":"begin","title":"clojure-lsp","percentage":0}'
}
on_message_received: Content-Length: 146

on_message_received: {"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"report","message":"Finding kondo config","percentage":5}}}Content-Length: 140

{"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"report","message":"Finding cache","percentage":10}}}
progress_notification: lsp.ProgressParams{
    token: 'clojure-lsp'
    value: '{"kind":"report","message":"Finding kondo config","percentage":5}'
}
progress_notification: lsp.ProgressParams{
    token: 'clojure-lsp'
    value: '{"kind":"report","message":"Finding cache","percentage":10}'
}
on_message_received: Content-Length: 148

on_message_received: {"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"report","message":"Copying kondo configs","percentage":15}}}
progress_notification: lsp.ProgressParams{
    token: 'clojure-lsp'
    value: '{"kind":"report","message":"Copying kondo configs","percentage":15}'
}
on_message_received: Content-Length: 149

on_message_received: {"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"report","message":"Resolving config paths","percentage":15}}}Content-Length: 150

{"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"report","message":"Analyzing project files","percentage":20}}}
progress_notification: lsp.ProgressParams{
    token: 'clojure-lsp'
    value: '{"kind":"report","message":"Resolving config paths","percentage":15}'
}
progress_notification: lsp.ProgressParams{
    token: 'clojure-lsp'
    value: '{"kind":"report","message":"Analyzing project files","percentage":20}'
}
on_message_received: Content-Length: 124

on_message_received: {"jsonrpc":"2.0","method":"$/progress","params":{"token":"clojure-lsp","value":{"kind":"end","message":"Project analyzed"}}}Content-Length: 1887

{"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":1,"save":{"includeText":true}},"hoverProvider":true,"completionProvider":{"resolveProvider":true,"triggerCharacters":[":","/"]},"signatureHelpProvider":{"triggerCharacters":[]},"definitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]},"codeLensProvider":{"resolveProvider":true},"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"renameProvider":{"prepareProvider":true},"declarationProvider":true,"executeCommandProvider":{"commands":["add-missing-libspec","add-import-to-namespace","move-coll-entry-up","cycle-privacy","create-test","drag-backward","promote-fn","change-coll","thread-last-all","drag-forward","unwind-all","move-to-let","clean-ns","suppress-diagnostic","move-coll-entry-down","thread-last","resolve-macro-as","introduce-let","add-missing-import","move-form","sort-map","unwind-thread","thread-first-all","thread-first","inline-symbol","extract-function","demote-fn","cycle-coll","expand-let","create-function","add-require-suggestion"]},"workspace":{"fileOperations":{"willRename":{"filters":[{"pattern":{"glob":"**/*.{clj,cljs,cljc,cljd,edn,bb,clj_kondo}","matches":"file"},"scheme":"file"}]}}},"callHierarchyProvider":true,"linkedEditingRangeProvider":true,"semanticTokensProvider":{"legend":{"tokenTypes":["namespace","type","function","macro","keyword","class","variable","method","event"],"tokenModifiers":["definition","defaultLibrary","implementation"]},"range":true,"full":true},"experimental":{"testTree":true,"cursorInfo":true,"serverInfo":true,"clojuredocs":true}}}}
progress_notification: lsp.ProgressParams{
    token: 'clojure-lsp'
    value: '{"kind":"end","message":"Project analyzed"}'
}
    initialized response received
write_to_stdin: Content-Length: 52

{"jsonrpc":"2.0","method":"initialized","params":{}}
on_file_opened:: clojure: D:\tmp\src\t.clj
on_file_opened: initialized=true
write_to_stdin: Content-Length: 258

{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///D%3A/tmp/src/t.clj","languageId":"clojure","version":0,"text":"\n(+ 1 2)\n\n(+ 4 6)\n\n(def x 1)\n\n(defn f123 [x]  1)\n\n(zip x)\n\n(zipmap)\n(flatten)\n(zipmap)\n"}}}
write_to_stdin: Content-Length: 126

{"jsonrpc":"2.0","id":1,"method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///D%3A/tmp/src/t.clj"}}}
on_message_received: Content-Length: 241

{"jsonrpc":"2.0","id":"1","method":"client/registerCapability","params":{"registrations":[{"id":"id","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"**/*.{clj,cljs,cljc,cljd,edn,bb,clj_kondo}"}]}}]}}
registerCapability: lsp.RegistrationParams{
    registrations: [lsp.Registration{
        id: 'id'
        method: 'workspace/didChangeWatchedFiles'
        register_options: '{"watchers":[{"globPattern":"**\/*.{clj,cljs,cljc,cljd,edn,bb,clj_kondo}"}]}'
    }]
}
write_to_stdin: Content-Length: 40

{"jsonrpc":"2.0","id":"1","result":null}
on_message_received: Content-Length: 267

on_message_received: {"jsonrpc":"2.0","id":1,"result":[{"name":"D:\\tmp\\src\\t.clj","kind":21,"range":{"start":{"line":0,"character":0},"end":{"line":999999,"character":999999}},"selectionRange":{"start":{"line":0,"character":0},"end":{"line":999999,"character":999999}},"children":[]}]}
on_message_received: Content-Length: 123

on_message_received: {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///D%3A/tmp/src/t.clj","diagnostics":[]}}
Ekopalypse commented 2 years ago

@linpengcheng From the client's point of view, it works as expected because the Clojure server does not send any symbol or diagnostic information messages.

image

The left side comes from running from d: while the right side comes from running from c:. I've highlighted the interesting parts.

First, the client sends the didOpen notification to the Clojure server, and then it sends a documentSymbol request with id=1. On the left side, you can see that the Clojure server's response message contains information about children, while on the right side, it is empty. The same is true for the server's diagnostic message. On the left side it contains the required information, while on the right side it is, again, empty.

According to https://clojure-lsp.io/troubleshooting, the Clojure server writes a log file to the temp directory. For example, mine are named clojure-lsp.7606130629827034341.out. Can you find a hint why C: is special in your case?

linpengcheng commented 2 years ago

@Ekopalypse

Thank you very much!

I have this problem on both Win7 and win10 computers, I still have this problem running notepad++ with the administrator account, I can't find any hint why C: is special, I don't remember any special settings.

Fortunately, I only need to install Npp on the D disk to use it, this is not a problem.

WARN [clojure-lsp.kondo:276] - Non-fatal error from clj-kondo: No configs copied.

INFO [clojure-lsp.handlers:124] - :did-open 10ms
INFO [clojure-lsp.handlers:227] - :document-symbol 0ms


ERROR [clojure-lsp.kondo:281] - Error running clj-kondo on D:\tmp\src\t.clj
com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine          WindowsJavaThreads.java:  138
          com.oracle.svm.core.thread.JavaThreads.threadStartRoutine                 JavaThreads.java:  596
                                               java.lang.Thread.run                      Thread.java:  829
                 java.util.concurrent.ThreadPoolExecutor$Worker.run          ThreadPoolExecutor.java:  628
                  java.util.concurrent.ThreadPoolExecutor.runWorker          ThreadPoolExecutor.java: 1128
                                java.util.concurrent.FutureTask.run                  FutureTask.java:  264
                java.util.concurrent.Executors$RunnableAdapter.call                   Executors.java:  515
      org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run  ConcurrentMessageProcessor.java:  113
        org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen       StreamMessageProducer.java:   94
 org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage       StreamMessageProducer.java:  194
                   org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume              RemoteEndpoint.java:  187
        org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification              RemoteEndpoint.java:  220
          org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify             GenericEndpoint.java:  152
   org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0             GenericEndpoint.java:   65
                                                                ...                                       
                        lsp4clj.core.LSPTextDocumentService/didOpen                         core.clj:  101
             clojure-lsp.handlers.ClojureLSPFeatureHandler/did-open                     handlers.clj:  496
                                      clojure-lsp.handlers/did-open                     handlers.clj:  128
                       clojure-lsp.feature.file-management/did-open              file_management.clj:   38
                               clojure-lsp.kondo/run-kondo-on-text!                        kondo.clj:  332
                                       clojure-lsp.kondo/run-kondo!                        kondo.clj:  272
                                    clojure-lsp.kondo/run-kondo!/fn                        kondo.clj:  274
                                                clj-kondo.core/run!                         core.clj:  195
                                  clj-kondo.impl.core/process-files                         core.clj:  543
                            clj-kondo.impl.core/copied-config-paths                         core.clj:  504
                                  sun.nio.fs.WindowsPath.relativize                 WindowsPath.java:   42
                                  sun.nio.fs.WindowsPath.relativize                 WindowsPath.java:  404
java.lang.IllegalArgumentException: 'other' has different root

INFO [clojure-lsp.handlers:124] - :did-open 46ms
INFO [clojure-lsp.handlers:227] - :document-symbol 0ms
Ekopalypse commented 2 years ago

I can replicate the issue and found the pattern when it happens

Npp C:
    LSP C:
        initial source is on C: ok
        initial source is on D: fail
    LSP D:
        initial source is on C: ok
        initial source is on D: fail
Npp D:
    LSP C:
        initial source is on C: fail
        initial source is on D: ok
    LSP D:
        initial source is on C: fail
        initial source is on D: ok

If the initial source file used to start the lsp server is on a drive other than Npp, it does not work. However, if it is on the same drive, source files from other drives can be opened afterwards. I assume the problem is in clj-kondo, a component used by the Clojure lsp server.

image

I've opened an issue with the clojure-lsp to get their opinion as well.

linpengcheng commented 2 years ago

@Ekopalypse

What a very unexpected bug! Thanks!