Update generated neovim config
This commit is contained in:
@ -0,0 +1,9 @@
|
||||
|
||||
root = true
|
||||
|
||||
[*.lua]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
51
config/neovim/store/lazy-plugins/nvim-jdtls/.github/ISSUE_TEMPLATE/bug.yml
vendored
Normal file
51
config/neovim/store/lazy-plugins/nvim-jdtls/.github/ISSUE_TEMPLATE/bug.yml
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
---
|
||||
name: 🐞 Bug Report
|
||||
description: |-
|
||||
Tell us about something that's not working the way you think it should.
|
||||
Please read the troubleshooting section (https://github.com/mfussenegger/nvim-jdtls#troubleshooting) first.
|
||||
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |-
|
||||
Please read the [troubleshooting section](https://github.com/mfussenegger/nvim-jdtls#troubleshooting) first.
|
||||
[Please make it easy for people to help you](https://zignar.net/2021/12/03/help-people-help-you-and-put-in-some-effort/)
|
||||
- type: textarea
|
||||
id: config
|
||||
attributes:
|
||||
label: LSP client configuration
|
||||
description: The configuration you pass to `require('jdtls').start_or_attach`
|
||||
- type: input
|
||||
id: jdtls_version
|
||||
attributes:
|
||||
label: Eclipse.jdt.ls version
|
||||
placeholder: 1.2.3
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: repro
|
||||
attributes:
|
||||
label: Steps to Reproduce
|
||||
description: How can we see what you're seeing? Please be specific
|
||||
placeholder: |-
|
||||
In a project using { gradle version .. | maven .. } (Ideally with link), opening a Java file ...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Expected Result
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: actual
|
||||
attributes:
|
||||
label: Actual Result
|
||||
description: Output? Logs? (:help vim.lsp.set_log_level and vim.lsp.log.get_filename). Run `:lua require('jdtls').compile('full')` and post the quickfix window output if there is any.
|
||||
validations:
|
||||
required: true
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |-
|
||||
## Thanks 🙏
|
||||
6
config/neovim/store/lazy-plugins/nvim-jdtls/.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
6
config/neovim/store/lazy-plugins/nvim-jdtls/.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Ask a question or start a discussion
|
||||
url: https://github.com/mfussenegger/nvim-jdtls/discussions
|
||||
about: Use the Github discussions feature
|
||||
23
config/neovim/store/lazy-plugins/nvim-jdtls/.github/ISSUE_TEMPLATE/feature.yml
vendored
Normal file
23
config/neovim/store/lazy-plugins/nvim-jdtls/.github/ISSUE_TEMPLATE/feature.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
name: 💡 Feature Request
|
||||
description: Tell us about a problem you'd like to solve with nvim-jdtls
|
||||
body:
|
||||
- type: textarea
|
||||
id: problem
|
||||
attributes:
|
||||
label: Problem Statement
|
||||
description: What problem could nvim-jdtls solve that it doesn't?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Ideas or possible solutions
|
||||
description: Share your ideas about potential solutions
|
||||
placeholder: |-
|
||||
🤷
|
||||
validations:
|
||||
required: false
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |-
|
||||
## Thanks 🙏
|
||||
11
config/neovim/store/lazy-plugins/nvim-jdtls/.github/linters/.luacheckrc
vendored
Normal file
11
config/neovim/store/lazy-plugins/nvim-jdtls/.github/linters/.luacheckrc
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
ignore = {
|
||||
"631", -- max_line_length
|
||||
}
|
||||
globals = {
|
||||
"vim"
|
||||
}
|
||||
read_globals = {
|
||||
"describe",
|
||||
"it",
|
||||
"assert",
|
||||
}
|
||||
23
config/neovim/store/lazy-plugins/nvim-jdtls/.github/workflows/linter.yml
vendored
Normal file
23
config/neovim/store/lazy-plugins/nvim-jdtls/.github/workflows/linter.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
name: Lint Code Base
|
||||
on:
|
||||
pull_request: ~
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Lint Code Base
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Lint Code Base
|
||||
uses: github/super-linter/slim@v4
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
LINTER_RULES_PATH: /
|
||||
VALIDATE_JSCPD: false
|
||||
39
config/neovim/store/lazy-plugins/nvim-jdtls/.github/workflows/tests.yml
vendored
Normal file
39
config/neovim/store/lazy-plugins/nvim-jdtls/.github/workflows/tests.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
---
|
||||
name: Run tests
|
||||
on:
|
||||
pull_request: ~
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Run tests
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
neovim_version: ['nightly', 'v0.6.1']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: date +%F > todays-date
|
||||
- name: Restore cache for today's nightly.
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: _neovim
|
||||
key: ${{ runner.os }}-x64-${{ hashFiles('todays-date') }}
|
||||
|
||||
- name: Prepare plenary
|
||||
run: |
|
||||
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
|
||||
ln -s "$(pwd)" ~/.local/share/nvim/site/pack/vendor/start
|
||||
|
||||
- name: Setup neovim
|
||||
uses: rhysd/action-setup-vim@v1
|
||||
with:
|
||||
neovim: true
|
||||
version: ${{ matrix.neovim_version }}
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal.vim'}"
|
||||
11
config/neovim/store/lazy-plugins/nvim-jdtls/.luacheckrc
Normal file
11
config/neovim/store/lazy-plugins/nvim-jdtls/.luacheckrc
Normal file
@ -0,0 +1,11 @@
|
||||
ignore = {
|
||||
"631", -- max_line_length
|
||||
}
|
||||
globals = {
|
||||
"vim"
|
||||
}
|
||||
read_globals = {
|
||||
"describe",
|
||||
"it",
|
||||
"assert",
|
||||
}
|
||||
4
config/neovim/store/lazy-plugins/nvim-jdtls/.luarc.json
Normal file
4
config/neovim/store/lazy-plugins/nvim-jdtls/.luarc.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
|
||||
"Lua.workspace.checkThirdParty": false
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
---
|
||||
MD013: false
|
||||
MD051: false
|
||||
675
config/neovim/store/lazy-plugins/nvim-jdtls/LICENSE.txt
Normal file
675
config/neovim/store/lazy-plugins/nvim-jdtls/LICENSE.txt
Normal file
@ -0,0 +1,675 @@
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
531
config/neovim/store/lazy-plugins/nvim-jdtls/README.md
Normal file
531
config/neovim/store/lazy-plugins/nvim-jdtls/README.md
Normal file
@ -0,0 +1,531 @@
|
||||
# nvim-jdtls
|
||||
|
||||
Extensions for the built-in [Language Server Protocol][1] support in [Neovim][2] (>= 0.6.0) for [eclipse.jdt.ls][3].
|
||||
|
||||
## Audience
|
||||
|
||||
This project follows the [KISS principle][kiss] and targets users with some
|
||||
experience with Neovim, Java and its build tools Maven or Gradle who prefer
|
||||
configuration as code over GUI configuration. Ease of use is not the main
|
||||
priority.
|
||||
|
||||
If you prioritize ease of use over simplicity, you may want to use an
|
||||
alternative:
|
||||
|
||||
- [coc-java](https://github.com/neoclide/coc-java)
|
||||
- [vscode](https://code.visualstudio.com/)
|
||||
- [IntelliJ IDEA](https://www.jetbrains.com/idea/)
|
||||
- [Eclipse](https://www.eclipse.org/ide/)
|
||||
|
||||
## Extensions
|
||||
|
||||
- [x] `organize_imports` function to organize imports
|
||||
- [x] `extract_variable` function to introduce a local variable
|
||||
- [x] `extract_variable_all` function to introduce a local variable and replace all occurrences.
|
||||
- [x] `extract_constant` function to extract a constant
|
||||
- [x] `extract_method` function to extract a block of code into a method
|
||||
- [x] Open class file contents
|
||||
- [x] Code action extensions
|
||||
- [x] Generate constructors
|
||||
- [x] Generate `toString` function
|
||||
- [x] `hashCode` and `equals` generation.
|
||||
- [x] Extract variables or methods
|
||||
- [x] Generate delegate methods
|
||||
- [x] Move package, instance method, static method or type
|
||||
- [x] Signature refactoring
|
||||
- [x] `javap` command to show bytecode of current file
|
||||
- [x] `jol` command to show memory usage of current file (`jol_path` must be set)
|
||||
- [x] `jshell` command to open up `jshell` with `classpath` from project set
|
||||
- [x] Debugger support via [nvim-dap][5]
|
||||
- [x] Optional vscode-java-test extensions
|
||||
- [x] Generate tests via `require("jdtls.tests").generate()`
|
||||
- [x] Jump to tests or subjects via `require("jdtls.tests").goto_subjects()`
|
||||
|
||||
Take a look at [a demo](https://github.com/mfussenegger/nvim-jdtls/issues/3) to
|
||||
see some of the functionality in action.
|
||||
|
||||
## Plugin Installation
|
||||
|
||||
- Requires Neovim (Latest stable (recommended) or nightly)
|
||||
- nvim-jdtls is a plugin. Install it like any other Vim plugin:
|
||||
- `git clone https://github.com/mfussenegger/nvim-jdtls.git ~/.config/nvim/pack/plugins/start/nvim-jdtls`
|
||||
- Or with [vim-plug][14]: `Plug 'mfussenegger/nvim-jdtls'`
|
||||
- Or with [packer.nvim][15]: `use 'mfussenegger/nvim-jdtls'`
|
||||
- Or any other plugin manager
|
||||
|
||||
|
||||
## Language Server Installation
|
||||
|
||||
Install [eclipse.jdt.ls][3] by following their [Installation instructions](https://github.com/eclipse/eclipse.jdt.ls#installation).
|
||||
|
||||
|
||||
## Configuration (quickstart)
|
||||
|
||||
Add the following to `~/.config/nvim/ftplugin/java.lua` (See `:help base-directory`):
|
||||
|
||||
```lua
|
||||
local config = {
|
||||
cmd = {'/path/to/jdt-language-server/bin/jdtls'},
|
||||
root_dir = vim.fs.dirname(vim.fs.find({'gradlew', '.git', 'mvnw'}, { upward = true })[1]),
|
||||
}
|
||||
require('jdtls').start_or_attach(config)
|
||||
```
|
||||
|
||||
**Important**:
|
||||
|
||||
- eclipse.jdt.ls requires Java 17
|
||||
- The `jdtls` script requires Python 3.9
|
||||
- You'll have to teach eclipse.jdt.ls about your JDK installations by setting
|
||||
up `runtimes` if your projects use a different Java version than the one
|
||||
you're using for eclipse.jdt.ls itself. See `Java XY language features are
|
||||
not available` in the troubleshooting section further below to learn how to
|
||||
do that.
|
||||
|
||||
This should get you started, but will create temporary eclipse data folders
|
||||
when you open a project. Please read the `Configuration (verbose)` section if
|
||||
you want more control over the configuration or want to understand how things
|
||||
work.
|
||||
|
||||
## Configuration (verbose)
|
||||
|
||||
To configure `nvim-jdtls`, add the following in `ftplugin/java.lua` within the
|
||||
Neovim configuration base directory (e.g. `~/.config/nvim/ftplugin/java.lua`,
|
||||
see `:help base-directory`).
|
||||
|
||||
Watch out for the 💀, it indicates that you must adjust something.
|
||||
|
||||
|
||||
```lua
|
||||
-- See `:help vim.lsp.start_client` for an overview of the supported `config` options.
|
||||
local config = {
|
||||
-- The command that starts the language server
|
||||
-- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line
|
||||
cmd = {
|
||||
|
||||
-- 💀
|
||||
'java', -- or '/path/to/java17_or_newer/bin/java'
|
||||
-- depends on if `java` is in your $PATH env variable and if it points to the right version.
|
||||
|
||||
'-Declipse.application=org.eclipse.jdt.ls.core.id1',
|
||||
'-Dosgi.bundles.defaultStartLevel=4',
|
||||
'-Declipse.product=org.eclipse.jdt.ls.core.product',
|
||||
'-Dlog.protocol=true',
|
||||
'-Dlog.level=ALL',
|
||||
'-Xmx1g',
|
||||
'--add-modules=ALL-SYSTEM',
|
||||
'--add-opens', 'java.base/java.util=ALL-UNNAMED',
|
||||
'--add-opens', 'java.base/java.lang=ALL-UNNAMED',
|
||||
|
||||
-- 💀
|
||||
'-jar', '/path/to/jdtls_install_location/plugins/org.eclipse.equinox.launcher_VERSION_NUMBER.jar',
|
||||
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
|
||||
-- Must point to the Change this to
|
||||
-- eclipse.jdt.ls installation the actual version
|
||||
|
||||
|
||||
-- 💀
|
||||
'-configuration', '/path/to/jdtls_install_location/config_SYSTEM',
|
||||
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
-- Must point to the Change to one of `linux`, `win` or `mac`
|
||||
-- eclipse.jdt.ls installation Depending on your system.
|
||||
|
||||
|
||||
-- 💀
|
||||
-- See `data directory configuration` section in the README
|
||||
'-data', '/path/to/unique/per/project/workspace/folder'
|
||||
},
|
||||
|
||||
-- 💀
|
||||
-- This is the default if not provided, you can remove it. Or adjust as needed.
|
||||
-- One dedicated LSP server & client will be started per unique root_dir
|
||||
--
|
||||
-- vim.fs.root requires Neovim 0.10.
|
||||
-- If you're using an earlier version, use: require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'}),
|
||||
root_dir = vim.fs.root(0, {".git", "mvnw", "gradlew"})
|
||||
|
||||
-- Here you can configure eclipse.jdt.ls specific settings
|
||||
-- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
|
||||
-- for a list of options
|
||||
settings = {
|
||||
java = {
|
||||
}
|
||||
},
|
||||
|
||||
-- Language server `initializationOptions`
|
||||
-- You need to extend the `bundles` with paths to jar files
|
||||
-- if you want to use additional eclipse.jdt.ls plugins.
|
||||
--
|
||||
-- See https://github.com/mfussenegger/nvim-jdtls#java-debug-installation
|
||||
--
|
||||
-- If you don't plan on using the debugger or other eclipse.jdt.ls plugins you can remove this
|
||||
init_options = {
|
||||
bundles = {}
|
||||
},
|
||||
}
|
||||
-- This starts a new client & server,
|
||||
-- or attaches to an existing client & server depending on the `root_dir`.
|
||||
require('jdtls').start_or_attach(config)
|
||||
```
|
||||
|
||||
The `ftplugin/java.lua` logic is executed each time a `FileType` event
|
||||
triggers. This happens every time you open a `.java` file or when you invoke
|
||||
`:set ft=java`:
|
||||
|
||||
You can also find more [complete configuration examples in the Wiki][11].
|
||||
|
||||
If you have trouble getting jdtls to work, please read the
|
||||
[Troubleshooting](#troubleshooting) section.
|
||||
|
||||
### data directory configuration
|
||||
|
||||
`eclipse.jdt.ls` stores project specific data within the folder set via the
|
||||
`-data` flag. If you're using `eclipse.jdt.ls` with multiple different projects
|
||||
you must use a dedicated data directory per project.
|
||||
|
||||
An example how you could accomplish that is to infer the workspace directory
|
||||
name from the current working directory:
|
||||
|
||||
|
||||
```lua
|
||||
-- If you started neovim within `~/dev/xy/project-1` this would resolve to `project-1`
|
||||
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
|
||||
|
||||
local workspace_dir = '/path/to/workspace-root/' .. project_name
|
||||
-- ^^
|
||||
-- string concattenation in Lua
|
||||
|
||||
local config = {
|
||||
cmd = {
|
||||
...,
|
||||
|
||||
'-data', workspace_dir,
|
||||
|
||||
...,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`...` is not valid Lua in this context. It is meant as placeholder for the
|
||||
other options from the [Configuration](#configuration) section above.)
|
||||
|
||||
### nvim-lspconfig and nvim-jdtls differences
|
||||
|
||||
Both [nvim-lspconfig][9] and nvim-jdtls use the client built into neovim:
|
||||
|
||||
```txt
|
||||
┌────────────┐ ┌────────────────┐
|
||||
│ nvim-jdtls │ │ nvim-lspconfig │
|
||||
└────────────┘ └────────────────┘
|
||||
| |
|
||||
start_or_attach nvim_lsp.jdtls.setup
|
||||
│ |
|
||||
│ setup java filetype hook
|
||||
│ ┌─────────┐ │
|
||||
└───►│ vim.lsp │◄─────────────────┘
|
||||
└─────────┘
|
||||
.start_client
|
||||
.buf_attach_client
|
||||
```
|
||||
|
||||
Some differences between the two:
|
||||
|
||||
- The `setup` of lspconfig creates a `java` `filetype` hook itself and provides
|
||||
some defaults for the `cmd` of the `config`.
|
||||
- `nvim-jdtls` delegates the choice when to call `start_or_attach` to the user.
|
||||
- `nvim-jdtls` adds some logic to handle `jdt://` URIs. These are necessary to
|
||||
load source code from third party libraries or the JDK.
|
||||
- `nvim-jdtls` adds some additional handlers and sets same extra capabilities
|
||||
to enable all the extensions.
|
||||
|
||||
You could use either to start the `eclipse.jdt.ls` client, but it is
|
||||
recommended to use the `start_or_attach` method from `nvim-jdtls` because of
|
||||
the additional capabilities it configures and because of the `jdt://` URI
|
||||
handling.
|
||||
|
||||
You **must not** use both at the same time for java. You'd end up with two
|
||||
clients and two language server instances.
|
||||
|
||||
### UI picker customization
|
||||
|
||||
**Tip**: You can get a better UI for code-actions and other functions by
|
||||
overriding the `jdtls.ui` picker. See [UI Extensions][10].
|
||||
|
||||
## Usage
|
||||
|
||||
`nvim-jdtls` extends the capabilities of the built-in LSP support in
|
||||
Neovim, so all the functions mentioned in `:help lsp` will work.
|
||||
|
||||
`nvim-jdtls` provides some extras, for those you'll want to create additional
|
||||
mappings:
|
||||
|
||||
```vimL
|
||||
nnoremap <A-o> <Cmd>lua require'jdtls'.organize_imports()<CR>
|
||||
nnoremap crv <Cmd>lua require('jdtls').extract_variable()<CR>
|
||||
vnoremap crv <Esc><Cmd>lua require('jdtls').extract_variable(true)<CR>
|
||||
nnoremap crc <Cmd>lua require('jdtls').extract_constant()<CR>
|
||||
vnoremap crc <Esc><Cmd>lua require('jdtls').extract_constant(true)<CR>
|
||||
vnoremap crm <Esc><Cmd>lua require('jdtls').extract_method(true)<CR>
|
||||
|
||||
|
||||
" If using nvim-dap
|
||||
" This requires java-debug and vscode-java-test bundles, see install steps in this README further below.
|
||||
nnoremap <leader>df <Cmd>lua require'jdtls'.test_class()<CR>
|
||||
nnoremap <leader>dn <Cmd>lua require'jdtls'.test_nearest_method()<CR>
|
||||
```
|
||||
|
||||
`nvim-jdtls` also adds several commands if the server starts up correctly:
|
||||
|
||||
- `JdtCompile`
|
||||
- `JdtSetRuntime`
|
||||
- `JdtUpdateConfig`
|
||||
- `JdtUpdateDebugConfig` (if `dap` and java-debug bundles are available)
|
||||
- `JdtUpdateHotcode` (if `dap` and java-debug bundles are available)
|
||||
- `JdtBytecode`
|
||||
- `JdtJol`
|
||||
- `JdtJshell`
|
||||
- `JdtRestart`
|
||||
|
||||
|
||||
## API Reference
|
||||
|
||||
See `:help jdtls`
|
||||
|
||||
## Debugger (via nvim-dap)
|
||||
|
||||
|
||||
`nvim-jdtls` provides integration with [nvim-dap][5].
|
||||
|
||||
Once setup correctly, it enables the following additional functionality:
|
||||
|
||||
1. Debug applications via explicit configurations
|
||||
2. Debug automatically discovered main classes
|
||||
3. Debug junit tests. Either whole classes or individual test methods
|
||||
|
||||
For 1 & 2 to work, [eclipse.jdt.ls][3] needs to load the [java-debug][6]
|
||||
extension. For 3 to work, it also needs to load the [vscode-java-test][7] extension.
|
||||
|
||||
For usage instructions once installed, read the [nvim-dap][5] help.
|
||||
Debugging junit test classes or methods will be possible via these two functions:
|
||||
|
||||
```lua
|
||||
require'jdtls'.test_class()
|
||||
require'jdtls'.test_nearest_method()
|
||||
```
|
||||
|
||||
### java-debug installation
|
||||
|
||||
- Clone [java-debug][6]
|
||||
- Navigate into the cloned repository (`cd java-debug`)
|
||||
- Run `./mvnw clean install`
|
||||
- Set or extend the `initializationOptions` (= `init_options` of the `config` from [configuration](#Configuration-verbose)) as follows:
|
||||
|
||||
|
||||
```lua
|
||||
config['init_options'] = {
|
||||
bundles = {
|
||||
vim.fn.glob("path/to/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar", 1)
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### nvim-dap setup
|
||||
|
||||
`nvim-jdtls` will automatically register a `java` debug adapter with nvim-dap,
|
||||
if nvim-dap is available.
|
||||
|
||||
If you're using a plugin manager with explicit dependency manager, make sure
|
||||
that `nvim-dap` is listed as dependency for `nvim-jdtls` for this to work.
|
||||
|
||||
|
||||
### nvim-dap configuration
|
||||
|
||||
`nvim-jdtls` includes functionality to discover main classes and create `nvim-dap` configuration entries for them.
|
||||
|
||||
To discover the main classes you have to call `require('jdtls.dap').setup_dap_main_class_configs()` or use the `JdtUpdateDebugConfigs` command. It will only discover classes once eclipse.jdt.ls fully loaded the project. Depending on the project that may take a while. Because of that, calling `require('jdtls.dap').setup_dap_main_class_configs()` as part of an `on_attach` handler may not work well.
|
||||
|
||||
For manual configuration see [nvim-dap Adapter Installation Wiki](https://github.com/mfussenegger/nvim-dap/wiki/Java).
|
||||
|
||||
To get an overview of all available `attach` and `launch` options, take a look at [java-debug options](https://github.com/microsoft/vscode-java-debug#options). Keep in mind that any `java.debug` options are settings of the vscode-java client extension and not understood by the debug-adapter itself.
|
||||
|
||||
### vscode-java-test installation
|
||||
|
||||
To be able to debug junit tests, it is necessary to install the bundles from [vscode-java-test][7]:
|
||||
|
||||
- Clone the repository
|
||||
- Navigate into the folder (`cd vscode-java-test`)
|
||||
- Run `npm install`
|
||||
- Run `npm run build-plugin`
|
||||
- Extend the bundles in the nvim-jdtls config:
|
||||
|
||||
|
||||
```lua
|
||||
|
||||
-- This bundles definition is the same as in the previous section (java-debug installation)
|
||||
local bundles = {
|
||||
vim.fn.glob("path/to/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar", 1),
|
||||
};
|
||||
|
||||
-- This is the new part
|
||||
vim.list_extend(bundles, vim.split(vim.fn.glob("/path/to/microsoft/vscode-java-test/server/*.jar", 1), "\n"))
|
||||
config['init_options'] = {
|
||||
bundles = bundles;
|
||||
}
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### The client exits with an error / eclipse.jdt.ls stopped working
|
||||
|
||||
This can have two reasons:
|
||||
|
||||
1) Your `cmd` definition in the [Configuration](#configuration) is wrong.
|
||||
|
||||
- Check the log files. Use `:JdtShowLogs` or open the log file manually. `:lua
|
||||
print(vim.fn.stdpath('cache'))` lists the path, there should be a `lsp.log`.
|
||||
You may have to increase the log level. See `:help vim.lsp.set_log_level()`.
|
||||
|
||||
- Ensure you can start the language server standalone by invoking the `cmd`
|
||||
defined in the configuration manually within a terminal.
|
||||
|
||||
2) The data folder got corrupted.
|
||||
|
||||
Wipe the folder and ensure that it is in a dedicated directory and not within
|
||||
your project repository. See [data directory
|
||||
configuration](#data-directory-configuration). You can use
|
||||
`:JdtWipeDataAndRestart` to do this.
|
||||
|
||||
|
||||
### Nothing happens when opening a Java file and I can't use any `vim.lsp.buf` functions
|
||||
|
||||
This can have several reasons:
|
||||
|
||||
1) You didn't follow [Configuration](#configuration) closely and aren't
|
||||
invoking `require('jdtls').start_or_attach(config)` as part of a `java`
|
||||
`filetype` event. Go back to the configuration section and follow it closely.
|
||||
|
||||
2) You made a mistake in your configuration and there is a failure happening
|
||||
when you open the file. Try `:set ft=java` and look at the `:messages` output.
|
||||
|
||||
3) eclipse.jdt.ls is starting but it cannot recognize your project, or it
|
||||
cannot import it properly. Try running `:JdtCompile full` or `:lua
|
||||
require('jdtls').compile('full')`. It should open the `quickfix` list with errors
|
||||
if eclipse.jdt.ls started but cannot handle your project.
|
||||
|
||||
Check the log files. Use `:JdtShowLogs` or open the log file manually. `:lua
|
||||
print(vim.fn.stdpath('cache'))` lists the path, there should be a `lsp.log`.
|
||||
You may have to increase the log level. See `:help vim.lsp.set_log_level()`.
|
||||
|
||||
|
||||
### Error: Unable to access jarfile
|
||||
|
||||
Either the file doesn't exist or you're using `~` characters in your path.
|
||||
Neovim doesn't automatically expand `~` characters in the `cmd` definition. You
|
||||
either need to write them out or wrap the fragments in `vim.fn.expand` calls.
|
||||
|
||||
### Unrecognized option: --add-modules=ALL-SYSTEM
|
||||
|
||||
Eclipse.jdt.ls requires at least Java 17. You're using a lower version.
|
||||
|
||||
### is a non-project file, only syntax errors are reported
|
||||
|
||||
You're opening a single file without having a Gradle or Maven project.
|
||||
You need to use Gradle or Maven for the full functionality.
|
||||
|
||||
### Java XY language features are not available
|
||||
|
||||
You need to set the language level via the Gradle or Maven configuration.
|
||||
|
||||
If you're starting eclipse.jdt.ls with a Java version that's different from the
|
||||
one the project uses, you need to configure the available Java runtimes. Add
|
||||
them to the `config` from the [configuration section](#configuration):
|
||||
|
||||
```lua
|
||||
local config = {
|
||||
..., -- not valid Lua, this is a placeholder for your other properties.
|
||||
settings = {
|
||||
java = {
|
||||
configuration = {
|
||||
-- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
|
||||
-- And search for `interface RuntimeOption`
|
||||
-- The `name` is NOT arbitrary, but must match one of the elements from `enum ExecutionEnvironment` in the link above
|
||||
runtimes = {
|
||||
{
|
||||
name = "JavaSE-11",
|
||||
path = "/usr/lib/jvm/java-11-openjdk/",
|
||||
},
|
||||
{
|
||||
name = "JavaSE-17",
|
||||
path = "/usr/lib/jvm/java-17-openjdk/",
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can also change the language level at runtime using the `:JdtSetRuntime`
|
||||
command.
|
||||
|
||||
|
||||
### Diagnostics and completion suggestions are slow
|
||||
|
||||
Completion requests can be quite expensive on big projects. If you're using
|
||||
some kind of auto-completion plugin that triggers completion requests
|
||||
automatically, consider deactivating it or tuning it so it is less aggressive.
|
||||
Triggering a completion request on each typed character is likely overloading
|
||||
[eclipse.jdt.ls][3].
|
||||
|
||||
|
||||
### Newly added dependencies are not found
|
||||
|
||||
You can try running `:JdtUpdateConfig` to refresh the configuration. If that
|
||||
doesn't work you'll need to restart the language server.
|
||||
|
||||
### Language server doesn't find classes that should be there
|
||||
|
||||
The language server supports [gradle](https://gradle.org/) and
|
||||
[maven](https://maven.apache.org/ref/3.8.4/) as build tools. Your project
|
||||
should either have a `pom.xml` or `settings.gradle` and `build.gradle` file to
|
||||
declare the dependencies.
|
||||
|
||||
As an alternative you could manually specify the dependencies within your
|
||||
nvim-jdtls configuration like the following, but this is not recommended.
|
||||
|
||||
```lua
|
||||
config.settings = {
|
||||
java = {
|
||||
project = {
|
||||
referencedLibraries = {
|
||||
'/path/to/dependencyA.jar',
|
||||
'/path/to/dependencyB.jar',
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you modify files outside of Neovim (for example with a git checkout), the
|
||||
language client and language server may not detect these changes and the state
|
||||
of the file on disk diverges with the mental model of the language server. If
|
||||
that happens, you need to open all changed files within Neovim and reload them
|
||||
with `:e!` to synchronize the state.
|
||||
|
||||
### Indentation settings from eclipse formatting configuration are not recognized
|
||||
|
||||
This is expected. The Neovim `shiftwidth` and `tabstop` settings have a higher
|
||||
priority.
|
||||
|
||||
|
||||
[1]: https://microsoft.github.io/language-server-protocol/
|
||||
[2]: https://neovim.io/
|
||||
[3]: https://github.com/eclipse/eclipse.jdt.ls
|
||||
[5]: https://github.com/mfussenegger/nvim-dap
|
||||
[6]: https://github.com/microsoft/java-debug
|
||||
[7]: https://github.com/microsoft/vscode-java-test
|
||||
[9]: https://github.com/neovim/nvim-lspconfig
|
||||
[10]: https://github.com/mfussenegger/nvim-jdtls/wiki/UI-Extensions
|
||||
[11]: https://github.com/mfussenegger/nvim-jdtls/wiki/Sample-Configurations
|
||||
[14]: https://github.com/junegunn/vim-plug
|
||||
[15]: https://github.com/wbthomason/packer.nvim
|
||||
[kiss]: https://en.wikipedia.org/wiki/KISS_principle
|
||||
280
config/neovim/store/lazy-plugins/nvim-jdtls/doc/jdtls.txt
Normal file
280
config/neovim/store/lazy-plugins/nvim-jdtls/doc/jdtls.txt
Normal file
@ -0,0 +1,280 @@
|
||||
==============================================================================
|
||||
LSP extensions for Neovim and eclipse.jdt.ls *jdtls*
|
||||
|
||||
*jdtls.start_or_attach*
|
||||
M.start_or_attach({config}, {opts?}, {start_opts?})
|
||||
Start the language server (if not started), and attach the current buffer.
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{config} (table<string,any>) configuration. See |vim.lsp.start_client|
|
||||
{opts?} (jdtls.start.opts)
|
||||
{start_opts?} (lsp.StartOpts) options passed to vim.lsp.start
|
||||
|
||||
Returns: ~
|
||||
(integer|nil) client_id
|
||||
|
||||
|
||||
M.organize_imports() *jdtls.organize_imports*
|
||||
Organize the imports in the current buffer
|
||||
|
||||
|
||||
M.compile({type}) *jdtls.compile*
|
||||
Compile the Java workspace
|
||||
If there are compile errors they'll be shown in the quickfix list.
|
||||
|
||||
Parameters: ~
|
||||
{type} (string|nil) |"full"
|
||||
|"incremental"
|
||||
|
||||
|
||||
M.build_projects({opts}) *jdtls.build_projects*
|
||||
Trigger a rebuild of one or more projects.
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{opts} (JdtBuildProjectOpts|nil) optional configuration options
|
||||
|
||||
|
||||
JdtBuildProjectOpts *JdtBuildProjectOpts*
|
||||
|
||||
Fields: ~
|
||||
{select_mode?} (JdtProjectSelectMode) Show prompt to select projects or select all. Defaults to "prompt"
|
||||
{full_build?} (boolean) full rebuild or incremental build. Defaults to true (full build)
|
||||
|
||||
|
||||
M.update_project_config() *jdtls.update_project_config*
|
||||
Update the project configuration (from Gradle or Maven).
|
||||
In a multi-module project this will only update the configuration of the
|
||||
module of the current buffer.
|
||||
|
||||
|
||||
M.update_projects_config({opts}) *jdtls.update_projects_config*
|
||||
Process changes made to the Gradle or Maven configuration of one or more projects.
|
||||
Requires eclipse.jdt.ls >= 1.13.0
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{opts} (JdtUpdateProjectsOpts|nil) configuration options
|
||||
|
||||
|
||||
JdtUpdateProjectsOpts *JdtUpdateProjectsOpts*
|
||||
|
||||
Fields: ~
|
||||
{select_mode?} (JdtProjectSelectMode) show prompt to select projects or select all. Defaults to "prompt"
|
||||
|
||||
|
||||
JdtProjectSelectMode *JdtProjectSelectMode*
|
||||
|
||||
Type: ~
|
||||
string
|
||||
|
||||
|
||||
jdtls.extract.opts *jdtls.extract.opts*
|
||||
|"all"
|
||||
|"prompt"
|
||||
|
||||
Type: ~
|
||||
{visual?:boolean,name?:string|fun():string}
|
||||
|
||||
|
||||
M.extract_constant({opts?}) *jdtls.extract_constant*
|
||||
Extract a constant from the expression under the cursor
|
||||
|
||||
Parameters: ~
|
||||
{opts?} (jdtls.extract.opts)
|
||||
|
||||
|
||||
M.extract_variable({opts?}) *jdtls.extract_variable*
|
||||
Extract a variable from the expression under the cursor
|
||||
|
||||
Parameters: ~
|
||||
{opts?} (jdtls.extract.opts)
|
||||
|
||||
|
||||
M.extract_variable_all({opts?}) *jdtls.extract_variable_all*
|
||||
Extract a local variable from the expression under the cursor and replace all occurrences
|
||||
|
||||
Parameters: ~
|
||||
{opts?} (jdtls.extract.opts)
|
||||
|
||||
|
||||
M.extract_method({opts?}) *jdtls.extract_method*
|
||||
Extract a method
|
||||
|
||||
Parameters: ~
|
||||
{opts?} (jdtls.extract.opts)
|
||||
|
||||
|
||||
M.super_implementation() *jdtls.super_implementation*
|
||||
Jump to the super implementation of the method under the cursor
|
||||
|
||||
|
||||
M.javap() *jdtls.javap*
|
||||
Run the `javap` tool in a terminal buffer.
|
||||
Sets the classpath based on the current project.
|
||||
|
||||
|
||||
M.jshell() *jdtls.jshell*
|
||||
Run the `jshell` tool in a terminal buffer.
|
||||
Sets the classpath based on the current project.
|
||||
|
||||
|
||||
M.jol({mode?}, {classname?}) *jdtls.jol*
|
||||
Run the `jol` tool in a terminal buffer to print the class layout
|
||||
You must configure `jol_path` to point to the `jol` jar file:
|
||||
|
||||
```
|
||||
require('jdtls').jol_path = '/absolute/path/to/jol.jar`
|
||||
```
|
||||
|
||||
https://github.com/openjdk/jol
|
||||
|
||||
Must be called from a regular java source file.
|
||||
|
||||
Examples:
|
||||
```
|
||||
lua require('jdtls').jol()
|
||||
```
|
||||
|
||||
```
|
||||
lua require('jdtls').jol(nil, "java.util.ImmutableCollections$List12")
|
||||
```
|
||||
|
||||
Parameters: ~
|
||||
{mode?} (string) |"estimates"
|
||||
|"footprint"
|
||||
|"externals"
|
||||
|"internals"
|
||||
{classname?} (string) fully qualified class name. Defaults to the current class.
|
||||
|
||||
|
||||
M.open_classfile({fname}) *jdtls.open_classfile*
|
||||
Open `jdt://` uri or decompile class contents and load them into the buffer
|
||||
|
||||
nvim-jdtls by defaults configures a `BufReadCmd` event which uses this function.
|
||||
You shouldn't need to call this manually.
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{fname} (string)
|
||||
|
||||
|
||||
M.set_runtime({runtime}) *jdtls.set_runtime*
|
||||
Change the Java runtime.
|
||||
This requires a `settings.java.configuration.runtimes` configuration.
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{runtime} (nil|string) Java runtime. Prompts for runtime if nil
|
||||
|
||||
|
||||
==============================================================================
|
||||
nvim-dap support for jdtls *jdtls.dap*
|
||||
|
||||
M.test_class() *jdtls.dap.test_class*
|
||||
Debug the test class in the current buffer
|
||||
@param opts JdtTestOpts|nil
|
||||
|
||||
|
||||
M.test_nearest_method() *jdtls.dap.test_nearest_method*
|
||||
Debug the nearest test method in the current buffer
|
||||
@param opts nil|JdtTestOpts
|
||||
|
||||
|
||||
M.pick_test({opts}) *jdtls.dap.pick_test*
|
||||
Prompt for a test method from the current buffer to run
|
||||
|
||||
Parameters: ~
|
||||
{opts} (nil|JdtTestOpts)
|
||||
|
||||
|
||||
M.fetch_main_configs({opts}, {callback}) *jdtls.dap.fetch_main_configs*
|
||||
Discover executable main functions in the project
|
||||
|
||||
Parameters: ~
|
||||
{opts} (nil|JdtMainConfigOpts) See |JdtMainConfigOpts|
|
||||
{callback} (fun(configurations:table[]))
|
||||
|
||||
|
||||
JdtMainConfigOpts *JdtMainConfigOpts*
|
||||
|
||||
Fields: ~
|
||||
{config_overrides} (nil|JdtDapConfig) Overrides for the |dap-configuration|, see |JdtDapConfig|
|
||||
|
||||
|
||||
M.setup_dap_main_class_configs({opts}) *jdtls.dap.setup_dap_main_class_configs*
|
||||
Discover main classes in the project and setup |dap-configuration| entries for Java for them.
|
||||
|
||||
Parameters: ~
|
||||
{opts} (nil|JdtSetupMainConfigOpts) See |JdtSetupMainConfigOpts|
|
||||
|
||||
|
||||
*JdtSetupMainConfigOpts*
|
||||
JdtSetupMainConfigOpts : JdtMainConfigOpts
|
||||
|
||||
Fields: ~
|
||||
{verbose} (nil|boolean) Print notifications on start and once finished. Default is false.
|
||||
{on_ready} (nil|function) Callback called when the configurations got updated
|
||||
|
||||
|
||||
M.setup_dap({opts}) *jdtls.dap.setup_dap*
|
||||
Register a |dap-adapter| for java. Requires nvim-dap
|
||||
|
||||
Parameters: ~
|
||||
{opts} (nil|JdtSetupDapOpts) See |JdtSetupDapOpts|
|
||||
|
||||
|
||||
JdtSetupDapOpts *JdtSetupDapOpts*
|
||||
|
||||
Fields: ~
|
||||
{config_overrides} (JdtDapConfig) These will be used as default overrides for |jdtls.dap.test_class|, |jdtls.dap.test_nearest_method| and discovered main classes
|
||||
{hotcodereplace?} (string) "auto"
|
||||
|
||||
|
||||
JdtDapContext *JdtDapContext*
|
||||
|
||||
Fields: ~
|
||||
{bufnr} (number)
|
||||
{win} (number)
|
||||
{uri} (string) uri equal to vim.uri_from_bufnr(bufnr)
|
||||
|
||||
|
||||
JdtDapConfig *JdtDapConfig*
|
||||
|
||||
Fields: ~
|
||||
{cwd} (string|nil) working directory for the test
|
||||
{vmArgs} (string|nil) vmArgs for the test
|
||||
{noDebug} (boolean|nil) If the test should run in debug mode
|
||||
|
||||
|
||||
JdtTestOpts *JdtTestOpts*
|
||||
|
||||
Fields: ~
|
||||
{config} (nil|table) Skeleton used for the |dap-configuration|
|
||||
{config_overrides} (nil|JdtDapConfig) Overrides for the |dap-configuration|, see |JdtDapConfig|
|
||||
{until_error} (number|nil) Number of times the test should be repeated if it doesn't fail
|
||||
{after_test} (nil|function) Callback triggered after test run
|
||||
{bufnr?} (number) Buffer that contains the test
|
||||
{lnum?} (number) 1-indexed line number. Used to find nearest test. Defaults to cursor position of the current window.
|
||||
|
||||
|
||||
==============================================================================
|
||||
Functions which require vscode-java-test *jdtls.tests*
|
||||
|
||||
M.generate() *jdtls.tests.generate*
|
||||
Generate tests for the current class
|
||||
@param opts? {bufnr: integer}
|
||||
|
||||
|
||||
M.goto_subjects() *jdtls.tests.goto_subjects*
|
||||
Go to the related subjects
|
||||
If in a test file, this will jump to classes the test might cover
|
||||
If in a non-test file, this will jump to related tests.
|
||||
|
||||
If no candidates are found, this calls `generate()`
|
||||
|
||||
@param opts? {goto_tests: boolean}
|
||||
|
||||
|
||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||
37
config/neovim/store/lazy-plugins/nvim-jdtls/doc/tags
Normal file
37
config/neovim/store/lazy-plugins/nvim-jdtls/doc/tags
Normal file
@ -0,0 +1,37 @@
|
||||
JdtBuildProjectOpts jdtls.txt /*JdtBuildProjectOpts*
|
||||
JdtDapConfig jdtls.txt /*JdtDapConfig*
|
||||
JdtDapContext jdtls.txt /*JdtDapContext*
|
||||
JdtMainConfigOpts jdtls.txt /*JdtMainConfigOpts*
|
||||
JdtProjectSelectMode jdtls.txt /*JdtProjectSelectMode*
|
||||
JdtSetupDapOpts jdtls.txt /*JdtSetupDapOpts*
|
||||
JdtSetupMainConfigOpts jdtls.txt /*JdtSetupMainConfigOpts*
|
||||
JdtTestOpts jdtls.txt /*JdtTestOpts*
|
||||
JdtUpdateProjectsOpts jdtls.txt /*JdtUpdateProjectsOpts*
|
||||
jdtls jdtls.txt /*jdtls*
|
||||
jdtls.build_projects jdtls.txt /*jdtls.build_projects*
|
||||
jdtls.compile jdtls.txt /*jdtls.compile*
|
||||
jdtls.dap jdtls.txt /*jdtls.dap*
|
||||
jdtls.dap.fetch_main_configs jdtls.txt /*jdtls.dap.fetch_main_configs*
|
||||
jdtls.dap.pick_test jdtls.txt /*jdtls.dap.pick_test*
|
||||
jdtls.dap.setup_dap jdtls.txt /*jdtls.dap.setup_dap*
|
||||
jdtls.dap.setup_dap_main_class_configs jdtls.txt /*jdtls.dap.setup_dap_main_class_configs*
|
||||
jdtls.dap.test_class jdtls.txt /*jdtls.dap.test_class*
|
||||
jdtls.dap.test_nearest_method jdtls.txt /*jdtls.dap.test_nearest_method*
|
||||
jdtls.extract.opts jdtls.txt /*jdtls.extract.opts*
|
||||
jdtls.extract_constant jdtls.txt /*jdtls.extract_constant*
|
||||
jdtls.extract_method jdtls.txt /*jdtls.extract_method*
|
||||
jdtls.extract_variable jdtls.txt /*jdtls.extract_variable*
|
||||
jdtls.extract_variable_all jdtls.txt /*jdtls.extract_variable_all*
|
||||
jdtls.javap jdtls.txt /*jdtls.javap*
|
||||
jdtls.jol jdtls.txt /*jdtls.jol*
|
||||
jdtls.jshell jdtls.txt /*jdtls.jshell*
|
||||
jdtls.open_classfile jdtls.txt /*jdtls.open_classfile*
|
||||
jdtls.organize_imports jdtls.txt /*jdtls.organize_imports*
|
||||
jdtls.set_runtime jdtls.txt /*jdtls.set_runtime*
|
||||
jdtls.start_or_attach jdtls.txt /*jdtls.start_or_attach*
|
||||
jdtls.super_implementation jdtls.txt /*jdtls.super_implementation*
|
||||
jdtls.tests jdtls.txt /*jdtls.tests*
|
||||
jdtls.tests.generate jdtls.txt /*jdtls.tests.generate*
|
||||
jdtls.tests.goto_subjects jdtls.txt /*jdtls.tests.goto_subjects*
|
||||
jdtls.update_project_config jdtls.txt /*jdtls.update_project_config*
|
||||
jdtls.update_projects_config jdtls.txt /*jdtls.update_projects_config*
|
||||
4
config/neovim/store/lazy-plugins/nvim-jdtls/lemmy.sh
Executable file
4
config/neovim/store/lazy-plugins/nvim-jdtls/lemmy.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/nix/store/4bj2kxdm1462fzcc2i2s4dn33g2angcc-bash-5.2p32/bin/bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
lemmy-help -f lua/jdtls.lua lua/jdtls/dap.lua lua/jdtls/tests.lua >doc/jdtls.txt
|
||||
1299
config/neovim/store/lazy-plugins/nvim-jdtls/lua/jdtls.lua
Normal file
1299
config/neovim/store/lazy-plugins/nvim-jdtls/lua/jdtls.lua
Normal file
File diff suppressed because it is too large
Load Diff
767
config/neovim/store/lazy-plugins/nvim-jdtls/lua/jdtls/dap.lua
Normal file
767
config/neovim/store/lazy-plugins/nvim-jdtls/lua/jdtls/dap.lua
Normal file
@ -0,0 +1,767 @@
|
||||
---@mod jdtls.dap nvim-dap support for jdtls
|
||||
|
||||
local api = vim.api
|
||||
local uv = vim.loop
|
||||
local util = require('jdtls.util')
|
||||
local resolve_classname = util.resolve_classname
|
||||
local with_java_executable = util.with_java_executable
|
||||
local M = {}
|
||||
local default_config_overrides = {}
|
||||
|
||||
---@diagnostic disable-next-line: deprecated
|
||||
local get_clients = vim.lsp.get_clients or vim.lsp.get_active_clients
|
||||
|
||||
local function fetch_needs_preview(mainclass, project, cb, bufnr)
|
||||
local params = {
|
||||
command = 'vscode.java.checkProjectSettings',
|
||||
arguments = vim.fn.json_encode({
|
||||
className = mainclass,
|
||||
projectName = project,
|
||||
inheritedOptions = true,
|
||||
expectedOptions = { ['org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures'] = 'enabled' }
|
||||
})
|
||||
}
|
||||
util.execute_command(params, function(err, use_preview)
|
||||
assert(not err, err and (err.message or vim.inspect(err)))
|
||||
cb(use_preview)
|
||||
end, bufnr)
|
||||
end
|
||||
|
||||
|
||||
local function enrich_dap_config(config_, on_config)
|
||||
if config_.mainClass
|
||||
and config_.projectName
|
||||
and config_.modulePaths ~= nil
|
||||
and config_.classPaths ~= nil
|
||||
and config_.javaExec then
|
||||
on_config(config_)
|
||||
return
|
||||
end
|
||||
local config = vim.deepcopy(config_)
|
||||
if not config.mainClass then
|
||||
config.mainClass = resolve_classname()
|
||||
end
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
util.execute_command({command = 'vscode.java.resolveMainClass'}, function(err, mainclasses)
|
||||
assert(not err, err and (err.message or vim.inspect(err)))
|
||||
|
||||
if not config.projectName then
|
||||
if not mainclasses then
|
||||
local msg = "Could not resolve classpaths. Project may have compile errors or unresolved dependencies"
|
||||
vim.notify(msg, vim.log.levels.WARN)
|
||||
else
|
||||
for _, entry in ipairs(mainclasses) do
|
||||
if entry.mainClass == config.mainClass then
|
||||
config.projectName = entry.projectName
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
config.projectName = config.projectName or ''
|
||||
with_java_executable(config.mainClass, config.projectName, function(java_exec)
|
||||
config.javaExec = config.javaExec or java_exec
|
||||
local params = {
|
||||
command = 'vscode.java.resolveClasspath',
|
||||
arguments = { config.mainClass, config.projectName }
|
||||
}
|
||||
util.execute_command(params, function(err1, paths)
|
||||
assert(not err1, err1 and (err1.message or vim.inspect(err1)))
|
||||
if paths then
|
||||
config.modulePaths = config.modulePaths or paths[1]
|
||||
config.classPaths = config.classPaths or vim.tbl_filter(
|
||||
function(x)
|
||||
return vim.fn.isdirectory(x) == 1 or vim.fn.filereadable(x) == 1
|
||||
end,
|
||||
paths[2]
|
||||
)
|
||||
else
|
||||
vim.notify("Could not resolve classpaths. Project may have compile errors or unresolved dependencies", vim.log.levels.WARN)
|
||||
end
|
||||
on_config(config)
|
||||
end, bufnr)
|
||||
end, bufnr)
|
||||
end, bufnr)
|
||||
end
|
||||
|
||||
|
||||
local function start_debug_adapter(callback, config)
|
||||
-- User could trigger debug session for another project, open in another buffer
|
||||
local jdtls = vim.tbl_filter(function(client)
|
||||
return client.name == 'jdtls'
|
||||
and client.config
|
||||
and client.config.root_dir == config.cwd
|
||||
end, get_clients())[1]
|
||||
local bufnr = vim.lsp.get_buffers_by_client_id(jdtls and jdtls.id)[1] or vim.api.nvim_get_current_buf()
|
||||
util.execute_command({command = 'vscode.java.startDebugSession'}, function(err0, port)
|
||||
assert(not err0, vim.inspect(err0))
|
||||
|
||||
callback({
|
||||
type = 'server';
|
||||
host = '127.0.0.1';
|
||||
port = port;
|
||||
enrich_config = enrich_dap_config;
|
||||
})
|
||||
end, bufnr)
|
||||
end
|
||||
|
||||
|
||||
local TestKind = {
|
||||
None = -1,
|
||||
JUnit = 0,
|
||||
JUnit5 = 1,
|
||||
TestNG = 2
|
||||
}
|
||||
|
||||
|
||||
local LegacyTestLevel = {
|
||||
Root = 0,
|
||||
Folder = 1,
|
||||
Package = 2,
|
||||
Class = 3,
|
||||
Method = 4,
|
||||
}
|
||||
|
||||
local TestLevel = {
|
||||
Workspace = 1,
|
||||
WorkspaceFolder = 2,
|
||||
Project = 3,
|
||||
Package = 4,
|
||||
Class = 5,
|
||||
Method = 6,
|
||||
}
|
||||
|
||||
|
||||
local function make_request_args(lens, uri)
|
||||
local methodname = ''
|
||||
local name_parts = vim.split(lens.fullName, '#')
|
||||
local classname = name_parts[1]
|
||||
if #name_parts > 1 then
|
||||
methodname = name_parts[2]
|
||||
if lens.paramTypes and #lens.paramTypes > 0 then
|
||||
methodname = string.format('%s(%s)', methodname, table.concat(lens.paramTypes, ','))
|
||||
end
|
||||
end
|
||||
-- Format changes with https://github.com/microsoft/vscode-java-test/pull/1257
|
||||
local new_api = lens.testKind ~= nil
|
||||
local req_arguments
|
||||
if new_api then
|
||||
req_arguments = {
|
||||
testKind = lens.testKind,
|
||||
projectName = lens.projectName,
|
||||
testLevel = lens.testLevel,
|
||||
}
|
||||
if lens.testKind == TestKind.TestNG or lens.testLevel == TestLevel.Class then
|
||||
req_arguments.testNames = { lens.fullName, }
|
||||
elseif lens.testLevel then
|
||||
req_arguments.testNames = { lens.jdtHandler, }
|
||||
end
|
||||
else
|
||||
req_arguments = {
|
||||
uri = uri,
|
||||
-- Got renamed to fullName in https://github.com/microsoft/vscode-java-test/commit/57191b5367ae0a357b80e94f0def9e46f5e77796
|
||||
-- Include both for BWC
|
||||
classFullName = classname,
|
||||
fullName = classname,
|
||||
testName = methodname,
|
||||
project = lens.project,
|
||||
projectName = lens.project,
|
||||
scope = lens.level,
|
||||
testKind = lens.kind,
|
||||
}
|
||||
if lens.level == LegacyTestLevel.Method then
|
||||
req_arguments['start'] = lens.location.range['start']
|
||||
req_arguments['end'] = lens.location.range['end']
|
||||
end
|
||||
end
|
||||
return req_arguments
|
||||
end
|
||||
|
||||
|
||||
local function fetch_candidates(context, on_candidates)
|
||||
local cmd_codelens = 'vscode.java.test.search.codelens'
|
||||
local cmd_find_tests = 'vscode.java.test.findTestTypesAndMethods'
|
||||
local client = nil
|
||||
local params = {
|
||||
arguments = { context.uri };
|
||||
}
|
||||
for _, c in ipairs(get_clients({ bufnr = context.bufnr })) do
|
||||
local command_provider = c.server_capabilities.executeCommandProvider
|
||||
local commands = type(command_provider) == 'table' and command_provider.commands or {}
|
||||
if vim.tbl_contains(commands, cmd_codelens) then
|
||||
params.command = cmd_codelens
|
||||
client = c
|
||||
break
|
||||
elseif vim.tbl_contains(commands, cmd_find_tests) then
|
||||
params.command = cmd_find_tests
|
||||
client = c
|
||||
break
|
||||
end
|
||||
end
|
||||
if not client then
|
||||
local msg = (
|
||||
'No LSP client found that supports resolving possible test cases. '
|
||||
.. 'Did you add the JAR files of vscode-java-test to `config.init_options.bundles`?')
|
||||
vim.notify(msg, vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
|
||||
local handler = function(err, result)
|
||||
if err then
|
||||
vim.notify('Error fetching test candidates: ' .. (err.message or vim.inspect(err)), vim.log.levels.ERROR)
|
||||
else
|
||||
on_candidates(result or {})
|
||||
end
|
||||
end
|
||||
client.request('workspace/executeCommand', params, handler, context.bufnr)
|
||||
end
|
||||
|
||||
|
||||
local function merge_unique(xs, ys)
|
||||
local result = {}
|
||||
local seen = {}
|
||||
local both = {}
|
||||
vim.list_extend(both, xs or {})
|
||||
vim.list_extend(both, ys or {})
|
||||
|
||||
for _, x in pairs(both) do
|
||||
if not seen[x] then
|
||||
table.insert(result, x)
|
||||
seen[x] = true
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
local function fetch_launch_args(lens, context, on_launch_args)
|
||||
local req_arguments = make_request_args(lens, context.uri)
|
||||
local cmd_junit_args = {
|
||||
command = 'vscode.java.test.junit.argument';
|
||||
arguments = { vim.fn.json_encode(req_arguments) };
|
||||
}
|
||||
util.execute_command(cmd_junit_args, function(err, launch_args)
|
||||
if err then
|
||||
print('Error retrieving launch arguments: ' .. (err.message or vim.inspect(err)))
|
||||
elseif not launch_args then
|
||||
error((
|
||||
'Server must return launch_args as response to "vscode.java.test.junit.argument" command. '
|
||||
.. 'Check server logs via `:JdtShowlogs`. Sent: ' .. vim.inspect(req_arguments)))
|
||||
elseif launch_args.errorMessage then
|
||||
vim.notify(launch_args.errorMessage, vim.log.levels.WARN)
|
||||
else
|
||||
-- forward/backward compat with format change in
|
||||
-- https://github.com/microsoft/vscode-java-test/commit/5a78371ad60e86f858eace7726f0980926b6c31d
|
||||
if launch_args.body then
|
||||
launch_args = launch_args.body
|
||||
end
|
||||
|
||||
-- the classpath in the launch_args might be missing some classes
|
||||
-- See https://github.com/microsoft/vscode-java-test/issues/1073
|
||||
--
|
||||
-- That is why `java.project.getClasspaths` is used as well.
|
||||
local options = vim.fn.json_encode({ scope = 'test'; })
|
||||
local cmd = {
|
||||
command = 'java.project.getClasspaths';
|
||||
arguments = { vim.uri_from_bufnr(0), options };
|
||||
}
|
||||
util.execute_command(cmd, function(err1, resp)
|
||||
assert(not err1, vim.inspect(err1))
|
||||
launch_args.classpath = merge_unique(launch_args.classpath, resp.classpaths)
|
||||
on_launch_args(launch_args)
|
||||
end, context.bufnr)
|
||||
end
|
||||
end, context.bufnr)
|
||||
end
|
||||
|
||||
|
||||
local function get_method_lens_above_cursor(lenses_tree, lnum)
|
||||
local result = {
|
||||
best_match = nil
|
||||
}
|
||||
local find_nearest
|
||||
find_nearest = function(lenses)
|
||||
for _, lens in pairs(lenses) do
|
||||
local is_method = lens.level == LegacyTestLevel.Method or lens.testLevel == TestLevel.Method
|
||||
local range = lens.location and lens.location.range or lens.range
|
||||
local line = range.start.line
|
||||
local best_match_line
|
||||
if result.best_match then
|
||||
local best_match = assert(result.best_match)
|
||||
best_match_line = best_match.location and best_match.location.range.start.line or best_match.range.start.line
|
||||
end
|
||||
if is_method and line <= lnum and (best_match_line == nil or line > best_match_line) then
|
||||
result.best_match = lens
|
||||
end
|
||||
if lens.children then
|
||||
find_nearest(lens.children)
|
||||
end
|
||||
end
|
||||
end
|
||||
find_nearest(lenses_tree)
|
||||
return result.best_match
|
||||
end
|
||||
|
||||
|
||||
local function get_first_class_lens(lenses)
|
||||
for _, lens in pairs(lenses) do
|
||||
-- compatibility for versions prior to
|
||||
-- https://github.com/microsoft/vscode-java-test/pull/1257
|
||||
if lens.level == LegacyTestLevel.Class then
|
||||
return lens
|
||||
end
|
||||
if lens.testLevel == TestLevel.Class then
|
||||
return lens
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Return path to com.microsoft.java.test.runner-jar-with-dependencies.jar if found in bundles
|
||||
---
|
||||
---@return string? path
|
||||
local function testng_runner()
|
||||
local vscode_runner = 'com.microsoft.java.test.runner-jar-with-dependencies.jar'
|
||||
local client = get_clients({name='jdtls'})[1]
|
||||
local bundles = client and client.config.init_options.bundles or {}
|
||||
for _, jar_path in pairs(bundles) do
|
||||
local parts = vim.split(jar_path, '/')
|
||||
if parts[#parts] == vscode_runner then
|
||||
return jar_path
|
||||
end
|
||||
local basepath = vim.fs.dirname(jar_path)
|
||||
if basepath then
|
||||
for name, _ in vim.fs.dir(basepath) do
|
||||
if name == vscode_runner then
|
||||
return vim.fs.joinpath(basepath, name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function make_config(lens, launch_args, config_overrides)
|
||||
local config = {
|
||||
name = lens.fullName;
|
||||
type = 'java';
|
||||
request = 'launch';
|
||||
mainClass = launch_args.mainClass;
|
||||
projectName = launch_args.projectName;
|
||||
cwd = launch_args.workingDirectory;
|
||||
classPaths = launch_args.classpath;
|
||||
modulePaths = launch_args.modulepath;
|
||||
vmArgs = table.concat(launch_args.vmArguments, ' ');
|
||||
noDebug = false;
|
||||
}
|
||||
config = vim.tbl_extend('force', config, config_overrides or default_config_overrides)
|
||||
if lens.testKind == TestKind.TestNG or lens.kind == TestKind.TestNG then
|
||||
local jar = testng_runner()
|
||||
if jar then
|
||||
config.mainClass = 'com.microsoft.java.test.runner.Launcher'
|
||||
config.args = string.format('testng %s', lens.fullName)
|
||||
table.insert(config.classPaths, jar);
|
||||
else
|
||||
local msg = (
|
||||
"Using basic TestNG integration. "
|
||||
.. "For better test results add com.microsoft.java.test.runner-jar-with-dependencies.jar to one of the `bundles` folders")
|
||||
vim.notify(msg)
|
||||
config.mainClass = 'org.testng.TestNG'
|
||||
-- id is in the format <project>@<class>#<method>
|
||||
local parts = vim.split(lens.id, '@')
|
||||
parts = vim.split(parts[2], '#')
|
||||
if #parts > 1 then
|
||||
config.args = string.format('-testclass %s -methods %s.%s', parts[1], parts[1], parts[2])
|
||||
else
|
||||
config.args = string.format('-testclass %s', parts[1])
|
||||
end
|
||||
end
|
||||
else
|
||||
config.args = table.concat(launch_args.programArguments, ' ');
|
||||
end
|
||||
return config
|
||||
end
|
||||
|
||||
|
||||
|
||||
---@param bufnr? integer
|
||||
---@return JdtDapContext
|
||||
local function make_context(bufnr)
|
||||
bufnr = assert((bufnr == nil or bufnr == 0) and api.nvim_get_current_buf() or bufnr)
|
||||
return {
|
||||
bufnr = bufnr,
|
||||
uri = vim.uri_from_bufnr(bufnr)
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
local function maybe_repeat(lens, config, context, opts, items)
|
||||
if not opts.until_error then
|
||||
return
|
||||
end
|
||||
if opts.until_error > 0 and #items == 0 then
|
||||
print('`until_error` set and no tests failed. Repeating.', opts.until_error)
|
||||
opts.until_error = opts.until_error - 1
|
||||
local repeat_test = function()
|
||||
M.experimental.run(lens, config, context, opts)
|
||||
end
|
||||
vim.defer_fn(repeat_test, 2000)
|
||||
elseif opts.until_error <= 0 then
|
||||
print('Stopping repeat, `until_error` reached', opts.until_error)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---@param opts JdtTestOpts
|
||||
local function run(lens, config, context, opts)
|
||||
local ok, dap = pcall(require, 'dap')
|
||||
if not ok then
|
||||
vim.notify('`nvim-dap` must be installed to run and debug methods')
|
||||
return
|
||||
end
|
||||
config = vim.tbl_extend('force', config, opts.config or {})
|
||||
local test_results
|
||||
local server = nil
|
||||
|
||||
if lens.kind == TestKind.TestNG or lens.testKind == TestKind.TestNG then
|
||||
local testng = require('jdtls.testng')
|
||||
local run_opts = {}
|
||||
if config.mainClass == "com.microsoft.java.test.runner.Launcher" then
|
||||
function run_opts.before(conf)
|
||||
server = assert(uv.new_tcp(), "uv.new_tcp() must return handle")
|
||||
test_results = testng.mk_test_results(context.bufnr)
|
||||
server:bind('127.0.0.1', 0)
|
||||
server:listen(128, function(err2)
|
||||
assert(not err2, err2)
|
||||
local sock = assert(vim.loop.new_tcp(), "uv.new_tcp must return handle")
|
||||
server:accept(sock)
|
||||
sock:read_start(test_results.mk_reader(sock))
|
||||
end)
|
||||
conf.args = string.format('%s %s', server:getsockname().port, conf.args)
|
||||
return conf
|
||||
end
|
||||
|
||||
function run_opts.after()
|
||||
if server then
|
||||
server:shutdown()
|
||||
server:close()
|
||||
end
|
||||
test_results.show(lens, context)
|
||||
if opts.after_test then
|
||||
opts.after_test()
|
||||
end
|
||||
end
|
||||
else
|
||||
function run_opts.after()
|
||||
if opts.after_test then
|
||||
opts.after_test()
|
||||
end
|
||||
end
|
||||
end
|
||||
dap.run(config, run_opts)
|
||||
return
|
||||
end
|
||||
|
||||
local junit = require('jdtls.junit')
|
||||
dap.run(config, {
|
||||
before = function(conf)
|
||||
server = assert(uv.new_tcp(), "uv.new_tcp() must return handle")
|
||||
test_results = junit.mk_test_results(context.bufnr)
|
||||
server:bind('127.0.0.1', 0)
|
||||
server:listen(128, function(err2)
|
||||
assert(not err2, err2)
|
||||
local sock = assert(vim.loop.new_tcp(), "uv.new_tcp must return handle")
|
||||
server:accept(sock)
|
||||
sock:read_start(test_results.mk_reader(sock))
|
||||
end)
|
||||
conf.args = conf.args:gsub('-port ([0-9]+)', '-port ' .. server:getsockname().port);
|
||||
return conf
|
||||
end;
|
||||
after = function()
|
||||
if server then
|
||||
server:shutdown()
|
||||
server:close()
|
||||
end
|
||||
local items = test_results.show(lens)
|
||||
maybe_repeat(lens, config, context, opts, items)
|
||||
if opts.after_test then
|
||||
opts.after_test(items)
|
||||
end
|
||||
end;
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
--- API of these methods is unstable and might change in the future
|
||||
M.experimental = {
|
||||
run = run,
|
||||
fetch_lenses = fetch_candidates,
|
||||
fetch_launch_args = fetch_launch_args,
|
||||
make_context = make_context,
|
||||
make_config = make_config,
|
||||
}
|
||||
|
||||
--- Debug the test class in the current buffer
|
||||
--- @param opts JdtTestOpts|nil
|
||||
function M.test_class(opts)
|
||||
opts = opts or {}
|
||||
local context = make_context(opts.bufnr)
|
||||
fetch_candidates(context, function(lenses)
|
||||
local lens = get_first_class_lens(lenses)
|
||||
if not lens then
|
||||
vim.notify('No test class found')
|
||||
return
|
||||
end
|
||||
fetch_launch_args(lens, context, function(launch_args)
|
||||
local config = make_config(lens, launch_args, opts.config_overrides)
|
||||
run(lens, config, context, opts)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
--- Debug the nearest test method in the current buffer
|
||||
--- @param opts nil|JdtTestOpts
|
||||
function M.test_nearest_method(opts)
|
||||
opts = opts or {}
|
||||
local context = make_context(opts.bufnr)
|
||||
local lnum = opts.lnum or api.nvim_win_get_cursor(0)[1]
|
||||
fetch_candidates(context, function(lenses)
|
||||
local lens = get_method_lens_above_cursor(lenses, lnum)
|
||||
if not lens then
|
||||
vim.notify('No suitable test method found')
|
||||
return
|
||||
end
|
||||
fetch_launch_args(lens, context, function(launch_args)
|
||||
local config = make_config(lens, launch_args, opts.config_overrides)
|
||||
run(lens, config, context, opts)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
local function populate_candidates(list, lenses)
|
||||
for _, v in pairs(lenses) do
|
||||
table.insert(list, v)
|
||||
if v.children ~= nil then
|
||||
populate_candidates(list, v.children)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Prompt for a test method from the current buffer to run
|
||||
---@param opts nil|JdtTestOpts
|
||||
function M.pick_test(opts)
|
||||
opts = opts or {}
|
||||
local context = make_context(opts.bufnr)
|
||||
|
||||
fetch_candidates(context, function(lenses)
|
||||
local candidates = {}
|
||||
populate_candidates(candidates, lenses)
|
||||
|
||||
require('jdtls.ui').pick_one_async(
|
||||
candidates,
|
||||
'Tests> ',
|
||||
function(lens) return lens.fullName end,
|
||||
function(lens)
|
||||
if not lens then
|
||||
return
|
||||
end
|
||||
fetch_launch_args(lens, context, function(launch_args)
|
||||
local config = make_config(lens, launch_args, opts.config_overrides)
|
||||
run(lens, config, context, opts)
|
||||
end)
|
||||
end
|
||||
)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
local hotcodereplace_type = {
|
||||
ERROR = "ERROR",
|
||||
WARNING = "WARNING",
|
||||
STARTING = "STARTING",
|
||||
END = "END",
|
||||
BUILD_COMPLETE = "BUILD_COMPLETE",
|
||||
}
|
||||
|
||||
|
||||
--- Discover executable main functions in the project
|
||||
---@param opts nil|JdtMainConfigOpts See |JdtMainConfigOpts|
|
||||
---@param callback fun(configurations: table[])
|
||||
function M.fetch_main_configs(opts, callback)
|
||||
opts = opts or {}
|
||||
if type(opts) == 'function' then
|
||||
vim.notify('First argument to `fetch_main_configs` changed to a `opts` table', vim.log.levels.WARN)
|
||||
callback = opts
|
||||
opts = {}
|
||||
end
|
||||
local configurations = {}
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
local jdtls = get_clients({ bufnr = bufnr, name = "jdtls"})[1]
|
||||
local root_dir = jdtls and jdtls.config and jdtls.config.root_dir
|
||||
util.execute_command({command = 'vscode.java.resolveMainClass'}, function(err, mainclasses)
|
||||
assert(not err, vim.inspect(err))
|
||||
|
||||
local remaining = #mainclasses
|
||||
if remaining == 0 then
|
||||
callback(configurations)
|
||||
return
|
||||
end
|
||||
for _, mc in pairs(mainclasses) do
|
||||
local mainclass = mc.mainClass
|
||||
local project = mc.projectName
|
||||
with_java_executable(mainclass, project, function(java_exec)
|
||||
fetch_needs_preview(mainclass, project, function(use_preview)
|
||||
util.execute_command({command = 'vscode.java.resolveClasspath', arguments = { mainclass, project }}, function(err1, paths)
|
||||
remaining = remaining - 1
|
||||
if err1 then
|
||||
print(string.format('Could not resolve classpath and modulepath for %s/%s: %s', project, mainclass, err1.message))
|
||||
return
|
||||
end
|
||||
local config = {
|
||||
cwd = root_dir;
|
||||
type = 'java';
|
||||
name = 'Launch ' .. (project or '') .. ': ' .. mainclass;
|
||||
projectName = project;
|
||||
mainClass = mainclass;
|
||||
modulePaths = paths[1];
|
||||
classPaths = paths[2];
|
||||
javaExec = java_exec;
|
||||
request = 'launch';
|
||||
console = 'integratedTerminal';
|
||||
vmArgs = use_preview and '--enable-preview' or nil;
|
||||
}
|
||||
config = vim.tbl_extend('force', config, opts.config_overrides or default_config_overrides)
|
||||
table.insert(configurations, config)
|
||||
if remaining == 0 then
|
||||
callback(configurations)
|
||||
end
|
||||
end, bufnr)
|
||||
end, bufnr)
|
||||
end, bufnr)
|
||||
end
|
||||
end, bufnr)
|
||||
end
|
||||
|
||||
---@class JdtMainConfigOpts
|
||||
---@field config_overrides nil|JdtDapConfig Overrides for the |dap-configuration|, see |JdtDapConfig|
|
||||
|
||||
|
||||
|
||||
--- Discover main classes in the project and setup |dap-configuration| entries for Java for them.
|
||||
---@param opts nil|JdtSetupMainConfigOpts See |JdtSetupMainConfigOpts|
|
||||
function M.setup_dap_main_class_configs(opts)
|
||||
opts = opts or {}
|
||||
local status, dap = pcall(require, 'dap')
|
||||
if not status then
|
||||
print('nvim-dap is not available')
|
||||
return
|
||||
end
|
||||
if dap.providers and dap.providers.configs then
|
||||
-- If users call this manually disable the automatic discovery on dap.continue()
|
||||
dap.providers.configs["jdtls"] = nil
|
||||
end
|
||||
if opts.verbose then
|
||||
vim.notify('Fetching debug configurations')
|
||||
end
|
||||
local on_ready = opts.on_ready or function() end
|
||||
M.fetch_main_configs(opts, function(configurations)
|
||||
local dap_configurations = dap.configurations.java or {}
|
||||
for _, config in ipairs(configurations) do
|
||||
for i, existing_config in pairs(dap_configurations) do
|
||||
if config.name == existing_config.name and config.cwd == existing_config["cwd"] then
|
||||
table.remove(dap_configurations, i)
|
||||
end
|
||||
end
|
||||
table.insert(dap_configurations, config)
|
||||
end
|
||||
dap.configurations.java = dap_configurations
|
||||
if opts.verbose then
|
||||
vim.notify(string.format('Updated %s debug configuration(s)', #configurations))
|
||||
end
|
||||
on_ready()
|
||||
end)
|
||||
end
|
||||
|
||||
---@class JdtSetupMainConfigOpts : JdtMainConfigOpts
|
||||
---@field verbose nil|boolean Print notifications on start and once finished. Default is false.
|
||||
---@field on_ready nil|function Callback called when the configurations got updated
|
||||
|
||||
|
||||
|
||||
--- Register a |dap-adapter| for java. Requires nvim-dap
|
||||
---@param opts nil|JdtSetupDapOpts See |JdtSetupDapOpts|
|
||||
function M.setup_dap(opts)
|
||||
local status, dap = pcall(require, 'dap')
|
||||
if not status then
|
||||
print('nvim-dap is not available')
|
||||
return
|
||||
end
|
||||
if dap.adapters.java then
|
||||
return
|
||||
end
|
||||
opts = opts or {}
|
||||
default_config_overrides = opts.config_overrides or {}
|
||||
dap.listeners.before['event_hotcodereplace']['jdtls'] = function(session, body)
|
||||
if body.changeType == hotcodereplace_type.BUILD_COMPLETE then
|
||||
if opts.hotcodereplace == 'auto' then
|
||||
vim.notify('Applying code changes')
|
||||
session:request('redefineClasses', nil, function(err)
|
||||
assert(not err, vim.inspect(err))
|
||||
end)
|
||||
end
|
||||
elseif body.message then
|
||||
vim.notify(body.message)
|
||||
end
|
||||
end
|
||||
dap.adapters.java = start_debug_adapter
|
||||
|
||||
if dap.providers and dap.providers.configs then
|
||||
dap.providers.configs["jdtls"] = function (bufnr)
|
||||
if vim.bo[bufnr].filetype ~= "java" then
|
||||
return {}
|
||||
end
|
||||
local co = coroutine.running()
|
||||
local resumed = false
|
||||
vim.defer_fn(function()
|
||||
if not resumed then
|
||||
resumed = true
|
||||
coroutine.resume(co, {})
|
||||
vim.schedule(function()
|
||||
vim.notify("Discovering main classes took too long", vim.log.levels.INFO)
|
||||
end)
|
||||
end
|
||||
end, 2000)
|
||||
M.fetch_main_configs(nil, function(configs)
|
||||
if not resumed then
|
||||
resumed = true
|
||||
coroutine.resume(co, configs)
|
||||
end
|
||||
end)
|
||||
return coroutine.yield()
|
||||
end
|
||||
end
|
||||
end
|
||||
---@class JdtSetupDapOpts
|
||||
---@field config_overrides JdtDapConfig These will be used as default overrides for |jdtls.dap.test_class|, |jdtls.dap.test_nearest_method| and discovered main classes
|
||||
---@field hotcodereplace? string "auto"
|
||||
|
||||
---@class JdtDapContext
|
||||
---@field bufnr number
|
||||
---@field win number
|
||||
---@field uri string uri equal to vim.uri_from_bufnr(bufnr)
|
||||
|
||||
---@class JdtDapConfig
|
||||
---@field cwd string|nil working directory for the test
|
||||
---@field vmArgs string|nil vmArgs for the test
|
||||
---@field noDebug boolean|nil If the test should run in debug mode
|
||||
|
||||
---@class JdtTestOpts
|
||||
---@field config nil|table Skeleton used for the |dap-configuration|
|
||||
---@field config_overrides nil|JdtDapConfig Overrides for the |dap-configuration|, see |JdtDapConfig|
|
||||
---@field until_error number|nil Number of times the test should be repeated if it doesn't fail
|
||||
---@field after_test nil|function Callback triggered after test run
|
||||
---@field bufnr? number Buffer that contains the test
|
||||
---@field lnum? number 1-indexed line number. Used to find nearest test. Defaults to cursor position of the current window.
|
||||
|
||||
return M
|
||||
245
config/neovim/store/lazy-plugins/nvim-jdtls/lua/jdtls/junit.lua
Normal file
245
config/neovim/store/lazy-plugins/nvim-jdtls/lua/jdtls/junit.lua
Normal file
@ -0,0 +1,245 @@
|
||||
local M = {}
|
||||
local ns = vim.api.nvim_create_namespace('junit')
|
||||
|
||||
local MessageId = {
|
||||
TestStart = '%TESTS',
|
||||
TestEnd = '%TESTE',
|
||||
TestFailed = '%FAILED',
|
||||
TestError = '%ERROR',
|
||||
TraceStart = '%TRACES',
|
||||
TraceEnd = '%TRACEE',
|
||||
IGNORE_TEST_PREFIX = '@Ignore: ',
|
||||
ASSUMPTION_FAILED_TEST_PREFIX = '@AssumptionFailure: ',
|
||||
}
|
||||
|
||||
local function parse_test_case(line)
|
||||
local matches = vim.fn.matchlist(line, '\\v\\d+,(\\@AssumptionFailure: |\\@Ignore: )?(.*)(\\[\\d+\\])?\\((.*)\\)')
|
||||
if #matches == 0 then
|
||||
return nil
|
||||
end
|
||||
return {
|
||||
fq_class = matches[5],
|
||||
method = matches[3],
|
||||
}
|
||||
end
|
||||
|
||||
local function parse(content, tests)
|
||||
local lines = vim.split(content, '\n')
|
||||
local tracing = false
|
||||
local test = nil
|
||||
for _, line in ipairs(lines) do
|
||||
if vim.startswith(line, MessageId.TestStart) then
|
||||
test = parse_test_case(line)
|
||||
if test then
|
||||
test.traces = {}
|
||||
test.failed = false
|
||||
else
|
||||
print('Could not parse line: ', line)
|
||||
end
|
||||
elseif vim.startswith(line, MessageId.TestEnd) then
|
||||
table.insert(tests, test)
|
||||
test = nil
|
||||
elseif vim.startswith(line, MessageId.TestFailed) or vim.startswith(line, MessageId.TestError) then
|
||||
-- Can get test failure without test start if it is a class initialization failure
|
||||
if not test then
|
||||
test = {
|
||||
fq_class = vim.split(line, ',')[2],
|
||||
traces = {},
|
||||
}
|
||||
end
|
||||
test.failed = true
|
||||
elseif vim.startswith(line, MessageId.TraceStart) then
|
||||
tracing = true
|
||||
elseif vim.startswith(line, MessageId.TraceEnd) then
|
||||
tracing = false
|
||||
elseif tracing and test then
|
||||
table.insert(test.traces, line)
|
||||
end
|
||||
end
|
||||
if test then
|
||||
table.insert(tests, test)
|
||||
end
|
||||
end
|
||||
|
||||
M.__parse = parse
|
||||
|
||||
local function mk_buf_loop(sock, handle_buffer)
|
||||
local buffer = ''
|
||||
return function(err, chunk)
|
||||
assert(not err, err)
|
||||
if chunk then
|
||||
buffer = buffer .. chunk
|
||||
else
|
||||
sock:close()
|
||||
handle_buffer(buffer)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.mk_test_results(bufnr)
|
||||
vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
|
||||
vim.diagnostic.reset(ns, bufnr)
|
||||
local tests = {}
|
||||
|
||||
local handle_buffer = function(buf)
|
||||
parse(buf, tests)
|
||||
end
|
||||
|
||||
local function get_test_start_line_num(lenses, test)
|
||||
if test.method ~= nil then
|
||||
if #lenses > 0 then
|
||||
for _, v in ipairs(lenses) do
|
||||
if vim.startswith(v.label, test.method) then
|
||||
return v.range.start.line
|
||||
end
|
||||
end
|
||||
else
|
||||
if vim.startswith(lenses.label, test.method) then
|
||||
return lenses.range.start.line
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
return {
|
||||
show = function(lens)
|
||||
local items = {}
|
||||
local repl = require('dap.repl')
|
||||
local num_failures = 0
|
||||
local lenses = lens.children or lens
|
||||
local failures = {}
|
||||
local results = {}
|
||||
local error_symbol = '❌'
|
||||
local success_symbol = '✔️ '
|
||||
for _, test in ipairs(tests) do
|
||||
local start_line_num = get_test_start_line_num(lenses, test)
|
||||
if test.failed then
|
||||
num_failures = num_failures + 1
|
||||
if start_line_num ~= nil then
|
||||
table.insert(results, {
|
||||
lnum = start_line_num,
|
||||
success = false
|
||||
})
|
||||
end
|
||||
|
||||
if test.method then
|
||||
repl.append(error_symbol .. ' ' .. test.method, '$')
|
||||
end
|
||||
local testMatch
|
||||
for _, msg in ipairs(test.traces) do
|
||||
local match = msg:match(string.format('at %s.%s', test.fq_class, test.method) .. '%(([%w%p]*:%d+)%)')
|
||||
if match then
|
||||
testMatch = true
|
||||
local lnum = vim.split(match, ':')[2]
|
||||
local trace = table.concat(test.traces, '\n')
|
||||
local cause = trace:sub(1, trace:find(msg, 1, true) - 1)
|
||||
if #trace > 140 then
|
||||
trace = trace:sub(1, 140) .. '...'
|
||||
end
|
||||
table.insert(items, {
|
||||
bufnr = bufnr,
|
||||
lnum = lnum,
|
||||
text = test.method .. ' ' .. trace,
|
||||
})
|
||||
table.insert(failures, {
|
||||
bufnr = bufnr,
|
||||
lnum = tonumber(lnum) - 1,
|
||||
col = 0,
|
||||
severity = vim.diagnostic.severity.ERROR,
|
||||
source = 'junit',
|
||||
message = cause,
|
||||
})
|
||||
break
|
||||
end
|
||||
repl.append(msg, '$')
|
||||
end
|
||||
if not testMatch then
|
||||
for _, msg in ipairs(test.traces) do
|
||||
local match = msg:match(string.format('at %s', test.fq_class) .. '[%w%p]+%(([%a%p]*:%d+)%)')
|
||||
if match then
|
||||
testMatch = true
|
||||
local lnum = vim.split(match, ':')[2]
|
||||
local trace = table.concat(test.traces, '\n')
|
||||
local cause = trace:sub(1, trace:find(msg, 1, true) - 1)
|
||||
table.insert(failures, {
|
||||
bufnr = bufnr,
|
||||
lnum = tonumber(lnum) - 1,
|
||||
col = 0,
|
||||
severity = vim.diagnostic.severity.ERROR,
|
||||
source = 'junit',
|
||||
message = cause,
|
||||
})
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if not testMatch then
|
||||
local cause = test.traces[1] .. '\n'
|
||||
if #test.traces > 2 then
|
||||
cause = cause .. test.traces[2] .. '\n'
|
||||
end
|
||||
table.insert(failures, {
|
||||
bufnr = bufnr,
|
||||
-- Generic error. Avoid overlay conflicts with virtual text
|
||||
lnum = start_line_num - 1,
|
||||
col = 0,
|
||||
severity = vim.diagnostic.severity.ERROR,
|
||||
source = 'junit',
|
||||
message = cause,
|
||||
})
|
||||
end
|
||||
else
|
||||
if start_line_num ~= nil then
|
||||
table.insert(results, {
|
||||
lnum = start_line_num,
|
||||
success = true
|
||||
})
|
||||
end
|
||||
repl.append(success_symbol .. ' ' .. test.method, '$')
|
||||
end
|
||||
end
|
||||
vim.diagnostic.set(ns, bufnr, failures, {})
|
||||
|
||||
local unique_lnums = {}
|
||||
-- Traverse in reverse order to preserve the mark position in case of Repeated/Parameterized Tests
|
||||
-- right_align doesn't seems to work correctly when set to false
|
||||
for i = #results, 1, -1 do
|
||||
local result = results[i]
|
||||
local symbol = result.success and success_symbol or error_symbol
|
||||
vim.api.nvim_buf_set_extmark(bufnr, ns, result.lnum, 0, {
|
||||
virt_text = { { symbol } },
|
||||
invalidate = true
|
||||
})
|
||||
unique_lnums[result.lnum] = true
|
||||
end
|
||||
for key, _ in pairs(unique_lnums) do
|
||||
local indent = '\t'
|
||||
vim.api.nvim_buf_set_extmark(bufnr, ns, key, 0, {
|
||||
virt_text = { { indent } },
|
||||
invalidate = true
|
||||
})
|
||||
end
|
||||
|
||||
if num_failures > 0 then
|
||||
vim.fn.setqflist({}, 'r', {
|
||||
title = 'jdtls-tests',
|
||||
items = items,
|
||||
})
|
||||
print(
|
||||
'Tests finished. Results printed to dap-repl.',
|
||||
#items > 0 and 'Errors added to quickfix list' or '',
|
||||
string.format('(%s %d / %d)', error_symbol, num_failures, #tests)
|
||||
)
|
||||
else
|
||||
print('Tests finished. Results printed to dap-repl.', success_symbol, #tests, 'succeeded')
|
||||
end
|
||||
return items
|
||||
end,
|
||||
mk_reader = function(sock)
|
||||
return vim.schedule_wrap(mk_buf_loop(sock, handle_buffer))
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
@ -0,0 +1,15 @@
|
||||
local M = {}
|
||||
|
||||
local is_windows = vim.loop.os_uname().version:match('Windows')
|
||||
|
||||
M.sep = is_windows and '\\' or '/'
|
||||
|
||||
function M.join(...)
|
||||
if vim.fs.joinpath then
|
||||
return vim.fs.joinpath(...)
|
||||
end
|
||||
local result = table.concat(vim.tbl_flatten {...}, M.sep):gsub(M.sep .. '+', M.sep)
|
||||
return result
|
||||
end
|
||||
|
||||
return M
|
||||
412
config/neovim/store/lazy-plugins/nvim-jdtls/lua/jdtls/setup.lua
Normal file
412
config/neovim/store/lazy-plugins/nvim-jdtls/lua/jdtls/setup.lua
Normal file
@ -0,0 +1,412 @@
|
||||
local api = vim.api
|
||||
local lsp = vim.lsp
|
||||
local uv = vim.loop
|
||||
local path = require('jdtls.path')
|
||||
local M = {}
|
||||
local URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*)://.*'
|
||||
|
||||
---@diagnostic disable-next-line: deprecated
|
||||
local get_clients = vim.lsp.get_clients or vim.lsp.get_active_clients
|
||||
|
||||
|
||||
local status_callback = function(_, result)
|
||||
api.nvim_command(string.format(':echohl Function | echo "%s" | echohl None',
|
||||
string.sub(result.message, 1, vim.v.echospace)))
|
||||
end
|
||||
|
||||
|
||||
M.restart = function()
|
||||
for _, client in ipairs(get_clients({ name = "jdtls" })) do
|
||||
local bufs = lsp.get_buffers_by_client_id(client.id)
|
||||
client.stop()
|
||||
vim.wait(30000, function()
|
||||
return lsp.get_client_by_id(client.id) == nil
|
||||
end)
|
||||
local client_id = lsp.start_client(client.config)
|
||||
if client_id then
|
||||
for _, buf in ipairs(bufs) do
|
||||
lsp.buf_attach_client(buf, client_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function may_jdtls_buf(bufnr)
|
||||
if vim.bo[bufnr].filetype == "java" then
|
||||
return true
|
||||
end
|
||||
local fname = api.nvim_buf_get_name(bufnr)
|
||||
return vim.endswith(fname, "build.gradle") or vim.endswith(fname, "pom.xml")
|
||||
end
|
||||
|
||||
---@return integer? client_id
|
||||
local function attach_to_active_buf(bufnr, client_name)
|
||||
local function try_attach(buf)
|
||||
if not may_jdtls_buf(buf) then
|
||||
return nil
|
||||
end
|
||||
local clients = get_clients({ bufnr = buf, name = client_name })
|
||||
local _, client = next(clients)
|
||||
if client then
|
||||
lsp.buf_attach_client(bufnr, client.id)
|
||||
return client.id
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
local altbuf = vim.fn.bufnr("#", -1)
|
||||
if altbuf and altbuf > 0 then
|
||||
local client_id = try_attach(altbuf)
|
||||
if client_id then
|
||||
return client_id
|
||||
end
|
||||
end
|
||||
for _, buf in ipairs(api.nvim_list_bufs()) do
|
||||
if api.nvim_buf_is_loaded(buf) then
|
||||
local client_id = try_attach(buf)
|
||||
if client_id then
|
||||
return client_id
|
||||
end
|
||||
end
|
||||
end
|
||||
print('No active LSP client found to use for jdt:// document')
|
||||
return nil
|
||||
end
|
||||
|
||||
function M.find_root(markers, source)
|
||||
source = source or api.nvim_buf_get_name(api.nvim_get_current_buf())
|
||||
local dirname = vim.fn.fnamemodify(source, ':p:h')
|
||||
local getparent = function(p)
|
||||
return vim.fn.fnamemodify(p, ':h')
|
||||
end
|
||||
while getparent(dirname) ~= dirname do
|
||||
for _, marker in ipairs(markers) do
|
||||
if uv.fs_stat(path.join(dirname, marker)) then
|
||||
return dirname
|
||||
end
|
||||
end
|
||||
dirname = getparent(dirname)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
M.extendedClientCapabilities = {
|
||||
classFileContentsSupport = true,
|
||||
generateToStringPromptSupport = true,
|
||||
hashCodeEqualsPromptSupport = true,
|
||||
advancedExtractRefactoringSupport = true,
|
||||
advancedOrganizeImportsSupport = true,
|
||||
generateConstructorsPromptSupport = true,
|
||||
generateDelegateMethodsPromptSupport = true,
|
||||
moveRefactoringSupport = true,
|
||||
overrideMethodsPromptSupport = true,
|
||||
executeClientCommandSupport = true,
|
||||
inferSelectionSupport = {
|
||||
"extractMethod",
|
||||
"extractVariable",
|
||||
"extractConstant",
|
||||
"extractVariableAllOccurrence"
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
local function configuration_handler(err, result, ctx, config)
|
||||
local client_id = ctx.client_id
|
||||
local bufnr = 0
|
||||
local client = lsp.get_client_by_id(client_id)
|
||||
if client then
|
||||
-- This isn't done in start_or_attach because a user could use a plugin like editorconfig to configure tabsize/spaces
|
||||
-- That plugin may run after `start_or_attach` which is why we defer the setting lookup.
|
||||
-- This ensures the language-server will use the latest version of the options
|
||||
local new_settings = {
|
||||
java = {
|
||||
format = {
|
||||
insertSpaces = vim.bo[bufnr].expandtab,
|
||||
tabSize = lsp.util.get_effective_tabstop(bufnr)
|
||||
}
|
||||
}
|
||||
}
|
||||
if client.settings then
|
||||
client.settings.java = vim.tbl_deep_extend('keep', client.settings.java or {}, new_settings.java)
|
||||
else
|
||||
client.config.settings = vim.tbl_deep_extend('keep', client.config.settings or {}, new_settings)
|
||||
end
|
||||
end
|
||||
return lsp.handlers['workspace/configuration'](err, result, ctx, config)
|
||||
end
|
||||
|
||||
|
||||
local function maybe_implicit_save()
|
||||
-- 💀
|
||||
-- If the client is attached to a buffer that doesn't exist on the filesystem,
|
||||
-- jdtls struggles and cannot provide completions and other functionality
|
||||
-- until the buffer is re-attached (`:e!`)
|
||||
--
|
||||
-- So this implicitly saves a file before attaching the lsp client.
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
if vim.o.buftype == '' then
|
||||
local uri = vim.uri_from_bufnr(bufnr)
|
||||
local scheme = uri:match(URI_SCHEME_PATTERN)
|
||||
if scheme ~= 'file' then
|
||||
return
|
||||
end
|
||||
local fname = api.nvim_buf_get_name(bufnr)
|
||||
if fname == '' then
|
||||
return
|
||||
end
|
||||
local stat = vim.loop.fs_stat(fname)
|
||||
if not stat then
|
||||
local filepath = vim.fn.expand('%:p:h')
|
||||
assert(type(filepath) == "string")
|
||||
vim.fn.mkdir(filepath, 'p')
|
||||
vim.cmd('w')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---@return string?, vim.lsp.Client?
|
||||
local function extract_data_dir(bufnr)
|
||||
-- Prefer client from current buffer, in case there are multiple jdtls clients (multiple projects)
|
||||
local client = get_clients({ name = "jdtls", bufnr = bufnr })[1]
|
||||
if not client then
|
||||
-- Try first matching jdtls client otherwise. In case the user is in a
|
||||
-- different buffer like the quickfix list
|
||||
local clients = get_clients({ name = "jdtls" })
|
||||
if vim.tbl_count(clients) > 1 then
|
||||
---@diagnostic disable-next-line: cast-local-type
|
||||
client = require('jdtls.ui').pick_one(
|
||||
clients,
|
||||
'Multiple jdtls clients found, pick one: ',
|
||||
function(c) return c.config.root_dir end
|
||||
)
|
||||
else
|
||||
client = clients[1]
|
||||
end
|
||||
end
|
||||
|
||||
if client and client.config and client.config.cmd then
|
||||
local cmd = client.config.cmd
|
||||
if type(cmd) == "table" then
|
||||
for i, part in pairs(cmd) do
|
||||
-- jdtls helper script uses `--data`, java jar command uses `-data`.
|
||||
if part == '-data' or part == '--data' then
|
||||
return client.config.cmd[i + 1], client
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nil, nil
|
||||
end
|
||||
|
||||
|
||||
---@param client vim.lsp.Client
|
||||
---@param opts jdtls.start.opts
|
||||
local function add_commands(client, bufnr, opts)
|
||||
local function create_cmd(name, command, cmdopts)
|
||||
api.nvim_buf_create_user_command(bufnr, name, command, cmdopts or {})
|
||||
end
|
||||
create_cmd("JdtCompile", "lua require('jdtls').compile(<f-args>)", {
|
||||
nargs = "?",
|
||||
complete = "custom,v:lua.require'jdtls'._complete_compile"
|
||||
})
|
||||
create_cmd("JdtSetRuntime", "lua require('jdtls').set_runtime(<f-args>)", {
|
||||
nargs = "?",
|
||||
complete = "custom,v:lua.require'jdtls'._complete_set_runtime"
|
||||
})
|
||||
create_cmd("JdtUpdateConfig", function(args)
|
||||
require("jdtls").update_projects_config(args.bang and { select_mode = "all" } or {})
|
||||
end, {
|
||||
bang = true
|
||||
})
|
||||
create_cmd("JdtJol", "lua require('jdtls').jol(<f-args>)", {
|
||||
nargs = "*"
|
||||
})
|
||||
create_cmd("JdtBytecode", "lua require('jdtls').javap()")
|
||||
create_cmd("JdtJshell", "lua require('jdtls').jshell()")
|
||||
create_cmd("JdtRestart", "lua require('jdtls.setup').restart()")
|
||||
local ok, dap = pcall(require, 'dap')
|
||||
if ok then
|
||||
local command_provider = client.server_capabilities.executeCommandProvider or {}
|
||||
local commands = command_provider.commands or {}
|
||||
if not vim.tbl_contains(commands, "vscode.java.startDebugSession") then
|
||||
return
|
||||
end
|
||||
|
||||
require("jdtls.dap").setup_dap(opts.dap or {})
|
||||
api.nvim_command "command! -buffer JdtUpdateDebugConfig lua require('jdtls.dap').setup_dap_main_class_configs({ verbose = true })"
|
||||
local redefine_classes = function()
|
||||
local session = dap.session()
|
||||
if not session then
|
||||
vim.notify('No active debug session')
|
||||
else
|
||||
vim.notify('Applying code changes')
|
||||
session:request('redefineClasses', nil, function(err)
|
||||
assert(not err, vim.inspect(err))
|
||||
end)
|
||||
end
|
||||
end
|
||||
api.nvim_create_user_command('JdtUpdateHotcode', redefine_classes, {
|
||||
desc = "Trigger reload of changed classes for current debug session",
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---@class jdtls.start.opts
|
||||
---@field dap? JdtSetupDapOpts
|
||||
|
||||
|
||||
--- Start the language server (if not started), and attach the current buffer.
|
||||
---
|
||||
---@param config table<string, any> configuration. See |vim.lsp.start_client|
|
||||
---@param opts? jdtls.start.opts
|
||||
---@param start_opts? vim.lsp.start.Opts? options passed to vim.lsp.start
|
||||
---@return integer? client_id
|
||||
function M.start_or_attach(config, opts, start_opts)
|
||||
opts = opts or {}
|
||||
assert(config, 'config is required')
|
||||
assert(
|
||||
config.cmd and type(config.cmd) == 'table',
|
||||
'Config must have a `cmd` property and that must be a table. Got: '
|
||||
.. table.concat(config.cmd, ' ')
|
||||
)
|
||||
config.name = 'jdtls'
|
||||
local on_attach = config.on_attach
|
||||
config.on_attach = function(client, bufnr)
|
||||
if on_attach then
|
||||
on_attach(client, bufnr)
|
||||
end
|
||||
add_commands(client, bufnr, opts)
|
||||
end
|
||||
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
local bufname = api.nvim_buf_get_name(bufnr)
|
||||
-- Won't be able to get the correct root path for jdt:// URIs
|
||||
-- So need to connect to an existing client
|
||||
if vim.startswith(bufname, 'jdt://') then
|
||||
local client_id = attach_to_active_buf(bufnr, config.name)
|
||||
if client_id then
|
||||
return client_id
|
||||
end
|
||||
end
|
||||
|
||||
local uri = vim.uri_from_bufnr(bufnr)
|
||||
-- jdtls requires files to exist on the filesystem; it doesn't play well with scratch buffers
|
||||
if not vim.startswith(uri, "file://") then
|
||||
return
|
||||
end
|
||||
|
||||
config.root_dir = (config.root_dir
|
||||
or M.find_root({'.git', 'gradlew', 'mvnw'}, bufname)
|
||||
or vim.fn.getcwd()
|
||||
)
|
||||
config.handlers = config.handlers or {}
|
||||
config.handlers['language/status'] = config.handlers['language/status'] or status_callback
|
||||
config.handlers['workspace/configuration'] = config.handlers['workspace/configuration'] or configuration_handler
|
||||
local capabilities = vim.tbl_deep_extend('keep', config.capabilities or {}, lsp.protocol.make_client_capabilities())
|
||||
local extra_code_action_literals = {
|
||||
"source.generate.toString",
|
||||
"source.generate.hashCodeEquals",
|
||||
"source.organizeImports",
|
||||
}
|
||||
local code_action_literals = vim.tbl_get(
|
||||
capabilities,
|
||||
"textDocument",
|
||||
"codeAction",
|
||||
"codeActionLiteralSupport",
|
||||
"codeActionKind",
|
||||
"valueSet"
|
||||
) or {}
|
||||
for _, extra_literal in ipairs(extra_code_action_literals) do
|
||||
if not vim.tbl_contains(code_action_literals, extra_literal) then
|
||||
table.insert(code_action_literals, extra_literal)
|
||||
end
|
||||
end
|
||||
local extra_capabilities = {
|
||||
textDocument = {
|
||||
codeAction = {
|
||||
codeActionLiteralSupport = {
|
||||
codeActionKind = {
|
||||
valueSet = code_action_literals
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
config.capabilities = vim.tbl_deep_extend('force', capabilities, extra_capabilities)
|
||||
|
||||
config.init_options = config.init_options or {}
|
||||
config.init_options.extendedClientCapabilities = (
|
||||
config.init_options.extendedClientCapabilities or vim.deepcopy(M.extendedClientCapabilities)
|
||||
)
|
||||
config.settings = vim.tbl_deep_extend('keep', config.settings or {}, {
|
||||
-- the `java` property is used in other places to detect the client as the jdtls client
|
||||
-- don't remove it without updating those places
|
||||
java = {
|
||||
}
|
||||
})
|
||||
maybe_implicit_save()
|
||||
return vim.lsp.start(config, start_opts)
|
||||
end
|
||||
|
||||
|
||||
function M.wipe_data_and_restart()
|
||||
local data_dir, client = extract_data_dir(vim.api.nvim_get_current_buf())
|
||||
if not data_dir or not client then
|
||||
vim.notify(
|
||||
"Data directory wasn't detected. " ..
|
||||
"You must call `start_or_attach` at least once and the cmd must include a `-data` parameter (or `--data` if using the official `jdtls` wrapper)")
|
||||
return
|
||||
end
|
||||
local opts = {
|
||||
prompt = 'Are you sure you want to wipe the data folder: ' .. data_dir .. ' and restart? ',
|
||||
}
|
||||
vim.ui.select({'Yes', 'No'}, opts, function(choice)
|
||||
if choice ~= 'Yes' then
|
||||
return
|
||||
end
|
||||
vim.schedule(function()
|
||||
local bufs = vim.lsp.get_buffers_by_client_id(client.id)
|
||||
client.stop()
|
||||
vim.wait(30000, function()
|
||||
return vim.lsp.get_client_by_id(client.id) == nil
|
||||
end)
|
||||
vim.fn.delete(data_dir, 'rf')
|
||||
local client_id
|
||||
if vim.bo.filetype == "java" then
|
||||
client_id = lsp.start(client.config)
|
||||
else
|
||||
client_id = vim.lsp.start_client(client.config)
|
||||
end
|
||||
if client_id then
|
||||
for _, buf in ipairs(bufs) do
|
||||
lsp.buf_attach_client(buf, client_id)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
---@deprecated not needed, start automatically adds commands
|
||||
function M.add_commands()
|
||||
end
|
||||
|
||||
|
||||
function M.show_logs()
|
||||
local data_dir = extract_data_dir(vim.api.nvim_get_current_buf())
|
||||
if data_dir then
|
||||
vim.cmd('split | e ' .. data_dir .. '/.metadata/.log | normal G')
|
||||
end
|
||||
if vim.fn.has('nvim-0.8') == 1 then
|
||||
vim.cmd('vsplit | e ' .. vim.fn.stdpath('log') .. '/lsp.log | normal G')
|
||||
else
|
||||
vim.cmd('vsplit | e ' .. vim.fn.stdpath('cache') .. '/lsp.log | normal G')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
@ -0,0 +1,97 @@
|
||||
local ns = vim.api.nvim_create_namespace('testng')
|
||||
local M = {}
|
||||
|
||||
local function parse(content, tests)
|
||||
local lines = vim.split(content, '\n')
|
||||
for _, line in ipairs(lines) do
|
||||
if vim.startswith(line, '@@<TestRunner-') then
|
||||
line = line.sub(line, 15)
|
||||
line = line:sub(1, -13)
|
||||
local test = vim.json.decode(line)
|
||||
if test.name ~= 'testStarted' then
|
||||
table.insert(tests, test)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.__parse = parse
|
||||
|
||||
|
||||
local function mk_buf_loop(sock, handle_buffer)
|
||||
local buffer = ''
|
||||
return function(err, chunk)
|
||||
assert(not err, err)
|
||||
if chunk then
|
||||
buffer = buffer .. chunk
|
||||
else
|
||||
sock:close()
|
||||
handle_buffer(buffer)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function M.mk_test_results(bufnr)
|
||||
vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
|
||||
local tests = {}
|
||||
local handle_buffer = function(buf)
|
||||
parse(buf, tests)
|
||||
end
|
||||
local function get_test_line_nr(lenses, name)
|
||||
if lenses.fullName == name then
|
||||
return lenses.range.start.line
|
||||
end
|
||||
for _, v in ipairs(lenses) do
|
||||
if v.fullName == name then
|
||||
return v.range.start.line
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
return {
|
||||
show = function(lens)
|
||||
local repl = require('dap.repl')
|
||||
|
||||
-- error = '✘',
|
||||
-- warn = '▲',
|
||||
-- hint = '⚑',
|
||||
-- info = '»'
|
||||
local lenses = lens.children or lens
|
||||
local failed = {}
|
||||
for _, test in ipairs(tests) do
|
||||
local lnum = get_test_line_nr(lenses, test.attributes.name)
|
||||
if lnum ~= nil then
|
||||
local testName = vim.split(test.attributes.name, '#')[2]
|
||||
local message = test.attributes.message or 'test failed'
|
||||
if test.name == 'testFailed' then
|
||||
table.insert(failed, {
|
||||
bufnr = bufnr,
|
||||
lnum = lnum,
|
||||
col = 0,
|
||||
severity = vim.diagnostic.severity.ERROR,
|
||||
source = 'testng',
|
||||
message = message,
|
||||
user_data = {}
|
||||
})
|
||||
repl.append('❌ ' .. testName .. ' failed')
|
||||
repl.append(message)
|
||||
repl.append(test.attributes.trace)
|
||||
elseif test.name == 'testFinished' then
|
||||
local text = { '✔️ ' }
|
||||
vim.api.nvim_buf_set_extmark(bufnr, ns, lnum, 0, {
|
||||
virt_text = { text },
|
||||
})
|
||||
repl.append('✔️ ' .. testName .. ' passed')
|
||||
end
|
||||
end
|
||||
end
|
||||
vim.diagnostic.set(ns, bufnr, failed, {})
|
||||
end,
|
||||
mk_reader = function(sock)
|
||||
return vim.schedule_wrap(mk_buf_loop(sock, handle_buffer))
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
159
config/neovim/store/lazy-plugins/nvim-jdtls/lua/jdtls/tests.lua
Normal file
159
config/neovim/store/lazy-plugins/nvim-jdtls/lua/jdtls/tests.lua
Normal file
@ -0,0 +1,159 @@
|
||||
---@mod jdtls.tests Functions which require vscode-java-test
|
||||
|
||||
|
||||
local api = vim.api
|
||||
local M = {}
|
||||
|
||||
--- Generate tests for the current class
|
||||
--- @param opts? {bufnr: integer}
|
||||
function M.generate(opts)
|
||||
opts = opts or {}
|
||||
local bufnr = opts.bufnr or api.nvim_get_current_buf()
|
||||
local win = api.nvim_get_current_win()
|
||||
local cursor = api.nvim_win_get_cursor(win) -- (1, 0) indexed
|
||||
local lnum = cursor[1]
|
||||
local line = api.nvim_buf_get_lines(bufnr, lnum -1, lnum, true)[1]
|
||||
local byteoffset = vim.fn.line2byte(lnum) + vim.str_byteindex(line, cursor[2], true)
|
||||
local command = {
|
||||
title = "Generate tests",
|
||||
command = "vscode.java.test.generateTests",
|
||||
arguments = {vim.uri_from_bufnr(bufnr), byteoffset},
|
||||
}
|
||||
---@param result? lsp.WorkspaceEdit
|
||||
local on_result = function(err, result)
|
||||
assert(not err, err)
|
||||
if not result then
|
||||
return
|
||||
end
|
||||
vim.lsp.util.apply_workspace_edit(result, "utf-16")
|
||||
|
||||
if not api.nvim_win_is_valid(win) or api.nvim_win_get_buf(win) ~= bufnr then
|
||||
return
|
||||
end
|
||||
|
||||
-- Set buffer of window to first created/changed file
|
||||
local uri = next(result.changes or {})
|
||||
if uri then
|
||||
local changed_buf = vim.uri_to_bufnr(uri)
|
||||
api.nvim_win_set_buf(win, changed_buf)
|
||||
else
|
||||
-- documentChanges?: ( TextDocumentEdit[] | (TextDocumentEdit | CreateFile | RenameFile | DeleteFile)[]);
|
||||
local changes = result.documentChanges or {}
|
||||
local _, change = next(changes)
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local document = changes.textDocument or change.textDocument
|
||||
if change.uri and change.kind ~= "delete" then
|
||||
local changed_buf = vim.uri_to_bufnr(change.uri)
|
||||
api.nvim_win_set_buf(win, changed_buf)
|
||||
elseif document then
|
||||
local changed_buf = vim.uri_to_bufnr(document.uri)
|
||||
api.nvim_win_set_buf(win, changed_buf)
|
||||
end
|
||||
end
|
||||
end
|
||||
require("jdtls.util").execute_command(command, on_result, bufnr)
|
||||
end
|
||||
|
||||
|
||||
--- Go to the related subjects
|
||||
--- If in a test file, this will jump to classes the test might cover
|
||||
--- If in a non-test file, this will jump to related tests.
|
||||
---
|
||||
--- If no candidates are found, this calls `generate()`
|
||||
---
|
||||
--- @param opts? {goto_tests: boolean}
|
||||
function M.goto_subjects(opts)
|
||||
opts = opts or {}
|
||||
local win = api.nvim_get_current_win()
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
local function on_result(err, result)
|
||||
assert(not err, err)
|
||||
if api.nvim_get_current_win() ~= win then
|
||||
return
|
||||
end
|
||||
|
||||
result = result or {}
|
||||
local items = result and (result.items or {})
|
||||
if not next(items) then
|
||||
M.generate({ bufnr = bufnr })
|
||||
elseif #items == 1 then
|
||||
local test_buf = vim.uri_to_bufnr(items[1].uri)
|
||||
api.nvim_win_set_buf(win, test_buf)
|
||||
else
|
||||
local function label(x)
|
||||
return x.simpleName
|
||||
end
|
||||
table.sort(items, function(x, y)
|
||||
if x.outOfBelongingProject and not y.outOfBelongingProject then
|
||||
return false
|
||||
elseif not x.outOfBelongingProject and y.outOfBelongingProject then
|
||||
return true
|
||||
else
|
||||
if x.relevance == y.relevance then
|
||||
return x.simpleName < y.simpleName
|
||||
end
|
||||
return x.relevance < y.relevance
|
||||
end
|
||||
end)
|
||||
require("jdtls.ui").pick_one_async(items, "Goto: ", label, function(choice)
|
||||
if choice then
|
||||
local test_buf = vim.uri_to_bufnr(choice.uri)
|
||||
api.nvim_win_set_buf(win, test_buf)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
local util = require("jdtls.util")
|
||||
if opts.goto_tests == nil then
|
||||
local is_testfile_cmd = {
|
||||
command = "java.project.isTestFile",
|
||||
arguments = { vim.uri_from_bufnr(bufnr) }
|
||||
}
|
||||
util.execute_command(is_testfile_cmd, function(err, is_testfile)
|
||||
assert(not err, err)
|
||||
local command = {
|
||||
command = "vscode.java.test.navigateToTestOrTarget",
|
||||
arguments = { vim.uri_from_bufnr(bufnr), not is_testfile }
|
||||
}
|
||||
require("jdtls.util").execute_command(command, on_result, bufnr)
|
||||
end, bufnr)
|
||||
else
|
||||
local command = {
|
||||
command = "vscode.java.test.navigateToTestOrTarget",
|
||||
arguments = { vim.uri_from_bufnr(bufnr), opts.goto_tests }
|
||||
}
|
||||
require("jdtls.util").execute_command(command, on_result, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---@private
|
||||
function M._ask_client_for_choice(prompt, choices, pick_many)
|
||||
local label = function(x)
|
||||
local description = x.description and (' ' .. x.description) or ''
|
||||
return x.label .. description
|
||||
end
|
||||
local ui = require("jdtls.ui")
|
||||
if pick_many then
|
||||
local opts = {
|
||||
is_selected = function(x) return x.picked end
|
||||
}
|
||||
local result = ui.pick_many(choices, prompt, label, opts)
|
||||
return vim.tbl_map(function(x) return x.value or x.label end, result)
|
||||
else
|
||||
local co, is_main = coroutine.running()
|
||||
local choice
|
||||
if co and not is_main then
|
||||
ui.pick_one_async(choices, prompt, label, function(result)
|
||||
coroutine.resume(co, result)
|
||||
end)
|
||||
choice = coroutine.yield()
|
||||
else
|
||||
choice = ui.pick_one(choices, prompt, label)
|
||||
end
|
||||
return choice and (choice.value or choice.label) or vim.NIL
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
93
config/neovim/store/lazy-plugins/nvim-jdtls/lua/jdtls/ui.lua
Normal file
93
config/neovim/store/lazy-plugins/nvim-jdtls/lua/jdtls/ui.lua
Normal file
@ -0,0 +1,93 @@
|
||||
local M = {}
|
||||
|
||||
|
||||
function M.pick_one_async(items, prompt, label_fn, cb)
|
||||
if vim.ui then
|
||||
return vim.ui.select(items, {
|
||||
prompt = prompt,
|
||||
format_item = label_fn,
|
||||
}, cb)
|
||||
end
|
||||
local result = M.pick_one(items, prompt, label_fn)
|
||||
cb(result)
|
||||
end
|
||||
|
||||
|
||||
---@generic T
|
||||
---@param items T[]
|
||||
---@param prompt string
|
||||
---@param label_fn fun(item: T): string
|
||||
---@result T|nil
|
||||
function M.pick_one(items, prompt, label_fn)
|
||||
local choices = {prompt}
|
||||
for i, item in ipairs(items) do
|
||||
table.insert(choices, string.format('%d: %s', i, label_fn(item)))
|
||||
end
|
||||
local choice = vim.fn.inputlist(choices)
|
||||
if choice < 1 or choice > #items then
|
||||
return nil
|
||||
end
|
||||
return items[choice]
|
||||
end
|
||||
|
||||
|
||||
local function index_of(xs, term)
|
||||
for i, x in pairs(xs) do
|
||||
if x == term then
|
||||
return i
|
||||
end
|
||||
end
|
||||
return -1
|
||||
end
|
||||
|
||||
|
||||
function M.pick_many(items, prompt, label_f, opts)
|
||||
if not items or #items == 0 then
|
||||
return {}
|
||||
end
|
||||
|
||||
label_f = label_f or function(item)
|
||||
return item
|
||||
end
|
||||
opts = opts or {}
|
||||
|
||||
local choices = {}
|
||||
local selected = {}
|
||||
local is_selected = opts.is_selected or function(_)
|
||||
return false
|
||||
end
|
||||
for i, item in pairs(items) do
|
||||
local label = label_f(item)
|
||||
local choice = string.format("%d. %s", i, label)
|
||||
if is_selected(item) then
|
||||
choice = choice .. " *"
|
||||
table.insert(selected, item)
|
||||
end
|
||||
table.insert(choices, choice)
|
||||
end
|
||||
|
||||
while true do
|
||||
local answer = vim.fn.input(string.format("\n%s\n%s (Esc to finish): ", table.concat(choices, "\n"), prompt))
|
||||
if answer == "" then
|
||||
break
|
||||
end
|
||||
|
||||
local index = tonumber(answer)
|
||||
if index ~= nil then
|
||||
local choice = choices[index]
|
||||
local item = items[index]
|
||||
if string.find(choice, "*") == nil then
|
||||
table.insert(selected, item)
|
||||
choices[index] = choice .. " *"
|
||||
else
|
||||
choices[index] = string.gsub(choice, " %*$", "")
|
||||
local idx = index_of(selected, item)
|
||||
table.remove(selected, idx)
|
||||
end
|
||||
end
|
||||
end
|
||||
return selected
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
163
config/neovim/store/lazy-plugins/nvim-jdtls/lua/jdtls/util.lua
Normal file
163
config/neovim/store/lazy-plugins/nvim-jdtls/lua/jdtls/util.lua
Normal file
@ -0,0 +1,163 @@
|
||||
local api = vim.api
|
||||
local M = {}
|
||||
|
||||
---@diagnostic disable-next-line: deprecated
|
||||
local get_clients = vim.lsp.get_clients or vim.lsp.get_active_clients
|
||||
|
||||
|
||||
function M.execute_command(command, callback, bufnr)
|
||||
local clients = {}
|
||||
local candidates = get_clients({ bufnr = bufnr })
|
||||
for _, c in pairs(candidates) do
|
||||
local command_provider = c.server_capabilities.executeCommandProvider
|
||||
local commands = type(command_provider) == 'table' and command_provider.commands or {}
|
||||
if vim.tbl_contains(commands, command.command) then
|
||||
table.insert(clients, c)
|
||||
end
|
||||
end
|
||||
local num_clients = vim.tbl_count(clients)
|
||||
if num_clients == 0 then
|
||||
if bufnr then
|
||||
-- User could've switched buffer to non-java file, try all clients
|
||||
return M.execute_command(command, callback, nil)
|
||||
else
|
||||
vim.notify('No LSP client found that supports ' .. command.command, vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if num_clients > 1 then
|
||||
vim.notify(
|
||||
'Multiple LSP clients found that support ' .. command.command .. ' you should have at most one JDTLS server running',
|
||||
vim.log.levels.WARN)
|
||||
end
|
||||
|
||||
local co
|
||||
if not callback then
|
||||
co = coroutine.running()
|
||||
if co then
|
||||
callback = function(err, resp)
|
||||
coroutine.resume(co, err, resp)
|
||||
end
|
||||
end
|
||||
end
|
||||
clients[1].request('workspace/executeCommand', command, callback, bufnr)
|
||||
if co then
|
||||
return coroutine.yield()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---@param mainclass string
|
||||
---@param project string
|
||||
---@param fn fun(java_exec: string)
|
||||
---@param bufnr integer?
|
||||
function M.with_java_executable(mainclass, project, fn, bufnr)
|
||||
vim.validate({
|
||||
mainclass = { mainclass, 'string' }
|
||||
})
|
||||
|
||||
bufnr = assert((bufnr == nil or bufnr == 0) and api.nvim_get_current_buf() or bufnr)
|
||||
|
||||
local client = get_clients({ name = "jdtls", bufnr = bufnr, method = "workspace/executeCommand" })[1]
|
||||
if not client then
|
||||
print("No jdtls client found")
|
||||
return
|
||||
end
|
||||
|
||||
local provider = client.server_capabilities.executeCommandProvider or {}
|
||||
local supported_commands = provider.commands or {}
|
||||
local resolve_java_executable = "vscode.java.resolveJavaExecutable"
|
||||
|
||||
---@type lsp.ExecuteCommandParams
|
||||
local params
|
||||
local on_response
|
||||
if vim.tbl_contains(supported_commands, resolve_java_executable) then
|
||||
params = {
|
||||
command = resolve_java_executable,
|
||||
arguments = { mainclass, project }
|
||||
}
|
||||
---@param err lsp.ResponseError?
|
||||
on_response = function(err, java_exec)
|
||||
if err then
|
||||
print('Could not resolve java executable: ' .. err.message)
|
||||
else
|
||||
fn(java_exec)
|
||||
end
|
||||
end
|
||||
else
|
||||
local setting = "org.eclipse.jdt.ls.core.vm.location"
|
||||
params = {
|
||||
command = "java.project.getSettings",
|
||||
arguments = {
|
||||
vim.uri_from_bufnr(bufnr),
|
||||
{
|
||||
setting
|
||||
}
|
||||
}
|
||||
}
|
||||
---@param err lsp.ResponseError?
|
||||
on_response = function(err, settings)
|
||||
if err then
|
||||
print('Could not resolve java executable from settings: ' .. err.message)
|
||||
else
|
||||
fn(settings[setting] .. "/bin/java")
|
||||
end
|
||||
end
|
||||
end
|
||||
client.request("workspace/executeCommand", params, on_response, bufnr)
|
||||
end
|
||||
|
||||
|
||||
function M.with_classpaths(fn)
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
local uri = vim.uri_from_bufnr(bufnr)
|
||||
coroutine.wrap(function()
|
||||
local is_test_file_cmd = {
|
||||
command = 'java.project.isTestFile',
|
||||
arguments = { uri }
|
||||
};
|
||||
local options
|
||||
if vim.startswith(uri, "jdt://") then
|
||||
options = vim.fn.json_encode({ scope = "runtime" })
|
||||
else
|
||||
local err, is_test_file = M.execute_command(is_test_file_cmd, nil, bufnr)
|
||||
assert(not err, vim.inspect(err))
|
||||
options = vim.fn.json_encode({
|
||||
scope = is_test_file and 'test' or 'runtime';
|
||||
})
|
||||
end
|
||||
local cmd = {
|
||||
command = 'java.project.getClasspaths';
|
||||
arguments = { uri, options };
|
||||
}
|
||||
local err1, resp = M.execute_command(cmd, nil, bufnr)
|
||||
if err1 then
|
||||
print('Error executing java.project.getClasspaths: ' .. err1.message)
|
||||
else
|
||||
fn(resp)
|
||||
end
|
||||
end)()
|
||||
end
|
||||
|
||||
|
||||
function M.resolve_classname()
|
||||
local lines = api.nvim_buf_get_lines(0, 0, -1, true)
|
||||
local pkgname
|
||||
for _, line in ipairs(lines) do
|
||||
local match = line:match('package ([a-z0-9_\\.]+);')
|
||||
if match then
|
||||
pkgname = match
|
||||
break
|
||||
end
|
||||
end
|
||||
local classname = vim.fn.fnamemodify(vim.fn.expand('%'), ':t:r')
|
||||
if pkgname then
|
||||
return pkgname .. '.' .. classname
|
||||
else
|
||||
return classname
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
@ -0,0 +1,9 @@
|
||||
if exists('g:nvim_jdtls')
|
||||
finish
|
||||
endif
|
||||
let g:nvim_jdtls = 1
|
||||
|
||||
au BufReadCmd jdt://* lua require('jdtls').open_classfile(vim.fn.expand('<amatch>'))
|
||||
au BufReadCmd *.class lua require("jdtls").open_classfile(vim.fn.expand("<amatch>"))
|
||||
command! JdtWipeDataAndRestart lua require('jdtls.setup').wipe_data_and_restart()
|
||||
command! JdtShowLogs lua require('jdtls.setup').show_logs()
|
||||
@ -0,0 +1,50 @@
|
||||
local junit = require 'jdtls.junit'
|
||||
describe('jdtls.junit', function()
|
||||
it('can parse result of successful test', function()
|
||||
local lines = {
|
||||
'%TESTC 1 v2',
|
||||
'%TSTTREE1,test_foo(io.bar.BarTest),false,1,false,-1,test_foo(io.bar.BarTest),,',
|
||||
'%TESTS 1,test_foo(io.bar.BarTest)',
|
||||
'%TESTE 1,test_foo(io.bar.BarTest)',
|
||||
'%RUNTIME2078',
|
||||
}
|
||||
local tests = {}
|
||||
junit.__parse(table.concat(lines, '\n'), tests)
|
||||
local expected = {
|
||||
{
|
||||
failed = false,
|
||||
fq_class = 'io.bar.BarTest',
|
||||
method = 'test_foo',
|
||||
traces = {},
|
||||
},
|
||||
}
|
||||
assert.are.same(expected, tests)
|
||||
end)
|
||||
it('can parse test result with initialization failure', function()
|
||||
local lines = {
|
||||
'%TESTC 1 v2',
|
||||
'%TSTTREE1,test_foo(io.foo.FooTest),false,1,false,-1,test_foo(io.foo.FooTest),,',
|
||||
'%ERROR 2,io.foo.FooTest',
|
||||
'%TRACES ',
|
||||
'java.lang.UnsupportedOperationException: foo',
|
||||
'\tat java.base/java.lang.Thread.run(Thread.java:833)',
|
||||
'',
|
||||
'%TRACEE ',
|
||||
'%RUNTIME698',
|
||||
}
|
||||
local tests = {}
|
||||
junit.__parse(table.concat(lines, '\n'), tests)
|
||||
local expected = {
|
||||
{
|
||||
failed = true,
|
||||
fq_class = 'io.foo.FooTest',
|
||||
traces = {
|
||||
'java.lang.UnsupportedOperationException: foo',
|
||||
'\tat java.base/java.lang.Thread.run(Thread.java:833)',
|
||||
'',
|
||||
},
|
||||
},
|
||||
}
|
||||
assert.are.same(expected, tests)
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,3 @@
|
||||
set rtp+=.
|
||||
set rtp+=../plenary.nvim
|
||||
runtime! plugin/plenary.vim
|
||||
Reference in New Issue
Block a user