Commit Graph

125 Commits

Author SHA1 Message Date
XeroOl
6152bed8a6 Move json dependency to fennel-ls/json, to represent that it's a modified version 2024-02-19 21:32:38 -06:00
XeroOl
647421f21b clean up diagnostics 2024-02-18 16:03:13 -06:00
XeroOl
bc31279f41 Refactoring diagnostics 2024-02-17 23:51:34 -06:00
XeroOl
33a412e299 Lint for any call to any op with no arguments 2024-02-17 22:50:23 -06:00
XeroOl
67b1fbfbef minor microoptimizations 2024-02-17 22:38:25 -06:00
XeroOl
21500707de updated changelog and fixed lint 2024-02-16 23:29:50 -06:00
XeroOl
d8f0d396a9 fix diagnostics indent 2024-02-16 23:00:51 -06:00
XeroOl
ea89ecad9f Diagnostics with similar iterators are fused together 2024-02-16 22:12:50 -06:00
XeroOl
814ebb4dfa the --check flag gives nonzero exit code if it found anything 2024-02-12 21:58:23 -06:00
XeroOl
ddbed43a7d changing some comments and doc comments 2024-02-12 21:41:32 -06:00
XeroOl
b8565bd146 More language.fnl changes 2024-02-12 21:41:14 -06:00
XeroOl
2e1a2b74b5 Shuffle docs around 2024-02-12 18:59:41 -06:00
XeroOl
68bad4eaba last working in middle of refactor 2024-02-12 17:40:53 -06:00
XeroOl
6f9935a781 Fix renames that cover method calls
That was a tough one to debug! I almost thought it was a bug in fennel,
but it, of course, turned out to be a fennel-ls problem.

When you have a symbol like (foo:bar), fennel compiles it by
"macroexpanding" it to (: foo :bar). When fennel macroexpands a macro,
it tries to clean up the output by giving it a best-guess
bytestart/byteend. Fennel-ls was picking up *both* the accurate
`foo:bar` sym and the best-guess virtual `foo` sym as separate
references to `foo`. When computing the renames, the best-guess values
were getting used, which made the replacement range inaccurate.
2024-02-11 23:45:08 -06:00
XeroOl
be5e167d67 very minor fix for completions 2024-02-11 23:11:45 -06:00
XeroOl
ad7c02a882 remove print statement 2024-02-11 23:10:28 -06:00
XeroOl
3a3b5d38d6 better multisym search, and hover tests to prove it
The search code is getting messy again. I may have to refactor it at
some point.
2024-02-10 01:07:43 -06:00
XeroOl
a3dcd92e85 (and) and (or) are covered by unpack diagnostic 2024-02-10 01:06:21 -06:00
XeroOl
a973de5f87 doc comment changes 2024-02-10 01:04:47 -06:00
XeroOl
68b149b1b6 Update docs 2024-02-09 12:31:07 -06:00
XeroOl
25e279eda3 completions textEdit initial code 2024-02-03 01:31:27 -06:00
XeroOl
8a988cb8be Make search-main slightly better when starting at a multival destructure 2024-02-02 02:44:05 -06:00
XeroOl
1c40c93b4d refactor compiler.fnl to share destructure recursion 2024-02-02 02:16:29 -06:00
XeroOl
8b6d905450 make multival definition tracking much better
there should now be no cases where multivals and table destructures are
confused. ie, (local [_ x] (values 1 2)) and (local (_ x) [1 2]) are recognized
as nonsense.
2024-02-02 02:12:30 -06:00
XeroOl
297f6c4fa9 fix set rename issue ~xerool/fennel-ls#8
Now unused variables and var-not-set lints use a different system.

References are now of type:
{:symbol sym :target ast :ref-type (or :read :write :mutate)}
instead of ast.

unused var will warn if all the references are :write references.
2024-01-25 00:06:59 -06:00
XeroOl
6e68552940 Renaming search to search-ast
I think this is a slightly better name, but I'm still not sure what to
call this function.
2024-01-25 00:06:59 -06:00
XeroOl
a29cbe496e Release 0.1.0 2023-12-06 18:03:12 -06:00
Phil Hagelberg
5055fd31ef Add diagnostic for var-never-set.
This uses the isvar field from the opts map of the destructure hook.
2023-12-06 17:59:26 -06:00
Phil Hagelberg
f25fd9fd60 Replace fork of Fennel with upstream.
* Rename "customhook-early-" hooks to "pre-"
* Change hook argument order to put scope second.
2023-12-03 16:32:15 -06:00
adjuvant
e4ec4dc9c4 Configuration of extra allowed globals 2023-12-03 16:25:54 -06:00
XeroOl
6329fb6ea3 bad-unpack lint warns about (+ (unpack t))
Also, there's a special message for the .. operator to let people know
about table.concat
2023-12-01 14:13:34 -06:00
XeroOl
a24cb97d5e use bytes instead of utf16 "code units" for --check mode 2023-12-01 14:12:30 -06:00
XeroOl
16e9fbd856 Update fennel to my extra-hooks-6 branch of 1.3.1-dev 2023-12-01 13:56:28 -06:00
Phil Hagelberg
5acaac966e Ensure that defining a function on an arg counts as a reference.
Otherwise you get a warning here saying that t is unused:

    (fn f [t x] (fn t.f []) x)
