Welcome to the CHICKEN Scheme pasting service
rgherdt: installs fine now, but I am getting loads of errors added by zilti 3 days ago
[jsonrpc] e[01:16:12.603] --> initialize[1] {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"processId":5568,"rootPath":"/home/zilti/projects/lsptest/scheme-lsp-server/","rootUri":"file:///home/zilti/projects/lsptest/scheme-lsp-server","initializationOptions":{},"capabilities":{"workspace":{"applyEdit":true,"executeCommand":{"dynamicRegistration":false},"workspaceEdit":{"documentChanges":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":false},"configuration":true,"workspaceFolders":true},"textDocument":{"synchronization":{"dynamicRegistration":false,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":false,"completionItem":{"snippetSupport":true,"deprecatedSupport":true,"resolveSupport":{"properties":["documentation","details","additionalTextEdits"]},"tagSupport":{"valueSet":[1]}},"contextSupport":true},"hover":{"dynamicRegistration":false,"contentFormat":["plaintext"]},"signatureHelp":{"dynamicRegistration":false,"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true},"activeParameterSupport":true}},"references":{"dynamicRegistration":false},"definition":{"dynamicRegistration":false,"linkSupport":true},"declaration":{"dynamicRegistration":false,"linkSupport":true},"implementation":{"dynamicRegistration":false,"linkSupport":true},"typeDefinition":{"dynamicRegistration":false,"linkSupport":true},"documentSymbol":{"dynamicRegistration":false,"hierarchicalDocumentSymbolSupport":true,"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]}},"documentHighlight":{"dynamicRegistration":false},"codeAction":{"dynamicRegistration":false,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"isPreferredSupport":true},"formatting":{"dynamicRegistration":false},"rangeFormatting":{"dynamicRegistration":false},"rename":{"dynamicRegistration":false},"inlayHint":{"dynamicRegistration":false},"publishDiagnostics":{"relatedInformation":false,"codeDescriptionSupport":false,"tagSupport":{"valueSet":[1,2]}}},"window":{"workDoneProgress":true},"general":{"positionEncodings":["utf-32","utf-8","utf-16"]},"experimental":{}},"workspaceFolders":[{"uri":"file:///home/zilti/projects/lsptest/scheme-lsp-server","name":"~/projects/lsptest/scheme-lsp-server/"}]}} [jsonrpc] e[01:16:12.952] <-- window/logMessage {"method":"window/logMessage","params":{"message":"Read error: \nError: invalid sharp-sign read syntax: #\\~\n\n","type":1}} [jsonrpc] e[01:16:12.973] <-- window/logMessage {"method":"window/logMessage","params":{"message":"Read error: \nError: unexpected list terminator: #\\)\n\n","type":1}} [jsonrpc] e[01:16:12.973] <-- window/logMessage {"method":"window/logMessage","params":{"message":"Read error: \nError: unexpected list terminator: #\\)\n\n","type":1}} [jsonrpc] e[01:16:12.973] <-- window/logMessage {"method":"window/logMessage","params":{"message":"Read error: \nError: unexpected list terminator: #\\)\n\n","type":1}} [jsonrpc] e[01:16:12.973] <-- window/logMessage {"method":"window/logMessage","params":{"message":"Read error: \nError: unexpected list terminator: #\\)\n\n","type":1}} [jsonrpc] e[01:16:12.973] <-- window/logMessage {"method":"window/logMessage","params":{"message":"Read error: \nError: unexpected list terminator: #\\)\n\n","type":1}} [jsonrpc] e[01:16:12.973] <-- window/logMessage {"method":"window/logMessage","params":{"message":"Read error: \nError: invalid sharp-sign read syntax: #\\~\n\n","type":1}} [jsonrpc] e[01:16:12.973] <-- window/logMessage {"method":"window/logMessage","params":{"message":"Read error: \nError: unexpected list terminator: #\\)\n\n","type":1}} [jsonrpc] e[01:16:12.973] <-- window/logMessage {"method":"window/logMessage","params":{"message":"Read error: \nError: unexpected list terminator: #\\)\n\n","type":1}} [jsonrpc] e[01:16:12.973] <-- window/logMessage {"method":"window/logMessage","params":{"message":"Read error: \nError: unexpected list terminator: #\\)\n\n","type":1}} [jsonrpc] e[01:16:12.973] <-- window/logMessage {"method":"window/logMessage","params":{"message":"Read error: \nError: unexpected list terminator: #\\)\n\n","type":1}} [jsonrpc] e[01:16:12.973] <-- window/logMessage {"method":"window/logMessage","params":{"message":"Read error: \nError: unexpected list terminator: #\\)\n\n","type":1}} [jsonrpc] e[01:16:12.973] <-- initialize[1] {"jsonrpc":"2.0","id":1,"result":{"capabilities":{"textDocumentSync":{"save":true,"openClose":true,"change":2},"hoverProvider":true,"completionProvider":{"resolveProvider":true},"signatureHelpProvider":{},"definitionProvider":{}},"serverInfo":{"name":"CHICKEN LSP server","version":"0.4.7"}}} [jsonrpc] e[01:16:12.973] --> initialized {"jsonrpc":"2.0","method":"initialized","params":{}} [jsonrpc] e[01:16:12.974] --> textDocument/didOpen {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///home/zilti/projects/lsptest/scheme-lsp-server/lsp-server-impl.scm","version":0,"languageId":"scheme","text":"(define lsp-server-log-level (make-parameter 'debug))\n\n(define lsp-server-state 'off)\n(define lsp-server-version \"0.4.7\")\n\n(define listening-threads '())\n(define listening-threads-mutex (make-mutex))\n\n(define (shutting-down?)\n (eqv? lsp-server-state 'shutdown))\n\n\n(define-syntax define-handler\n (syntax-rules ()\n ((define-handler (handler params) body ...)\n (define (handler params)\n (when (shutting-down?)\n (raise (make-json-rpc-invalid-request-error\n \"Only exit request allowed after shutdown.\")))\n (write-log 'debug\n (format \"Handler ~a called with params ~s\"\n 'handler\n (truncate-string (format \"~a\" params))))\n body ...))))\n\n;; all implementations should implement at least following\n;; capabilities.\n(define mandatory-capabilities\n '((textDocumentSync . ((save . #t)\n (openClose . #t)\n (change . 2)))\n (hoverProvider . #t)\n (completionProvider . ((resolveProvider . #t)))\n (signatureHelpProvider . ())))\n\n(cond-expand\n (gambit (define thread-start! (primitive thread-start!))\n (define make-thread (primitive make-thread)))\n (else))\n\n(define-handler (initialize-handler params)\n (let ((root-path (get-root-path params)))\n ;; (thread-start!\n ;; (make-thread (lambda () ($initialize-lsp-server! root-path))))\n ($initialize-lsp-server! root-path)\n (set! lsp-server-state 'on)\n `((capabilities . ,(append mandatory-capabilities\n $server-capabilities))\n (serverInfo . ((name . ,$server-name)\n (version . ,lsp-server-version))))))\n\n(define-handler (initialized-handler params)\n (write-log 'info \"LSP server running\")\n #f)\n\n(define (shutdown-handler . params)\n (write-log 'info \"LSP server shutting down\")\n (set! lsp-server-state 'shutdown)\n 'null)\n\n(define (lsp-exit-handler . params)\n (write-log 'info \"Exiting LSP server.\")\n (json-rpc-exit)\n #f)\n\n(define-handler (ignore-request params)\n #f)\n\n(define-handler (text-document/definition params)\n (let* ((editor-word (get-word-under-cursor params))\n (file-path (get-uri-path params))\n (mod-name (and file-path\n (file-library-name file-path))))\n (if editor-word\n (let* ((word-text (editor-word-text editor-word))\n (def-locs ($get-definition-locations mod-name\n (string->symbol word-text))))\n (cond ((not (null? def-locs))\n (let ((v (list->vector def-locs)))\n (write-log 'debug\n (format \"$get-definition-locations resulted in ~a\"\n v))\n v))\n (else\n (write-log 'debug\n (format \"no definitions found for ~a\"\n (editor-word-text editor-word)))\n 'null)))\n 'null)))\n\n;; Dump file content to a temp file. For debugging, disabled in delivered\n;; code\n(define (dump-file file-path)\n (let ((tmp-file (string-append \"/tmp/\" (remove-slashes file-path))))\n (write-log 'debug\n (format \"dumping content read into ~a\" tmp-file))\n (mutex-lock! file-table-mutex)\n (with-output-to-file tmp-file\n (lambda ()\n (let ((doc (hash-table-ref file-table file-path)))\n (display (document-contents doc)))))\n (mutex-unlock! file-table-mutex)))\n\n(define-handler (text-document/did-change params)\n (let* ((file-path (get-uri-path params))\n (changes\n (string-lines\n (alist-ref 'text\n (vector-ref (alist-ref 'contentChanges params) 0))))\n (file-already-read?\n (begin\n (mutex-lock! file-table-mutex)\n (let ((res (hash-table-exists? file-table file-path)))\n (mutex-unlock! file-table-mutex)\n res))))\n (cond ((and file-path file-already-read?)\n ;;(generate-meta-data! file-path)\n (read-text! file-path)\n (update-file! file-path\n (alist-ref 'contentChanges params))\n (write-log 'debug\n (format \"file contents read: ~a\"\n file-path))\n ;; TODO first make this portable (i.e. not relying on /tmp), then\n ;; uncomment it.\n ;; We leave it in, since it's helpful when debugging problems\n ;; regarding the internal document representation (out-of-index etc).\n ;; (when (satisfies-log-level? 'debug)\n ;; (dump-file file-path))\n )\n\n (file-path\n (update-file! file-path\n (alist-ref 'contentChanges params))\n (write-log 'debug (format \"file contents updated: ~a\"\n file-path)))\n (else\n (write-log 'warning (format \"file-path not found: ~a\"\n file-path)))))\n #f)\n\n(define-handler (text-document/did-close params)\n (let ((file-path (get-uri-path params)))\n (when (free-file! file-path)\n (write-log 'info (format \"File closed: ~a\" file-path)))\n #f))\n\n(define (apply-file-operation params proc)\n (let ((file-path (get-uri-path params))\n (text (alist-ref* '(textDocument text) params)))\n (cond ((and file-path text)\n (let ((doc (read-text! file-path text)))\n (if doc\n (proc file-path (document-contents doc))\n (proc file-path)))\n (write-log 'debug (format \"text read: ~a\"\n text)))\n ((and file-path (file-exists? file-path))\n (let ((doc (read-file! file-path)))\n (if doc\n (proc file-path (document-contents doc))\n (proc file-path))))\n (else\n (write-log 'warning (format \"file-path missing: ~a\"\n file-path))))\n file-path))\n\n(define-handler (text-document/did-open params)\n (let ((file-path (apply-file-operation params $open-file!))\n (file-uri (alist-ref* '(textDocument uri) params)))\n (cond ((and file-path\n (file-exists? file-path))\n (write-log 'info (format \"File opened: ~a~%\" file-path))\n (let ((diags ($compute-diagnostics file-path)))\n (if (not (null? diags))\n (send-diagnostics file-uri diags)\n (clear-diagnostics file-uri))))\n (else\n (write-log 'warning (format \"Invalid file-path. Params: ~a~%\"\n params))))\n #f))\n\n(define-handler (text-document/did-save params)\n (let ((file-path (apply-file-operation params $save-file!))\n (file-uri (alist-ref* '(textDocument uri) params)))\n (cond ((and file-path\n (file-exists? file-path))\n (write-log 'info (format \"File saved: ~s~%\" file-path))\n (let ((diags ($compute-diagnostics file-path)))\n (if (not (null? diags))\n (send-diagnostics file-uri diags)\n (clear-diagnostics file-uri))))\n (else\n (write-log 'warning (format \"Invalid file-path. Params ~a~%\"\n params))))\n #f))\n\n(define-handler (text-document/completion params)\n (let* ((cur-char-number\n (alist-ref* '(position character) params))\n (editor-word (get-word-under-cursor params))\n (file-path (get-uri-path params))\n (mod-name (and file-path\n (file-library-name file-path))))\n (if (or (not editor-word)\n (< (string-length (editor-word-text editor-word))\n 1))\n 'null\n (let* ((word (editor-word-text editor-word))\n (suggestions ($apropos-list mod-name word)))\n (write-log 'debug\n (format \"getting completion suggestions for word ~a.\"\n word))\n (write-log 'debug (format \"suggestions list: ~a\" suggestions))\n\n `((isIncomplete . #t)\n (items .\n ,(list->vector\n (map (lambda (suggestion)\n (let* ((id-name (car suggestion))\n (mod-name-str (stringify (cdr suggestion)))\n (start-line (alist-ref* '(position line)\n params))\n (start-char (editor-word-start-char\n editor-word))\n (end-char (editor-word-end-char\n editor-word))\n (text-edit\n `((range . ((start . ((line . ,start-line)\n (character . ,start-char)))\n (end . ((line . ,start-line)\n (character . ,cur-char-number)))))\n (newText . ,id-name))))\n `((label . ,id-name)\n (insertText . ,id-name)\n (sortText . ,id-name)\n (textEdit . ,text-edit)\n (data . ((identifier . ,id-name) (module . ,mod-name-str))))))\n suggestions))))))))\n\n\n(define-handler (completion-item/resolve params)\n (let* ((id (string->symbol\n (alist-ref* '(data identifier) params)))\n (file-path (get-uri-path params))\n (mod-name (and file-path\n (file-library-name file-path)))\n (mod (let ((m (alist-ref* '(data module) params)))\n (if m\n (split-module-name m)\n mod-name))))\n (write-log 'debug (format \"params: ~a\" params))\n (guard\n (condition\n ((json-rpc-error? condition)\n (write-log 'error (format \"Error resolving ~a ~a\"\n mod\n id))\n (if (satisfies-log-level? 'debug)\n (raise (make-json-rpc-internal-error\n (format \"Error resolving ~a ~a\"\n mod\n id)))\n 'null)))\n (let ((doc (or ($fetch-documentation mod id)\n \"\")))\n (cons `(documentation . ,doc)\n params)))))\n\n(define (fetch-signature-under-cursor params)\n (let* ((editor-word\n (get-word-under-cursor params))\n (file-path (get-uri-path params))\n (mod-name (and file-path\n (file-library-name file-path))))\n\n (if (and editor-word (not (string=? (editor-word-text editor-word)\n \"\")))\n (begin\n (let* ((cur-word (editor-word-text editor-word))\n (signature ($fetch-signature mod-name\n (string->symbol cur-word))))\n (if (not signature)\n (begin\n (write-log 'debug\n (format \"no signature found for: ~a\" cur-word))\n \"\")\n signature)))\n \"\")))\n\n(define-handler (text-document/signature-help params)\n (let ((signature (fetch-signature-under-cursor params)))\n (if signature\n `((signatures . ,(vector `((label . ,signature)))))\n `((signatures . ,(vector))))))\n\n(define-handler (text-document/hover params)\n (write-log 'debug\n (format \"hover with params: ~a\" params))\n\n (let ((signature (fetch-signature-under-cursor params)))\n (if (and signature\n (not (equal? signature \"\"))\n (not (equal? signature 'null)))\n `((contents . ((kind . \"plaintext\")\n (value . ,signature))))\n 'null)))\n\n(define-handler (custom/load-file params)\n (let ((file-path (get-uri-path params)))\n (write-log 'info (format \"Loading file: ~a.\" file-path))\n (guard\n (condition\n (else (write-log 'error (format \"Error loading file: ~a.\"\n file-path))))\n (load file-path))\n #f))\n\n(define (parameterize-and-run out-port thunk)\n (parameterize\n ((server-out-port out-port)\n ;;(json-rpc-log-file \"/tmp/example.log\")\n ;; logging to stderr may cause problems with some clients\n ;; (particularly vscode), so we silence log messages from json-rpc lib.\n (json-rpc-log-level 'silent)\n ;; log messages are sent using window/logMessage notification,\n ;; so no problem allowing them here.\n (log-level (lsp-server-log-level))\n (custom-error-codes '((definition-not-found-error . -32000)\n (load-error . -32001)))\n (json-rpc-reader lsp-read)\n (json-rpc-writer lsp-write)\n (json-rpc-handler-table\n `((\"initialize\" . ,initialize-handler)\n (\"initialized\" . ,initialized-handler)\n (\"textDocument/definition\" . ,text-document/definition)\n (\"textDocument/diagnostic\" . ,(lambda (p)\n (write-log 'error \"textDocument/diagnostic not implemented\")\n #f))\n (\"textDocument/didChange\" . ,text-document/did-change)\n (\"workspace/didChangeConfiguration\" . ,ignore-request)\n (\"textDocument/didClose\" . ,text-document/did-close)\n (\"textDocument/didOpen\" . ,text-document/did-open)\n (\"textDocument/didSave\" . ,text-document/did-save)\n (\"textDocument/completion\" . ,text-document/completion)\n (\"textDocument/hover\" . ,text-document/hover)\n (\"completionItem/resolve\" . ,completion-item/resolve)\n (\"textDocument/signatureHelp\" . ,text-document/signature-help)\n (\"$/setTraceNotification\" . ,ignore-request)\n (\"$/cancelRequest\" . ,ignore-request)\n (\"window/logMessage\" . ,ignore-request)\n (\"exit\" . ,lsp-exit-handler)\n (\"shutdown\" . ,shutdown-handler)\n ;; custom commands\n (\"custom/loadFile\" . ,custom/load-file))))\n (thunk)))\n\n(define lsp-server-start/stdio\n (case-lambda\n (()\n (lsp-server-start/stdio (current-input-port) (current-output-port)))\n ((in-port out-port)\n (parameterize-and-run out-port\n (lambda ()\n (json-rpc-loop in-port out-port))))))\n\n(define (lsp-server-start/tcp port-num)\n (parameterize (($tcp-read-timeout #f))\n (let ((listener ($tcp-listen port-num)))\n (guard\n (condition\n (else (write-log 'error\n (format \"LSP-SERVER: JSON-RPC error: ~a\"\n condition))\n (cond-expand (chicken (print-error-message condition))\n (else (display condition)))\n (write-log 'info \"Exiting.\")\n (raise condition)))\n (let loop ()\n (call-with-values (lambda () ($tcp-accept listener))\n (lambda (in-port out-port)\n (parameterize-and-run\n out-port\n (lambda ()\n (cond ((eqv? (json-rpc-loop in-port out-port) 'json-rpc-exit)\n (when (input-port-open? in-port)\n (close-input-port in-port))\n (when (output-port-open? out-port)\n (close-output-port out-port))\n ($tcp-close listener))\n (else\n (write-log 'info \"Accepted incoming request\")\n (loop))))))))))))\n\n(define (parameterize-log-levels thunk)\n (parameterize ((log-level (lsp-server-log-level))\n (json-rpc-log-level (lsp-server-log-level)))\n (thunk)))\n\n(define (remove-slashes path)\n (define new-path (make-string (string-length path)))\n (string-fold (lambda (c i)\n (if (char=? c #\\/)\n (string-set! new-path i #\\.)\n (string-set! new-path i c))\n (+ i 1))\n 0\n path)\n new-path)\n\n(define (truncate-string str)\n (define max-length 40)\n (if (< (string-length str) max-length)\n str\n (string-append (string-take str max-length) \" ...\")))\n"}}} [jsonrpc] e[01:16:12.975] --> shutdown[2] {"jsonrpc":"2.0","id":2,"method":"shutdown","params":null} [jsonrpc] e[01:16:13.192] <-- textDocument/publishDiagnostics {"method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/zilti/projects/lsptest/scheme-lsp-server/lsp-server-impl.scm","diagnostics":[]}} [jsonrpc] e[01:16:13.213] <-- shutdown[2] {"jsonrpc":"2.0","id":2,"result":null} [jsonrpc] e[01:16:13.213] --> exit {"jsonrpc":"2.0","method":"exit","params":null}