swyddfa / esbonio

A language server for working with Sphinx projects.
https://docs.esbon.io/
131 stars 21 forks source link

Unable to recognize esbonio language server's diagnostic message on "Windows" #166

Closed yaegassy closed 3 years ago

yaegassy commented 3 years ago

I'm using esbonio's language server from Vim (coc.nvim), "coc.nvim" is a VSCode-like plug-in for Vim.

I usually use it on macOS, but when I try it on Windows, I can't get the "diagnostics".

"Completion", etc. are working fine.

This is the output of my Vim (coc.nvim) channel log on Windows.

[esbonio.lsp] Workspace root file:///c%3A/Users/yaegassy/esbcheck
[esbonio.lsp] Config dir c:\Users\yaegassy\esbcheck
[esbonio.lsp] Src dir c:\Users\yaegassy\esbcheck
[esbonio.lsp] Build dir C:\Users\yaegassy\AppData\Local\coc\extensions\coc-esbonio-data\sphinx
[esbonio.lsp] Doctree dir C:\Users\yaegassy\AppData\Local\coc\extensions\coc-esbonio-data\sphinx\doctrees
Running Sphinx v3.5.4
loading pickled environment...
done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 0 source files that are out of date
updating environment:
0 added, 0 changed, 0 removed
looking for now-outdated files...
none found
no targets are out of date.
build succeeded.

