Skip to content

Commit 28d29f6

Browse files
authored
fix: be more resilient LSP protocol errors (#491)
fix: properly log unknown workspace command chore: justfile
1 parent ac49272 commit 28d29f6

File tree

9 files changed

+101
-17
lines changed

9 files changed

+101
-17
lines changed

.github/workflows/ci.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
branches: main
66

7+
concurrency:
8+
group: ${{ github.ref }}
9+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
10+
711
jobs:
812
tests:
913
runs-on: ${{matrix.os}}

README.md

+25-6
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,35 @@ https://github.com/sponsors/mhanberg
3737

3838
## Development
3939

40+
Next LS uses [just](https://github.com/casey/just) to coordinate command tasks.
41+
4042
```bash
43+
# list all tasks
44+
just --list
45+
# show a fzf finder of all tasks
46+
just choose
47+
48+
# default task, runs `deps compile build-local
49+
just
50+
4151
# install deps
42-
mix deps.get
52+
just deps
53+
54+
# install compile
55+
just compile
4356

4457
# start the local server for development in TCP mode
4558
# see editor extension docs for information on how to connect to a server in TCP mode
46-
bin/start --port 9000
59+
just start
4760

4861
# run the tests
49-
mix test
62+
just test
63+
64+
# build a local burrito'd exe
65+
just build-local
66+
67+
# build burrito'd exes for all platforms
68+
just build-all
5069
```
5170

5271
## Production release
@@ -59,18 +78,18 @@ Executables are output to `./burrito_out`.
5978

6079
```bash
6180
# produces executables for all the targets specified in the `mix.exs` file
62-
NEXTLS_RELEASE_MODE="burrito" MIX_ENV=prod mix release
81+
just build-all
6382

6483
# produce an executable for a single target
65-
BURRITO_TARGET=linux_amd64 MIX_ENV=prod mix release
84+
just build-local
6685
```
6786

6887
### Traditional
6988

7089
You can also build Next LS as a traditional Mix release.
7190

7291
```bash
73-
MIX_ENV=prod mix release plain
92+
just build-plain
7493
```
7594

7695
## Contributing

config/config.exs

+8
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,12 @@ import Config
22

33
config :next_ls, :indexing_timeout, 100
44

5+
case System.get_env("NEXTLS_RELEASE_MODE", "plain") do
6+
"burrito" ->
7+
config :next_ls, arg_parser: {Burrito.Util.Args, :get_arguments, []}
8+
9+
"plain" ->
10+
config :next_ls, arg_parser: {System, :argv, []}
11+
end
12+
513
import_config "#{config_env()}.exs"

config/runtime.exs

-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
import Config
22

3-
case System.get_env("NEXTLS_RELEASE_MODE", "plain") do
4-
"burrito" ->
5-
config :next_ls, arg_parser: {Burrito.Util.Args, :get_arguments, []}
6-
7-
"plain" ->
8-
config :next_ls, arg_parser: {System, :argv, []}
9-
end
10-
113
if System.get_env("NEXTLS_OTEL") == "1" do
124
config :next_ls,
135
otel: true

flake.nix

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
elixir
112112
aliased_7zz
113113
pkgs.autoconf
114+
pkgs.just
114115
pkgs.automake
115116
pkgs.ncurses5
116117
pkgs.openssl

justfile

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
default: deps compile build-local
2+
3+
choose:
4+
just --choose
5+
6+
deps:
7+
mix deps.get
8+
9+
compile:
10+
mix compile
11+
12+
start:
13+
bin/start --port 9000
14+
15+
test:
16+
mix test
17+
18+
format:
19+
mix format
20+
21+
lint:
22+
#!/usr/bin/env bash
23+
set -euxo pipefail
24+
25+
mix format --check-formatted
26+
mix credo
27+
mix dialyzer
28+
29+
[unix]
30+
build-local:
31+
#!/usr/bin/env bash
32+
case "{{os()}}-{{arch()}}" in
33+
"linux-arm" | "linux-aarch64")
34+
target=linux_arm64;;
35+
"linux-x86" | "linux-x86_64")
36+
target=linux_amd64;;
37+
"macos-arm" | "macos-aarch64")
38+
target=darwin_arm64;;
39+
"macos-x86" | "macos-x86_64")
40+
target=darwin_amd64;;
41+
*)
42+
echo "unsupported OS/Arch combination"
43+
exit 1;;
44+
esac
45+
46+
NEXTLS_RELEASE_MODE=burrito BURRITO_TARGET="$target" MIX_ENV=prod mix release
47+
48+
[windows]
49+
build-local:
50+
# idk actually how to set env vars like this on windows, might crash
51+
NEXTLS_RELEASE_MODE=burrito BURRITO_TARGET="windows_amd64" MIX_ENV=prod mix release
52+
53+
build-all:
54+
NEXTLS_RELEASE_MODE=burrito MIX_ENV=prod mix release
55+
56+
build-plain:
57+
MIX_ENV=prod mix release plain
58+
59+
bump-spitfire:
60+
mix deps.update spitfire

lib/next_ls.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ defmodule NextLS do
777777

778778
_ ->
779779
NextLS.Logger.show_message(
780-
lsp.logger,
780+
lsp.assigns.logger,
781781
:warning,
782782
"[Next LS] Unknown workspace command: #{command}"
783783
)

mix.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ defmodule NextLS.MixProject do
6363
defp deps do
6464
[
6565
{:exqlite, "~> 0.13.14"},
66-
{:gen_lsp, "~> 0.8"},
66+
{:gen_lsp, "~> 0.9"},
6767
# {:gen_lsp, path: "../gen_lsp"},
6868
{:req, "~> 0.3"},
6969
{:schematic, "~> 0.2"},

mix.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"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"},
2121
"file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"},
2222
"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"},
23-
"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"},
23+
"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"},
2424
"gproc": {:hex, :gproc, "0.9.1", "f1df0364423539cf0b80e8201c8b1839e229e5f9b3ccb944c5834626998f5b8c", [:rebar3], [], "hexpm", "905088e32e72127ed9466f0bac0d8e65704ca5e73ee5a62cb073c3117916d507"},
2525
"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"},
2626
"hpack": {:hex, :hpack_erl, "0.3.0", "2461899cc4ab6a0ef8e970c1661c5fc6a52d3c25580bc6dd204f84ce94669926", [:rebar3], [], "hexpm", "d6137d7079169d8c485c6962dfe261af5b9ef60fbc557344511c1e65e3d95fb0"},

0 commit comments

Comments
 (0)