Skip to content

Commit

Permalink
fix: be more resilient LSP protocol errors (#491)
Browse files Browse the repository at this point in the history
fix: properly log unknown workspace command

chore: justfile
  • Loading branch information
mhanberg authored May 21, 2024
1 parent ac49272 commit 28d29f6
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -59,18 +78,18 @@ 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

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

```bash
MIX_ENV=prod mix release plain
just build-plain
```

## Contributing
Expand Down
8 changes: 8 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
8 changes: 0 additions & 8 deletions config/runtime.exs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
elixir
aliased_7zz
pkgs.autoconf
pkgs.just
pkgs.automake
pkgs.ncurses5
pkgs.openssl
Expand Down
60 changes: 60 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion lib/next_ls.ex
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ defmodule NextLS do

_ ->
NextLS.Logger.show_message(
lsp.logger,
lsp.assigns.logger,
:warning,
"[Next LS] Unknown workspace command: #{command}"
)
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 28d29f6

Please sign in to comment.