The HTML pages are in ..\AppData\Local\coc\extensions\coc-esbonio-data\sphinx.
[esbonio.lsp.Directives] Discovered 121 directives
[esbonio.lsp.Directives] Directives: ['attention', 'caution', 'code', 'danger', 'error', 'important', 'note', 'tip', 'hint', 'warning', 'admonition', 'sidebar', 'topic', 'line-block', 'parsed-literal', 'math', 'rubric', 'epigraph', 'highlights', 'pull-quote', 'compound', 'container', 'table', 'csv-table', 'list-table', 'image', 'figure', 'contents', 'sectnum', 'header', 'footer', 'target-notes', 'meta', 'raw', 'include', 'replace', 'unicode', 'class', 'role', 'default-role', 'title', 'date', 'deprecated', 'versionadded', 'versionchanged', 'index', 'default-domain', 'describe', 'object', 'highlight', 'highlightlang', 'code-block', 'sourcecode', 'literalinclude', 'toctree', 'sectionauthor', 'moduleauthor', 'codeauthor', 'seealso', 'tabularcolumns', 'centered', 'acks', 'hlist', 'only', 'cssclass', 'rst-class', 'c:member', 'c:var', 'c:function', 'c:macro', 'c:struct', 'c:union', 'c:enum', 'c:enumerator', 'c:type', 'c:namespace', 'c:namespace-push', 'c:namespace-pop', 'c:alias', 'cpp:class', 'cpp:struct', 'cpp:union', 'cpp:function', 'cpp:member', 'cpp:var', 'cpp:type', 'cpp:concept', 'cpp:enum', 'cpp:enum-struct', 'cpp:enum-class', 'cpp:enumerator', 'cpp:namespace', 'cpp:namespace-push', 'cpp:namespace-pop', 'cpp:alias', 'js:function', 'js:method', 'js:class', 'js:data', 'js:attribute', 'js:module', 'function', 'data', 'exception', 'method', 'classmethod', 'staticmethod', 'attribute', 'module', 'currentmodule', 'decorator', 'decoratormethod', 'rst:directive', 'rst:directive:option', 'rst:role', 'program', 'cmdoption', 'option', 'envvar', 'glossary', 'productionlist']
[esbonio.lsp.Roles] Discovered 84 roles
[esbonio.lsp.Roles] Roles: ['eq', 'command', 'dfn', 'kbd', 'mailheader', 'makevar', 'manpage', 'mimetype', 'newsgroup', 'program', 'regexp', 'download', 'any', 'pep', 'rfc', 'guilabel', 'menuselection', 'file', 'samp', 'abbr', 'abbreviation', 'acronym', 'emphasis', 'literal', 'strong', 'subscript', 'superscript', 'title-reference', 'pep-reference', 'rfc-reference', 'raw', 'code', 'math', 'c:member', 'c:data', 'c:var', 'c:func', 'c:macro', 'c:struct', 'c:union', 'c:enum', 'c:enumerator', 'c:type', 'c:expr', 'c:texpr', 'cpp:any', 'cpp:class', 'cpp:struct', 'cpp:union', 'cpp:func', 'cpp:member', 'cpp:var', 'cpp:type', 'cpp:concept', 'cpp:enum', 'cpp:enumerator', 'cpp:expr', 'cpp:texpr', 'js:func', 'js:meth', 'js:class', 'js:data', 'js:attr', 'js:mod', 'math:numref', 'data', 'exc', 'func', 'class', 'const', 'attr', 'meth', 'mod', 'obj', 'rst:dir', 'rst:role', 'option', 'envvar', 'token', 'term', 'ref', 'numref', 'keyword', 'doc']
[esbonio.lsp.Roles] Discovered 45 target types
[esbonio.lsp.Roles] Target types: {'c:var': ['c:member', 'c:var', 'c:functionParam'], 'c:member': ['c:member', 'c:var', 'c:functionParam'], 'c:data': ['c:member', 'c:var', 'c:functionParam'], 'c:identifier': ['c:member', 'c:var', 'c:function', 'c:macro', 'c:struct', 'c:union', 'c:enum', 'c:enumerator', 'c:type', 'c:functionParam'], 'c:func': ['c:function'], 'c:type': ['c:function', 'c:struct', 'c:union', 'c:enum', 'c:type'], 'c:macro': ['c:macro'], 'c:struct': ['c:struct'], 'c:union': ['c:union'], 'c:enum': ['c:enum'], 'c:enumerator': ['c:enumerator'], 'cpp:class': ['cpp:class', 'cpp:templateParam'], 'cpp:struct': ['cpp:class', 'cpp:templateParam'], 'cpp:identifier': ['cpp:class', 'cpp:union', 'cpp:function', 'cpp:member', 'cpp:type', 'cpp:concept', 'cpp:enum', 'cpp:enumerator', 'cpp:functionParam', 'cpp:templateParam'], 'cpp:type': ['cpp:class', 'cpp:union', 'cpp:function', 'cpp:type', 'cpp:enum', 'cpp:templateParam'], 'cpp:union': ['cpp:union', 'cpp:templateParam'], 'cpp:func': ['cpp:function'], 'cpp:member': ['cpp:member', 'cpp:functionParam', 'cpp:templateParam'], 'cpp:var': ['cpp:member', 'cpp:functionParam', 'cpp:templateParam'], 'cpp:concept': ['cpp:concept'], 'cpp:enum': ['cpp:enum'], 'cpp:enumerator': ['cpp:enumerator'], 'js:func': ['js:function'], 'js:meth': ['js:method'], 'js:class': ['js:class'], 'js:data': ['js:data'], 'js:attr': ['js:attribute'], 'js:mod': ['js:module'], 'func': ['function'], 'obj': ['function', 'data', 'class', 'exception', 'method', 'classmethod', 'staticmethod', 'attribute', 'module'], 'data': ['data'], 'class': ['class', 'exception'], 'exc': ['class', 'exception'], 'meth': ['method', 'classmethod', 'staticmethod'], 'attr': ['attribute'], 'mod': ['module'], 'rst:dir': ['rst:directive', 'rst:directive:option'], 'rst:role': ['rst:role'], 'term': ['term'], 'token': ['token'], 'ref': ['label'], 'keyword': ['label'], 'envvar': ['envvar'], 'option': ['cmdoption'], 'doc': ['doc']}
[esbonio.lsp] LSP Server Initialized
[esbonio.lsp] DidSave: Object(textDocument=Object(uri='file:///c%3A/Users/yaegassy/esbcheck/index.rst', version=1))
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment:
0 added, 1 changed, 0 removed
reading sources... [100%] index

c:\Users\yaegassy\esbcheck\index.rst:2: WARNING: Title underline too short.

