Giter VIP home page Giter VIP logo

company-flow's Introduction

Company flow MELPA

Flow backend for company-mode. Flow-based autocomplete for Emacs.

Installation

You can install this package from Melpa

M-x package-install RET company-flow RET

Usage

Ensure that flow is in your path.

Add to your company-backends for your preferred javascript modes, for example:

(eval-after-load 'company
  (add-to-list 'company-backends 'company-flow))

Configuration

company-flow-executable

Buffer local variable that should point to the flow executable. Defaults to "flow". Set to nil to disable company-flow.

For best performance, you can set this to the actual flow binary in your project. Here's one way to do that:

(defun flow/set-flow-executable ()
  (interactive)
  (let* ((os (pcase system-type
               ('darwin "osx")
               ('gnu/linux "linux64")
               (_ nil)))
         (root (locate-dominating-file  buffer-file-name  "node_modules/flow-bin"))
         (executable (car (file-expand-wildcards
                           (concat root "node_modules/flow-bin/*" os "*/flow")))))
    (setq-local company-flow-executable executable)
    ;; These are not necessary for this package, but a good idea if you use
    ;; these other packages
    (setq-local flow-minor-default-binary executable)
    (setq-local flycheck-javascript-flow-executable executable)))

;; Set this to the mode you use, I use rjsx-mode
(add-hook 'rjsx-mode-hook #'flow/set-flow-executable t)

company-flow-modes

List of major modes where company-flow should provide completions if it is part of company-backends. Set to nil to enable company-flow for all major modes.

Thanks

company-flow's People

Contributors

aaronjensen avatar ailrun avatar jdelstrother 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  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

company-flow's Issues

Import auto completion issue

For case using default export like,

import React from 'react';

export function test() {
}

export default class Something extends React.Component/*::<*, *, *>*/ {
  constructor(props/*: **/) {
  }
}

and including such file, auto completion of import keyword doesn't work well.

import { |} from 'Something';

| is position of my cursor, then I try an autocompletion, it shows me default and test.

However, default case can't have any sense, because import { default } from 'Something'; is just a error.

Is there any reason for this default?

blocks other backends if no suggestions?

I would like to combine flow with "fallbacks" to dabbrev-code, like

(set (make-local-variable 'company-backends)
         '((company-flow :with company-yasnippet :with company-dabbrev-code)))

so that in case there's something up with company-flow, I at least get dabbrevs. However, sometimes this leads to no suggestions at all. If I switch the priority to

(set (make-local-variable 'company-backends)
         '((company-dabbrev-code :with company-yasnippet :with company-flow)))

I always get suggestions, but then the company-flow ones (with good type info etc.) are last in the list. Does company-flow somehow block moving on to other backends?

Extra line in completion candidates

Hey! First of all, huge thanks for writing this package \o/

The problem I'm having is that I get an extra line (Easier to show):

screen shot 2018-02-25 at 1 32 31 pm

It shows up 90% of the time when doing completions.

Flow Version: 0.66.0

I'm very new to the JS world, so I might be doing something wrong? Not sure what other info to provide. Thanks!

Support local flow-bin

Any plans to support the local flow-bin executable via something like npx flow ...? That would be nice, so that project-specific flow-bin versions could be used instead of depending on a globally installed version. Other editor tools in the npm ecosystem support this if we need to draw from a precedent.

how to use flow within node_modules?

The flow project recommends you install flow-bin inside a project in node_modules, not globally. I found emacs integration somewhere for flycheck that makes sure it uses the flow binary from node_modules instead of the globally installed one. Would it be possible to make this work with company-flow as well?

For reference here is the snippet I use:

(defun my/use-flow-from-node-modules ()
  (let* ((root (locate-dominating-file
                (or (buffer-file-name) default-directory)
                "node_modules"))
         (flow (and root
                    (expand-file-name "node_modules/flow-bin/vendor/flow"
                                      root))))
    (when (and flow (file-executable-p flow))
      (setq-local flycheck-javascript-flow-executable flow))))

(add-hook 'flycheck-mode-hook #'my/use-flow-from-node-modules)

Does not complete full flow type syntax?

I have a function definition
function(User: Class<UserModel>,

trying to recreate with company-flowonly autocompletesUserModelit dosen't contain theClass<>` syntax

Candidates not displaying

I'm having trouble getting the autocompletion candidates to display. I've tried to manually invoke company-flow, but I get the following error message: Cannot complete at point.

I tried reading through the company-flow.el source, and I called (company-flow--candidates-query nil (lambda (x) (print x))) in the Eval: buffer. This produced a list of candidates that matches the list I get when I run:

$ flow autocomplete LINE COL <FILE

I'm having a tough time debugging this, however. Any help would be greatly appreciated.

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.