Skip to content

fix: add pylyzer dependency info (erg) (#3433) #3770

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

Merged
merged 3 commits into from
Apr 26, 2025
Merged

Conversation

fishBone000
Copy link
Contributor

Pylyzer requires Erg as dependency. This info is missing in default config and doc.

Pylyzer requires Erg as dependency. This info is missing in default
config and doc.
@fishBone000 fishBone000 requested a review from glepnir as a code owner April 24, 2025 05:08
@fishBone000
Copy link
Contributor Author

Opened this PR as a fixer to #3441 (update the file in /lsp/ instead of /lua/lspconfig/...)

lsp/pylyzer.lua Outdated
@@ -22,4 +28,7 @@ return {
checkOnType = false,
},
},
on_new_config = function(new_config, _)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no such thing in vim.lsp.config. try before_init ? and please test that it actually works.

Copy link
Collaborator

@lithammer lithammer Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, why not just define it directly in cmd_env instead? Something like this:

return {
  cmd = { 'pylyzer', '--server' },
  cmd_env = {
    ERG_PATH = vim.env.ERG_PATH or vim.fs.joinpath(vim.uv.os_homedir(), '.erg')
  },
  ...
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, though that means the CWD "sticks" and won't dynamically update. I don't use this config so I have no strong opinion :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean it wasn't really doing anything dynamic anyway. It was essentially just setting ERG_PATH=~/.erg. Unless I'm missing something...?

And before_init happens after starting the binary. So setting cmd_env wouldn't have any effect?

Copy link
Member

@justinmk justinmk Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before_init happens after starting the binary

oh. Then cmd should be defined as a function (again, assuming this functionality is important for users of this config)

I'm also fine with your cmd_env suggestion.

Copy link
Collaborator

@lithammer lithammer Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before_init happens after starting the binary

oh. Then cmd should be defined as a function (again, assuming this functionality is important for users of this config)

I'm not sure about this though. Just going by the docs:

Callback invoked before the LSP "initialize" phase, where params contains the parameters being sent to the server and config is the config that was passed to vim.lsp.start(). You can use this to modify parameters before they are sent.

Seems to indicate that vim.lsp.start() has already been called.

Copy link
Collaborator

@lithammer lithammer Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With that said. I suppose cmd being a function could be useful when you want to start a server relative to the resolved root.

For example you might want to call ./node_modules/.bin/biome relative to that root.

Though I suppose that could also be solved by having relative paths be relative to workspace root instead of cwd (though relative paths aren't supported at all at the moment I think?).

Or do the VS Code way (or CoC, don't remember which). By using some magic marker like {root_dir}/node_modules/.bin/biome.

@fishBone000
Copy link
Contributor Author

Fixed, tested and it works.

Not sure what's about the CWD you were talking about though? I kind of get the idea but can't see how it's related to this pylyzer config?

@justinmk justinmk merged commit faec80d into neovim:master Apr 26, 2025
9 of 10 checks passed
@lithammer
Copy link
Collaborator

Not sure what's about the CWD you were talking about though? I kind of get the idea but can't see how it's related to this pylyzer config?

Yeah sorry. I digressed.

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

Successfully merging this pull request may close these issues.

3 participants