Giter VIP home page Giter VIP logo

nixd's Introduction

nixd

Nix language server

About

This is a feature-rich nix language server interoperating with C++ nix.

Some notable features provided by linking with the Nix library include:

  • Nixpkgs option support, for all option system (NixOS/home-manager/flake-parts).
  • Nixpkgs package complete, lazily evaluated.
  • Shared eval caches (flake, file) with your system's Nix.
  • Support for cross-file analysis (goto definition to locations in nixpkgs).

Get Started

You can try nixd without installation. We have tested some working & reproducible editor environments.

Resources

nixd's People

Contributors

a-kenji avatar adisbladis avatar cmacrae avatar dtcxzyw avatar euphgh avatar federicoschonborn avatar freed-wu avatar happysalada avatar harshal662 avatar hellodword avatar inclyc avatar jaypankajpatel avatar jonathanjameswatson avatar junaire avatar katexochen avatar origami404 avatar peterbecich avatar ruixi-rebirth avatar shivaraj-bh avatar szicari-streambit avatar xokdvium avatar yvan-sraka 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  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  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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nixd's Issues

nixd: status

LSP Spec

Lifecycle Messages

  • initialize
  • initialized
  • $/setTrace

Text Document Synchronization

  • textDocument/didOpen #2
  • textDocument/didChange #2
  • textDocument/didClose #82

