Giter Site home page Giter Site logo

company-irony-c-headers's People

Contributors

hotpxl avatar syohex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

company-irony-c-headers's Issues

Dosen't completes system headers

Is able to show completion for projects based header files (#include "someheader.h") but fails to show anything on #include < .

Incorrect working directory on reload compiler output

The company-irony-c-headers--working-dir is used to set default-directory, that must end in slash to work correctly (otherwise it ends up in parent directory). This confuses the reload of compiler output.

Fixed as follows:

 (defun company-irony-c-headers--working-dir ()
    "Get working directory."
    (if irony--working-directory
        (concat irony--working-directory "/")
      default-directory))

Paths from -I command line don't seem to be searched?

I can autocomplete system headers, but not project headers.

I was assuming that this plugin was going to look at the json database for compile options and pull paths from that?

Or, is it supposed to work like that already?

Compiler options such as -MMD confuse header path reload

I fixed this by pruning such options as follows:

  (defun company-irony-c-headers--clean-compiler-options (options)
    (cond ((null options)
       nil)
      ((or (string-equal "-MF" (car options))
           (string-equal "-MT" (car options))
           (string-equal "-MQ" (car options)))
       (company-irony-c-headers--clean-compiler-options (cddr options)))
      ((string-prefix-p "-M" (car options))
       (company-irony-c-headers--clean-compiler-options (cdr options)))
      (t
       (cons (car options)
         (company-irony-c-headers--clean-compiler-options (cdr options))))))

  (defun company-irony-c-headers--user-compiler-options ()
    "Get compiler options."
    (company-irony-c-headers--clean-compiler-options irony--compile-options))

Add extra include paths/work together with company-c-headers?

Hi:

I was trying to find a way to add additional include paths to company-irony-c-headers through a .dir-locals.el file or getting it to work with company-c-headers existing include flags.

Is it possible to pass in additional include paths to company-irony-c-headers for this purpose in a .dir-locals.el file or combine the two completions output from company-c-headers and company-irony-c-headers?

I have not been able to find a way to add header files using a .dir-locals file. Right now I do this in one of my emacs startup files:

; C++ Autocomplete for clang
(require 'fuzzy)
(require 'auto-complete-clang)
(require 'auto-complete)
(define-key c++-mode-map (kbd "C-S-SPC") 'ac-complete-clang)

; Use irony autocomplete for C languages
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'objc-mode-hook 'irony-mode)

;; replace the `completion-at-point' and `complete-symbol' bindings in
;; irony-mode's buffers by irony-mode's function
(defun my-irony-mode-hook ()
  (define-key irony-mode-map [remap completion-at-point]
    'irony-completion-at-point-async)
  (define-key irony-mode-map [remap complete-symbol]
    'irony-completion-at-point-async))
(add-hook 'irony-mode-hook 'my-irony-mode-hook)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
(setq w32-pipe-read-delay 0)

; Use company-mode with irony
(add-hook 'irony-mode-hook 'company-irony-setup-begin-commands)
(setq company-backends (delete 'company-semantic company-backends))
; Enable completion of C/C++ headers
;; Load with `irony-mode` as a grouped backend
(require 'company-irony-c-headers)
(require 'company-c-headers)
(eval-after-load 'company
  '(add-to-list
    'company-backends '(company-irony-c-headers company-irony company-c-headers)))

; (add-to-list 'company-backends 'company-c-headers)
; Set autocomplete header search paths based on OS type
; NOTE: Can find the include paths with the shell command ``echo "" | g++ -v -x c++ -E -``
(cond
 ((string-equal system-type "windows-nt") ; any flavor of Windows
    (setq ac-clang-flags
          (mapcar (lambda (item)(concat "-I" item))
                  (split-string
    "
    c:/Qt/4.8.5/include
    "
    )))
    (add-to-list 'company-c-headers-path-system "c:/Qt/4.8.5/include")
  )
((string-equal system-type "gnu/linux")
 )
((string-equal system-type "darwin") ; Mac
)
)

; Use tab-completion with no delay
(setq company-idle-delay 0.5)
(define-key c-mode-map [(control tab)] 'company-complete)
(define-key c++-mode-map [(control tab)] 'company-complete)

But when I hit C-tab, I only get the completions coming from company-irony-c-headers (i.e.stdlib stuff like string, vector), and not company-c-headers (i.e. QtCore, QtGui). Is there a way I can combine both backend completion results so that company-complete shows them all? If I run company-c-headers manually, the completions show up, so I know at least the candidates themselves are being loaded, they're just not being combined with the candidates in company-complete for some reason.

Additionally, I was trying to set the include paths for company-c-headers using a .dir-locals.el file instead of hardcoding it in my emacs startup script, like so:

((c++-mode (eval setq company-clang-arguments (append 
                                               company-clang-arguments
                                               '("-I C:/Qt/4.8.5/include")))))

But this doesn't seem to have any effect whatsoever when I attempt to use company-c-headers; it doesn't show me the completions from Qt.

Autocomplete keeps first #

For some reason auto-completing headers is not replacing the initial # but adding another one as apart of the autocomplete.

For example typing "#in" and accepting any of the autocomplete suggestions results in "##include <>"

how do I fix this?

Completion not working if without .clang_complete file in working directory.

Hello,
I noticed that completion does not work if without .clang_complete file in working directory.
So I looked at company-irony-c-headers.el source and found some useless code in function of company-irony-c-headers-reload-compiler-output.

< in 89 >

  (when (and company-irony-c-headers--compiler-executable
             (company-irony-c-headers--working-dir))

I think conditional branching by (company-irony-c-headers--working-dir) cause the problem.

< in 94 >

     (let ((uco (company-irony-c-headers--user-compiler-options))
           (dco (company-irony-c-headers--default-compiler-options))
           (default-directory (company-irony-c-headers--working-dir)))

The variable of default-directory isn't use in company-irony-c-headers-reload-compiler-output.

So I removed these useless code then completion working perfectly without .clang_complete file in working directory.
Could you apply this modification if there is no problem?

Sorry for my bad English. Thank you.

Should auto-trigger completion on directories

Hello,

After a simple test it seems to work nicely.

I noticed one thing. Company triggers the completion after company-minimum-prefix-length (3 characters by default). It would be nice to to trigger the completion automatically after a '/' though.

So if I ask for:

#include <boost/[]>

Completion should be triggered automatically.

This is achievable via company's prefix return value, see https://github.com/company-mode/company-mode/blob/c6af7d29ef7b8d2b6b4800151511ead26c521532/company.el#L346-L347

Adding user path in addition to system paths

Hello,

Is it possible as in company-c-headers to add user directories for the completion ?

(add-to-list 'company-irony-c-headers-user-path '"/home/...")
(add-to-list 'company-irony-c-headers-user-path '"/home/...")
(add-to-list 'company-irony-c-headers-user-path '"/home/...")

Thanks !

Sorting order is confusing sometimes

Hello.
Assume we have some files:
SomeClass.h
SomeClass.cpp
main.cpp

I would like to unclude SomeClass.h into main.cpp, so:
main.cpp:

include "Some|

SomeClass.cpp
SomeClass.h

First candidate is .cpp file, but in 99% cases I would like to include .h, .hpp, .inl and other files, but not .cpp.
I think this is due to 'sort' function, and 'c' is smaller than 'h', right?
Is there any way to customize sorting behavior?
Thank you a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.