sourcery icon indicating copy to clipboard operation
sourcery copied to clipboard

Sourcery doesn't support your editor?

Open Hellebore opened this issue 4 years ago • 26 comments

Add a comment here to register interest in Sourcery support for other IDEs.

Or read our docs for how to write an editor plugin using our LSP server

Hellebore avatar May 07 '20 12:05 Hellebore

vim/neovim...?

hedyhli avatar May 30 '20 09:05 hedyhli

Vim would definitely be a welcomed addition.

collinarnett avatar May 31 '20 23:05 collinarnett

Emacs please!

zingbretsen avatar Jun 03 '20 16:06 zingbretsen

Are you open to people making community plugins? Are there any references for how we might do such a thing with Sourcery?

zingbretsen avatar Jun 03 '20 16:06 zingbretsen

Are you open to people making community plugins? Are there any references for how we might do such a thing with Sourcery?

It is something we've thought about - We've done the VS Code plugin as a language server so it should certainly be possible. I think we want to nail down the functionality first - we're still in beta so might still be making large changes to how things work.

Hellebore avatar Jun 03 '20 17:06 Hellebore

After an internal discussion we've realised that the API should be stable enough to support community plugins. The Sourcery binary uses LSP so that's not going to change and the core functionality of Sourcery is not going to change much either

@zingbretsen - we would be delighted if you wrote a plugin for emacs. At the moment we have no documentation on how to do this and are not quite clear what documentation would be needed. I'll drop you an email and we can see if we can get something rolling

brendanator avatar Jun 04 '20 13:06 brendanator

How about Sublime Text? :)

isukrit avatar Jun 07 '20 16:06 isukrit

I use Eclipse + Pydev and believe it's still quite popular. At least it figures in lots Top best Python IDE's ;-)

PhilipLacombe avatar Jun 09 '20 11:06 PhilipLacombe

I'm using Geany and I feel like a plugin would be a nice addition. If you want to, of course :smile:

CartoonFan avatar Jun 19 '20 07:06 CartoonFan

:atom: Atom Editor please!

weiji14 avatar Jun 22 '20 10:06 weiji14

:atom: Atom Editor, please.

f0rest8 avatar Jul 04 '20 16:07 f0rest8

Spyder please!

carlesilla avatar Aug 19 '20 07:08 carlesilla

vim/neovim...?

I'm using it via coc.nvim, it is quite easy to setup:

  1. Download and extract a release of Sourcery or use pip install --user sourcery-cli
  2. Add this to your coc-settings.json:
{
    "languageserver": {
        "sourcery": {
            "command": "<Sourcery Directory>/sourcery",
            "args": [
                "lsp"
            ],
            "filetypes": [
                "python"
            ],
            "initializationOptions": {
                "token": " <Your Token Here>",
                "extension_version": "coc.nvim",
                "editor_version": "vim"
            },
            "settings": {},
            "trace.server": "verbose"
        }
    }
}
  1. Profit!

PS: This can be Sourcery can be used in any LSP capable editor

marcoaaguiar avatar Oct 15 '20 03:10 marcoaaguiar

Thanks for the instructions on setting it up in Vim @marcoaaguiar.

I've written it up into full install and usage instructions in our wiki.

brendanator avatar Oct 22 '20 13:10 brendanator

I'm using @marcoaaguiar's suggestion and when I attempt to run :CocDiagnostics in a Python file, I see this message:

[coc.nvim] Sourcery sign-up required. Click [here](https://sourcery.ai/download/) for a free token then enter it into the Sourcery section of the [settings](command:workbench.action.openSettings "Open Settings").

I've confirmed that my token is added in languageserver.sourcery.initializationOptions.token in my coc-settings.json.

Versions:

  • Neovim 0.4.4
  • Node.js 10.20.1
  • coc.nvim 0.0.79-8da7b2139d

bachya avatar Oct 22 '20 14:10 bachya

Thanks for raising @bachya. #89 has been raised with a solution for this

brendanator avatar Oct 22 '20 15:10 brendanator

notepad++

muhammedfurkan avatar Nov 19 '20 08:11 muhammedfurkan

How about Sublime Text? :)

Sourcery is now available for Sublime! https://sourcery.ai/blog/sourcery-sublime/

Hellebore avatar Dec 10 '20 11:12 Hellebore

https://nova.app it's the editor by Panic. Same developers who built coda and transmit. Thanks in advance

Shivam-Agrawal-e2684 avatar Dec 17 '20 15:12 Shivam-Agrawal-e2684

image Atom Editor, please!

diego021 avatar Mar 05 '21 21:03 diego021

If anyone is interested you can use Sourcery with native Neovim LSP. I have the following setup in a file called sourcery.lua:

local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'

local server_name = 'sourcery'

configs[server_name] = {
    default_config = {
        cmd = {server_name, 'lsp'},
        filetypes = {'python'},
        init_options = {
            editor_version = 'vim',
            extension_version = 'vim.lsp',
            token = '<YOUR_TOKEN>'
        },
        root_dir = function(fname)
            local root_files = {
                'pyproject.toml',
                'setup.py',
                'setup.cfg',
                'requirements.txt',
                'Pipfile'
            }
            return util.root_pattern(unpack(root_files))(fname) or
                       util.find_git_ancestor(fname) or util.path.dirname(fname)
        end
    },
    docs = {
        description = [[
https://github.com/sourcery-ai/sourcery

Refactor Python instantly using the power of AI.
]]
    }
}

Mainly based off the pyright config from here.

In your main config just add

require('sourcery')
require('lspconfig').sourcery.setup {}

cjber avatar Sep 10 '21 16:09 cjber

@cjber would you mind elaborating one would choose the native Neovim LSP integration over the coc config approach from the wiki? Improved integration, improved performance, any other reasons?

fvdnabee avatar Oct 01 '21 07:10 fvdnabee

@fvdnabee I believe it's probably mostly personal preference, although native LSP may be slightly faster. I have switched over to fully use native LSP so wanted to integrate sourcery that way and luckily it's easy to use currently unsupported language servers.

cjber avatar Oct 01 '21 08:10 cjber

Just going to leave this here: if anyone struggles to get Sourcery working on Arch as I was, just getting cryptic error messages from neovim exit code 127, it's because Arch is missing libcrypt.so.1. You can get round this by installing ibxcrypt-compat

silentjay avatar Jun 07 '22 22:06 silentjay

I couldn't get the Sublime Text to work, perhaps because the instructions are out of date.

reagle avatar Mar 01 '23 20:03 reagle