diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 30c4dedf..f1575f2e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,6 +4,10 @@ on: push: branches: main +concurrency: + group: ${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + jobs: tests: runs-on: ${{matrix.os}} diff --git a/README.md b/README.md index 97059948..49ddc759 100644 --- a/README.md +++ b/README.md @@ -37,16 +37,35 @@ https://github.com/sponsors/mhanberg ## Development +Next LS uses [just](https://github.com/casey/just) to coordinate command tasks. + ```bash +# list all tasks +just --list +# show a fzf finder of all tasks +just choose + +# default task, runs `deps compile build-local +just + # install deps -mix deps.get +just deps + +# install compile +just compile # start the local server for development in TCP mode # see editor extension docs for information on how to connect to a server in TCP mode -bin/start --port 9000 +just start # run the tests -mix test +just test + +# build a local burrito'd exe +just build-local + +# build burrito'd exes for all platforms +just build-all ``` ## Production release @@ -59,10 +78,10 @@ Executables are output to `./burrito_out`. ```bash # produces executables for all the targets specified in the `mix.exs` file -NEXTLS_RELEASE_MODE="burrito" MIX_ENV=prod mix release +just build-all # produce an executable for a single target -BURRITO_TARGET=linux_amd64 MIX_ENV=prod mix release +just build-local ``` ### Traditional @@ -70,7 +89,7 @@ BURRITO_TARGET=linux_amd64 MIX_ENV=prod mix release You can also build Next LS as a traditional Mix release. ```bash -MIX_ENV=prod mix release plain +just build-plain ``` ## Contributing diff --git a/config/config.exs b/config/config.exs index 66b093dd..153bd03b 100644 --- a/config/config.exs +++ b/config/config.exs @@ -2,4 +2,12 @@ import Config config :next_ls, :indexing_timeout, 100 +case System.get_env("NEXTLS_RELEASE_MODE", "plain") do + "burrito" -> + config :next_ls, arg_parser: {Burrito.Util.Args, :get_arguments, []} + + "plain" -> + config :next_ls, arg_parser: {System, :argv, []} +end + import_config "#{config_env()}.exs" diff --git a/config/runtime.exs b/config/runtime.exs index 51307dcc..ce04f4b4 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -1,13 +1,5 @@ import Config -case System.get_env("NEXTLS_RELEASE_MODE", "plain") do - "burrito" -> - config :next_ls, arg_parser: {Burrito.Util.Args, :get_arguments, []} - - "plain" -> - config :next_ls, arg_parser: {System, :argv, []} -end - if System.get_env("NEXTLS_OTEL") == "1" do config :next_ls, otel: true diff --git a/flake.nix b/flake.nix index 6ac8abc1..1f574c30 100644 --- a/flake.nix +++ b/flake.nix @@ -111,6 +111,7 @@ elixir aliased_7zz pkgs.autoconf + pkgs.just pkgs.automake pkgs.ncurses5 pkgs.openssl diff --git a/justfile b/justfile new file mode 100644 index 00000000..c1ff4933 --- /dev/null +++ b/justfile @@ -0,0 +1,60 @@ +default: deps compile build-local + +choose: + just --choose + +deps: + mix deps.get + +compile: + mix compile + +start: + bin/start --port 9000 + +test: + mix test + +format: + mix format + +lint: + #!/usr/bin/env bash + set -euxo pipefail + + mix format --check-formatted + mix credo + mix dialyzer + +[unix] +build-local: + #!/usr/bin/env bash + case "{{os()}}-{{arch()}}" in + "linux-arm" | "linux-aarch64") + target=linux_arm64;; + "linux-x86" | "linux-x86_64") + target=linux_amd64;; + "macos-arm" | "macos-aarch64") + target=darwin_arm64;; + "macos-x86" | "macos-x86_64") + target=darwin_amd64;; + *) + echo "unsupported OS/Arch combination" + exit 1;; + esac + + NEXTLS_RELEASE_MODE=burrito BURRITO_TARGET="$target" MIX_ENV=prod mix release + +[windows] +build-local: + # idk actually how to set env vars like this on windows, might crash + NEXTLS_RELEASE_MODE=burrito BURRITO_TARGET="windows_amd64" MIX_ENV=prod mix release + +build-all: + NEXTLS_RELEASE_MODE=burrito MIX_ENV=prod mix release + +build-plain: + MIX_ENV=prod mix release plain + +bump-spitfire: + mix deps.update spitfire diff --git a/lib/next_ls.ex b/lib/next_ls.ex index f77c6440..c52d15b9 100644 --- a/lib/next_ls.ex +++ b/lib/next_ls.ex @@ -777,7 +777,7 @@ defmodule NextLS do _ -> NextLS.Logger.show_message( - lsp.logger, + lsp.assigns.logger, :warning, "[Next LS] Unknown workspace command: #{command}" ) diff --git a/mix.exs b/mix.exs index a2982a40..fef8d601 100644 --- a/mix.exs +++ b/mix.exs @@ -63,7 +63,7 @@ defmodule NextLS.MixProject do defp deps do [ {:exqlite, "~> 0.13.14"}, - {:gen_lsp, "~> 0.8"}, + {:gen_lsp, "~> 0.9"}, # {:gen_lsp, path: "../gen_lsp"}, {:req, "~> 0.3"}, {:schematic, "~> 0.2"}, diff --git a/mix.lock b/mix.lock index e391027e..ecb363f0 100644 --- a/mix.lock +++ b/mix.lock @@ -20,7 +20,7 @@ "exqlite": {:hex, :exqlite, "0.13.15", "a32c0763915e2b0d7ced9dd8638802d38e9569053f3b28b815bd0faef1cbe6d9", [:make, :mix], [{:cc_precompiler, "~> 0.1", [hex: :cc_precompiler, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "4afcc870a33b57781a1e57cd4294eef68815059d26b774c7cd075536b21434b7"}, "file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"}, "finch": {:hex, :finch, "0.18.0", "944ac7d34d0bd2ac8998f79f7a811b21d87d911e77a786bc5810adb75632ada4", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.3", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2.6 or ~> 1.0", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "69f5045b042e531e53edc2574f15e25e735b522c37e2ddb766e15b979e03aa65"}, - "gen_lsp": {:hex, :gen_lsp, "0.8.1", "847587dfcb1d6c08c1fc9506a2b47af134e64346b14df551c286623c318705f2", [:mix], [{:jason, "~> 1.3", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.5 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:schematic, "~> 0.2.1", [hex: :schematic, repo: "hexpm", optional: false]}, {:typed_struct, "~> 0.3.0", [hex: :typed_struct, repo: "hexpm", optional: false]}], "hexpm", "33a4890b707025491a0c7c907a71516d3b37e08567231d0b0ac3950cda8bc088"}, + "gen_lsp": {:hex, :gen_lsp, "0.9.0", "a47bb094a97113419fac02d98103f333209c77a660c9441e9a0e5a9e0aa75f91", [:mix], [{:jason, "~> 1.3", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.5 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:schematic, "~> 0.2.1", [hex: :schematic, repo: "hexpm", optional: false]}, {:typed_struct, "~> 0.3.0", [hex: :typed_struct, repo: "hexpm", optional: false]}], "hexpm", "9a64d6ed15bb0152054b0aba5b7d2d48d1c4a65a937b43f956e6ec1f33039a07"}, "gproc": {:hex, :gproc, "0.9.1", "f1df0364423539cf0b80e8201c8b1839e229e5f9b3ccb944c5834626998f5b8c", [:rebar3], [], "hexpm", "905088e32e72127ed9466f0bac0d8e65704ca5e73ee5a62cb073c3117916d507"}, "grpcbox": {:hex, :grpcbox, "0.17.1", "6e040ab3ef16fe699ffb513b0ef8e2e896da7b18931a1ef817143037c454bcce", [:rebar3], [{:acceptor_pool, "~> 1.0.0", [hex: :acceptor_pool, repo: "hexpm", optional: false]}, {:chatterbox, "~> 0.15.1", [hex: :ts_chatterbox, repo: "hexpm", optional: false]}, {:ctx, "~> 0.6.0", [hex: :ctx, repo: "hexpm", optional: false]}, {:gproc, "~> 0.9.1", [hex: :gproc, repo: "hexpm", optional: false]}], "hexpm", "4a3b5d7111daabc569dc9cbd9b202a3237d81c80bf97212fbc676832cb0ceb17"}, "hpack": {:hex, :hpack_erl, "0.3.0", "2461899cc4ab6a0ef8e970c1661c5fc6a52d3c25580bc6dd204f84ce94669926", [:rebar3], [], "hexpm", "d6137d7079169d8c485c6962dfe261af5b9ef60fbc557344511c1e65e3d95fb0"},