Open humanitiesNerd opened 2 years ago
I think this issue highlights a point where python-lsp-server's documentation is lacking, I would like to see it addressed by improving it.
Part of the problem is that the LSP server configuration is passed in different ways depending on the client (e.g. Emacs, Vim, VSCode...). Still it would be useful to either point to the popular clients' documentation in this regard or even to put some examples in python-lsp-server's documentation so users have at least a starting point.
About overriding config per workspace, that is also client-specific. For Emacs I think it's doable with dir_locals.el. Again it would be useful to have either examples or links to clients' documentation.
I came up with this dir_locals.el in my project root, but it seems it doesn't work
(
(lsp-mode . ((lsp-clients-pylsp-library-directories . '("contrib" "odoo"))))
)
or maybe it DOES work and I'm misinterpreting what I see
Here it says that the type of lsp-clients-pylsp-library-directories
is (repat string)
I assumed it's a list of strings but I'm not sure
I'm not well versed in Elisp
How do I express a repeat string ?
I say it seems it's not working becaue if I call lsp-find-definition
on the "many2one method (from Odoo) it says "not found"
So I guess it's not working
I think I achieved a bit of progress thanks to this answer
but it still doesn't work
at this point, I think it's more about pypls than it is about lsp-mode
This is my project root layout
$ tree -L 2
.
├── contrib
│ ├── l10n-italy
│ └── OCA
├── dir_locals.el
├── filestore
├── local
│ └── my-project
├── logs
├── poetry.lock
├── pyproject.toml
├── my-project.cfg
├── src
│ └── odoo
└── stubs
└── odoo
I think this is related to #157
I've spend awhile trying to figure this out. I'm using Emacs with lsp-mode, and I hope this will be applicable to others.
I wanted to ignore a D100 error, so I tried putting it in .flake8
, .flake8rc
, .pylintrc
, etc. Nothing was working. Eventually I found that is has to go in .pydocstyle
. (I'd never even heard of pydocstyle
before. :shrug: )
As best I can tell, pylsp is using several different checking / linting packages and it can be tricky to figure out where a specific error came from. When it seems your config is being ignored, maybe it's because you're configuring the wrong package.
I eventually put something like the following in setup.cfg
at the root of my project and it seems to be working well:
[pydocstyle]
ignore = D100
[flake8]
ignore = F401
There's flake8
, pydocstyle
, pycodestyle
, pylint
and maybe others. Try them on the command line to figure them out and track down where specific errors or warnings are coming from, and remember you'll have to configure all of them.
How do I write a configuration file that is local to a project ?
The home page says that Pylsp follows this order
How do I get a workspace local configuration file ?
Thanks