Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use nix-company.el #89

Open
alexarice opened this issue Aug 30, 2019 · 5 comments
Open

How to use nix-company.el #89

alexarice opened this issue Aug 30, 2019 · 5 comments

Comments

@alexarice
Copy link

I cannot work out how to use the nix-company.el file. It does not seem to make it into my installation.

.
├── nix-support
│   └── setup-hook
└── share
    └── emacs
        └── site-lisp
            └── elpa
                └── nix-mode-20190703.526
                    ├── nix-build.el
                    ├── nix-build.elc
                    ├── nix-drv-mode.el
                    ├── nix-edit.el
                    ├── nix-edit.elc
                    ├── nix.el
                    ├── nix.elc
                    ├── nix-format.el
                    ├── nix-format.elc
                    ├── nix-instantiate.el
                    ├── nix-instantiate.elc
                    ├── nix-log.el
                    ├── nix-log.elc
                    ├── nix-mode-autoloads.el
                    ├── nix-mode.el
                    ├── nix-mode.elc
                    ├── nix-mode-pkg.el
                    ├── nix-prettify-mode.el
                    ├── nix-prettify-mode.elc
                    ├── nix-repl.el
                    ├── nix-repl.elc
                    ├── nix-search.el
                    ├── nix-search.elc
                    ├── nix-shebang.el
                    ├── nix-shebang.elc
                    ├── nix-shell.el
                    ├── nix-shell.elc
                    ├── nix-store.el
                    └── nix-store.elc

6 directories, 30 files

I currently have nix-mode installed by

(use-package nix-mode
:mode "\\.nix\\'"
:custom
(nix-indent-function 'nix-indent-line)
)

but company-nix does not seem to be an available backend

@matthewbauer
Copy link
Member

matthewbauer commented Aug 30, 2019

I'm not sure why it is missing from the install.

I think it also may be broken currently. nix repl was changed since company-nix was originally written. It was originally contributed by @ljli and hopefully we can rework it to support the newer nix repl. Something like this should configure it:

(use-package nix-company
    :ensure nil
    :commands nix-company
    :hook (nix-mode . (lambda ()
                        (setq-local company-backends '(nix-company))))
    )

But you also need to start a nix-repl buffer to work.

@alexarice
Copy link
Author

alexarice commented Aug 30, 2019

I have tried this and get

Cannot open load file: No such file or directory, nix-company

I currently have the configuration

(use-package nix-company
:commands (company-nix)
)

(use-package nix-drv-mode
:mode "\\.drv\\'"
)

(use-package nix-mode
:mode "\\.nix\\'"
:custom
(nix-indent-function 'nix-indent-line)
)

(use-package nix-repl
:commands (nix-repl)
)

(use-package nix-shell
:commands (nix-shell-unpack nix-shell-configure nix-shell-build)
)

(use-package nix-update
)

(use-package nixos-options
:defer t
)

as well as

(use-package company
:config
(progn
(add-hook 'LaTeX-mode
(lambda ()
(set (make-local-variable 'company-backends) '(company-auctex company-dabbrev company-bbdb company-oddmuse company-eclim company-semantic company-xcode company-cmake company-capf company-files (company-dabbrev-code company-gtags company-etags company-keywords)))))
(add-hook 'irony-mode-hook
(lambda ()
(set (make-local-variable 'company-backends) '(company-irony company-dabbrev company-bbdb company-oddmuse company-eclim company-semantic company-xcode company-cmake company-capf company-files (company-dabbrev-code company-gtags company-etags company-keywords)))))
(add-hook 'nix-mode-hook
(lambda ()
(set (make-local-variable 'company-backends) '(company-nixos-options company-nix company-dabbrev company-bbdb company-oddmuse company-eclim company-semantic company-xcode company-cmake company-capf company-files (company-dabbrev-code company-gtags company-etags company-keywords)))))
(global-company-mode 1)
)
:custom
(company-idle-delay 0.100000)
(company-minimum-prefix-length 2)
(company-seletcion-wrap-around t)
:diminish
company-mode
)

This is using nix-mode obtained with nix and using emacsWithPackages

@alexarice
Copy link
Author

Would it be easier if company-nix was provided as a separate melpa package or would this cause problems with it relying on nix repl

@twlz0ne
Copy link

twlz0ne commented Sep 14, 2020

@matthewbauer commented on Aug 31, 2019, 1:09 AM GMT+8:

I'm not sure why it is missing from the install.

The nix-company.el is excluded in Melpa recipe:

       (:exclude "nix-company.el" "nix-mode-mmm.el")))

@jcs090218
Copy link
Member

Why did the nix-company.el get excluded? Can someone explain this? 😕 Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants