From e5742bbc4e6a62db0e8ad15d638fcb05e1e6d453 Mon Sep 17 00:00:00 2001 From: XeroOl Date: Fri, 9 Jun 2023 01:36:59 -0500 Subject: [PATCH] make fennel-ls crash a bit less --- Makefile | 2 +- TODO.md | 13 +++++++------ src/fennel-ls/compiler.fnl | 11 ++++++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 23336da..8bad4a2 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ clean: rm -f $(EXE) test: - LUA_PATH="./src/?.lua;./?.lua" FENNEL_PATH="./src/?.fnl;./?.fnl" \ + TESTING=1 LUA_PATH="./src/?.lua;./?.lua" FENNEL_PATH="./src/?.fnl;./?.fnl" \ $(FENNEL) test/init.fnl install: $(EXE) diff --git a/TODO.md b/TODO.md index 40283ed..e6354c3 100644 --- a/TODO.md +++ b/TODO.md @@ -15,8 +15,8 @@ Here is my feature wishlist. I don't expect to ever get all of this done, but th - [X] Neovim (This project isn't a neovim plugin, but there are instructions on how to inform neovim of the fennel-ls binary once you build it.) - [X] emacs - [X] helix - - [ ] vscode - - [ ] vim+coc + - [ ] vscode (publish an extension) + - [ ] vim+coc (publish a node thingy) - [x] Go-to-definition: - [X] literal table constructor - [X] table destructuring @@ -36,12 +36,12 @@ Here is my feature wishlist. I don't expect to ever get all of this done, but th - [ ] Completion Suggestions - [X] from globals - [X] from current scope - - [ ] from macros (only on first form in a list) - - [ ] from specials (only on first form in a list) + - [X] from macros (only on first form in a list) + - [X] from specials (only on first form in a list) - [X] "dot completion" for table fields - [ ] dot completion is aware of a stdlib - [ ] actually compliant rules about lexical scope (only see things declared before, not after) - - [ ] show docs/icons on each suggestion + - [x] show docs/icons on each suggestion - [ ] "dot completion" for metatable `__index` fields - [ ] `(. obj :` string completions - [ ] `(: "foo" :` string completions @@ -52,6 +52,7 @@ Here is my feature wishlist. I don't expect to ever get all of this done, but th - [X] Report more than one error per top-level form - [ ] Reports linting issues - [X] Unused locals + - [X] Unknown fields of modules - [ ] Discarding results from pcall/xpcall/other functions - [ ] `unpack` or `values` into a special - [ ] `do`/`values` with only one inner form @@ -67,7 +68,7 @@ Here is my feature wishlist. I don't expect to ever get all of this done, but th - [ ] respond to signature help queries - [ ] hide or grey out the `self` in an `a:b` multisym call - [ ] Go-to-references - - [ ] lexical scope in the same file + - [x] lexical scope in the same file - [ ] fields - [ ] go to references of fields when tables are aliased - [ ] global search across other files diff --git a/src/fennel-ls/compiler.fnl b/src/fennel-ls/compiler.fnl index a4cff95..d4ba213 100644 --- a/src/fennel-ls/compiler.fnl +++ b/src/fennel-ls/compiler.fnl @@ -274,11 +274,12 @@ later by fennel-ls.language to answer requests from the client." (each [_i form (ipairs (if macro-file? (ast->macro-ast ast) ast))] (case (xpcall #(fennel.compile form opts) fennel.traceback) (where (or (nil err) (false err)) (not (err:find "^[^\n]-__NOT_AN_ERROR\n"))) - (error (.. "\nYou have crashed the fennel compiler or fennel-ls with the following message\n:" err - "\n\n^^^ the error message above here is the root problem\n\n")))) - ; (table.insert diagnostics - ; {:range (message.pos->range 0 0 0 0) - ; :message (.. "unrecoverable compiler error: " err)}) + (if (os.getenv :TESTING) + (error (.. "\nYou have crashed the fennel compiler or fennel-ls with the following message\n:" err + "\n\n^^^ the error message above here is the root problem\n\n")) + (table.insert diagnostics + {:range (message.pos->range 0 0 0 0) + :message (.. "unrecoverable compiler error: " err)})))) (set fennel.macro-path old-macro-path))