Commit Graph

250 Commits

Author SHA1 Message Date
XeroOl
5bb3f76050 fix documentation for macros, and fix completion item kind 2025-04-23 23:42:29 -05:00
XeroOl
3f1c2ea361 clean up some tests, restore (fn M.method []) completion handling 2025-04-23 23:42:29 -05:00
XeroOl
8a1aa53505 fix string methods, and some tests 2025-04-23 23:42:29 -05:00
XeroOl
5017177b44 horrible messy code that does deeper completions 2025-04-23 23:42:29 -05:00
XeroOl
a4d99be235 macro modules and regular modules in separate namespaces
implements #49
2025-04-10 14:28:21 -05:00
Michele Campeotto
945eb86b4c SignatureHelp returns parameters ranges instead just the name.
This fixes an issue where a parameter name that is a substring of the
function name causes the client to highlight the function name substring
instead of the argument. Using ranges of the signature string avoids the
problem.
2025-04-07 20:56:19 -07:00
XeroOl
f68d8ba6fc compiler warnings 2025-04-06 16:14:42 -05:00
Michele Campeotto
f3d5984091 Improved signature help and active argument detection.
This now uses a more correct algorithm to find the function call the
user is typing and also adds active argument detection.
2025-04-02 08:50:12 -07:00
Michele Campeotto
6325b9c6ff Fix operator with no arguments lint incorrect report.
Operator with no arguments check failed when the first argument to the
operator was falsy. We might want to have a new lint to check for
"always false/true" expressions but this report was incorrect and the
quickfix replaced incorrect code.
2025-03-24 08:31:23 -07:00
Michele Campeotto
7345d1bcd6 Update diagnostics to be spec compliant.
The spec says diagnostic.codeDescription should be an object with an URI
linking to information about the error, we were using it as a string
identifier for the diagnostic.

This was making Helix ignore all diagnostics from fennel-ls.

Changed diagnostic.code to be the string identifier, removed numeric
identifiers and codeDescription field.
2025-03-22 12:10:54 -07:00
Michele Campeotto
e504013663 Update unnecessary tset lint to handle any key nesting depth.
The unnecessary tset lint was assuming a single key, but it was
triggering for calls with multiple nested keys, causing the quickfix
action to drop all elements after the fourth argument, which was assumed
to be the value.

Now it's been updated to handle nested calls of any depth.
2025-03-22 12:03:57 -07:00
Michele Campeotto
8d74f0134a Format function signatures from ast and metadata the same.
Function signatures rendered from ast were being rendered differently
from signatures rendered from metadata, this unifies them, using the
metadata format for both.

Before:
    (fn func-name [arg1 arg2] ...)
After:
    (func-name arg1 arg2)

This signature is used in the 'hover' feature and in completion
documentation.

This patch also adds three dashes as a separator between the signature
and the documentation text to improve readability. Since the text is
being interpreted as Markdown, this results in a line being drawn. This
format convention matches other language servers, for example LuaLS.
2025-03-21 10:42:21 -07:00
Michele Campeotto
627a02e2c0 Implement basic signatureHelp feature.
This implements the simple form of the signatureHelp feature, which only
displays the signature of the function being typed, without indication
of the active argument.

Active argument detection, while accounting for destructuring to support
each and for special forms turned out to be more involved than expected
and is left for a follow up patch.
2025-03-21 10:42:13 -07:00
Phil Hagelberg
3eb016a369 Search for special forms in analyzer. 2025-03-15 12:26:15 -07:00
Michele Campeotto
b1986395cf Provide human readable code action descriptions
These strings will be displayed in a menu for the user to select.

The error codes, in addition to not being human readable sentences,
describe the issue being reported, not the solution that will be
applied.

