From 224684d68835fea800430a2bf9bde0a7e93c2e2a Mon Sep 17 00:00:00 2001 From: XeroOl Date: Sat, 20 Aug 2022 16:07:14 -0500 Subject: [PATCH] refactoring and README update --- README.md | 35 +++++++++++++++++++---------------- src/fennel-ls/compiler.fnl | 8 ++++++-- src/fennel-ls/language.fnl | 2 +- src/fennel-ls/message.fnl | 9 ++++++++- 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index c9e58c5..ed48850 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ # fennel-ls -TO PROSPECTIVE USERS: -THIS PROJECT IS NOT IN A USABLE STATE YET. CHECK BACK LATER. - A language server for fennel-ls. +Uses static analysis, and doesn't actually run your code, which makes it perfect for analyzing your (os.execute "rm -rf") code. +If you want live analysis of your code as it runs, consider using a REPL. Features / To Do List / Things I would enjoy patches for: @@ -10,24 +9,28 @@ Features / To Do List / Things I would enjoy patches for: - [ ] Support for UTF-8 characters that aren't just plain ASCII. (especially `λ`) - [ ] Settings to configure lua / fennel path, allowed globals, etc - [ ] Builds for anything other than arch linux -- [ ] Go-to-definition - - [ ] directly on require statements - - [X] for definitions in the same file - - [X] for definitions in other files - - [X] follows multisyms through table constructor - - [ ] follows multisyms through mutations (difficult) - - [ ] for methods/metamethods (difficult, in the general case may require type annotations or some insane global type inference logic) - - [ ] into lua files (maybe cheeseable with antifennel if it has --correlate?) - -- [ ] Reports compiler errors +- [ ] Go-to-definition understands: + - [X] literal table constructor + - [X] table destructuring + - [X] require + - [X] multisyms + - [X] . builtin (when called with constants) + - [X] macros (a little bit) + - [ ] lua files + - [ ] setmetatable + - [ ] function arguments / function calls +- [X] Reports compiler errors - [ ] including in macro files - [ ] Reports linting issues - [ ] Completion Suggestions - [X] Hover over a symbol for documentation - [ ] Signature help -- [ ] Go-to-references on definition sites -- [ ] integration with fnlfmt -- [ ] Maybe some sort of type checking?? +- [ ] Go-to-references +- [ ] rename +- [ ] formatting with fnlfmt +- [ ] Maybe some sort of type checking??? + +{field: {}} ## Setup: diff --git a/src/fennel-ls/compiler.fnl b/src/fennel-ls/compiler.fnl index 6c608c1..bf9074f 100644 --- a/src/fennel-ls/compiler.fnl +++ b/src/fennel-ls/compiler.fnl @@ -120,7 +120,7 @@ (table.insert diagnostics {:range range :message msg - :severity 3 + :severity message.severity.ERROR :code 201 :codeDescription "compiler error"})) (call-me-to-reset-the-compiler) @@ -145,7 +145,11 @@ (let [scope (fennel.scope)] (each [_i form (ipairs ast)] ;; COMPILE - (match (pcall fennel.compile form {:filename file.uri : scope :plugins [plugin]}) + (match (pcall fennel.compile form {:filename file.uri + :plugins [plugin] + :allowedGlobals (icollect [k v (pairs _G)] k) + :requireAsInclude false + : scope}) (where (nil err) (not= err "__NOT_AN_ERROR")) (error err))) (set file.ast ast)) diff --git a/src/fennel-ls/language.fnl b/src/fennel-ls/language.fnl index ad11072..24471e3 100644 --- a/src/fennel-ls/language.fnl +++ b/src/fennel-ls/language.fnl @@ -51,7 +51,7 @@ (set search (λ search [self file item stack] - (if + (if (sym? item) (search-symbol self file item stack) (list? item) (search-list self file item stack) (= :table (type item)) (search-table self file item stack) diff --git a/src/fennel-ls/message.fnl b/src/fennel-ls/message.fnl index 4649718..ef84d93 100644 --- a/src/fennel-ls/message.fnl +++ b/src/fennel-ls/message.fnl @@ -23,6 +23,12 @@ to look to fix this in the future." :ContentModified -32801 ;; I don't think this one is useful unless we do async things :RequestCancelled -32800}) ;; I don't think I'm going to even support cancelling things, that sounds like a pain +(local severity + {:ERROR 1 + :WARN 2 + :INFO 3 + :HINT 4}) + (λ create-error [code message ?id ?data] {:jsonrpc "2.0" :id ?id @@ -80,4 +86,5 @@ to look to fix this in the future." : ast->range : log : range-and-uri - : diagnostics} + : diagnostics + : severity}