Commit Graph

293 Commits

Author SHA1 Message Date
XeroOl
456acb4e15 be less picky about XDG_DATA_HOME and HOME environment variable trailing slash
In fennel-ls.utils, there's a path-join function that has the logic
for joining paths and putting a slash in the middle if it's not already
there.
2025-06-02 22:49:01 -05:00
XeroOl
055f9f9811 rename completions to completion internally 2025-06-02 22:36:11 -05:00
XeroOl
1ac5d72a8e short flags: -h for help, -v for version 2025-06-02 22:36:11 -05:00
Jason Shipman
87d01b8ba9 Avoid double forward slash in docsets data dir when XDG_DATA_HOME is undefined
fennel-ls was reporting this error:
Could not find docset for library love2d at /Users/jship/.local/share//fennel-ls/docsets/love2d.lua
2025-05-28 21:51:35 -07:00
Yuta Sakurai
9b28815dd8 Resolved JSON-RPC issue on Windows. 2025-05-25 16:43:56 -07:00
XeroOl
39fdd0c282 Better completions! lazy documentation, deduplicated editRange. I have no tests for these completions >:^) 2025-04-26 17:06:28 -05:00
XeroOl
75839a2f13 finish naming the completion functions 2025-04-26 14:45:56 -05:00
XeroOl
6771feb6b5 remove unused import 2025-04-23 23:42:29 -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
2800038005 Make sure we're not suggesting a "_G" version of everything 2025-04-23 23:42:29 -05:00
XeroOl
163ea1fd80 parse lua reference manual more accurately
the files and io are now properly treated like two different things
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
1e3edf800d replace completions with a completely new completions.fnl implementation
the tests are failing now, because it's generating completions
differently, with no documentation or completion types, but it seems
like its working well.
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
Michele Campeotto
61defc86c4 Treat .fnlm files as macro files.
Now that .fnlm files are in the macro path we should also treat those as
macro files without needing the special comment.
2025-04-13 10:54:34 -07:00
XeroOl
3fbad644a9 prepare for warnings with column numbers
Fennel doesn't yet support column numbers in its warnings, but I'm going
to attempt to add them in 1.5.4+. This code will take advantage of those
numbers if/when that happens.
2025-04-11 22:24:59 -05:00
XeroOl
f129605630 future proofing against fennel 1.5.4's arglist nesting
In fennel 90732f3, some arglists are added that have tables, not just strings.
2025-04-11 22:24:42 -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
Phil Hagelberg
b7984ca51b Put .fnlm on the macro path. 2025-04-02 08:58:16 -07: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
96aef99728 Update compiler diagnostics to follow the spec. 2025-03-24 08:32:47 -07:00
Michele Campeotto
f396450293 Don't send invalid signatureHelp activeParameter values.
Leaving the arguments in place for when we implement the rest of the
feature.
2025-03-24 08:32:32 -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
9dfe25b8cb Fix crash when requesting signature help at the top level. 2025-03-22 12:10:11 -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
XeroOl
6f2d697087 fix the previous commit 2025-03-15 12:59:22 -05:00
XeroOl
4d4d288214 suppress "unknown field" for generated symbols 2025-03-15 12:37:25 -05: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
Michele Campeotto
3200483011 Add --help and --version flags 2025-03-07 08:42:59 -08:00
Andrey Listopadov
e229f93fc1 allow linting from stdin 2025-03-05 18:10:52 -08:00
Andrey Listopadov
db37838272 print severity levels in the output when linting with --lint 2025-03-04 21:03:19 -08:00
Phil Hagelberg
48d939916c Compatibility with Lua 5.1 ... again. 2025-03-04 08:58:59 -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
Phil Hagelberg
356c6bcae7 Fix indeterminate analyze search results. 2025-03-02 21:45:57 -08:00
Phil Hagelberg
1c2f5364be Use match-try instead of case-try to avoid a where clause.
Add changelog entry.
2025-03-02 09:01:35 -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
Phil Hagelberg
80b4f9d29a Simplify some handlers case-try to avoid use of where clause. 2025-02-27 18:38:37 -08:00
Michele Campeotto
bb2ccd67c2 Add support for textDocument/documentHighlight 2025-02-27 18:18:35 -08:00
Phil Hagelberg
a7ce5f7826 Queue up validations during initialization and send later.
This is a dumb hack but the validation warnings aren't very useful
without it.

Still needs tests.
2025-02-27 02:30:25 -08:00
Phil Hagelberg
bc0898510e Missing Lua versions or libraries cause warnings, not crashes.
Unfortunately the experience here is not great, at least in emacs; the
spec states that the server may send showMessage during initialization,
but eglot displays these messages only for a brief flash, quickly
replacing them with the "Connected!" message.

We probably need a different solution here but it might get ugly; like
some kind of outbound queue.
2025-02-27 00:56:45 -08:00