MIT License
-Copyright (c) 2020 Yegappan Lakshmanan
+Copyright (c) 2020-2023 Yegappan Lakshmanan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
mtype = msgType[reply.params.type]
endif
- util.TraceLog(false, $'[{mtype}]: {reply.params.message}')
+ util.TraceLog(false, $'{strftime("%m/%d/%y %T")}: [{mtype}]: {reply.params.message}')
enddef
# process unsupported notification messages
# Enable/disable the logging of the language server protocol messages
export def ServerDebug(arg: string)
- if arg !=? 'on' && arg !=? 'off'
+ if arg !=? 'errors' && arg !=? 'messages' && arg !=? 'on' && arg !=? 'off'
util.ErrMsg($'Error: Invalid argument ("{arg}") for LSP server debug')
return
endif
if arg ==? 'on'
util.ClearTraceLogs()
util.ServerTrace(true)
- else
+ elseif arg ==? 'off'
util.ServerTrace(false)
+ elseif arg ==? 'messages'
+ util.ServerMessagesShow(false)
+ else
+ util.ServerMessagesShow(true)
endif
enddef
# LSP server standard output handler
def Output_cb(lspserver: dict<any>, chan: channel, msg: any): void
- util.TraceLog(false, $'Received [{strftime("%m/%d/%y %T")}]: {msg->string()}')
+ util.TraceLog(false, $'{strftime("%m/%d/%y %T")}: Received {msg->string()}')
lspserver.data = msg
lspserver.processMessages()
enddef
# LSP server exit callback
def Exit_cb(lspserver: dict<any>, job: job, status: number): void
- util.WarnMsg($'[{strftime("%m/%d/%y %T")}]: LSP server exited with status {status}')
+ util.WarnMsg($'{strftime("%m/%d/%y %T")}: LSP server exited with status {status}')
lspserver.running = false
lspserver.ready = false
lspserver.requests = {}
endif
job->ch_sendexpr(content)
if content->has_key('id')
- util.TraceLog(false, $'Sent [{strftime("%m/%d/%y %T")}]: {content->string()}')
+ util.TraceLog(false, $'{strftime("%m/%d/%y %T")}: Sent {content->string()}')
endif
enddef
return {}
endif
- util.TraceLog(false, $'Sent [{strftime("%m/%d/%y %T")}]: {req->string()}')
+ util.TraceLog(false, $'{strftime("%m/%d/%y %T")}: Sent {req->string()}')
# Do the synchronous RPC call
var reply = job->ch_evalexpr(req)
- util.TraceLog(false, $'Received [{strftime("%m/%d/%y %T")}]: {reply->string()}')
+ util.TraceLog(false, $'{strftime("%m/%d/%y %T")}: Received {reply->string()}')
if reply->has_key('result')
# successful reply
# LSP server asynchronous RPC callback
def AsyncRpcCb(lspserver: dict<any>, method: string, RpcCb: func, chan: channel, reply: dict<any>)
- util.TraceLog(false, $'Received [{strftime("%m/%d/%y %T")}]: {reply->string()}')
+ util.TraceLog(false, $'{strftime("%m/%d/%y %T")}: Received {reply->string()}')
if reply->empty()
return
return -1
endif
- util.TraceLog(false, $'Sent [{strftime("%m/%d/%y %T")}]: {req->string()}')
+ util.TraceLog(false, $'{strftime("%m/%d/%y %T")}: Sent {req->string()}')
# Do the asynchronous RPC call
var Fn = function('AsyncRpcCb', [lspserver, method, Cbfunc])
writefile([], $'{lsp_log_dir}lsp-server.err')
enddef
+# Open the LSP server debug messages file. If errors is true, then open the
+# error messages file.
+export def ServerMessagesShow(errors: bool = false)
+ var fname: string
+ if errors
+ fname = $'{lsp_log_dir}lsp-server.err'
+ else
+ fname = $'{lsp_log_dir}lsp-server.out'
+ endif
+ if filereadable(fname)
+ var wid = fname->bufwinid()
+ if wid == -1
+ exe $'split {fname}'
+ else
+ win_gotoid(wid)
+ endif
+ setlocal autoread
+ setlocal nomodified
+ setlocal nomodifiable
+ endif
+enddef
+
# Parse a LSP Location or LocationLink type and return a List with two items.
# The first item is the DocumentURI and the second item is the Range.
export def LspLocationParse(lsploc: dict<any>): list<any>
Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
For Vim version 9.0 and above
-Last change: March 24, 2023
+Last change: April 2, 2023
==============================================================================
*lsp-license*
License: MIT License
-Copyright (c) 2020-2022 Yegappan Lakshmanan
+Copyright (c) 2020-2023 Yegappan Lakshmanan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
successively to shrink the current symbol visual
region.
-:LspServerDebug { on | off } *:LspServerDebug*
- Enable or disable the logging of the messages emitted
- by a language server in the standard output and
- standard error. On a Unix-like system, these messages
- are logged to the /tmp/lsp-server.out and
+ *:LspServerDebug*
+:LspServerDebug { on | off | messages | errors }
+ The following arguments are supported:
+
+ errors Open the log file containing the language
+ server error messages.
+ messages
+ Open the log file containing the language
+ server debug messages.
+ off Disable the logging of the language server
+ messages.
+ on Enable the logging of the messages emitted
+ by the language server in the standard output
+ and standard error.
+ By default, the language server messages are not
+ logged. On a Unix-like system, when enabled, these
+ messages are logged to the /tmp/lsp-server.out and
/tmp/lsp-server.err file respectively. On MS-Windows,
the %TEMP%/lsp-server.out and %TEMP%/lsp-server.err%
files are used. See |lsp-debug| for more information.
/tmp directory. On MS-Windows, these files are created in the %TEMP%
directory.
+The following command opens the file containing the messages printed by the
+language server in the stdout: >
+
+ :LspServerDebug messages
+<
+The following command opens the file containing the messages printed by the
+language server in the stderr: >
+
+ :LspServerDebug errors
+<
+To debug language server initialization problems, after enabling the above
+server debug, you can restart the server for the file type in the current
+buffer using the following command: >
+
+ :LspServerRestart
+<
The language servers typically support command line options to enable debug
messages and to increase the verbosity of the messages. You can refer to the
language server documentation for information about this. You can include
# Command line completion function for the LspSetTrace command.
def LspServerDebugComplete(arglead: string, cmdline: string, cursorpos: number): list<string>
- var l = ['off', 'on']
+ var l = ['errors', 'messages', 'off', 'on']
if arglead->empty()
return l
else