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

lsp-nix completions dont work #4374

Closed
2 of 3 tasks
Celibistrial opened this issue Mar 16, 2024 · 4 comments
Closed
2 of 3 tasks

lsp-nix completions dont work #4374

Celibistrial opened this issue Mar 16, 2024 · 4 comments
Labels

Comments

@Celibistrial
Copy link

Celibistrial commented Mar 16, 2024

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

No completions when using nil language sever in emacs but works in other code editors (tested in neovim and VScode)
Same issue reported here oxalica/nil#117

Steps to reproduce

Open .nix file and M-x lsp!

Expected behavior

Pressing space+tab should give context appropriate completions but instead gives generic completions / no completions at all

Which Language Server did you use?

lsp-nix

OS

Linux

Error callstack

No response

Anything else?

No response

@psibi
Copy link
Member

psibi commented Mar 17, 2024

Pressing space+tab should give context appropriate completions but instead gives generic completions / no completions at all

Can you give a small reproducible example of a nix file that works with other editors too ?

@Celibistrial
Copy link
Author

Celibistrial commented Mar 18, 2024

vscode

image

emacs

image

example code
{
  inputs = {
    nixpkgs.url = "github:nixOS/nixpkgs/release-23.05";
    utils.url = "github:numtide/flake-utils";
  };
  outputs = {
    nixpkgs,
    utils,
    ...
  }:
    utils.lib.eachSystem ["i686-linux" "x86_64-linux"]
    (system: let
      pkgs = nixpkgs.legacyPackages.${system};
    in rec {
      packages = {
        nbfc = pkgs.stdenv.mkDerivation {
          name = "nbfc-linux";
          version = "0.1.15";

          src = nixpkgs.lib.cleanSource ./.;

          buildFlags = ["PREFIX=$(out)" "confdir=/etc"];
          installFlags = ["PREFIX=$(out)" "confdir=$(out)/etc"];
          installTargets = ["install-core" "install-configs" "install-docs" "install-completion"];
        };
        default = packages.nbfc;
      };
    });
}

@psibi
Copy link
Member

psibi commented Mar 18, 2024

@Celibistrial Thanks, that helps. I tried reproducing it in my emacs, but unfortunately couldn't:

nix-lsp-mode

I'm using company-mode for the completions.

@Celibistrial
Copy link
Author

Hmm , in that case its probably a doom emacs specific issue.

Whats weird is it does seem to give completions but only when i type in the first letter

image
image
image

Relevant parts of my personal config
(after! lsp-ui
  (setq lsp-ui-sideline-show-code-actions   nil)
  (setq lsp-headerline-breadcrumb-enable t)
  (setq lsp-enable-symbol-highlighting t)
  (setq lsp-signature-auto-activate t)

  (setq lsp-headerline-breadcrumb-enable t)
  (setq lsp-ui-sideline-enable t)
  (setq lsp-ui-sideline-enable t)
  (setq lsp-modeline-code-actions-enable t)
  (setq lsp-ui-sideline-enable t)
  (setq lsp-eldoc-enable-hover t)
  (setq lsp-completion-show-detail t)
  (setq lsp-completion-show-kind t))
;; //(setq lsp-auto-guess-root t)
(defun lsp-ui-sideline--compute-height nil '(height unspecified))

(use-package! lsp-nix
  :ensure lsp-mode
  :after
  (lsp-mode)
  :demand t
  :custom
  (lsp-nix-nil-formatter
   ["alejandra"]))

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

No branches or pull requests

2 participants