Skip to content
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

Settings for Microsoft Python Language Server #633

Closed
hanspinckaers opened this issue Oct 15, 2018 · 16 comments
Closed

Settings for Microsoft Python Language Server #633

hanspinckaers opened this issue Oct 15, 2018 · 16 comments

Comments

@hanspinckaers
Copy link

Hi,

I'm trying to get Microsoft Python Language Server working. Sadly, I can't get it to work. I'm seeing this error when enabling the highest logging level:

10:08:18 INFO reader-python src/vim.rs:380 <= Some("python") {
  "jsonrpc": "2.0",
  "id": 9,
  "error": {
    "code": -32000,
    "message": "Object reference not set to an instance of an object.",
    "data": {
      "stack": "   at Microsoft.Python.LanguageServer.Implementation.LanguageServer.Initialize(JToken token, CancellationToken cancellationToken) in /mnt/data/python-language-server/src/LanguageServer/Impl/LanguageServer.Lifetime.cs:line 41",
      "code": "-2147467261"
    }
  }
}

I think this is related to certain initializationOptions that need to be set. They should be like these:
https://github.com/Microsoft/python-language-server/blob/master/Using_in_sublime_text.md

{
    "clients":
    {
        "mspyls":
        {
            "command": [ "dotnet.exe", "exec", "C:\\python-language-server\\Microsoft.Python.LanguageServer.dll" ],
            "scopes": ["source.python"],
            "syntaxes": ["Packages/Python/Python.sublime-syntax"],
            "languageId": "python",
            "initializationOptions": 
            {
                "interpreter": 
                {
                    "properties": 
                    {
                        "UseDefaultDatabase": true,
                        "Version": "3.7"
                    }                    
                }
            }
        }
    }
}

I've tried various syntax in settings.json, but I cannot seem to get it to work. My current settings.json:

{
    "python": {
        "UseDefaultDatabase": true,
        "Version": "3.6.4"
    }
}

Thanks!

@dimbleby
Copy link
Contributor

initializationOptions needs to be a top-level entry in settings.json I think.

