-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat: add support for sourcery #1495
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
local util = require 'lspconfig/util' | ||
|
||
local root_files = { | ||
'pyproject.toml', | ||
'setup.py', | ||
'setup.cfg', | ||
'requirements.txt', | ||
'Pipfile', | ||
'pyrightconfig.json', | ||
} | ||
|
||
return { | ||
default_config = { | ||
cmd = { 'sourcery', 'lsp' }, | ||
filetypes = { 'python' }, | ||
init_options = { | ||
editor_version = 'vim', | ||
extension_version = 'vim.lsp', | ||
token = '<YOUR_TOKEN>', | ||
kylo252 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
root_dir = function(fname) | ||
return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname) | ||
end, | ||
single_file_support = true, | ||
}, | ||
docs = { | ||
description = [[ | ||
https://github.com/sourcery-ai/sourcery | ||
|
||
Refactor Python instantly using the power of AI. | ||
|
||
It requires the initializationOptions param to be populated as shown below and will respond with the list of ServerCapabilities that it supports. | ||
|
||
init_options = { | ||
--- The Sourcery token for authenticating the user. | ||
--- This is retrieved from the Sourcery website and must be | ||
--- provided by each user. The extension must provide a | ||
--- configuration option for the user to provide this value. | ||
token = <YOUR_TOKEN> | ||
|
||
--- The extension's name and version as defined by the extension. | ||
extension_version = 'vim.lsp' | ||
|
||
--- The editor's name and version as defined by the editor. | ||
editor_version = 'vim' | ||
} | ||
]], | ||
}, | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should a remove the token section, and instead require that people use the
auth.yaml
file in the~/.config/sourcery/auth.yaml
file. Sourcery even gives the user the command:sourcery login
to do this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it not work with a local
auth.yaml
? otherwise, where's the path for Windows? I can't find that info on their site, could you please share the link?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, I guess it can. But from what I see, I can't understand where the token is used, besides the variable assignment
Unless I am wrong, and it is used inside the mechanics of lspconfig?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is considered a "local"
![image](https://user-images.githubusercontent.com/48220549/147111889-1ef68346-14d9-4747-b131-10813142e9ba.png)
auth.yaml
file?Also, output from
sourcery login --help
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The best docs I found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was specifically asking about the docs where they mention
~/.config/sourcery/auth.yaml
since I couldn't find it anywhere, because for Windows it would have to be something like~/AppData/Local/sourcery/..
I guess the local file would be
.sourcery.yaml
? but I can't find if it has anything to do with storing the auth token.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. I'll have to look around. But why use the path? Once it is setup(i.e i am logged in), I dont have to use the Path again. Sourcery fetches the token and saves it for future usage. I.e the LSP works everything after the initial setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay. Turns out there are no docs on this...Which is a bad thing. Opened an issue regarding this.