1

I've set up company-mode in emacs and enabled the company-files backend, and am now able to start typing in code which looks like this:

import Foo from '../

and have company provide some auto-completion options, resulting in e.g.:

import Foo from '../../baz/bar/Foo.js

. Is it now possible to configure company-files to begin its process in some other directory (e.g. ../../baz), so that I can write code that looks like this:

import Foo from 'bar/Foo.js';

and still get autocompletion along the way?

Ideally I'd like a way to tell company-mode "traverse up the filesystem tree from this file's location until you find a directory containing a file named 'package.json' and begin auto-completion from there", but providing an absolute filesystem path string would be okay too.

thanks!

1

It's currently not possible. Note that, in addition to specifying the base path, you'll need to somehow tell company-files (or rather, a future, expanded version of it) that strings following import ... from are relative file names in JavaScript.

If you ask company-files to treat every string as file name, there will be too many false positives.

Together with that logic, though, you might want to try writing a new backend. company-files itself is not big, and you probably don't even need the "listing files from all subdirectories 1 level deep" thing.

Feel free to file a feature request, but be prepared to write some Elisp, even if only to perform JS-specific configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.