{
    "initializationOptions": {
        "interpreter": {
      etc ...

FWIW I also had a go at the microsoft python language server a few weeks ago, and decided that it wasn't (yet?) as good as pyls anyway, as well as being much harder to get working in Vim.

@hanspinckaers
Copy link
Author

Thanks! That did the trick. And I see completions in the log, however I get this error message afterwards:

08:43:58 ERROR main src/vim.rs:59 Error handling message: data did not match any variant of untagged enum CompletionResponse

I think because microsoft python ls returns a dictionary:

08:43:58 INFO reader-python src/vim.rs:380 <= Some("python") {
  "jsonrpc": "2.0",
  "id": 20,
  "result": {
    "isIncomplete": false,
    "items": [
      {
        "label": "next",
        "kind": 21,
        "detail": null,
        "documentation": {
          "kind": null,
          "value": "None"
        },
        "sortText": "1",
        "filterText": null,
        "preselect": null,
        "insertText": "next",
        "insertTextFormat": 0,
        "textEdit": null,
        "additionalTextEdits": null,
        "commitCharacters": null,
        "command": null,
        "data": null,
        "_kind": "constant",
        "_values": null
      },
      {
        "label": "previous",
        "kind": 21,
        "detail": null,
        "documentation": {
          "kind": null,
          "value": "None"
        },
        "sortText": "1",
        "filterText": null,
        "preselect": null,
        "insertText": "previous",
        "insertTextFormat": 0,
        "textEdit": null,
        "additionalTextEdits": null,
        "commitCharacters": null,
        "command": null,
        "data": null,
        "_kind": "constant",
        "_values": null
      }
    ],
    "_applicableSpan": null,
    "_allowSnippet": null,
    "_expr": "self",
    "_commitByDefault": true
  }
}

I however do not know enough rust to add this case to:

let mut matches = match result {

@dimbleby
Copy link
Contributor

dimbleby commented Oct 20, 2018

This one looks like a problem with the microsoft language server to me. Specifically this bit:

"documentation": {
    "kind": null,
    "value": "None"
}

which does not parse, as you can verify like this:

extern crate serde_json;
extern crate languageserver_types as lsp;
use lsp::Documentation;

fn main() {
    // let serialized = "\"just a string\"";
    // let serialized = "{\"kind\": \"plaintext\", \"value\": \"None\"}";
    let serialized = "{\"kind\": null, \"value\": \"None\"}";
    let doc: serde_json::Result<Documentation> = serde_json::from_str(&serialized);
    println!("{:?}", doc);
}

producing Err(Error("data did not match any variant of untagged enum Documentation", line: 0, column: 0)). (The commented out examples deserialize just fine).

Relevant spec is here - search for MarkupContent - and so far as I can see there's indeed no default value for the kind so I believe that the client is right to reject this and the server is wrong to send it.

(There may be other problems too, I stopped on finding this one).

@hanspinckaers: suggest you take this issue over to the language server repository, if you still care about it.

@autozimu
Copy link
Owner

@dimbleby Nice finding!

@autozimu
Copy link
Owner

This is an issue with the language server and has been acknowledged in the corresponding issue.

@johngalambos
Copy link

I went through the remainder of the exercise @dimbleby started (thanks for the nice troubleshooting method!) and I think the remaining property causing trouble (at least for me so far) is insertTextFormat values of 0. I've created another issue here: microsoft/python-language-server#342.

@Congee
Copy link

Congee commented Nov 6, 2018

The upstream seems to have fixed the issue. Anyone tested it?

@johngalambos
Copy link

@Congee I tried it last night and Deoplete completion was working in neovim. The completion suggestion list was pretty huge though--I think there may be some other initializationOptions that need to be pushed in via settings similar to the VSCode configuration (see here: https://github.com/Microsoft/vscode-python/blob/efa175ca29476469136c07c783f6cbd28a976ff0/src/client/activation/languageServer/languageServer.ts#L280-L286) . I haven't explored this yet though. The following .settings file worked for me (I could probably clean this up a bit and make it Python specific):

{
  "enabled": true,
  "initializationOptions": {
    "displayOptions": {
      "preferredFormat": "plaintext",
      "trimDocumentationLines": true,
      "maxDocumentationLineLength": 0,
      "trimDocumentationText": true,
      "maxDocumentationTextLength": 0
    },
    "interpreter": {
      "properties": {
        "InterpreterPath": "C:/Apps/Miniconda3/envs/neovim3/python.exe",
        "UseDefaultDatabase": true,
        "Version": "3.6"
      }
    }
  }
}

@Congee
Copy link

Congee commented Nov 8, 2018

@johngalambos Thank you for your .vim/settings.json config file 🎉🎉🎉🎉🎉🎉🎉

@shri3k
Copy link

shri3k commented Mar 17, 2019

@hanspinckaers sorry to ping you here but I'm facing an issue similar to your original one. Could you please tell me where you placed your settings.json? I have my on ~/.local/share/nvim/settings.json but apparently it's not working. I'm still getting the same error 😞.

@hanspinckaers
Copy link
Author

Did you set let g:LanguageClient_settingsPath='~/.local/share/nvim/settings.json'? I found it outcommented in my vimrc. However I'm not sure, I'm using https://github.com/prabirshrestha/vim-lsp now which seems to handle the errors in the pyls server better.

@shri3k
Copy link

shri3k commented Mar 17, 2019

I went ahead and added let g:LanguageClient_settingsPath=expand('~/.local/share/nvim/settings.json') but getting the same error even though I do see it getting loaded in the log. I think I'm just going to use https://github.com/palantir/python-language-server LS instead of trying to get Microsoft's working.

Edit: It looks like that did it!! There was something wrong with the way I built my binaries that seemed to have caused this. I dropped in this binary instead and it's working flawlessly now. Thank you so much for your help.

@mjlbach
Copy link

mjlbach commented Apr 1, 2019

I'm still having trouble getting code completions to show up.

"Add global settings
let g:LanguageClient_settingsPath=expand('~/.config/nvim/settings_mpls.json')

"Configure LSP
let g:LanguageClient_serverCommands = {
    \ 'rust': ['rls'],
    \ 'python': ['dotnet', 'exec', '/Users/michael/.config/coc/extensions/coc-python- 
      data/languageServer.0.2.38/Microsoft.Python.LanguageServer.dll'],
    \ 'cpp': ['cquery', '--log-file=/tmp/cq.log'],
    \ 'c': ['cquery', '--log-file=/tmp/cq.log'],
    \ }

And my settings.json

{
  "enabled": true,
  "initializationOptions": {
"displayOptions": {
  "preferredFormat": "plaintext",
  "trimDocumentationLines": true,
  "maxDocumentationLineLength": 0,
  "trimDocumentationText": true,
  "maxDocumentationTextLength": 0
},
"interpreter": {
  "properties": {
    "InterpreterPath": "/usr/local/bin/python3",
    "UseDefaultDatabase": true,
    "Version": "3.7"
  }
}
  }
}

Here is my log file

@gotgenes
Copy link

gotgenes commented Jul 25, 2019

Does anybody have this working? Like @hanspinckaers, I'm seeing a lot of messages like:

ERROR unnamed src/rpchandler.rs:13 Error handling message: data did not match any variant of untagged enum CompletionResponse

My LanguageClient settings in my ~/.vimrc

" LanguageClient configuration
let g:LanguageClient_loggingLevel = 'INFO'
let g:LanguageClient_loggingFile = expand('~/languageclient.log')
let g:LanguageClient_serverCommands = {
      \ 'python': ['dotnet', 'exec', '/Users/chris.lasher/python-language-server/output/bin/Release/Microsoft.Python.LanguageServer.dll']
      \ }

I am using Shougo/deoplete.nvim for completion.

My ~/.vim/settings.json:

{
  "enabled": true,
  "initializationOptions": {
    "displayOptions": {
      "preferredFormat": "plaintext",
      "trimDocumentationLines": true,
      "maxDocumentationLineLength": 0,
      "trimDocumentationText": true,
      "maxDocumentationTextLength": 0
    },
    "interpreter": {
      "properties": {
        "InterpreterPath": "/usr/local/bin/python3.7",
        "UseDefaultDatabase": true,
        "Version": "3.7"
      }
    }
  }
}

DLL created by cloning microsoft/python-language-server into $HOME (current commit f30603826b887ad5f70a5a414235b2d019c32c1d), then

cd ~/python-language-server/src
dotnet build -c Release

Here is the content of foo.py

import logging

logging.getLogge

With GA, go to the last line, and edit from the end, triggering completion. Here are the last results coming out of the server:

15:28:26 INFO reader-Some("python") src/rpcclient.rs:169 <= Some("python") {"jsonrpc":"2.0","result":{"isIncomplete":false,"items":[{"label":"getLevelName","kind":3,"documentation":{"kind":"plaintext","value":"getLevelName(level) -> str\n\nReturn the textual representation of logging level 'level'.\n\nIf the level is one of the predefined levels (CRITICAL, ERROR, WARNING,\nINFO, DEBUG) then you get the corresponding string. If you have\nassociated levels with names using addLevelName then the name you have\nassociated with 'level' is returned.\n\nIf a numeric value corresponding to one of the defined levels is passed\nin, the corresponding string representation is returned.\n\nOtherwise, the string \"Level %s\" % level is returned."},"sortText":"1","insertText":"getLevelName","insertTextFormat":1},{"label":"addLevelName","kind":3,"documentation":{"kind":"plaintext","value":"addLevelName(level, levelName)\n\nAssociate 'levelName' with 'level'.\n\nThis is used when converting levels to text during message formatting."},"sortText":"1","insertText":"addLevelName","insertTextFormat":1},{"label":"<lambda>","kind":3,"documentation":{"kind":"plaintext","value":"<lambda>()"},"sortText":"2","insertText":"<lambda>","insertTextFormat":1},{"label":"currentframe","kind":3,"documentation":{"kind":"plaintext","value":"<lambda>()"},"sortText":"1","insertText":"currentframe","insertTextFormat":1},{"label":"_checkLevel","kind":3,"documentation":{"kind":"plaintext","value":"_checkLevel(level)"},"sortText":"2","insertText":"_checkLevel","insertTextFormat":1},{"label":"_acquireLock","kind":3,"documentation":{"kind":"plaintext","value":"_acquireLock()\n\nAcquire the module-level lock for serializing access to shared data.\n\nThis should be released with _releaseLock()."},"sortText":"2","insertText":"_acquireLock","insertTextFormat":1},{"label":"_releaseLock","kind":3,"documentation":{"kind":"plaintext","value":"_releaseLock()\n\nRelease the module-level lock acquired by calling _acquireLock()."},"sortText":"2","insertText":"_releaseLock","insertTextFormat":1},{"label":"_register_at_fork_reinit_lock","kind":3,"documentation":{"kind":"plaintext","value":"_register_at_fork_reinit_lock(instance)"},"sortText":"2","insertText":"_register_at_fork_reinit_lock","insertTextFormat":1},{"label":"_after_at_fork_child_reinit_locks","kind":3,"documentation":{"kind":"plaintext","value":"_after_at_fork_child_reinit_locks()"},"sortText":"2","insertText":"_after_at_fork_child_reinit_locks","insertTextFormat":1},{"label":"LogRecord","kind":7,"documentation":{"kind":"plaintext","value":"class LogRecord\n\nA LogRecord instance represents an event being logged.\n\nLogRecord instances are created every time something is logged. They\ncontain all the information pertinent to the event being logged. The\nmain information passed in is in msg and args, which are combined\nusing str(msg) % args to create the message field of the record. The\nrecord also includes information such as when the record was created,\nthe source line where the logging call was made, and any exception\ninformation to be logged."},"sortText":"1","insertText":"LogRecord","insertTextFormat":1},{"label":"setLogRecordFactory","kind":3,"documentation":{"kind":"plaintext","value":"setLogRecordFactory(factory)\n\nSet the factory to be used when instantiating a log record.\n\n:param factory: A callable which will be called to instantiate\na log record."},"sortText":"1","insertText":"setLogRecordFactory","insertTextFormat":1},{"label":"getLogRecordFactory","kind":3,"documentation":{"kind":"plaintext","value":"getLogRecordFactory() -> LogRecord\n\nReturn the factory to be used when instantiating a log record."},"sortText":"1","insertText":"getLogRecordFactory","insertTextFormat":1},{"label":"makeLogRecord","kind":3,"documentation":{"kind":"plaintext","value":"makeLogRecord(dict) -> LogRecord\n\nMake a LogRecord whose attributes are defined by the specified dictionary,\nThis function is useful for converting a logging event received over\na socket connection (which is sent as a dictionary) into a LogRecord\ninstance."},"sortText":"1","insertText":"makeLogRecord","insertTextFormat":1},{"label":"PercentStyle","kind":7,"documentation":{"kind":"plaintext","value":"class PercentStyle"},"sortText":"1","insertText":"PercentStyle","insertTextFormat":1},{"label":"StrFormatStyle","kind":7,"documentation":{"kind":"plaintext","value":"class StrFormatStyle"},"sortText":"1","insertText":"StrFormatStyle","insertTextFormat":1},{"label":"StringTemplateStyle","kind":7,"documentation":{"kind":"plaintext","value":"class StringTemplateStyle"},"sortText":"1","insertText":"StringTemplateStyle","insertTextFormat":1},{"label":"Formatter","kind":7,"documentation":{"kind":"plaintext","value":"class Formatter\n\nFormatter instances are used to convert a LogRecord to text.\n\nFormatters need to know how a LogRecord is constructed. They are\nresponsible for converting a LogRecord to (usually) a string which can\nbe interpreted by either a human or an external system. The base Formatter\nallows a formatting string to be specified. If none is supplied, the\nthe style-dependent default value, \"%(message)s\", \"{message}\", or\n\"${message}\", is used.\n\nThe Formatter can be initialized with a format string which makes use of\nknowledge of the LogRecord attributes - e.g. the default value mentioned\nabove makes use of the fact that the user's message and arguments are pre-\nformatted into a LogRecord's message attribute. Currently, the useful\nattributes in a LogRecord are described by:\n\n%(name)s            Name of the logger (logging channel)\n%(levelno)s         Numeric logging level for the message (DEBUG, INFO,\n                    WARNING, ERROR, CRITICAL)\n%(levelname)s       Text logging level for the message (\"DEBUG\", \"INFO\",\n                    \"WARNING\", \"ERROR\", \"CRITICAL\")\n%(pathname)s        Full pathname of the source file where the logging\n                    call was issued (if available)\n%(filename)s        Filename portion of pathname\n%(module)s          Module (name portion of filename)\n%(lineno)d          Source line number where the logging call was issued\n                    (if available)\n%(funcName)s        Function name\n%(created)f         Time when the LogRecord was created (time.time()\n                    return value)\n%(asctime)s         Textual time when the LogRecord was created\n%(msecs)d           Millisecond portion of the creation time\n%(relativeCreated)d Time in milliseconds when the LogRecord was created,\n                    relative to the time the logging module was loaded\n                    (typically at application startup time)\n%(thread)d          Thread ID (if available)\n%(threadName)s      Thread name (if available)\n%(process)d         Process ID (if available)\n%(message)s         The result of record.getMessage(), computed just as\n                    the record is emitted"},"sortText":"1","insertText":"Formatter","insertTextFormat":1},{"label":"BufferingFormatter","kind":7,"documentation":{"kind":"plaintext","value":"class BufferingFormatter\n\nA formatter suitable for formatting a number of records."},"sortText":"1","insertText":"BufferingFormatter","insertTextFormat":1},{"label":"Filter","kind":7,"documentation":{"kind":"plaintext","value":"class Filter\n\nFilter instances are used to perform arbitrary filtering of LogRecords.\n\nLoggers and Handlers can optionally use Filter instances to filter\nrecords as desired. The base filter class only allows events which are\nbelow a certain point in the logger hierarchy. For example, a filter\ninitialized with \"A.B\" will allow events logged by loggers \"A.B\",\n\"A.B.C\", \"A.B.C.D\", \"A.B.D\" etc. but not \"A.BB\", \"B.A.B\" etc. If\ninitialized with the empty string, all events are passed."},"sortText":"1","insertText":"Filter","insertTextFormat":1},{"label":"Filterer","kind":7,"documentation":{"kind":"plaintext","value":"class Filterer\n\nA base class for loggers and handlers which allows them to share\ncommon code."},"sortText":"1","insertText":"Filterer","insertTextFormat":1},{"label":"_removeHandlerRef","kind":3,"documentation":{"kind":"plaintext","value":"_removeHandlerRef(wr)\n\nRemove a handler reference from the internal cleanup list."},"sortText":"2","insertText":"_removeHandlerRef","insertTextFormat":1},{"label":"_addHandlerRef","kind":3,"documentation":{"kind":"plaintext","value":"_addHandlerRef(handler)\n\nAdd a handler to the internal cleanup list using a weak reference."},"sortText":"2","insertText":"_addHandlerRef","insertTextFormat":1},{"label":"Handler","kind":7,"documentation":{"kind":"plaintext","value":"class Handler\n\nHandler instances dispatch logging events to specific destinations.\n\nThe base handler class. Acts as a placeholder which defines the Handler\ninterface. Handlers can optionally use Formatter instances to format\nrecords as desired. By default, no formatter is specified; in this case,\nthe 'raw' message as determined by record.message is logged."},"sortText":"1","insertText":"Handler","insertTextFormat":1},{"label":"StreamHandler","kind":7,"documentation":{"kind":"plaintext","value":"class StreamHandler\n\nA handler class which writes logging records, appropriately formatted,\nto a stream. Note that this class does not close the stream, as\nsys.stdout or sys.stderr may be used."},"sortText":"1","insertText":"StreamHandler","insertTextFormat":1},{"label":"FileHandler","kind":7,"documentation":{"kind":"plaintext","value":"class FileHandler\n\nA handler class which writes formatted logging records to disk files."},"sortText":"1","insertText":"FileHandler","insertTextFormat":1},{"label":"_StderrHandler","kind":7,"documentation":{"kind":"plaintext","value":"class _StderrHandler\n\nThis class is like a StreamHandler using sys.stderr, but always uses\nwhatever sys.stderr is currently set to rather than the value of\nsys.stderr at handler construction time."},"sortText":"2","insertText":"_StderrHandler","insertTextFormat":1},{"label":"PlaceHolder","kind":7,"documentation":{"kind":"plaintext","value":"class PlaceHolder\n\nPlaceHolder instances are used in the Manager logger hierarchy to take\nthe place of nodes for which no loggers have been defined. This class is\nintended for internal use only and not as part of the public API."},"sortText":"1","insertText":"PlaceHolder","insertTextFormat":1},{"label":"setLoggerClass","kind":3,"documentation":{"kind":"plaintext","value":"setLoggerClass(klass)\n\nSet the class to be used when instantiating a logger. The class should\ndefine __init__() such that only a name argument is required, and the\n__init__() should call Logger.__init__()"},"sortText":"1","insertText":"setLoggerClass","insertTextFormat":1},{"label":"getLoggerClass","kind":3,"documentation":{"kind":"plaintext","value":"getLoggerClass() -> Logger\n\nReturn the class to be used when instantiating a logger."},"sortText":"1","insertText":"getLoggerClass","insertTextFormat":1},{"label":"Manager","kind":7,"documentation":{"kind":"plaintext","value":"class Manager\n\nThere is [under normal circumstances] just one Manager instance, which\nholds the hierarchy of loggers."},"sortText":"1","insertText":"Manager","insertTextFormat":1},{"label":"Logger","kind":7,"documentation":{"kind":"plaintext","value":"class Logger\n\nInstances of the Logger class represent a single logging channel. A\n\"logging channel\" indicates an area of an application. Exactly how an\n\"area\" is defined is up to the application developer. Since an\napplication can have any number of areas, logging channels are identified\nby a unique string. Application areas can be nested (e.g. an area\nof \"input processing\" might include sub-areas \"read CSV files\", \"read\nXLS files\" and \"read Gnumeric files\"). To cater for this natural nesting,\nchannel names are organized into a namespace hierarchy where levels are\nseparated by periods, much like the Java or Python package namespace. So\nin the instance given above, channel names might be \"input\" for the upper\nlevel, and \"input.csv\", \"input.xls\" and \"input.gnu\" for the sub-levels.\nThere is no arbitrary limit to the depth of nesting."},"sortText":"1","insertText":"Logger","insertTextFormat":1},{"label":"RootLogger","kind":7,"documentation":{"kind":"plaintext","value":"class RootLogger\n\nA root logger is not that different to any other logger, except that\nit must have a logging level and there is only one instance of it in\nthe hierarchy."},"sortText":"1","insertText":"RootLogger","insertTextFormat":1},{"label":"LoggerAdapter","kind":7,"documentation":{"kind":"plaintext","value":"class LoggerAdapter\n\nAn adapter for loggers which makes it easier to specify contextual\ninformation in logging output."},"sortText":"1","insertText":"LoggerAdapter","insertTextFormat":1},{"label":"basicConfig","kind":3,"documentation":{"kind":"plaintext","value":"basicConfig(kwargs)\n\nDo basic configuration for the logging system.\n\nThis function does nothing if the root logger already has handlers\nconfigured. It is a convenience method intended for use by simple scripts\nto do one-shot configuration of the logging package.\n\nThe default behaviour is to create a StreamHandler which writes to\nsys.stderr, set a formatter using the BASIC_FORMAT format string, and\nadd the handler to the root logger.\n\nA number of optional keyword arguments may be specified, which can alter\nthe default behaviour.\n\nfilename  Specifies that a FileHandler be created, using the specified\n          filename, rather than a StreamHandler.\nfilemode  Specifies the mode to open the file, if filename is specified\n          (if filemode is unspecified, it defaults to 'a').\nformat    Use the specified format string for the handler.\ndatefmt   Use the specified date/time format.\nstyle     If a format string is specified, use this to specify the\n          type of format string (possible values '%', '{', '$', for\n          %-formatting, :meth:`str.format` and :class:`string.Template`\n          - defaults to '%').\nlevel     Set the root logger level to the specified level.\nstream    Use the specified stream to initialize the StreamHandler. Note\n          that this argument is incompatible with 'filename' - if both\n          are present, 'stream' is ignored.\nhandlers  If specified, this should be an iterable of already created\n          handlers, which will be added to the root handler. Any handler\n          in the list which does not have a formatter assigned will be\n          assigned the formatter created in this function.\n\nNote that you could specify a stream created using open(filename, mode)\nrather than passing the filename and mode in. However, it should be\nremembered that StreamHandler does not close its stream (since it may be\nusing sys.stdout or sys.stderr), whereas FileHandler closes its stream\nwhen the handler is closed.\n\n.. versionchanged:: 3.2\n   Added the ``style`` parameter.\n\n.. versionchanged:: 3.3\n   Added the ``handlers`` parameter. A ``ValueError`` is now thrown for\n   incompatible arguments (e.g. ``handlers`` specified together with\n   ``filename``/``filemode``, or ``filename``/``filemode`` specified\n   together with ``stream``, or ``handlers`` specified together with\n   ``stream``."},"sortText":"1","insertText":"basicConfig","insertTextFormat":1},{"label":"getLogger","kind":3,"documentation":{"kind":"plaintext","value":"getLogger(name=None)\n\nReturn a logger with the specified name, creating it if necessary.\n\nIf no name is specified, return the root logger."},"sortText":"1","insertText":"getLogger","insertTextFormat":1},{"label":"critical","kind":3,"documentation":{"kind":"plaintext","value":"critical(msg, args, kwargs)\n\nLog a message with severity 'CRITICAL' on the root logger. If the logger\nhas no handlers, call basicConfig() to add a console handler with a\npre-defined format."},"sortText":"1","insertText":"critical","insertTextFormat":1},{"label":"error","kind":3,"documentation":{"kind":"plaintext","value":"error(msg, args, kwargs)\n\nLog a message with severity 'ERROR' on the root logger. If the logger has\nno handlers, call basicConfig() to add a console handler with a pre-defined\nformat."},"sortText":"1","insertText":"error","insertTextFormat":1},{"label":"exception","kind":3,"documentation":{"kind":"plaintext","value":"exception(msg, args, exc_info=True, kwargs)\n\nLog a message with severity 'ERROR' on the root logger, with exception\ninformation. If the logger has no handlers, basicConfig() is called to add\na console handler with a pre-defined format."},"sortText":"1","insertText":"exception","insertTextFormat":1},{"label":"warning","kind":3,"documentation":{"kind":"plaintext","value":"warning(msg, args, kwargs)\n\nLog a message with severity 'WARNING' on the root logger. If the logger has\nno handlers, call basicConfig() to add a console handler with a pre-defined\nformat."},"sortText":"1","insertText":"warning","insertTextFormat":1},{"label":"warn","kind":3,"documentation":{"kind":"plaintext","value":"warn(msg, args, kwargs)"},"sortText":"1","insertText":"warn","insertTextFormat":1},{"label":"info","kind":3,"documentation":{"kind":"plaintext","value":"info(msg, args, kwargs)\n\nLog a message with severity 'INFO' on the root logger. If the logger has\nno handlers, call basicConfig() to add a console handler with a pre-defined\nformat."},"sortText":"1","insertText":"info","insertTextFormat":1},{"label":"debug","kind":3,"documentation":{"kind":"plaintext","value":"debug(msg, args, kwargs)\n\nLog a message with severity 'DEBUG' on the root logger. If the logger has\nno handlers, call basicConfig() to add a console handler with a pre-defined\nformat."},"sortText":"1","insertText":"debug","insertTextFormat":1},{"label":"log","kind":3,"documentation":{"kind":"plaintext","value":"log(level, msg, args, kwargs)\n\nLog 'msg % args' with the integer severity 'level' on the root logger. If\nthe logger has no handlers, call basicConfig() to add a console handler\nwith a pre-defined format."},"sortText":"1","insertText":"log","insertTextFormat":1},{"label":"disable","kind":3,"documentation":{"kind":"plaintext","value":"disable(level=CRITICAL)\n\nDisable all logging calls of severity 'level' and below."},"sortText":"1","insertText":"disable","insertTextFormat":1},{"label":"shutdown","kind":3,"documentation":{"kind":"plaintext","value":"shutdown(handlerList=_handlerList)\n\nPerform any cleanup actions in the logging system (e.g. flushing\nbuffers).\n\nShould be called at application exit."},"sortText":"1","insertText":"shutdown","insertTextFormat":1},{"label":"NullHandler","kind":7,"documentation":{"kind":"plaintext","value":"class NullHandler\n\nThis handler does nothing. It's intended to be used to avoid the\n\"No handlers could be found for logger XXX\" one-off warning. This is\nimportant for library code, which may contain code to log events. If a user\nof the library does not configure logging, the one-off warning might be\nproduced; to avoid this, the library developer simply needs to instantiate\na NullHandler and add it to the top-level logger of the library module or\npackage."},"sortText":"1","insertText":"NullHandler","insertTextFormat":1},{"label":"_showwarning","kind":3,"documentation":{"kind":"plaintext","value":"_showwarning(message, category, filename, lineno, file=None, line=None)\n\nImplementation of showwarnings which redirects to logging, which will first\ncheck to see if the file parameter is None. If a file is specified, it will\ndelegate to the original warnings implementation of showwarning. Otherwise,\nit will call warnings.formatwarning and will log the resulting string to a\nwarnings logger named \"py.warnings\" with level logging.WARNING."},"sortText":"2","insertText":"_showwarning","insertTextFormat":1},{"label":"captureWarnings","kind":3,"documentation":{"kind":"plaintext","value":"captureWarnings(capture)\n\nIf capture is true, redirect all warnings to the logging package.\nIf capture is False, ensure that warnings are not redirected to logging\nbut to their original destinations."},"sortText":"1","insertText":"captureWarnings","insertTextFormat":1},{"label":"_logRecordFactory","kind":7,"documentation":{"kind":"plaintext","value":"class LogRecord\n\nA LogRecord instance represents an event being logged.\n\nLogRecord instances are created every time something is logged. They\ncontain all the information pertinent to the event being logged. The\nmain information passed in is in msg and args, which are combined\nusing str(msg) % args to create the message field of the record. The\nrecord also includes information such as when the record was created,\nthe source line where the logging call was made, and any exception\ninformation to be logged."},"sortText":"2","insertText":"_logRecordFactory","insertTextFormat":1},{"label":"_loggerClass","kind":7,"documentation":{"kind":"plaintext","value":"class Logger\n\nInstances of the Logger class represent a single logging channel. A\n\"logging channel\" indicates an area of an application. Exactly how an\n\"area\" is defined is up to the application developer. Since an\napplication can have any number of areas, logging channels are identified\nby a unique string. Application areas can be nested (e.g. an area\nof \"input processing\" might include sub-areas \"read CSV files\", \"read\nXLS files\" and \"read Gnumeric files\"). To cater for this natural nesting,\nchannel names are organized into a namespace hierarchy where levels are\nseparated by periods, much like the Java or Python package namespace. So\nin the instance given above, channel names might be \"input\" for the upper\nlevel, and \"input.csv\", \"input.xls\" and \"input.gnu\" for the sub-levels.\nThere is no arbitrary limit to the depth of nesting."},"sortText":"2","insertText":"_loggerClass","insertTextFormat":1},{"label":"sys","kind":9,"documentation":{"kind":"plaintext","value":"module sys\n\nThis module provides access to some objects used or maintained by the\ninterpreter and to functions that interact strongly with the interpreter.\n\nDynamic objects:\n\nargv -- command line arguments; argv[0] is the script pathname if known\npath -- module search path; path[0] is the script directory, else ''\nmodules -- dictionary of loaded modules\n\ndisplayhook -- called to show results in an interactive session\nexcepthook -- called to handle any uncaught exception other than SystemExit\n  To customize printing in an interactive session or to install a custom\n  top-level exception handler, assign other functions to replace these.\n\nstdin -- standard input file object; used by input()\nstdout -- standard output file object; used by print()\nstderr -- standard error object; used for error messages\n  By assigning other file objects (or objects that behave like files)\n  to these, it is possible to redirect all of the interpreter's I/O.\n\nlast_type -- type of last uncaught exception\nlast_value -- value of last uncaught exception\nlast_traceback -- traceback of last uncaught exception\n  These three are only available in an interactive session after a\n  traceback has been printed.\n\nStatic objects:\n\nbuiltin_module_names -- tuple of module names built into this interpreter\ncopyright -- copyright notice pertaining to this interpreter\nexec_prefix -- prefix used to find the machine-specific Python library\nexecutable -- absolute path of the executable binary of the Python interpreter\nfloat_info -- a struct sequence with information about the float implementation.\nfloat_repr_style -- string indicating the style of repr() output for floats\nhash_info -- a struct sequence with information about the hash algorithm.\nhexversion -- version information encoded as a single integer\nimplementation -- Python implementation information.\nint_info -- a struct sequence with information about the int implementation.\nmaxsize -- the largest supported length of containers.\nmaxunicode -- the value of the largest Unicode code point\nplatform -- platform identifier\nprefix -- prefix used to find the Python library\nthread_info -- a struct sequence with information about the thread implementation.\nversion -- the version of this interpreter as a string\nversion_info -- version information as a named tuple\n__stdin__ -- the original stdin; don't touch!\n__stdout__ -- the original stdout; don't touch!\n__stderr__ -- the original stderr; don't touch!\n__displayhook__ -- the original displayhook; don't touch!\n__excepthook__ -- the original excepthook; don't touch!\n\nFunctions:\n\ndisplayhook() -- print an object to the screen, and save it in builtins._\nexcepthook() -- print an exception and its traceback to sys.stderr\nexc_info() -- return thread-safe information about the current exception\nexit() -- exit the interpreter by raising SystemExit\ngetdlopenflags() -- returns flags to be used for dlopen() calls\ngetprofile() -- get the global profiling function\ngetrefcount() -- return the reference count for an object (plus one :-)\ngetrecursionlimit() -- return the max recursion depth for the interpreter\ngetsizeof() -- return the size of an object in bytes\ngettrace() -- get the global debug tracing function\nsetcheckinterval() -- control how often the interpreter checks for events\nsetdlopenflags() -- set the flags to be used for dlopen() calls\nsetprofile() -- set the global profiling function\nsetrecursionlimit() -- set the max recursion depth for the interpreter\nsettrace() -- set the global debug tracing function"},"sortText":"1","insertText":"sys","insertTextFormat":1},{"label":"os","kind":9,"documentation":{"kind":"plaintext","value":"module os\n\nThis exports:\n  - all functions from posix or nt, e.g. unlink, stat, etc.\n  - os.path is either posixpath or ntpath\n  - os.name is either 'posix' or 'nt'\n  - os.curdir is a string representing the current directory (always '.')\n  - os.pardir is a string representing the parent directory (always '..')\n  - os.sep is the (or a most common) pathname separator ('/' or '\\\\')\n  - os.extsep is the extension separator (always '.')\n  - os.altsep is the alternate pathname separator (None or '/')\n  - os.pathsep is the component separator used in $PATH etc\n  - os.linesep is the line separator in text files ('\\r' or '\\n' or '\\r\\n')\n  - os.defpath is the default search path for executables\n  - os.devnull is the file path of the null device ('/dev/null', etc.)\n\nPrograms that import and use 'os' stand a better chance of being\nportable between different platforms.  Of course, they must then\nonly use functions that are defined by all platforms (e.g., unlink\nand opendir), and leave all pathname manipulation to os.path\n(e.g., split and join)."},"sortText":"1","insertText":"os","insertTextFormat":1},{"label":"time","kind":9,"documentation":{"kind":"plaintext","value":"module time\n\nThis module provides various functions to manipulate time values.\n\nThere are two standard representations of time.  One is the number\nof seconds since the Epoch, in UTC (a.k.a. GMT).  It may be an integer\nor a floating point number (to represent fractions of seconds).\nThe Epoch is system-defined; on Unix, it is generally January 1st, 1970.\nThe actual value can be retrieved by calling gmtime(0).\n\nThe other representation is a tuple of 9 integers giving local time.\nThe tuple items are:\n  year (including century, e.g. 1998)\n  month (1-12)\n  day (1-31)\n  hours (0-23)\n  minutes (0-59)\n  seconds (0-59)\n  weekday (0-6, Monday is 0)\n  Julian day (day in the year, 1-366)\n  DST (Daylight Savings Time) flag (-1, 0 or 1)\nIf the DST flag is 0, the time is given in the regular time zone;\nif it is 1, the time is given in the DST time zone;\nif it is -1, mktime() should guess based on the date and time."},"sortText":"1","insertText":"time","insertTextFormat":1},{"label":"io","kind":9,"documentation":{"kind":"plaintext","value":"module io\n\nThe io module provides the Python interfaces to stream handling. The\nbuiltin open function is defined in this module.\n\nAt the top of the I/O hierarchy is the abstract base class IOBase. It\ndefines the basic interface to a stream. Note, however, that there is no\nseparation between reading and writing to streams; implementations are\nallowed to raise an OSError if they do not support a given operation.\n\nExtending IOBase is RawIOBase which deals simply with the reading and\nwriting of raw bytes to a stream. FileIO subclasses RawIOBase to provide\nan interface to OS files.\n\nBufferedIOBase deals with buffering on a raw byte stream (RawIOBase). Its\nsubclasses, BufferedWriter, BufferedReader, and BufferedRWPair buffer\nstreams that are readable, writable, and both respectively.\nBufferedRandom provides a buffered interface to random access\nstreams. BytesIO is a simple stream of in-memory bytes.\n\nAnother IOBase subclass, TextIOBase, deals with the encoding and decoding\nof streams into text. TextIOWrapper, which extends it, is a buffered text\ninterface to a buffered raw stream (`BufferedIOBase`). Finally, StringIO\nis an in-memory stream for text.\n\nArgument names are not part of the specification, and only the arguments\nof open() are intended to be used as keyword arguments.\n\ndata:\n\nDEFAULT_BUFFER_SIZE\n\n   An int containing the default buffer size used by the module's buffered\n   I/O classes. open() uses the file's blksize (as obtained by os.stat) if\n   possible."},"sortText":"1","insertText":"io","insertTextFormat":1},{"label":"traceback","kind":9,"documentation":{"kind":"plaintext","value":"module traceback\n\nExtract, format and print information about Python stack traces."},"sortText":"1","insertText":"traceback","insertTextFormat":1},{"label":"warnings","kind":9,"documentation":{"kind":"plaintext","value":"module warnings\n\nPython part of the warnings subsystem."},"sortText":"1","insertText":"warnings","insertTextFormat":1},{"label":"weakref","kind":9,"documentation":{"kind":"plaintext","value":"module weakref\n\nThis module is an implementation of PEP 205:\n\nhttp://www.python.org/dev/peps/pep-0205/"},"sortText":"1","insertText":"weakref","insertTextFormat":1},{"label":"collections","kind":9,"documentation":{"kind":"plaintext","value":"module collections\n\nalternatives to Python's general purpose built-in containers, dict,\nlist, set, and tuple.\n\n* namedtuple   factory function for creating tuple subclasses with named fields\n* deque        list-like container with fast appends and pops on either end\n* ChainMap     dict-like class for creating a single view of multiple mappings\n* Counter      dict subclass for counting hashable objects\n* OrderedDict  dict subclass that remembers the order entries were added\n* defaultdict  dict subclass that calls a factory function to supply missing values\n* UserDict     wrapper around dictionary objects for easier dict subclassing\n* UserList     wrapper around list objects for easier list subclassing\n* UserString   wrapper around string objects for easier string subclassing"},"sortText":"1","insertText":"collections","insertTextFormat":1},{"label":"Template","kind":7,"documentation":{"kind":"plaintext","value":"class Template\n\nA string class for supporting $-substitutions."},"sortText":"1","insertText":"Template","insertTextFormat":1},{"label":"__all__","kind":12,"documentation":{"kind":"plaintext","value":"__all__: list"},"sortText":"2","insertText":"__all__","insertTextFormat":1},{"label":"threading","kind":9,"documentation":{"kind":"plaintext","value":"module threading\n\nThread module emulating a subset of Java's threading model."},"sortText":"1","insertText":"threading","insertTextFormat":1},{"label":"__author__","kind":12,"documentation":{"kind":"plaintext","value":"__author__: str"},"sortText":"2","insertText":"__author__","insertTextFormat":1},{"label":"__status__","kind":12,"documentation":{"kind":"plaintext","value":"__status__: str"},"sortText":"2","insertText":"__status__","insertTextFormat":1},{"label":"__version__","kind":12,"documentation":{"kind":"plaintext","value":"__version__: str"},"sortText":"2","insertText":"__version__","insertTextFormat":1},{"label":"__date__","kind":12,"documentation":{"kind":"plaintext","value":"__date__: str"},"sortText":"2","insertText":"__date__","insertTextFormat":1},{"label":"_startTime","kind":12,"documentation":{"kind":"plaintext","value":"_startTime: float"},"sortText":"2","insertText":"_startTime","insertTextFormat":1},{"label":"raiseExceptions","kind":12,"documentation":{"kind":"plaintext","value":"raiseExceptions: bool"},"sortText":"1","insertText":"raiseExceptions","insertTextFormat":1},{"label":"logThreads","kind":12,"documentation":{"kind":"plaintext","value":"logThreads: bool"},"sortText":"1","insertText":"logThreads","insertTextFormat":1},{"label":"logMultiprocessing","kind":12,"documentation":{"kind":"plaintext","value":"logMultiprocessing: bool"},"sortText":"1","insertText":"logMultiprocessing","insertTextFormat":1},{"label":"logProcesses","kind":12,"documentation":{"kind":"plaintext","value":"logProcesses: bool"},"sortText":"1","insertText":"logProcesses","insertTextFormat":1},{"label":"CRITICAL","kind":12,"documentation":{"kind":"plaintext","value":"CRITICAL: int"},"sortText":"1","insertText":"CRITICAL","insertTextFormat":1},{"label":"FATAL","kind":12,"documentation":{"kind":"plaintext","value":"FATAL: int"},"sortText":"1","insertText":"FATAL","insertTextFormat":1},{"label":"ERROR","kind":12,"documentation":{"kind":"plaintext","value":"ERROR: int"},"sortText":"1","insertText":"ERROR","insertTextFormat":1},{"label":"WARNING","kind":12,"documentation":{"kind":"plaintext","value":"WARNING: int"},"sortText":"1","insertText":"WARNING","insertTextFormat":1},{"label":"WARN","kind":12,"documentation":{"kind":"plaintext","value":"WARN: int"},"sortText":"1","insertText":"WARN","insertTextFormat":1},{"label":"INFO","kind":12,"documentation":{"kind":"plaintext","value":"INFO: int"},"sortText":"1","insertText":"INFO","insertTextFormat":1},{"label":"DEBUG","kind":12,"documentation":{"kind":"plaintext","value":"DEBUG: int"},"sortText":"1","insertText":"DEBUG","insertTextFormat":1},{"label":"NOTSET","kind":12,"documentation":{"kind":"plaintext","value":"NOTSET: int"},"sortText":"1","insertText":"NOTSET","insertTextFormat":1},{"label":"_levelToName","kind":12,"documentation":{"kind":"plaintext","value":"_levelToName: dict"},"sortText":"2","insertText":"_levelToName","insertTextFormat":1},{"label":"_nameToLevel","kind":12,"documentation":{"kind":"plaintext","value":"_nameToLevel: dict"},"sortText":"2","insertText":"_nameToLevel","insertTextFormat":1},{"label":"_srcfile","kind":0,"sortText":"2","insertText":"_srcfile","insertTextFormat":1},{"label":"_lock","kind":12,"documentation":{"kind":"plaintext","value":"_lock: Union[_RLock, NoneType]"},"sortText":"2","insertText":"_lock","insertTextFormat":1},{"label":"_at_fork_reinit_lock_weakset","kind":12,"documentation":{"kind":"plaintext","value":"_at_fork_reinit_lock_weakset: WeakSet"},"sortText":"2","insertText":"_at_fork_reinit_lock_weakset","insertTextFormat":1},{"label":"BASIC_FORMAT","kind":12,"documentation":{"kind":"plaintext","value":"BASIC_FORMAT: str"},"sortText":"1","insertText":"BASIC_FORMAT","insertTextFormat":1},{"label":"_STYLES","kind":12,"documentation":{"kind":"plaintext","value":"_STYLES: dict"},"sortText":"2","insertText":"_STYLES","insertTextFormat":1},{"label":"_defaultFormatter","kind":12,"documentation":{"kind":"plaintext","value":"_defaultFormatter: Formatter"},"sortText":"2","insertText":"_defaultFormatter","insertTextFormat":1},{"label":"_handlers","kind":12,"documentation":{"kind":"plaintext","value":"_handlers: WeakValueDictionary"},"sortText":"2","insertText":"_handlers","insertTextFormat":1},{"label":"_handlerList","kind":12,"documentation":{"kind":"plaintext","value":"_handlerList: list"},"sortText":"2","insertText":"_handlerList","insertTextFormat":1},{"label":"_defaultLastResort","kind":12,"documentation":{"kind":"plaintext","value":"_defaultLastResort: _StderrHandler"},"sortText":"2","insertText":"_defaultLastResort","insertTextFormat":1},{"label":"lastResort","kind":12,"documentation":{"kind":"plaintext","value":"lastResort: _StderrHandler"},"sortText":"1","insertText":"lastResort","insertTextFormat":1},{"label":"root","kind":12,"documentation":{"kind":"plaintext","value":"root: RootLogger"},"sortText":"1","insertText":"root","insertTextFormat":1},{"label":"fatal","kind":3,"documentation":{"kind":"plaintext","value":"critical(msg, args, kwargs)\n\nLog a message with severity 'CRITICAL' on the root logger. If the logger\nhas no handlers, call basicConfig() to add a console handler with a\npre-defined format."},"sortText":"1","insertText":"fatal","insertTextFormat":1},{"label":"atexit","kind":9,"documentation":{"kind":"plaintext","value":"module atexit\n\nallow programmer to define multiple exit functions to be executedupon normal program termination.\n\nTwo public functions, register and unregister, are defined."},"sortText":"1","insertText":"atexit","insertTextFormat":1},{"label":"_warnings_showwarning","kind":12,"documentation":{"kind":"plaintext","value":"_warnings_showwarning: NoneType"},"sortText":"2","insertText":"_warnings_showwarning","insertTextFormat":1}]},"id":4}
15:28:26 ERROR unnamed src/rpchandler.rs:13 Error handling message: data did not match any variant of untagged enum CompletionResponse

@dimbleby
Copy link
Contributor

Given the history of this thread, the most likely explanation would seem to be that the server is sending a faulty response.

You can debug per #633 (comment) to try and pin down what the Rust lsp-types library does not like about the message.

@dimbleby
Copy link
Contributor

In particular - I haven't checked, but I like the chances of this being right - this completion item looks suspect:

      {
        "label": "_srcfile",
        "kind": 0,
        "sortText": "2",
        "insertText": "_srcfile",
        "insertTextFormat": 1
      },

0 is not a valid CompletionItemKind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants