Open kentookura opened 2 weeks ago
Can you share your project? Are you building everything with opam-nix
? Is it all part of a single scope?
Of course:
Full repo: https://git.sr.ht/~jonsterling/ocaml-forester/tree/lsp
dune-project:
(lang dune 3.13)
;;; SPDX-FileCopyrightText: 2024 The Forester Project Contributors
;;;
;;; SPDX-License-Identifier: GPL-3.0-or-later
(using menhir 3.0)
(name forester)
(authors "Jonathan Sterling")
(maintainers "Jonathan Sterling")
(version 5.0)
(generate_opam_files true)
(implicit_transitive_deps false)
(source
(sourcehut jonsterling/ocaml-forester))
(bug_reports https://todo.sr.ht/~jonsterling/forester)
(homepage https://sr.ht/~jonsterling/forester/)
(license GPL-3.0-or-later)
(package
(name forester)
(synopsis "A tool for tending mathematical forests")
(depends
(menhir
(>= 20240715))
(ocamlgraph
(>= 2.1.0))
(ocaml
(>= 5.2.0))
dune
ppx_deriving
(cmdliner
(>= 1.2.0))
dune-build-info
(iri
(>= 1.0.0))
(uucp
(>= 15.1.0))
(eio_main
(>= 1.1))
(ptime
(>= 1.1.0))
(asai
(>= 0.3.0))
(yuujinchou
(>= 5.2.0))
(bwd
(>= 2.3.0))
(algaeff
(>= 2.0.0))
(yojson
(>= 2.1.2))
(toml
(>= 7.1.0))
(repr
(>= 0.7.0))
(ppx_repr
(>= 0.7.0))
(uri
(>= 4.4.0))
(pure-html
(>= 3.6.1))
(base64
(>= 3.5.1))
(datalog
(>= 0.7))
(cid
(>= 0.1.0))
(lsp
(>= 0.19.0))
(ppx_yojson_conv
(>= 0.17.0))))
opam file:
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "5.0"
synopsis: "A tool for tending mathematical forests"
maintainer: ["Jonathan Sterling"]
authors: ["Jonathan Sterling"]
license: "GPL-3.0-or-later"
homepage: "https://sr.ht/~jonsterling/forester/"
bug-reports: "https://todo.sr.ht/~jonsterling/forester"
depends: [
"menhir" {>= "20240715"}
"ocamlgraph" {>= "2.1.0"}
"ocaml" {>= "5.2.0"}
"dune" {>= "3.13"}
"ppx_deriving"
"cmdliner" {>= "1.2.0"}
"dune-build-info"
"iri" {>= "1.0.0"}
"uucp" {>= "15.1.0"}
"eio_main" {>= "1.1"}
"ptime" {>= "1.1.0"}
"asai" {>= "0.3.0"}
"yuujinchou" {>= "5.2.0"}
"bwd" {>= "2.3.0"}
"algaeff" {>= "2.0.0"}
"yojson" {>= "2.1.2"}
"toml" {>= "7.1.0"}
"repr" {>= "0.7.0"}
"ppx_repr" {>= "0.7.0"}
"uri" {>= "4.4.0"}
"pure-html" {>= "3.6.1"}
"base64" {>= "3.5.1"}
"datalog" {>= "0.7"}
"cid" {>= "0.1.0"}
"lsp" {>= "0.19.0"}
"ppx_yojson_conv" {>= "0.17.0"}
"odoc" {with-doc}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://git.sr.ht/~jonsterling/ocaml-forester"
flake.nix:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
opam-repository.url = "github:ocaml/opam-repository";
opam-repository.flake = false;
opam-nix.url = "github:tweag/opam-nix";
};
outputs =
{
self,
flake-utils,
opam-nix,
nixpkgs,
opam-repository,
}@inputs:
let
package = "forester";
in
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
on = opam-nix.lib.${system};
devPackagesQuery = {
ocaml-base-compiler = "5.2.0";
ocaml-lsp-server = "*";
ocamlformat = "*";
memtrace = "*";
};
query = devPackagesQuery // { };
scope = on.buildOpamProject' { repos = [ "${opam-repository}" ]; } ./. query;
overlay = final: prev: {
${package} = prev.${package}.overrideAttrs (_: {
doNixSupport = false;
});
};
scope' = scope.overrideScope' overlay;
main = scope'.${package};
devPackages = builtins.attrValues (pkgs.lib.getAttrs (builtins.attrNames devPackagesQuery) scope');
in
{
legacyPackages = scope';
packages.default = main;
devShells.default = pkgs.mkShell {
inputsFrom = [ main ];
buildInputs = devPackages ++ [
pkgs.topiary
pkgs.reuse
];
};
}
);
}
This seems to be correct, and it's definitely building both forester
and ocaml-lsp-server
with the same ocaml compiler. The symbol picker (workspace/symbol
) also seems to work for me (I'm using Helix). I just cloned the project, checked out the lsp
branch, then direnv allow
and dune build
:
Perhaps you need to direnv reload
, run dune build
again, or start your editor from a new shell to refresh some non-invalidated cache somewhere?
This does not seem to be the problem. My environment is definitely up to date, and if I try to use the symbol picker in helix, it reports "protocol error: InternalError: uncaught exception"...
I just pushed a new flake.lock
file, to make sure we are debugging the same environment.
I just tried with your updated flake.lock
; I entered a "pure" shell with nix develop --ignore-environment
, ran Helix with nix run np#helix
, and was still able to use the workspace_symbol_picker
with no issues.
Is there a chance you have ocaml-lsp-server
or merlin
or something like that installed globally that might be "poisoning" your environment? Can you try inside the pure shell with nix develop --ignore-environment
?
No, the lsp and merlin are not available in the global environment. Running nix develop --ignore-environment
and nix run nixpkgs#helix
results in the same error.
This is quite weird. I was able to get it working easily on another (NixOS) machine. Here are the exact things I did:
$ git clone https://git.sr.ht/~jonsterling/ocaml-forester
Cloning into 'ocaml-forester'...
remote: Enumerating objects: 7951, done.
remote: Counting objects: 100% (721/721), done.
remote: Compressing objects: 100% (399/399), done.
remote: Total 7951 (delta 511), reused 363 (delta 315), pack-reused 7230 (from 1)
Receiving objects: 100% (7951/7951), 2.47 MiB | 31.96 MiB/s, done.
Resolving deltas: 100% (5377/5377), done.
$ cd ocaml-forester
$ git checkout lsp
branch 'lsp' set up to track 'origin/lsp'.
Switched to a new branch 'lsp'
$ nix develop --ignore-environment
bash-5.2$ dune build
File "lib/compiler/Grammar.mly", line 15, characters 16-23:
Warning: the token COMMENT is unused.
File "Grammar.mly", line 15, characters 16-23:
Warning: the token COMMENT is unused.
Read 92 sample input sentences and 19 error messages.
bash-5.2$ nix run nixpkgs#helix
SPACE+f lib/forest/Forest.ml RET SPACE+S
And it gave me the list of all symbols in the workspace just fine.
Hmm, oh well. It's not urgent at all. If this persists after the issue on the merlin repo is solved, I might try to get it working again, but in the meantime, you don't need to waste any more time on this. Thanks for your quick respones!
I am experiencing a bug with ocamllsp and it was indicated to me that this may be due to a version mismatch between the compiler that builds my project and the compiler that compiled the language server: https://github.com/ocaml/merlin/issues/1860
What do I need to do to verify and fix this?
Thanks!