Welcome to check's documentation!
===============================
looking for now-outdated files...
none found
pickling environment...
done
checking consistency...
[esbonio.lsp.SphinxManagement] Unable to parse line number: 'None'
[esbonio.lsp.SphinxManagement] int() argument must be a string, a bytes-like object or a number, not 'NoneType'
c:\Users\yaegassy\esbcheck\check.rst: WARNING: document isn't included in any toctree
[esbonio.lsp.SphinxManagement] Unable to parse line number: 'None'
[esbonio.lsp.SphinxManagement] int() argument must be a string, a bytes-like object or a number, not 'NoneType'
c:\Users\yaegassy\esbcheck\venv\Lib\site-packages\Jinja2-2.11.3.dist-info\LICENSE.rst: WARNING: document isn't included in any toctree
[esbonio.lsp.SphinxManagement] Unable to parse line number: 'None'
[esbonio.lsp.SphinxManagement] int() argument must be a string, a bytes-like object or a number, not 'NoneType'
c:\Users\yaegassy\esbcheck\venv\Lib\site-packages\MarkupSafe-1.1.1.dist-info\LICENSE.rst: WARNING: document isn't included in any toctree
[esbonio.lsp.SphinxManagement] Unable to parse line number: 'None'
[esbonio.lsp.SphinxManagement] int() argument must be a string, a bytes-like object or a number, not 'NoneType'
c:\Users\yaegassy\esbcheck\venv\Lib\site-packages\alabaster-0.7.12.dist-info\DESCRIPTION.rst: WARNING: document isn't included in any toctree
[esbonio.lsp.SphinxManagement] Unable to parse line number: 'None'
[esbonio.lsp.SphinxManagement] int() argument must be a string, a bytes-like object or a number, not 'NoneType'
c:\Users\yaegassy\esbcheck\venv\Lib\site-packages\attrs-20.3.0.dist-info\AUTHORS.rst: WARNING: document isn't included in any toctree
[esbonio.lsp.SphinxManagement] Unable to parse line number: 'None'
[esbonio.lsp.SphinxManagement] int() argument must be a string, a bytes-like object or a number, not 'NoneType'
c:\Users\yaegassy\esbcheck\venv\Lib\site-packages\idna-2.10.dist-info\LICENSE.rst: WARNING: document isn't included in any toctree
[esbonio.lsp.SphinxManagement] Unable to parse line number: 'None'
[esbonio.lsp.SphinxManagement] int() argument must be a string, a bytes-like object or a number, not 'NoneType'
c:\Users\yaegassy\esbcheck\venv\Lib\site-packages\imagesize-1.2.0.dist-info\LICENSE.rst: WARNING: document isn't included in any toctree
[esbonio.lsp.SphinxManagement] Unable to parse line number: 'None'
[esbonio.lsp.SphinxManagement] int() argument must be a string, a bytes-like object or a number, not 'NoneType'
c:\Users\yaegassy\esbcheck\venv\Lib\site-packages\ipython_genutils-0.2.0.dist-info\DESCRIPTION.rst: WARNING: document isn't included in any toctree
[esbonio.lsp.SphinxManagement] Unable to parse line number: 'None'
[esbonio.lsp.SphinxManagement] int() argument must be a string, a bytes-like object or a number, not 'NoneType'
c:\Users\yaegassy\esbcheck\venv\Lib\site-packages\pytz-2021.1.dist-info\DESCRIPTION.rst: WARNING: document isn't included in any toctree
[esbonio.lsp.SphinxManagement] Unable to parse line number: 'None'
[esbonio.lsp.SphinxManagement] int() argument must be a string, a bytes-like object or a number, not 'NoneType'
c:\Users\yaegassy\esbcheck\venv\Lib\site-packages\sphinx\ext\autosummary\templates\autosummary\base.rst: WARNING: document isn't included in any toctree
[esbonio.lsp.SphinxManagement] Unable to parse line number: 'None'
[esbonio.lsp.SphinxManagement] int() argument must be a string, a bytes-like object or a number, not 'NoneType'
c:\Users\yaegassy\esbcheck\venv\Lib\site-packages\sphinx\ext\autosummary\templates\autosummary\class.rst: WARNING: document isn't included in any toctree
[esbonio.lsp.SphinxManagement] Unable to parse line number: 'None'
[esbonio.lsp.SphinxManagement] int() argument must be a string, a bytes-like object or a number, not 'NoneType'
c:\Users\yaegassy\esbcheck\venv\Lib\site-packages\sphinx\ext\autosummary\templates\autosummary\module.rst: WARNING: document isn't included in any toctree
[esbonio.lsp.SphinxManagement] Unable to parse line number: 'None'
[esbonio.lsp.SphinxManagement] int() argument must be a string, a bytes-like object or a number, not 'NoneType'
c:\Users\yaegassy\esbcheck\venv\Lib\site-packages\urllib3-1.26.4.dist-info\DESCRIPTION.rst: WARNING: document isn't included in any toctree
done
preparing documents...
done
writing output... [100%] index

