Using YCM completion in Emacs Jeff Trull 15 July 2015 Getting - - PowerPoint PPT Presentation

using ycm completion in emacs
SMART_READER_LITE
LIVE PREVIEW

Using YCM completion in Emacs Jeff Trull 15 July 2015 Getting - - PowerPoint PPT Presentation

Using YCM completion in Emacs Jeff Trull 15 July 2015 Getting Started with YCM for C and C++ YouCompleteMe Download and build YCMD (a YouCompleteMe fork) Jeff Trull https://github.com/Valloric/ycmd#building Install the ycmd and company-ycmd


slide-1
SLIDE 1

Using YCM completion in Emacs

Jeff Trull 15 July 2015

slide-2
SLIDE 2

YouCompleteMe Jeff Trull

Getting Started with YCM

for C and C++

Download and build YCMD (a YouCompleteMe fork) https://github.com/Valloric/ycmd#building Install the ycmd and company-ycmd packages Set things up in your init file:

( eval-after-load " company-ycmd-autoloads " ’(progn ( company-ycmd-setup ))) ( eval-after-load " ycmd-autoloads " ’(progn ( set-variable ’ycmd-server-command ’("python")) ( add-to-list ’ycmd-server-command ( expand-file-name "~/ oss/emacs/ycmd/ycmd") t ) ( set-variable ’ycmd-global-config ( expand-file-name "~/ oss/emacs/ ycmd/cpp/ycm /. ycm_extra_conf . py")) (add-hook ’c++- mode-hook (lambda () (ycmd-mode) ( company-mode )))))

slide-3
SLIDE 3

YouCompleteMe Jeff Trull

Test Code

Fun with namespaces

namespace Outer { struct Foo { int x, y; typedef double float_t; }; namespace Inner { struct Bar { size_t p, q; typedef char byte_t; }; } using namespace Inner; // promote Bar into Outer }

slide-4
SLIDE 4

YouCompleteMe Jeff Trull

Test Code

Inheritance+Templates

struct Base { std :: string _str; }; template <typename T> struct Baz : Base , std :: enable_shared_from_this <Baz <T>> { typedef std :: vector <T> sequence_t ; // the *names* of methods

  • n

this

  • bject

are independent

  • f T

sequence_t sequence_; std :: size_t string_length () const { // see if it knows about inherited _str whose type is independent

  • f T

return _str.length (); } // see if it knows about inherited (and CRTP ’ed) shared_from_this () };

slide-5
SLIDE 5

YouCompleteMe Jeff Trull

Results

CLion seems to get everything YCM struggles with dependent types within templates YCM suggests some inappropriate completions

slide-6
SLIDE 6

YouCompleteMe Jeff Trull

Other good stuff

YCM supports Go and Python YCM supports Flycheck The emacs-ycm author made a couple of blog posts about writing company-mode backends that are interesting http://sixty-north.com/blog/ writing-the-simplest-emacs-company-mode-backend There is a company-clang mode but I haven’t tried it