Commit Graph

213 Commits

Author SHA1 Message Date
XeroOl
561f199505 hardcode in some argument counting exceptions 2025-07-11 23:39:01 -05:00
XeroOl
5143310b90 introduce mismatched-argument-count lint 2025-07-11 19:16:06 -05:00
XeroOl
772d59fff1 more changes to the linting system 2025-07-11 18:22:16 -05:00
XeroOl
7b215e15e8 fix completions in comments and strings, and more reliable binding completions 2025-07-11 14:06:33 -05:00
XeroOl
28e20f74cb better completions in destructure bindings 2025-07-08 23:01:11 -05:00
XeroOl
e17ecef292 macroexpansion feature for hover and code action 2025-07-08 20:49:35 -05:00
XeroOl
1e8784a55a rework hovering 2025-07-02 22:37:02 -05:00
XeroOl
0641b1b098 simplify completions 2025-07-02 19:11:10 -05:00
XeroOl
e2e020e3ba slightly better hashfn support 2025-06-28 19:35:39 -05:00
XeroOl
fc57612fea clean up quickfix lint title system 2025-06-25 00:52:46 -05:00
XeroOl
6f946c76ea add lint that (let [] ...) should be (do ...) 2025-06-19 12:56:29 -05:00
XeroOl
cb9f09ba84 hotfix issue with path join
Not sure why I didn't test these changes, but the path-join function
didn't actually work fully as expected.
Now, various edge cases have been ironed out:
"/path" + "/foo/bar" -> "/foo/bar", instead of "/path/foo/bar"
"" + "code.fnl" -> "code.fnl", instead of "/code.fnl"
2025-06-06 11:43:49 -05:00
XeroOl
87439744b8 rename "check" test to "cli"
technically the corresponding item in the real code was renamed to
--lint, but that's the file we should use to write future tests.
2025-06-02 22:36:11 -05:00
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