Language Features

  • textDocument/publishDiagnostics #7
  • textDocument/hover #22
  • textDocument/completion
    #33
    #87
    #88
  • textDocument/semanticTokens/* #52
  • textDocument/declaration #93
  • textDocument/definition
    #61
    #62
    #65
    #66
  • textDocument/references
  • textDocument/documentLink
  • textDocument/formatting
    #78
    #79

Workspace Features

  • workspace/configuration #23
  • workspace/didChangeConfiguration #23

Non-LSP Notes

Nix Evaluator Extension

Milestones

  • Evaluation performance #50

Vendor

  • Flake package #41
  • Flake overlay #55

Docs

  • Developers' Manual #39
  • User Guide #58

misc: platform testing

Currently the binaries are only tested on x86_64-linux. But actually nixd may work on other platforms (e.g. aarch64-linux).

If you have tested this please update the flake (if it works), or submit an issue (oops...).

docs/editor: add editor setup guide

Most users would like to know just one thing: how to setup their editor to use nixd.

It would be good to document that in the README.md, in my case VSCode.

aarch64-linux build failing

2023-06-02T08:04:05.4886792Z error: builder for '/nix/store/ddisyw8qp2bvqdnpnzpnl54ljjv6476x-nixd-0.0.1.drv' failed with exit code 1;
2023-06-02T08:04:05.4893892Z last 10 log lines:
2023-06-02T08:04:05.4894283Z > | |
2023-06-02T08:04:05.4909442Z > | std::string {aka std::__cxx11::basic_string}
2023-06-02T08:04:05.4910661Z > In file included from ../lib/nixd/include/nixd/CallbackExpr.h:4,
2023-06-02T08:04:05.4910984Z > from ../lib/nixd/include/nixd/AST.h:3,
2023-06-02T08:04:05.4911443Z > from ../lib/nixd/src/AST.cpp:1:
2023-06-02T08:04:05.4933509Z > /nix/store/y5w2djdr3mlqhr579wfnyh1idha6b9ji-nix-2.16.0-dev/include/nix/eval.hh:361:28: note: initializing argument 1 of 'void nix::EvalState::cacheFile(const nix::SourcePath&, const nix::SourcePath&, nix::Expr*, nix::Value&, bool)'
2023-06-02T08:04:05.4934037Z > 361 | const SourcePath & path,
2023-06-02T08:04:05.4934274Z > | ~~~~~~~~~~~~~~~~~~~^~~~
2023-06-02T08:04:05.4934668Z > [11/25] Compiling C++ object lib/nixd/libnixd-lsp.so.p/src_CallbackExpr.cpp.o
2023-06-02T08:04:05.4934995Z > ninja: build stopped: subcommand failed.
2023-06-02T08:04:05.4935446Z For full logs, run 'nix log /nix/store/ddisyw8qp2bvqdnpnzpnl54ljjv6476x-nixd-0.0.1.drv'.

Completion fails, "no AST available"

Requesting completions fails with the following errors:

I[01:11:13.054] 2100851: <-- textDocument/completion(25)
I[01:11:13.055] 2100851: --> call nixd/ipc/textDocument/completion(266)
I[01:11:13.055] 2100851: --> call nixd/ipc/textDocument/completion(267)
I[01:11:13.055] 2225720: <-- nixd/ipc/textDocument/completion(266)
I[01:11:13.055] 2100851: --> call nixd/ipc/textDocument/completion(268)
I[01:11:13.055] 2225720: --> reply:nixd/ipc/textDocument/completion(266) no AST available on requested file /home/n/git/config/modules/nix.nix, error: 3
I[01:11:13.055] 2225724: <-- nixd/ipc/textDocument/completion(267)
I[01:11:13.055] 2100851: --> call nixd/ipc/textDocument/completion(269)
I[01:11:13.055] 2225724: --> reply:nixd/ipc/textDocument/completion(267) no AST available on requested file /home/n/git/config/modules/nix.nix, error: 3
I[01:11:13.055] 2225728: <-- nixd/ipc/textDocument/completion(268)
I[01:11:13.055] 2100851: <-- reply(266)
I[01:11:13.055] 2225732: <-- nixd/ipc/textDocument/completion(269)
E[01:11:13.055] 2100851: worker 0 reported error: -32001: no AST available on requested file /home/n/git/config/modules/nix.nix
I[01:11:13.055] 2225728: --> reply:nixd/ipc/textDocument/completion(268) no AST available on requested file /home/n/git/config/modules/nix.nix, error: 3
I[01:11:13.056] 2100851: <-- reply(267)
[truncated, more of the same]

nixd/AST: improve location map

nix::ExprAttrs nix::ExprLambda contain pos information on their own data structure, we may want to associate the expressions with that pos information, to get more accurate response.

VSCode setup doesn't work

I followed the instructions to the tee: https://github.com/nix-community/nixd/blob/main/docs/editor-setup.md#vscode

The result?

image
[Info  - 1:32:56 PM] Connection to server got closed. Server will restart.
[Error - 1:32:56 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 1:32:56 PM] Nix client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 

Is there anything I can do on my end to get more debug information?

segfaults on aarch64-darwin

I actually don't know how to find coredumps on MacOS but every command segfaults immediately:

arian@Arians-MacBook-Pro nixos-stuff % nixd
zsh: segmentation fault  nixd
arian@Arians-MacBook-Pro nixos-stuff % nixd --help
zsh: segmentation fault  nixd --help

nixd/configuration: mandatory field "args" is confusing for new users

Curious if anybody got emacs(elgot) setup with nixd.

I've got basic elgot setup working with nixd:

(add-to-list 'eglot-server-programs '((nix-mode) "nixd"))

But I couldn't figure out how to config nixd properly with elgot:

(setq-default eglot-workspace-configuration
		'((nixd
		   (options
		    (enable . t)
		    (target
		     (installable . "/home/xx/myflake#nixosConfigurations.myhost.options"))))))

For example, if I hard coded above installable, I don't think it's doing anything. I'm pretty new to lsp and elgot, I have no idea how to debug this case.

Also, even without the installable, I found the complete result pretty weird:

for example, it completes builtins.fromTOML but obviously missing builtins.fromJSON somehow, maybe this is a separate issue.

image

nixd/diagnostic: send evaluation diagnostic to client

Installable specified in workspace configuration is now evaluated at worker process, however, we just log the exception encountered, but not reported the bug to our client, how about send diagnostic issue at the first line of textDocument/did{Open,Change} ?

nixd: remove possible extra `textDocument/publishDiagnostics` message

// Since this file is updated, we first clear its diagnostic
PublishDiagnosticsParams Notification;
Notification.uri = URIForFile::canonicalize(File, File);
Notification.diagnostics = {};
Notification.version = DraftStore::decodeVersion(Version);
PublishDiagnostic(Notification);

This is might be unnecessary because we will clear diagnostics later. You can test this locally, and if it is really unnecessary, just remove it!

Or, we should use this method instead:

clearDiagnostics

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.