iquiw / company-ghc

Company-mode completion back-end for haskell-mode via ghc-mod
125 stars 6 forks source link

company-ghc shadows other back-ends #3

Closed bixuanzju closed 10 years ago

bixuanzju commented 10 years ago

As I was playing with company-ghc, it seems to block other back-ends, e.g. company-dabbrev-code because now company-mode won't complete symbol names as shown in the below screenshot. screen shot 2014-06-24 at 5 31 10 pm

iquiw commented 10 years ago

Maybe related to https://github.com/company-mode/company-mode/issues/142 (or not?).

I noticed the behavior, but had no idea how to fix before. Since company-ghc takes any symbols as prefix, it won't pass to other back-ends. I think it is usual in company-mode to use grouped back-end in such case. e.g.

(add-to-list 'company-backends '(company-ghc company-dabbrev))

I am now considering to move some logic in company-ghc-candidates to company-ghc-prefix as written in [1], but I am not sure it will work well.

[1] https://github.com/company-mode/company-mode/issues/142#issuecomment-46801125

dgutov commented 10 years ago

I am now considering to move some logic in company-ghc-candidates to company-ghc-prefix as written in [1], but I am not sure it will work well.

I'd suggest you try to detect the cases which your backend isn't able to handle lexically, somehow, and delegate to dabbrev only in those cases (by returning nil).

Or implement some completion logic in Elisp. In the example on the picture, for instance, point is after a word on the line directly after a function signature. There can be only one completion, no?

iquiw commented 10 years ago

I'd suggest you try to detect the cases which your backend isn't able to handle lexically, somehow, and delegate to dabbrev only in those cases (by returning nil).

OK. I will consider the direction. For the first step, I changed to return nil if the prefix starts from the line beginning.

Or implement some completion logic in Elisp. In the example on the picture, for instance, point is after a word on the line directly after a function signature. There can be only one completion, no?

Another function signature or different function name is possible here. And this aVeryLongName can appear in function body also.

Some function in haskell-mode may be used to build candidates though. I will investigate on it.

iquiw commented 10 years ago

@bixuanzju Can you clarify the goal of this issue?

I think the reported problem was fixed in very narrow sense.

So is it either (1) To pass control to other back-ends if there is no candidates or (2) To provide candidates from locally defined functions/variables. ?

I think (1) is not possible in general, and only grouped back-end is reasonable solution. If you want (2), I'd like to create new issue to focus to it explicitly.

bixuanzju commented 10 years ago

Sorry, I forgot to close this issue. For now, grouped back-end works happily for me :)