summary refs log tree commit diff stats
path: root/nimsuggest
Commit message (Collapse)AuthorAgeFilesLines
* fix nimsuggest crash with arrow type sugar (#24185)metagn2024-09-271-0/+20
| | | | | | | | | fixes #24179 The original fix made it so calls to `skError`/`skUnknown` (in this case `->`, for some reason `sugar` couldn't be imported) returned an error node, however this breaks tsug_accquote for some reason I don't understand (it even parses as `tsug_accquote.discard`) so I've just added a guard based on the stacktrace.
* handle explicit generic routine instantiations in sigmatch (#24010)metagn2024-09-021-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #16376 The way the compiler handled generic proc instantiations in calls (like `foo[int](...)`) up to this point was to instantiate `foo[int]`, create a symbol for the instantiated proc (or a symchoice for multiple procs excluding ones with mismatching generic param counts), then perform overload resolution on this symbol/symchoice. The exception to this was when the called symbol was already a symchoice node, in which case it wasn't instantiated and overloading was called directly ([these lines](https://github.com/nim-lang/Nim/blob/b7b1313d21deb687adab2b4a162e716ba561a26b/compiler/semexprs.nim#L3366-L3371)). This has several problems: * Templates and macros can't create instantiated symbols, so they couldn't participate in overloaded explicit generic instantiations, causing the issue #16376. * Every single proc that can be instantiated with the given generic params is fully instantiated including the body. #9997 is about this but isn't fixed here since the instantiation isn't in a call. The way overload resolution handles explicit instantiations by itself is also buggy: * It doesn't check constraints. * It allows only partially providing the generic parameters, which makes sense for implicit generics, but can cause ambiguity in overloading. Here is how this PR deals with these problems: * Overload resolution now always handles explicit generic instantiations in calls, in `initCandidate`, as long as the symbol resolves to a routine symbol. * Overload resolution now checks the generic params for constraints and correct parameter count (ignoring implicit params). If these don't match, the entire overload is considered as not matching and not instantiated. * Special error messages are added for mismatching/missing/extra generic params. This is almost all of the diff in `semcall`. * Procs with matching generic parameters now instantiate only the type of the signature in overload resolution, not the proc itself, which also works for templates and macros. Unfortunately we can't entirely remove instantiations because overload resolution can't handle some cases with uninstantiated types even though it's resolved in the binding (see the last 2 blocks in `texplicitgenerics`). There are also some instantiation issues with default params that #24005 didn't fix but I didn't want this to become the 3rd huge generics PR in a row so I didn't dive too deep into trying to fix them. There is still a minor instantiation fix in `semtypinst` though for subscripts in calls. Additional changes: * Overloading of `[]` wasn't documented properly, it somewhat is now because we need to mention the limitation that it can't be done for generic procs/types. * Tests can now enable the new type mismatch errors with just `-d:testsConciseTypeMismatch` in the command. Package PRs: - using fork for now: [combparser](https://github.com/PMunch/combparser/pull/7) (partial generic instantiation) - merged: [cligen](https://github.com/c-blake/cligen/pull/233) (partial generic instantiation but non-overloaded + template) - merged: [neo](https://github.com/andreaferretti/neo/pull/56) (trying to instantiate template with no generic param)
* fixes #23867; fixes #23316; rework nimsuggest for ORC (#23879)ringabout2024-07-232-0/+47
| | | | | | | | fixes #23867 fixes #23316 follow up https://github.com/nim-lang/Nim/pull/22805; fixes https://github.com/nim-lang/Nim/issues/22794 in a different method
* Fixes #23695: On Linux, "nimsuggest" crashes if Nim is installed in /usr/bin ↵Juan M Gómez2024-06-101-16/+2
| | | | | and the library in /usr/lib/nim (#23697) (Not tested)
* nimsuggest v3+ handles unknownFile (#23696)Juan M Gómez2024-06-081-5/+2
|
* + added nimsuggest support for exception inlay hints (#23202)Nikolay Nikolov2024-03-152-28/+156
| | | | | | | | | | | | | | | | | This adds nimsuggest support for displaying inlay hints for exceptions. An inlay hint is displayed around function calls, that can raise an exception, which isn't handled in the current subroutine (in other words, exceptions that can propagate back to the caller). On mouse hover on top of the hint, a list of exceptions that could propagate is shown. The changes, required to support this are already commited to nimlangserver and the VS code extension. The extension and the server allow configuration for whether these new exception hints are enabled (they can be enabled or disabled independently from the type hints), as well as the inlay strings that are inserted before and after the name of the function, around the function call. Potentially, one of these strings can be empty, for example, the user can choose to add an inlay hint only before the name of the function, or only after the name of the function.
* makes nimsuggest listen on localhost by default (#23351)Juan M Gómez2024-03-041-1/+1
|
* Fix nimsuggest highlight for import statements (#23263)autumngray2024-03-031-0/+12
| | | | | | | | | | | Currently, I don't have syntax highlighting (+ no/wrong jump-to-definition) for some import statement forms, namely: - `import module/name/with/(slashes)` - `import (mod) as alias` - `import basemod/[ (sub1), (sub2) ]` With this patch, highlight/def will work for the regions indicated by parentheses.
* * fixed nimsuggest crash with 'Something = concept' put (erroneously) ↵Nikolay Nikolov2024-02-242-0/+27
| | | | outside of a 'type' block (#23331)
* * fixed nimsuggest crash when opening a .nim file, that contain a {.fatal: ↵Nikolay Nikolov2024-02-201-0/+15
| | | | "msg".} pragma. (#23325)
* fixes nimsuggest sug doesnt return anything on first pass #23283 (#23288)Juan M Gómez2024-02-151-8/+6
| | | fixes #23283
* nimsuggest --ic:on compiles (#23298)Juan M Gómez2024-02-091-0/+20
|
* [fix] nimsuggest `con` sometimes doesnt return anything on first pass fixes ↵Juan M Gómez2024-02-051-2/+3
| | | | | #23281 (#23282) fixes #23281
* + show the inferred exception list (as part of the type) for functions that ↵Nikolay Nikolov2024-01-1512-39/+39
| | | | don't have an explicit `.raises` pragma (#23193)
* Adds info:capabilities to NimSuggest (#23134)Juan M Gómez2023-12-291-0/+8
|
* makes nimsuggest `con` work under v3 (#23113)Juan M Gómez2023-12-222-3/+19
| | | Co-authored-by: Jake Leahy <jake@leahy.dev>
* Only suggest symbols that could be pragmas when typing a pragma (#23040)Jake Leahy2023-12-071-0/+40
| | | | | | Currently pragmas just fall through to `suggestSentinel` and show everything which isn't very useful. Now it filters for symbols that could be pragmas (templates with `{.pragma.}`, macros, user pragmas) and only shows them
* Fix nimsuggest `def` being different on proc definition/use (#23025)Jake Leahy2023-12-042-4/+14
| | | | | | | | | | | | | | | | | | Currently the documentation isn't shown when running `def` on the definition of a proc (Which works for things like variables). `gcsafe`/`noSideEffects` status also isn't showing up when running `def` on the definition Images of current behavior. After PR both look like "Usage" **Definition** ![image](https://github.com/nim-lang/Nim/assets/19339842/bf75ff0b-9a96-49e5-bf8a-d2c503efa784) **Usage** ![image](https://github.com/nim-lang/Nim/assets/19339842/15ea3ebf-64e1-48f5-9233-22605183825f) Issue was the symbol getting passed too early to nimsuggest so it didn't have all that info, now gets passed once proc is fully semmed
* Register declaration of enum field has a use (#22990)Jake Leahy2023-11-271-0/+15
| | | | | | | Currently when using `use` with nimsuggest on an enum field, it doesn't return the definition of the field. Breaks renaming in IDEs since it will replace all the usages, but not the declaration
* nimsuggest: Added optional command line option '--clientProcessId:XXX' (#22969)Nikolay Nikolov2023-11-242-0/+41
| | | | | | | | | | When it is specified, the nimsuggest instance monitors whether this process is still alive. In case it's found to be dead, nimsuggest shuts itself down. Currently only implemented on POSIX and Windows platforms. The switch is silently ignored on other platforms. Note that the Nim language server should still try to shut down its child nimsuggest processes. This switch just adds extra protection against crashing Nim language server and gets rid of the remaining nimsuggest processes, which consume memory and system resources.
* Don't provide suggestions for enum fields (#22959)Jake Leahy2023-11-201-0/+17
| | | | | | | | | Currently the suggestions create a lot of noise when creating enum fields. I don't see any way of a macro creating fields (when called inside an enum) so it should be safe to not show suggestions --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Introduced version 4 of the NimSuggest protocol. The InlayHints feature made ↵Nikolay Nikolov2023-11-181-2/+8
| | | | | | | | | | V4 or later only. (#22953) Since nimsuggest now has a protocol version support detection via `--info:protocolVer`, the InlayHints feature can be moved to protocol V4. This way, the Nim language server can detect the nimsuggest version and avoid sending unsupported `InlayHints` commands to older nimsuggest versions. Related nim language server PR: https://github.com/nim-lang/langserver/pull/60
* nimsuggest: Instead of checking for protocol version 3 exactly, check for ↵Nikolay Nikolov2023-11-151-3/+3
| | | | | | | | | version 3 or later. (#22945) Refactored the way nimsuggest checks for protocol version 3. Instead of checking for version 3 exactly, it now checks for version 3 or later. This way, once a version 4 is introduced, it will use version 3 as a base line, and then extra changes to the protocol can be added on top. No functional changes are introduced in this commit.
* Added new command line option `--info:X` to nimsuggest for obtaining ↵Nikolay Nikolov2023-11-151-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | information. (#22940) `--info:protocolVer` returns the highest nimsuggest protocol version that is supported (currently, it's version 3). `--info:nimVer` returns the Nim compiler version that nimsuggest uses internally. Note that you can obtain the Nim compiler version via `nimsuggest -v`, but that requires parsing the output, which looks like this: ``` Nim Compiler Version 2.1.1 [Linux: amd64] Compiled at 2023-11-14 Copyright (c) 2006-2023 by Andreas Rumpf git hash: 47ddfeca5247dce992becd734d1ae44e621207b8 active boot switches: -d:release -d:danger --gc:markAndSweep ``` `--info:nimVer` will return just: ``` 2.1.1 ```
* Inlay hints for types of consts (#22916)Nikolay Nikolov2023-11-071-1/+1
| | | This adds inlay hint support for the types of consts.
* Inlay hints support (#22896)Nikolay Nikolov2023-11-041-2/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | This adds inlay hints support to nimsuggest. It adds a new command to nimsuggest, called 'inlayHints'. Currently, it provides type information to 'var' and 'let' variables. In the future, inlay hints can also be added for 'const' and for function parameters. The protocol also reserves space for a tooltip field, which is not used, yet, but support for it can be added in the future, without further changing the protocol. The change includes refactoring to allow the 'inlayHints' command to return a completely different structure, compared to the other nimsuggest commands. This will allow other future commands to have custom return types as well. All the previous commands return the same structure as before, so perfect backwards compatibility is maintained. To use this feature, an update to the nim language server, as well as the VS code extension is needed. Related PRs: nimlangserver: https://github.com/nim-lang/langserver/pull/53 VS code extension: https://github.com/saem/vscode-nim/pull/134 --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* nimsuggest: Clear generic inst cache before partial recompilation (#22783)Pylgos2023-10-033-3/+57
| | | | | fixes #19371 fixes #21093 fixes #22119
* fix #22448 Remove `structuredErrorHook` temporary in `tryConstExpr` (#22450)Pylgos2023-08-111-0/+11
| | | | | * fix #22448 * add test
* Fix nimsuggest not showing suggestions for imported tuples (#22241)Jake Leahy2023-07-103-0/+22
| | | | | | | | | | | * Add tests Also test if exported all tuple fields works. This seems like a hacky solution so will try and dive further to find a better solution * Always suggest tuple fields if it passes the filter If the tuple we are accessing is in scope then all the fields will also be in scope * Update tests so line numbers are correct
* Create compiler and nimsuggest packages (#22118)Ivan Yonchovski2023-06-182-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I have tested it locally with the following in my local packages_official.json ``` { "name": "compiler", "url": "https://github.com/yyoncho/Nim.git/?subdir=compiler", "method": "git", "tags": [ "library", "compiler" ], "description": "Package providing the Nim compiler binaries plus all its source files that can be used as a library", "license": "MIT", "web": "https://github.com/nim-lang/Nim" }, { "name": "nimsuggest", "url": "https://github.com/yyoncho/Nim.git/?nimsuggest=compiler", "method": "git", "tags": [ "library", "compiler" ], "description": "Package providing the Nim compiler binaries plus all its source files that can be used as a library", "license": "MIT", "web": "https://github.com/nim-lang/Nim" }, ``` Then `nimble install compiler`, `nimble install nimsuggest` work as expected.
* Improve nimsuggest (#21825)Juan Carlos2023-05-111-1/+1
| | | Small improvement for nimsuggest
* fixes #19863; move sha1, md5 to nimble packages for 2.0 (#21702)ringabout2023-05-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * move sha1, md5 to nimble packages * boot the compiler * fixes tests * build the documentation * fixes docs * lol, I forgot koch.nim * add `nimHasChecksums` define * clone checksums but maybe copying is better * bump nimble hash * use ChecksumsStableCommit * fixes tests * deprecate them * fixes paths * fixes koch
* Fix infinite recursion introduced in 7031ea6 [backport 1.6] (#21555)Peter Munch-Ellingsen2023-03-201-1/+1
| | | Fix infinite recursion introduced in 7031ea6
* replaces implicit passes array registed at runtime with explicit function ↵ringabout2023-03-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | calls; simplify compilation pipeline (#21444) * abolish using passes in the compiler; simplify compilation pipeline * duplicate code * Really cool to have the same signature... * haul * unify other backends * refactor process * introduce PipelinePhase * refactor compiler * fixes passes * fixes nimsuggest * add a sentinel * enable docs checkj * activate doc testing * clean up * complete cleanups
* fixes #19795; fixes #11852; fixes #19974; remove parsing pipeline, Nim now ↵ringabout2023-02-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | parses the whole module at one time (#21379) * fixes #19795; remove parse pipeline * isScript * fixes nimscriptapi * don't touch reorder * check script * fixes tests * it seems implicit imports of system cause troubles * access the first child of `nkStmtList` * ignore comments * minor messages * perhaps increases hloLoopDetector * the module is a stmtList, which changes the errors * fixes nimdoc * fixes tlinter * fixes nim secret tests * fixes arc_misc * fixes nim secret tests again * safe; fixes one more test * GlobalError is the root cause too * fixes parsing errors * put emit types to the cfsForwardTypes section * fixes #11852; `{.push checks:off}` now works in procs * disable navigator * fixes nimdoc * add tests for JS * fixes nimsuggest
* Implemented basic macro expand functionality (#20579)Ivan Yonchovski2023-01-274-51/+206
| | | | | | | | | | | | | | | | | | * Implemented level based macro expand functionality - it can handle single macro call or expand whole function/proc/etc and it - In addition, I have altered the parser to provide the endInfo for the node. The usefulness of the `endInfo` is not limited to the `expandMacro` functionality but also it is useful for `ideOutline` functionality and I have altered the ideOutline functionality to use `endInfo`. Note `endInfo` most of the time is lost during the AST transformation thus in `nimsuggest.nim` I am using freshly parsed tree to get the location information. * Make sure we stop expanding correctly * Test CI * Fix tv3_outline.nim
* Fix nimsuggest not suggesting fields in when theres static parameters (#21189)Jake Leahy2022-12-281-0/+18
| | | | | Don't check against empty arguments Add test case
* Nimsuggest now defines the backends symbol (#21083)Jake Leahy2022-12-123-2/+13
| | | | | | | * Add testcase * Define the backend symbol * Remove unneeded whitespace
* fix bugs with dot & call operators [backport] (#20931)metagn2022-11-281-2/+0
| | | | | | | | | | | | | | | | | | | * better error messages for dot operators [backport] fixes #13063 * also fixes #7777 * fix #6981 and #9831 too * fix * minor improvement * sus test fixes * make test multiplatform lol * fix nimsuggest test, extra improvements
* rename `std/threads` to `std/typedthreads` (#20850)ringabout2022-11-161-1/+1
| | | | | | | | | * rename `std/threads` to `std/oldthreads` * fixes tests * rename to `typedthreads` * changelog
* Fix typo in nimsuggest.nim (#20767)Ikko Ashimine2022-11-051-1/+1
| | | becase -> because
* fixes #20526; use `nimPreviewSlimSystem` for documentation build (#20714)ringabout2022-11-011-0/+3
| | | | | | | * fixes #20526; use `nimPreviewSlimSystem` for `koch docs` * fixes documentation errors * fixes remaning issues
* put std/threads under the umbrella of nimPreviewSlimSystem (#20711)ringabout2022-10-311-0/+2
| | | | | | | | | | | * put `std/threads` under the umbrella of `nimPreviewSlimSystem` * add changelog * fixes tests * fixes tests again * fixes tests
* fixes #19162; enable `strictEffects` for v2 (#19380)ringabout2022-10-151-1/+1
| | | | | | | | | | | | | | | | | | | * enable stricteffects * add gcsafe * fix tests * use func * fixes pegs tests * explicitly mark repr related procs with noSideEffect * add nimLegacyEffects * change URL * fixes docopt * add `raises: []` to repr * fixes weave * fixes nimyaml * fixes glob * fixes parsetoml * Apply suggestions from code review * Update testament/important_packages.nim * add legacy:laxEffects
* 'lock levels' are deprecated, now a noop (#20539)ringabout2022-10-118-24/+24
| | | | | * 'lock levels' are deprecated, now a noop * fixes tests
* Fix/improve handling of forward declarations in nimsuggest (#20493)Ivan Yonchovski2022-10-063-9/+114
| | | | | | | | | | | | | | | | | * Fix/improve handling of forward declarations in nimsuggest - ideUse now works fine when invoked on the implementation - implemented ideDeclaration to make cover lsp feature textDocument/declaration - fixed performance issue related to deduplicating symbols. Now the deduplication happens after the symbols are filtered. As a alternative we might change the way cached symbols are stored(e. g. use set). - I also fixed the way globalSymbols work. Now it will sort the responses based on the match location to make sure that the results are sorted in user friendly way. * Update nimsuggest/nimsuggest.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* moderate system cleanup & refactor (#20355)metagn2022-09-282-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * system refactor, move out 600 lines * compilation, slice, backwardsindex, misc_num moved out of system * some procs/types moved into arithmetics, basic_types * system no longer depends on syncio * some procs moved around to fit with their surroundings * make exceptions an import, old ops to misc_num * move instantiationInfo back * move back nim version, fix windows echo * include compilation * better docs for imported modules, fix unsigned ops also remove ze, ze64, toU8, toU16, toU32 with nimPreviewSlimSystem * fix terminal * workaround IC test & weird csize bug, changelog * move NimMajor etc back to compilation, rebase for CI * try ic fix * form single `indices`, slim out TaintedString, try fix IC * fix CI, update changelog, addQuitProc * fix CI * try fix CI * actually fix CI finally hopefully * Update lib/system/compilation.nim Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> * update kochdocs * hopefully fix csize uses for slimsystem * fix tquit Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* defaults to ORC (#19972)ringabout2022-09-231-12/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * defaults to Orc * bootstrap using refc * use gc * init orc defines * unregister orc * fix gc * fix commands * add prepareMutation for orc * enable deepcopy for orc * prepareMutation * more fixes * some cases * bug #20081 * partial fixes * partial fixes * fixes command line * more fixes * build Nim with refc * use gc * more fixes * rstore * orc doesn't support threadpool * more shallowCopy * more fixes * fixes unsafeNew * workarounds * small * more fixes * fixes some megatest * tcodegenbugs1 refc * fxies megatest * build nimble with refc * workaround tensordsl tests * replace shallowCopy with move * fixes action * workaround * add todo * fixes important packages * unpublic unregisterArcOrc * fixes cpp * enable windows Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
* Partially Revert "Change nim's nimble files to make it installable" (#20296)ringabout2022-09-021-0/+8
| | | add nimsuggest.nimble back
* Change nim's nimble files to make it installable (#20179)Ivan Yonchovski2022-08-311-8/+0
| | | | | | | | - needs #20168 to make the stuff working I went for this minimal solution because it seems like `compiler.nimble` and `nimsuggest.nimble` are not in use Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>