The code action response only includes the human readable string, so the
tests need to check for that. I considered adding a custom field but
decided against going out of spec.
2025-03-11 08:58:18 -07:00
Andrey Listopadov
db37838272 print severity levels in the output when linting with --lint 2025-03-04 21:03:19 -08:00
Phil Hagelberg
3a30fc83ed Support (or table.unpack _G.unpack) pattern without unknown field lint.
Now we are selflint clean! We can enable it in the ci target now.
2025-03-02 22:05:33 -08:00
Michele Campeotto
0b979f1e78 documentHighlight should not show references in other files
documentHighlight was highlighting symbols that were defined in other
files (incorrectly, because the response only contains ranges, not
locations), but this feature is meant for the current document only.
2025-03-02 08:56:29 -08:00
Phil Hagelberg
32350ec44b Recognize deprecated functions that haven't been removed yet. 2025-02-28 04:18:36 -08:00
Phil Hagelberg
024083c7d2 Add test for config validation. 2025-02-28 02:30:59 -08:00
Phil Hagelberg
670f7d108b Only generate lua manual docs; move tic80/love2d to other repo.
https://git.sr.ht/~technomancy/fennel-ls-docsets
2025-02-28 02:30:55 -08:00
Michele Campeotto
bb2ccd67c2 Add support for textDocument/documentHighlight 2025-02-27 18:18:35 -08:00
Phil Hagelberg
d23d36a414 Support :union as lua-version setting. 2025-02-26 23:09:11 -08:00
Phil Hagelberg
0d7e9b6183 Add test to ensure that evil docsets can't run evil code. 2025-02-26 22:54:42 -08:00
Phil Hagelberg
9b54f882c9 Add tests for tic80 docset and fake external docset. 2025-02-26 22:41:59 -08:00
Phil Hagelberg
98cd94d212 Add aliases for lua-versions.
Now you can specify "lua54" OR "lua5.4" and get what you need.
2025-02-26 01:38:58 -08:00
Phil Hagelberg
d7b88efe69 Only set default completion kind when it's not already present! 2025-02-26 01:12:02 -08:00
Michele Campeotto
1d2ea48c16 allow docs to set the item kind 2025-02-25 05:38:50 -08:00
Phil Hagelberg
78da9c2edc Add support for :intersection as lua version.
This will only accept globals which are present in every Lua version
from 5.1-5.4. Using this for selflint currently fails, so let's fix
that next.
2025-02-25 01:08:07 -08:00
Phil Hagelberg
dc833b8db9 Disable failing tests. 2025-02-15 09:51:54 -08:00
Phil Hagelberg
adcff56050 Fix warning in completion test; remove unused stuff from makefile. 2025-02-15 09:51:54 -08:00
XeroOl
ae66e6d002 analyzer can search into macro expansions and functions
shoutouts to rudy for working with me on these changes.
2025-01-19 19:56:37 -06:00
Phil Hagelberg
e5dc04764c Allow trailing underscores to bypass unused local warnings. 2025-01-05 12:40:25 -08:00
Phil Hagelberg
3979ab4c3c Strings beginning with digits can't be rewritten as syms.
Also fix a self-lint.
2025-01-05 12:39:10 -08:00
XeroOl
7f15f64e22 tset lint should only apply when rewriting as sym is valid 2024-12-28 15:50:44 -06:00
Phil Hagelberg
baf1065f0b Add assert-ok helper for linting tests.
Also factor out FAITH_TEST flag so you can use it to run an entire
module, not just individual tests.
2024-10-10 19:54:18 -05:00
Phil Hagelberg
b5dbeb28fe Add unnecessary-tset, unnecessary-do, and redundant-do lints.
"Redundant" means that it's a `do` in a context where there's already
an implicit `do`, as defined by fennel.syntax indicating body-form? is
true. Unnecessary means it only has one argument.
2024-10-10 19:50:16 -05:00
Phil Hagelberg
a27f42bfa4 Add match-should-case lint and fix action.
When a `match` call's patterns do not contain any symbols that reference
the outer scope, then there is no reason to use `match`; that call
should be replaced with `case`.

This allocates diagnostic code 308 to match-should-case.

In order to detect this, I had to add a loop over file.lexicals. This
is often a very large table, so it could adverse performance impact. I
believe it is necessary in order to distinguish between case vs match
since other means seem to only be applied after macroexpansion by
which time neither one exists.

I've updated docs/linting.md to mention the new loop and cleaned up a
few things in that file that were outdated.

I've added tests for the new lint to ensure it doesn't trigger when it
shouldn't.
2024-10-10 19:46:59 -05:00
XeroOl
5e8b31ea47 use fennel 1.5's native debug tracking 2024-09-03 12:17:53 -05:00
XeroOl
58c79a727e Add tests for editing flsconfig 2024-07-30 22:30:56 -05:00
XeroOl
3d1485060c fix "unknown module field" when accessing fields from doc objects with no known fields
this means stuff like `io.stderr:write` isn't a warning anymore
2024-07-15 17:48:11 -05:00
XeroOl
07e8239216 goto module definition tested 2024-07-09 20:37:11 -05:00
XeroOl
6801d0d3d9 unknown module field lint works on definitions 2024-07-07 23:54:17 -05:00
XeroOl
d015776f5e configuration rename some keys 2024-07-07 22:00:59 -05:00
XeroOl
b0b91a4fd4 refactoring 2024-07-07 14:31:22 -05:00
XeroOl
fbd9b0981f switch from initialization options and didChangeConfiguration to flsproject.fnl 2024-07-05 12:40:15 -05:00
XeroOl
d309c80541 simplify tests. only one create-client function 2024-07-05 00:25:51 -05:00
XeroOl
9e9af12f41 fix issue with (set (. x y) z)
fennel needs to skip these instead of failing to parse them
2024-06-30 18:37:55 -05:00
XeroOl
eff9bced51 basic hovering 2024-06-24 00:48:51 -05:00
XeroOl
b11b5b7962 small changes 2024-06-24 00:22:51 -05:00
XeroOl
d8bfaa3559 --check is now --lint 2024-06-23 15:44:35 -05:00
XeroOl
664ba9b13d bunch of small changes 2024-06-15 22:32:46 -05:00
Rudolf Adamkovič
d4343392ab Format '--check' errors so that tooling can detect them 2024-06-15 22:30:18 -05:00
XeroOl
14094762ab Switch from rxi/json to dkjson, switch folder structure 2024-06-09 17:36:19 -05:00
XeroOl
7469a8854c Remove faith's readme 2024-06-09 17:36:08 -05:00
XeroOl
8dc4f3d0f8 Rename language -> analyzer 2024-06-05 01:22:08 -05:00
XeroOl
c56ce89ccf λ now warns about unused arguments 2024-06-04 20:17:21 -05:00
XeroOl
7194838132 return both the server and client from create-client 2024-06-01 23:17:00 -05:00
XeroOl
9770e3eefd Rename self->client in tests 2024-06-01 23:12:42 -05:00
XeroOl
0ddd8f0bf0 TIC-80 docs sort of work?
{:fennel-ls {:native-libraries [:tic80]}}
2024-06-01 15:14:15 -05:00
XeroOl
e0067880d1 Unknown field lint only triggers at stack size 1
This is probably not a good commit message, but basically, if you
require a module foo, and then look for foo.bar.baz, it won't trigger,
but foo.bar will trigger it.
2024-05-29 22:38:55 -05:00
XeroOl
3f5984df06 Add extra check to textEdit
I really should just make it (pairs) through all the keys, but for now
I'll just keep adding the checks manually.
2024-05-29 22:01:56 -05:00
XeroOl
4c92af1bc5 Align allowed-globals with the currently selected docs 2024-05-17 20:45:37 -05:00
XeroOl
a122d9d361 Make the root folder optional 2024-05-17 20:45:16 -05:00
XeroOl
1a21ee623d fix positionEncoding to be a capability 2024-05-15 22:58:51 -05:00
XeroOl
3dc9e36af6 workaround for fennel#221 2024-05-14 00:46:10 -05:00
XeroOl
e37c77958d fix zero-arg documented function formatting 2024-05-14 00:18:07 -05:00
XeroOl
3fad66a476 Switch docs to autogenerated 2024-05-13 23:58:37 -05:00
XeroOl
0068662c8b add test for a fix I did a while ago 2024-05-13 01:53:52 -05:00
XeroOl
8d57f60369 remove some comments :) 2024-05-13 01:07:05 -05:00
XeroOl
4bce5c87ec Tests for reader macros 2024-05-13 01:06:46 -05:00
XeroOl
f17342b7ce Fix hashfn and quote and unquote 2024-05-12 16:45:18 -05:00
XeroOl
34e0bce092 Hover in hashfn 2024-05-12 15:32:43 -05:00
XeroOl
be44cda696 Unknown field errors in _G are suppressed 2024-05-12 12:26:24 -05:00
XeroOl
711c225e9c Fix crash when searching non-table documentation 2024-05-06 10:36:07 -05:00
XeroOl
2d7c8b1ad7 Lints for doc fields, doc hovers on strings 2024-05-04 15:37:01 -05:00
XeroOl
926dff9267 Docs when completing string fields 2024-05-04 15:37:01 -05:00
XeroOl
d06e0dfbe8
test function to check code actions don't exist 2024-05-04 01:27:37 -05:00
XeroOl
944f57cc08 No duplicate scope completions 2024-04-30 21:42:00 -05:00
XeroOl
343777d301 eglot completion quirk tests 2024-04-30 21:40:07 -05:00
XeroOl
311ce2645e fix fennel-ls#22
This is getting messy, but now the same sym can reference multiple
places. (. file references mysym) only holds the last one, but
(. file definitions <x> :referenced-by) could still hold older
references.
2024-04-07 23:18:14 -05:00
XeroOl
59b966a25f Add a bunch of tests for compiler recovery
Ideally, any time you write:

(local x (<some form with compiler error>))
(print x)

I don't want it to say "unknown variable x". To make sure that's the
case, I need to do as much error recovery as possible. I don't have full
error recovery, but I've got the common cases, and I'm working down the
fennel.friends list
2024-03-28 23:51:22 -05:00
XeroOl
3bc530e11b in tests, separate compile error diagnostics from lints 2024-03-28 23:04:25 -05:00
XeroOl
b5750b1a8a rename diagnostic to lint 2024-03-28 23:01:20 -05:00
XeroOl
0fd6a48ed2 basic code action test for the (+) -> 0 lint 2024-03-28 22:41:23 -05:00
XeroOl
e81920585d add more tests for error recovery 2024-03-28 22:39:13 -05:00
XeroOl
e47ee55784 shuffle around how encoding works in the tests 2024-03-28 22:38:01 -05:00
XeroOl
7c81ffcbb3 First attempt at code actions, no tests yet 2024-03-26 14:12:34 -05:00
XeroOl
cc05d7089f final attempt at fixing builds.sr.ht 2024-03-04 00:38:47 -06:00
XeroOl
80d0e297a1 more likely pass builds.sr.ht tests 2024-03-04 00:36:53 -06:00
XeroOl
65ea473197 new rockspec to make the luarocks rock work 2024-03-04 00:30:06 -06:00
XeroOl
888689a3a1 Make tests pass on old lua versions 2024-03-03 23:14:22 -06:00
XeroOl
f14d91b9c4
add test for hover over modules 2024-03-03 23:03:31 -06:00
XeroOl
0a766c6425 Finally, documentation for table.insert 2024-03-02 20:12:27 -06:00
XeroOl
308f7d9930 fix broken test 2024-03-02 10:55:15 -06:00
XeroOl
1eb4a770dd Make the multisym splitter tiebreak the right way 2024-03-01 21:36:00 -06:00
XeroOl
cb8dc29bed Analyze (include) the same way as (require) 2024-03-01 17:37:32 -06:00
XeroOl
be997dc7fb add diagnostic test for unknown module field 2024-03-01 17:32:51 -06:00
XeroOl
0dd9c0ff65 improved formatting for destructure 2024-03-01 17:29:01 -06:00
XeroOl
cab3bbc49d remove the dummy test project files 2024-03-01 17:01:10 -06:00