generating indices...
genindex
done
writing additional pages...
search
done
copying static files...
done
copying extra files...
done
dumping search index in English (code: en)...
done
dumping object inventory...
done
build succeeded, 14 warnings.

The HTML pages are in ..\AppData\Local\coc\extensions\coc-esbonio-data\sphinx.

This may not be a problem for VSCode extensions, but perhaps it needs to be adjusted for use outside of VSCode. (regex, path, etc...)

(I'm sorry if this is a problem specific to my Windows environment.)

yaegassy commented 3 years ago

As a side note, this problem was confirmed in esbonio v0.5.1.

This is not a bug in the v0.6.0 release.

alcarney commented 3 years ago

:thinking:....

I can't say for sure but my guess is that the language server is not correctly encoding the filepaths when on Windows. I've opened #167 which might fix this issue - is there any chance you could download and install this version of the language server in a test environment and see if it does?

alcarney commented 3 years ago

Side note: would you mind sharing the esbonio portion of your vim config? It would come in handy for #45 :smile:

yaegassy commented 3 years ago

I tried this pull request. https://github.com/swyddfa/esbonio/pull/167

The "diagnostics" worked correctly.

esbonio-win-diagnostic-ok
alcarney commented 3 years ago

Awesome, I'll look to get #167 merged soon

yaegassy commented 3 years ago

Side note: would you mind sharing the esbonio portion of your vim config? It would come in handy for #45 😄

I created a vim-plugin(coc.nvim extension) the coc-esbonio using esbonio's language server and VSCode extension as reference.

I also use another LSP client plugin called vim-lsp.

coc.nvim

:CocInstall coc-esbonio

vim-lsp

settings(.vimrc):

'cmd' should be python where "esbonio" is installed '--cache-dir' can be set to any directory.

augroup LspEsbonio
 autocmd!
 autocmd User lsp_setup call lsp#register_server({
   \ 'name': 'esbonio',
   \ 'cmd': {server_info->[
   \    expand('~/.local/src/esbonio/venv/bin/python'), '-m', 'esbonio',
   \    '--cache-dir', '/tmp/esbonio/sphinx',
   \    '--log-level', 'error'
   \ ]},
   \ 'allowlist': ['rst'],
   \ 'workspace_config': {
   \   'esbonio': {
   \     'sphinx': {
   \       'confDir': "",
   \       'srcDir': "",
   \     },
   \   },
   \ }
   \ })
augroup END
yaegassy commented 3 years ago

@alcarney As a separate report, the esbonio.sphinx.confDir and esbonio.sphinx.srcDir settings have been added since "v0.6.0".

If this setting itself "does not exist", esbonio will fail to start.


Error:

Exception occurred in notification: "{'code': -32602, 'message': 'None: None', 'data': "{'traceback': []}"}"

For the VSCode extension, there is of course a setting in package.json, which is passed as the default value, but for other LSP clients, the setting can be omitted.

I thought it would be good to adjust the default value to "" if the setting itself is not passed on the language server side.

alcarney commented 3 years ago

I created a vim-plugin(coc.nvim extension) the coc-esbonio using esbonio's language server and VSCode extension as reference.

That's awesome :smile:, and thank you for the config examples

@alcarney As a separate report, the esbonio.sphinx.confDir and esbonio.sphinx.srcDir settings have been added since "v0.6.0". If this setting itself "does not exist", esbonio will fail to start.

Ah good catch... I think I handled the case where confDir or srcDir were missing but not the case where the parent esbonio.sphinx namespace is not available. I've opened #171 to track this.

yaegassy commented 3 years ago

@alcarney When is the next release scheduled to reflect this fix?

alcarney commented 3 years ago

There's a few more fixes I'd like to get in first, but I'm hoping to get something out within the next week or so :crossed_fingers:

alcarney commented 3 years ago

@yaegassy v0.6.1 of the language server is now out! :smiley: