[GSoC2017] Proposal of golang integration.

Mikhail Ivchenko ematirov at gmail.com
Tue Mar 21 14:34:48 UTC 2017


Hello,

Thank you for your reply!

> You only mentioned code completion, does that mean you are not
> interested in working on a DUChain implementation for Go?

I was looking at GSoC 2016 ideas page (
https://community.kde.org/GSoC/2016/Ideas#Project:_KDevelop:_Go_language_integration)
which states that's ideally solution shouldn't use custom parser so I
thought about implementing gocode support for autocompletion. In case I
misunderstood the idea correct me please.

> Have you considered implementing it using LSP?
> https://github.com/sourcegraph/go-langserver
Looks interesting. Thought it doesn't provide support for autocompletion
yet it allows to integrate support for other languages using LSP.
Probably it could be implemented as library which allows building specific
language plugins on top of it.

As far as I see it's possible to create AbstractLSPLanguageSupport (name
will be changed probably) class implementing ILanguageSupport by calling
language server. Then, for each supported language specific plugin could be
implemented which inherits AbstractLSPLanguageSupport and implements
specific methods such as "StartServer", "GetConnectionUrl" + implements
support to language-specific configuration (smthg like GOPATH \ go
executable path, source code formatting options, etc).
So, most LSP-specific things would be handled in one library and for
implementing language support it would be possible to just tweak it to
specific server implementation + provide IProjectBuilder since LSP doesn't
support building \ installing \ etc AFAIK.

Does it looks like a good design or there is something that I'm missing?


In case of implementing LSP support I can change my proposal to following
items:
1) Research best way of implementing LSP support.
2) Implement basic LSP support: starting server and making requests to it.
3) Implement basic Go or C# (That's languages I know and used so I have
some knowledge about their environment) LSP plugin.
4) Implement support for formatting by implementing ISourceFormatter which
passes calls to LSP.
5) Implement support for formatting using made in 4) source formatter with
options specific to chosen language.
6) Implement 4-5 for completion and as much as possible of rest LSP
capabilities.

So, developing LSP library will go in parallel with implementing a plugin
which uses it so it'll be possible to actually 1) test it. 2) check design
issues while implementing plugin.

As a result, a library providing LSP support is expected and, actually, a
plugin built on top of it which allows:
1) build some basic Go (or C#) project
2) use formatting, autocompletion (probably not possible in case of Go
since there is no support in current server implementation), renaming of
symbols.

Any suggestions are really welcome!

P.S.
Yep, I had some patches merged to KDevelop:
https://phabricator.kde.org/diffusion/commit/query/Lmfx1Bbz5syo/
In case there are not enough of them I can try to start implementing
support for building Go (or C#) projects by implementing IProjectBuilder as
I mentioned before.
(kdev-go now doesn't support building, usage of custom build system is
suggested in README.md)

Best regards,
Mikhail Ivchenko

On Tue, Mar 21, 2017 at 4:03 AM Aleix Pol <aleixpol at kde.org> wrote:

On Tue, Mar 21, 2017 at 12:29 AM, Aleix Pol <aleixpol at kde.org> wrote:
> On Mon, Mar 20, 2017 at 9:43 PM, Mikhail Ivchenko <ematirov at gmail.com>
wrote:
>> Hello,
>>
>> Firstly, I want to apologize since I understand that ideally some kind of
>> proposal should have been submitted before actual start of application.
>>
>> Briefly about me:
>> I'm 18 years old student from Russia who has some kind of experience in
>> C++\Qt and Go. I was Google Code-In GP Winner with KDE in 2013 and 2014
>> years and have some commits to KDevelop as well. Also, I mentored few
tasks
>> in GCI this year.
>>
>> So, my proposal is mostly inspired by GSoC 2017 page. I had a quick
research
>> and come up with such ideas about Go language integration:
>> 1. For support building \ project exploring:
>>     - Implement IProjectBuilder in something like
>> projectbuilders/golangbuilder
>>     - Implement IBuildSystemManager in smtg like projectmanagers/golang
>>     Main goal is to add 1) possibility to open golang projects and handle
>> files of it. (Probably all files inside specific folder using
>> AbstractFileManagerPlugin); 2) possibility to build \ install project and
>> change such parameters as "GOPATH" and "go" executable path (for using
>> different versions of Gofor example).
>> 2. For source code formatting it's possible to use "go fmt" - standard
tool
>> for formatting. Just need to implement ISourceFormatter and pass calls to
>> "go fmt".
>> 3. For autocompletion support it's possible to use gocode
>> (https://github.com/nsf/gocode). It's a popular autocompletion daemon
for Go
>> which is used in such editors as Vim, Atom, Emacs, VS Code. This will be
>> probably one of hardest features to implement.
>> 4. Re semantic highlighting - as far as I know there are no real tools
for
>> highlighting - so I can only try to update existing Kate syntax files if
>> they are outdated.
>> 5. Addition but probably even more hard part could be implementing
support
>> for calling "gometalinter" (https://github.com/alecthomas/gometalinter)
and
>> parsing \ displaying list of warnings.
>>
>> I personally would like to go with 1-4 and try to work on 5 if I'll have
>> time remaining.
>>
>> Does it look interesting to anyone? Could someone mentor me please?
>>
>> Best regards,
>> Mikhail Ivchenko
>
> Hi Mikhail,
> That's certainly interesting.
>
> Do you have any experience with KDevelop? It would be really
> interesting to see a patch of yours (maybe fix a bug that bothers
> you?). This way we get to see how you work.
>
> You only mentioned code completion, does that mean you are not
> interested in working on a DUChain implementation for Go?
>
> Somebody worked on a go plugin some time ago:
> https://github.com/KDE/kdev-go
>
> Would it make sense to build on top of it?
>
> Looking forward to your reply!
> Aleix

Hi Mikhail,
Just another thing.
Have you considered implementing it using LSP?
https://github.com/sourcegraph/go-langserver

Aleix
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20170321/c4fb7e12/attachment.html>


More information about the KDevelop-devel mailing list