2023-11-26 13:40:20 -06:00
Phil Hagelberg
765b3d784f Change format of --check output to look like compiler errors.
They'll look like this now:

src/fennel-ls/compiler.fnl:123:15 unused definition: ?definition
src/fennel-ls/compiler.fnl:5:52 unused definition: view
src/fennel-ls/compiler.fnl:197:13 unused definition: i
src/fennel-ls/compiler.fnl:271:25 unnecessary : call; use multisym
src/fennel-ls/handlers.fnl:14:10 unused definition: view
src/fennel-ls/handlers.fnl:170:3 unused definition: create-completion-item
src/fennel-ls/language.fnl:187:3 unused definition: does-not-contain?
src/fennel-ls/language.fnl:221:28 unused definition: i
src/fennel-ls/language.fnl:4:51 unused definition: view
src/fennel-ls/language.fnl:171:3 unused definition: past?
src/fennel-ls/language.fnl:208:23 unused definition: i
src/fennel-ls/searcher.fnl:12:4 unnecessary : call; use multisym
src/fennel-ls/state.fnl:23:3 unused definition: get-by-path
src/fennel-ls/state.fnl:12:2 unnecessary : call; use multisym
src/fennel-ls/utils.fnl:15:16 unused definition: i

This has the advantage of making it so that existing tooling will work
with it; for example, Emacs can hyperlink these and jump right to the
code causing the issue.

Use 1-indexed line numbers instead of 0-indexing because Emacs and Vim
expect this.
2023-11-26 10:41:21 -08:00
Phil Hagelberg
4a121f70b0 Add selfcheck make target.
Also cleans up repeated path options in the makefile, and cleans up
warnings where fennel-ls warns on itself.

There were some unused functions; I just put a _ before their name but
that might be a bit silly. Maybe they should be removed? Or just left alone?
2023-11-26 10:41:21 -08:00
XeroOl
b861812b24 Re-enable the : lint, but with better checks 2023-11-26 12:38:20 -06:00
XeroOl
d74c6fbdc0 Disable the method check 2023-11-26 00:42:07 -06:00
Phil Hagelberg
802ff4ab17 Support --check for batch mode diagnostics.
Mostly taken from the separate fennel-lint.fnl file.
2023-11-25 18:16:33 -06:00
Phil Hagelberg
c8f9b71057 Add diagnostic warning for unnecessary : call.
When you have a call to the `:` special which could just be a multisym
method call, emit a warning for that.
2023-11-25 18:16:28 -06:00
XeroOl
27d1df23eb Do not warn on fennel rest in function
I kept the test from Tibor Classen's patch, but the code is fixed by
preventing & from ever being a definition, instead of ignoring it only
in the diagnostic.

Co-authored-by: Tibor Claassen <tc@codebeige.net>
2023-11-25 17:55:06 -06:00
XeroOl
824525573a fix a crash
This isn't a great fix, but now finding the definition of a number
doesn't cause a crash.

It used to crash because there's no way to get metadata about the
source-code location of a number.
2023-09-18 17:00:29 -05:00
XeroOl
223976194e textDocument/rename Filter out when symbol references itself
When a symbol is recorded to be its own reference, fennel-ls
accidentally counts the reference twice. That's fine, but we don't want
to replace the same words multiple times
2023-09-16 13:02:14 -05:00
XeroOl
364d02b90d
Better completions for fields of tables
Now it does a two-level-deep search when creating competions for tables,
which means that a completion for module fields have better metadata.
the completion code is a bit of a mess, so I want to look into
refactoring it soon.
2023-09-03 10:23:33 -05:00
XeroOl
9db2ec7537 Documented initializationOptions
We accept the settings object either from initialize:initializationOptions or
workspace/didChangeConfiguration:settings. The readme now explains this.
2023-08-26 22:31:40 -05:00
adjuvant
31ea7a1039 Allow configuration through initialization options 2023-08-26 20:02:07 -05:00
adjuvant
1710649105 Fix textDocument/hover returning invalid message
The `result` key must not be missing in the response.
2023-08-21 12:16:29 -05:00
adjuvant
7c1bbc8c2b json.lua: Allow encoding null values
A similar proposal was already rejected upstream:
https://github.com/rxi/json.lua/pull/6
2023-08-21 12:16:29 -05:00
XeroOl
e7c642e12a don't advertise pull diagnostics if fennel-ls uses push diagnostics 2023-07-20 09:27:19 -05:00
XeroOl
3c2bc8c35c refactor compiler.fnl 2023-07-18 23:53:19 -05:00