Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b30e36fad | ||
|
|
8d41141e9a | ||
|
|
919d141c6a | ||
|
|
89bf0333c4 | ||
|
|
9210dff133 | ||
|
|
262e377873 | ||
|
|
5cec285828 | ||
|
|
22215cccda | ||
|
|
2ca6c62cd8 | ||
|
|
d99dc30dcd | ||
|
|
62015919dd | ||
|
|
e0cbc48cc0 | ||
|
|
15718d57fa | ||
|
|
c907211784 | ||
|
|
053c567618 | ||
|
|
faf87f3643 | ||
|
|
1df75ee212 | ||
|
|
ce406bfad3 | ||
|
|
0dec930412 | ||
|
|
d7b949d9f9 | ||
|
|
bf56094156 | ||
|
|
1a450ff79a | ||
|
|
76791fd7c1 | ||
|
|
45fcdf78be | ||
|
|
d1cb867cf8 | ||
|
|
5bf74a6639 | ||
|
|
2b440c2935 | ||
|
|
5420c54d9a | ||
|
|
ad97a31a31 | ||
|
|
0a8495fe79 | ||
|
|
a246f2ab03 | ||
|
|
5765c8ea19 | ||
|
|
e701aa1feb | ||
|
|
bc825895ac | ||
|
|
0cc4374865 | ||
|
|
66ae61f2c9 | ||
|
|
cf84fe2080 | ||
|
|
beddb26757 | ||
|
|
df473b1d33 | ||
|
|
e3fdeb53b3 | ||
|
|
8c2498d00f | ||
|
|
69c648c4f4 | ||
|
|
60e5d9ea2f | ||
|
|
109489a2aa | ||
|
|
6937318b2e | ||
|
|
23bc6c2bfc | ||
|
|
38284658dd | ||
|
|
759278b9ff | ||
|
|
14b302151b | ||
|
|
e6c3353b51 | ||
|
|
eea8def35c | ||
|
|
d5fadfa55e | ||
|
|
7e047478d5 | ||
|
|
9eb38ba06e | ||
|
|
85f05563ce | ||
|
|
7646aa3295 | ||
|
|
3942f88ef6 | ||
|
|
46eb126ebe | ||
|
|
70ff086e0c | ||
|
|
b348710bd5 | ||
|
|
dc0cf79188 | ||
|
|
0ac0267888 | ||
|
|
46263ca5e0 | ||
|
|
28fdb698bf | ||
|
|
9105add777 | ||
|
|
eb3e75fe67 | ||
|
|
def81ab3f3 | ||
|
|
4d34b5d1be | ||
|
|
fa7851a787 | ||
|
|
632add5f4a | ||
|
|
95bad52a3e | ||
|
|
31929db357 | ||
|
|
e888571c63 | ||
|
|
645ddcab04 | ||
|
|
2787644994 | ||
|
|
e884de149a | ||
|
|
71c88ec956 | ||
|
|
4c6b1289fc | ||
|
|
e8f51361ad | ||
|
|
ee73604008 | ||
|
|
cf5c7d8bbb | ||
|
|
9c4a50da8e | ||
|
|
2c8ae6b254 | ||
|
|
fa975c2aab | ||
|
|
88910d039b | ||
|
|
75b43d31c9 | ||
|
|
e935cad8b7 | ||
|
|
b5b1cfa449 | ||
|
|
1306f86a65 | ||
|
|
41e6fa1c48 | ||
|
|
5f45ee5029 | ||
|
|
3a50bf9375 | ||
|
|
8d913ce979 | ||
|
|
2d2164c380 | ||
|
|
a2c43661c4 | ||
|
|
4ddbe07a30 | ||
|
|
fe6d03981c | ||
|
|
294047bcda | ||
|
|
b07b2aec9d | ||
|
|
c6ea4f4f89 | ||
|
|
8584ed4bbf | ||
|
|
4ecaf54f82 | ||
|
|
677e5bbc67 | ||
|
|
674dd47dbc | ||
|
|
1e987bf5b6 | ||
|
|
acb859f9e5 | ||
|
|
734b60f145 | ||
|
|
34aa8346e9 | ||
|
|
96378ec33d | ||
|
|
6c53a052b3 | ||
|
|
368a5d98f8 | ||
|
|
15913c75b7 | ||
|
|
20a375aaf5 | ||
|
|
cac1fdb02c | ||
|
|
bb9efdbd8a | ||
|
|
bbb1e0c24a | ||
|
|
ff360658e4 | ||
|
|
908cb7ae03 | ||
|
|
9aedf18379 | ||
|
|
cbaf74418b | ||
|
|
e2ebe918bd | ||
|
|
546d204f9d | ||
|
|
534dc2819e | ||
|
|
5449c2a9f3 | ||
|
|
9db6059fb7 | ||
|
|
a725faaac8 | ||
|
|
c70246818e | ||
|
|
3db95f1b7c | ||
|
|
467d864eb4 | ||
|
|
919a856d93 | ||
|
|
cb476fa5ec | ||
|
|
f5b59c0f95 | ||
|
|
e28bcc41ea | ||
|
|
8425a838d0 | ||
|
|
71bc395125 | ||
|
|
b6640dfcee | ||
|
|
11ecd94afd | ||
|
|
a5c8a04e0f | ||
|
|
87e6408291 | ||
|
|
4cf429c210 |
@@ -1,22 +0,0 @@
|
||||
name: ci
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
permissions:
|
||||
contents: write
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: 3.x
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
key: ${{ github.ref }}
|
||||
path: .cache
|
||||
- run: pip install mkdocs-material
|
||||
- run: mkdocs gh-deploy --force
|
||||
+1
-2
@@ -1,3 +1,2 @@
|
||||
*.polydev
|
||||
LICENSE
|
||||
Lua_Annotation_CheatSheet/
|
||||
venv/
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
dmm.dev@pm.me.
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||
enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at
|
||||
https://www.contributor-covenant.org/translations.
|
||||
@@ -0,0 +1 @@
|
||||
- Its really simple. Just if you see an error/bug, enhancment or feature to be improved on just make an issue or make a pr.
|
||||
@@ -1,21 +1,201 @@
|
||||
MIT License
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
Copyright (c) 2025 DarthMooMancer
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
1. Definitions.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2025 DarthMooMancer
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
@@ -1,29 +1,55 @@
|
||||
# Polydev
|
||||
A multi-lingual plugin that adds some nice features to neovim for managing, creating, building and runnning projects all within neovim.
|
||||
<h1 align="center">Polydev</h1>
|
||||
|
||||

|
||||
<p align="center"><em>A multi-language project managing plugin for file creation, building, and running code—all within neovim. Whether you're coding in C/C++ Java, Python, Lua, Rust, and more, Polydev provides seamless integration to boost your productivity inside Neovim.</em></p>
|
||||
|
||||
### Quick Features
|
||||
The ability to -
|
||||
* Create new projects
|
||||
* Create new files
|
||||
* Build those files
|
||||
* Run those files
|
||||
* Builtin terminal for running code
|
||||
* And More!
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/badge/Lua-1e90ff?style=for-the-badge&logo=lua&logoColor=white" />
|
||||
<img src="https://img.shields.io/badge/Neovim-0.10%2B-32c48d?style=for-the-badge&logo=neovim&logoColor=white" />
|
||||
<img src="https://img.shields.io/badge/License-Apache-yellow.svg?style=for-the-badge" />
|
||||
<img src="https://img.shields.io/badge/Docs-Available-blue?style=for-the-badge&logo=readthedocs&logoColor=white" />
|
||||
</p>
|
||||
|
||||
Documentation is over at [Polydev Documentation](https://darthmoomancer.github.io/Polydev/)
|
||||
|
||||
### Currently Supported (And working) Languages
|
||||
## Features
|
||||
|
||||
* Create and manage projects directly from Neovim
|
||||
* Generate new files quickly
|
||||
* Build your code with customizable build systems
|
||||
* Run programs without leaving the editor
|
||||
* Integrated terminal for flexible command execution
|
||||
* Lightweight, fast project manager UI
|
||||
* Minimal configuration with extensibility in mind
|
||||
* Built-in diagnostics with `:checkhealth Polydev`
|
||||
|
||||
> 📚 [View the full documentation](https://git.moomancer.xyz/DarthMooMancer/polydev/wiki/Home$0) for setup, configuration, and usage details.
|
||||
|
||||
## Supported Languages
|
||||
|
||||
Polydev currently supports the following languages:
|
||||
|
||||
* Java
|
||||
* Python
|
||||
* C/C++
|
||||
* C / C++
|
||||
* Lua
|
||||
* Rust
|
||||
* Html
|
||||
* HTML
|
||||
|
||||
## Things planned
|
||||
* The use of rust to speed up some aspects of the plugin
|
||||
## Questions and Contributing
|
||||
Additional language support is planned for future releases.
|
||||
|
||||
If you want to contribute, make a PR or issue and I will answer as soon as I see it. If there is a language that you want added for easier use, please voice it. If you have questions, just ask in issues or discussions and I will answer them.
|
||||
|
||||
## Roadmap
|
||||
|
||||
Current focus:
|
||||
* **Refactoring and internal cleanup.**
|
||||
* **Remaking it not in nui to make tabs, mainly for recent projects as the main page**
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome and appreciated.
|
||||
|
||||
* Open an issue for bug reports, questions, or feature requests.
|
||||
* Submit a pull request if you'd like to contribute directly.
|
||||
|
||||
If you have an idea or use case you'd like to see supported, let’s discuss it.
|
||||
Your feedback and contributions are key to making Polydev even better! Thank you for being part of the journey. 🙏
|
||||
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
DIR="$(pwd)"
|
||||
|
||||
while [[ ! -f "$DIR/CMakeLists.txt" && \
|
||||
! -f "$DIR/package.json" && \
|
||||
! -f "$DIR/venv" && \
|
||||
! -d "$DIR/.git" && \
|
||||
"$DIR" != "/" ]]; do
|
||||
DIR="$(dirname "$DIR")"
|
||||
done
|
||||
|
||||
if [[ "$DIR" == "/" ]]; then
|
||||
echo "❌ Project root not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$DIR"
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
# 🚀 Welcome to Polydev
|
||||
|
||||
Polydev is a highly customizable and extensible Neovim plugin aimed at streamlining project creation and management for multiple programming languages. It’s especially suited for developers who work across different languages and want a consistent workflow for initializing, building, and running projects.
|
||||
|
||||

|
||||
|
||||
## ❓ What is Polydev?
|
||||
|
||||
Polydev is designed to be a centralized workspace tool that reduces repetitive tasks involved in setting up development environments. Whether you’re working on a Lua plugin, a Rust CLI tool, or a C++ project, Polydev helps you scaffold project directories, create boilerplate code, and define keybinds to streamline execution — all from within Neovim.
|
||||
|
||||
## 💡 Why Polydev?
|
||||
|
||||
Modern development often involves juggling multiple languages. Setting up similar environments repeatedly or manually running commands wastes time. Polydev solves this by providing:
|
||||
|
||||
- 📦 **Project templates per language**
|
||||
- 🎯 **Custom keybindings for common actions**
|
||||
- 💻 **Floating terminal support**
|
||||
- 🗂 **Easy file creation and directory structure generation**
|
||||
- 🔌 **Plugin-first architecture to expand functionality**
|
||||
|
||||
## 🔧 Core Features
|
||||
|
||||
- 🌐 **Language Support**: Define custom settings per language including `project_root`, `keybinds`, and `build_attributes`.
|
||||
- 🪟 **Floating Terminals**: Run builds and executions in a Neovim floating terminal.
|
||||
- 🧱 **Scaffolding**: Automatically create the appropriate directory and file layout for new projects.
|
||||
- 🎹 **Keybind Mapping**: Rebind keys to execute project-specific commands like `Build`, `Run`, or `Test`.
|
||||
- 🔌 **Pluggable**: Designed to easily integrate with other tools or extend with your own commands and language presets.
|
||||
|
||||
## 👥 Target Audience
|
||||
|
||||
Polydev is perfect for:
|
||||
|
||||
- 🧑💻 Developers building across multiple languages
|
||||
- 🔌 Plugin authors and power users of Neovim
|
||||
- ⚡ Anyone who wants automated project bootstrapping
|
||||
|
||||
## 🎯 Goals
|
||||
|
||||
- 📏 **Consistency**: Provide a common interface for all your dev projects.
|
||||
- 🧩 **Extensibility**: Let users add their own languages and tools.
|
||||
- ✨ **Simplicity**: Reduce boilerplate and context switching.
|
||||
|
||||
## 🧪 Example Use Case
|
||||
|
||||
Say you're a developer who works with Rust, Lua, and Python. Instead of remembering build commands, directory structures, or manually creating a `main.rs` or `init.lua`, Polydev:
|
||||
|
||||
1. 🏗 Sets up your directory based on language conventions.
|
||||
2. 📄 Generates boilerplate files.
|
||||
3. 🎛 Maps `<leader>pr` to `Run`, `<leader>pb` to `Build`, and so on.
|
||||
4. 🖥 Opens a floating terminal to show your output.
|
||||
|
||||
## 🏷 Versioning
|
||||
|
||||
Polydev uses GitHub tags and branches to manage plugin versions. Each version corresponds to a stable release that users can track.
|
||||
|
||||
---
|
||||
@@ -1,127 +0,0 @@
|
||||
# 📦 Installation
|
||||
|
||||
Polydev can be installed using any plugin manager of your choice—or even manually. Below are some examples for popular managers to get you started.
|
||||
|
||||
> ⚠️ **Disclaimer**: The `opts` and configuration values shown below are simply examples. You can customize them based on your preferences or even omit them entirely if not needed.
|
||||
> 💡 **Heads up!** Many language presets in Polydev require a file named `<project_name>.polydev` in your project root. If it's missing, Polydev will let you know (loudly 😅).
|
||||
|
||||
---
|
||||
|
||||
## 🛌 Lazy.nvim
|
||||
|
||||
This is the **recommended** way if you're using [Lazy.nvim](https://github.com/folke/lazy.nvim):
|
||||
|
||||
```lua
|
||||
{
|
||||
"DarthMooMancer/Polydev",
|
||||
opts = {
|
||||
lua = {
|
||||
project_root = "~/Projects/Lua",
|
||||
keybinds = {
|
||||
["<leader>pr"] = "LuaRun",
|
||||
},
|
||||
},
|
||||
terminal = {
|
||||
border = true,
|
||||
number = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
> ✅ Keep the `opts` key! It’s the modern way of setting up plugins in Lazy.
|
||||
|
||||
---
|
||||
|
||||
## 🧸 Mini.deps
|
||||
|
||||
For users of [mini.nvim](https://github.com/echasnovski/mini.nvim)'s dependency manager:
|
||||
|
||||
```lua
|
||||
MiniDeps.add({ source = "DarthMooMancer/Polydev" })
|
||||
|
||||
require("Polydev").setup({
|
||||
rust = {
|
||||
project_root = "~/Projects/Rust",
|
||||
keybinds = {
|
||||
["<leader>pb"] = "RustBuild",
|
||||
["<leader>pr"] = "RustRun",
|
||||
},
|
||||
},
|
||||
terminal = {
|
||||
border = true,
|
||||
number = true,
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📁 Packer.nvim
|
||||
|
||||
For fans of [Packer.nvim](https://github.com/wbthomason/packer.nvim):
|
||||
|
||||
```lua
|
||||
use({
|
||||
"DarthMooMancer/Polydev",
|
||||
config = function()
|
||||
require("Polydev").setup({
|
||||
python = {
|
||||
project_root = "~/Projects/Python",
|
||||
keybinds = {
|
||||
["<leader>pb"] = "PythonPip",
|
||||
["<leader>pr"] = "PythonRun",
|
||||
},
|
||||
},
|
||||
terminal = {
|
||||
relativenumber = true,
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Vim-Plug (Classic)
|
||||
|
||||
Even if you're still using [vim-plug](https://github.com/junegunn/vim-plug), you’re covered:
|
||||
|
||||
```vim
|
||||
Plug 'DarthMooMancer/Polydev'
|
||||
|
||||
lua << EOF
|
||||
require("Polydev").setup({
|
||||
c = {
|
||||
project_root = "~/Projects/C",
|
||||
keybinds = {
|
||||
["<leader>pb"] = "CBuild",
|
||||
["<leader>pr"] = "CRun",
|
||||
},
|
||||
},
|
||||
terminal = {
|
||||
number = true,
|
||||
},
|
||||
})
|
||||
EOF
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🛠 Manual Install
|
||||
|
||||
Clone the repo into your `~/.config/nvim/lua` or any runtime path:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/DarthMooMancer/Polydev ~/.config/nvim/lua/Polydev
|
||||
```
|
||||
|
||||
Then in your config:
|
||||
|
||||
```lua
|
||||
require("Polydev").setup({
|
||||
terminal = {
|
||||
border = true,
|
||||
},
|
||||
})
|
||||
```
|
||||
@@ -1,61 +0,0 @@
|
||||
### C Setup for Polydev 🛠️
|
||||
|
||||
#### Key Notes ⚠️
|
||||
> **Important**: The first time you build a project, it might throw an error. This is expected behavior. Simply rerun the build, and if errors persist, it may be an issue with your project setup rather than the plugin.
|
||||
|
||||
---
|
||||
|
||||
#### Keybinds 🎮
|
||||
You can customize keybinds for your C projects with Polydev.
|
||||
|
||||
| Keybind | Action |
|
||||
|---------------------|--------------------------------------------------|
|
||||
| `<leader>pb` | Build all C files in the `src` directory |
|
||||
| `<leader>pr` | Run `<Project_name>` in your build directory |
|
||||
| `<leader>nh` | Create a new header file in the current project’s `src` folder |
|
||||
|
||||
#### Configuration Example:
|
||||
|
||||
```lua
|
||||
require("Polydev").c.setup({
|
||||
keybinds = {
|
||||
["<leader>pb"] = "CBuild", -- Build all C files in the src directory
|
||||
["<leader>pr"] = "CRun", -- Run <Project_name> in your build directory
|
||||
["<leader>nh"] = "NewCHeaderFile" -- Create a new header file in the current project’s src folder
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### File Structure 📂
|
||||
This is the recommended file structure for your C projects using Polydev:
|
||||
|
||||
| Directory/File Path | Description |
|
||||
|----------------------------|------------------------------------------------------|
|
||||
| `CMakeLists.txt` | Configuration file for your project build |
|
||||
| `src/` | Folder containing source files for the project |
|
||||
| `main.c` | Main C file for the project |
|
||||
| `*.c` | Additional C source files |
|
||||
| `build/` | Folder where the build artifacts will be generated |
|
||||
| `<project_name>.polydev` | Polydev metadata file (generated during build) |
|
||||
| `include/` | Folder for header files |
|
||||
| `*.h` | C header files |
|
||||
|
||||
#### Example Structure:
|
||||
|
||||
```md
|
||||
Projects/
|
||||
└── C/
|
||||
└── Project_Name/
|
||||
├── CMakeLists.txt
|
||||
├── src/
|
||||
│ ├── main.c
|
||||
│ └── *.c
|
||||
├── build/
|
||||
│ └── <project_name>.polydev
|
||||
└── include/
|
||||
└── *.h
|
||||
```
|
||||
|
||||
---
|
||||
@@ -1,61 +0,0 @@
|
||||
### C Setup for Polydev 🛠️
|
||||
|
||||
#### Key Notes ⚠️
|
||||
> **Important**: The first time you build a project, it might throw an error. This is expected behavior. Simply rerun the build, and if errors persist, it may be an issue with your project setup rather than the plugin.
|
||||
|
||||
---
|
||||
|
||||
#### Keybinds 🎮
|
||||
You can customize keybinds for your C projects with Polydev.
|
||||
|
||||
| Keybind | Action |
|
||||
|---------------------|--------------------------------------------------|
|
||||
| `<leader>pb` | Build all C files in the `src` directory |
|
||||
| `<leader>pr` | Run `<Project_name>` in your build directory |
|
||||
| `<leader>nh` | Create a new header file in the current project’s `src` folder |
|
||||
|
||||
#### Configuration Example:
|
||||
|
||||
```lua
|
||||
require("Polydev").c.setup({
|
||||
keybinds = {
|
||||
["<leader>pb"] = "CppBuild", -- Build all C files in the src directory
|
||||
["<leader>pr"] = "CppRun", -- Run <Project_name> in your build directory
|
||||
["<leader>nh"] = "NewCppHeaderFile" -- Create a new header file in the current project’s src folder
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### File Structure 📂
|
||||
This is the recommended file structure for your C projects using Polydev:
|
||||
|
||||
| Directory/File Path | Description |
|
||||
|----------------------------|------------------------------------------------------|
|
||||
| `CMakeLists.txt` | Configuration file for your project build |
|
||||
| `src/` | Folder containing source files for the project |
|
||||
| `main.cpp` | Main Cpp file for the project |
|
||||
| `*.cpp` | Additional Cpp source files |
|
||||
| `build/` | Folder where the build artifacts will be generated |
|
||||
| `<project_name>.polydev` | Polydev metadata file (generated during build) |
|
||||
| `include/` | Folder for header files |
|
||||
| `*.hpp` | Cpp header files |
|
||||
|
||||
#### Example Structure:
|
||||
|
||||
```md
|
||||
Projects/
|
||||
└── Cpp/
|
||||
└── Project_Name/
|
||||
├── CMakeLists.txt
|
||||
├── src/
|
||||
│ ├── main.cpp
|
||||
│ └── *.cpp
|
||||
├── build/
|
||||
│ └── <project_name>.polydev
|
||||
└── include/
|
||||
└── *.hpp
|
||||
```
|
||||
|
||||
---
|
||||
@@ -1,58 +0,0 @@
|
||||
### Java Setup for Polydev ☕️
|
||||
|
||||
#### Keybinds 🎮
|
||||
You can customize the keybinds for your Java projects in Polydev.
|
||||
|
||||
| Keybind | Action |
|
||||
|---------------------|-----------------------------------------------------|
|
||||
| `<leader>pb` | Build all Java files in the `src` directory |
|
||||
| `<leader>pr` | Run `Main.java` from the `out` folder in your project |
|
||||
| `<leader>nf` | Create a new Java file in the `src` folder |
|
||||
|
||||
#### Configuration Example:
|
||||
|
||||
```lua
|
||||
-- These are defaults, so no need to copy them
|
||||
require("Polydev").java.setup({
|
||||
keybinds = {
|
||||
["<leader>pb"] = "JavaBuild", -- Build all Java files in the src directory
|
||||
["<leader>pr"] = "JavaRun", -- Run Main.java in the out folder
|
||||
["<leader>nf"] = "NewJavaFile" -- Create a new Java file in the src folder
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### Java Features ✨
|
||||
|
||||
* **Java Build and Run**:
|
||||
Polydev allows you to build all Java files in the `src` directory with the press of a keybind. Once built, you can run the project from the `out` folder, with the `Main.java` file executed automatically.
|
||||
|
||||
* **Project File Management**:
|
||||
The plugin manages your Java project files efficiently, helping you quickly add new Java files to the `src` directory. It also ensures that your build and run processes are streamlined.
|
||||
|
||||
---
|
||||
|
||||
#### File Structure 📂
|
||||
Here’s the recommended structure for your Java projects using Polydev:
|
||||
|
||||
| Directory/File Path | Description |
|
||||
|----------------------------|------------------------------------------------------|
|
||||
| `src/` | Contains the source code files, including `Main.java` |
|
||||
| `build/` | Contains compiled `.class` files |
|
||||
| `Main.java` | The main entry point of your Java project |
|
||||
|
||||
#### Example Structure:
|
||||
|
||||
```md
|
||||
Projects/
|
||||
└── Java/
|
||||
└── Project_Name/
|
||||
├── src/
|
||||
│ └── Main.java
|
||||
└── build/
|
||||
└── *.class
|
||||
```
|
||||
|
||||
---
|
||||
@@ -1,64 +0,0 @@
|
||||
### Lua Setup for Polydev 🐢
|
||||
|
||||
#### Key Notes ⚠️
|
||||
|
||||
* Polydev provides seamless integration with Lua projects, allowing you to easily run and manage Lua code.
|
||||
* You must include a `<Project_name>.polydev` file in your project root directory for Polydev to recognize the project. Missing this file will lead to errors.
|
||||
* The file structure should be organized to ensure smooth execution and functionality.
|
||||
|
||||
---
|
||||
|
||||
#### Keybinds 🎮
|
||||
|
||||
Below are the default keybinds for Lua projects using Polydev. You can adjust them to suit your personal preferences.
|
||||
|
||||
| Keybind | Action |
|
||||
|---------------------|-------------------------------------------------|
|
||||
| `<leader>pr` | Run the Lua project |
|
||||
|
||||
##### Configuration Example:
|
||||
|
||||
```lua
|
||||
-- These are the defaults for Lua, adjust as needed
|
||||
require("Polydev").lua.setup({
|
||||
keybinds = {
|
||||
["<leader>pr"] = "LuaRun", -- Run the Lua project
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### Lua Features ✨
|
||||
|
||||
* **Run Lua Projects**:
|
||||
Easily run your Lua project from within your terminal using the `<leader>pr` keybind. This automatically runs your `init.lua` or the entry point of your Lua code.
|
||||
|
||||
* **Create New Lua Files**:
|
||||
With the `<leader>nf` keybind, you can quickly create new Lua files in the `src` directory, maintaining an organized project structure.
|
||||
|
||||
---
|
||||
|
||||
#### File Structure 📂
|
||||
|
||||
Here’s the suggested directory structure for your Lua projects with Polydev:
|
||||
|
||||
| Directory/File Path | Description |
|
||||
|----------------------------|-----------------------------------------------------|
|
||||
| `<Project_name>.polydev` | Project metadata file that Polydev uses for configuration |
|
||||
| `lua/` | Directory containing the main Lua project files |
|
||||
| `lua/<Project_name>/init.lua` | The main entry point for your Lua project |
|
||||
|
||||
##### Example File Structure:
|
||||
|
||||
```md
|
||||
Projects/
|
||||
└── Lua/
|
||||
└── Project_Name/
|
||||
├── <Project_name>.polydev -- Polydev configuration file
|
||||
└── lua/
|
||||
└── Project_name/
|
||||
└── init.lua -- Main Lua file
|
||||
```
|
||||
|
||||
---
|
||||
@@ -1,63 +0,0 @@
|
||||
### Python Setup for Polydev 🐍
|
||||
|
||||
#### Keybinds 🎮
|
||||
You can easily customize the keybinds for your Python projects using Polydev.
|
||||
|
||||
| Keybind | Action |
|
||||
|---------------------|---------------------------------------------------|
|
||||
| `<leader>pr` | Run the Python project in your active terminal |
|
||||
| `<leader>pb` | Install dependencies using pip |
|
||||
|
||||
#### Configuration Example:
|
||||
|
||||
```lua
|
||||
require("Polydev").python.setup({
|
||||
keybinds = {
|
||||
["<leader>pr"] = "PythonRun", -- Run the Python project
|
||||
["<leader>pb"] = "PythonPip" -- Install dependencies using pip
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### Python Features 🚀
|
||||
|
||||
Here are some cool features available for Python projects using Polydev:
|
||||
|
||||
- **Automatic Virtual Environment Creation** 🔧
|
||||
Each Python project automatically sets up and uses a new virtual environment. You don’t need to worry about environment management. Just install your dependencies with `pip` as needed.
|
||||
|
||||
- **Dependency Management with Pip** 📦
|
||||
Need to install Python modules? Simply type the name of the module in the terminal, and Polydev will take care of the installation using `pip`. You can even update `pip` if required, ensuring smooth installation.
|
||||
|
||||
- **Effortless Dependency Handling** ⚡
|
||||
You no longer need to manually activate or deactivate virtual environments. With Polydev, the environment is set up and activated automatically, simplifying your workflow.
|
||||
|
||||
---
|
||||
|
||||
#### File Structure 📂
|
||||
Here’s the recommended structure for your Python projects using Polydev:
|
||||
|
||||
| Directory/File Path | Description |
|
||||
|----------------------------|------------------------------------------------------|
|
||||
| `requirements.txt` | File for listing project dependencies |
|
||||
| `setup.py` | Python project setup file |
|
||||
| `tests/` | Folder containing test files |
|
||||
| `venv/` | Virtual environment folder |
|
||||
| `main.py` | Main Python file for your project |
|
||||
|
||||
#### Example Structure:
|
||||
|
||||
```md
|
||||
Projects/
|
||||
└── Python/
|
||||
└── Project_Name/
|
||||
├── main.py
|
||||
├── requirements.txt
|
||||
├── setup.py
|
||||
├── tests/
|
||||
└── venv/
|
||||
```
|
||||
|
||||
---
|
||||
-136
@@ -1,136 +0,0 @@
|
||||
|
||||
# Setup and Customizing Polydev
|
||||
|
||||
## 🔧 Project Name Customization
|
||||
You can easily customize the default directory for your project! The project can be created from any directory, and Polydev will automatically create the required project root directory for you.
|
||||
|
||||
> **Note:** `project_root` allows you to customize where your project will be stored. If you don't specify it, the default is `~/Projects/Language`.
|
||||
|
||||
---
|
||||
### LazyVim Example
|
||||
|
||||
```lua
|
||||
return {
|
||||
...
|
||||
opts = {
|
||||
<language> = {
|
||||
project_root = "~/Home/..." -- Default: ~/Projects/Language
|
||||
}
|
||||
}
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### Packer Example
|
||||
|
||||
```lua
|
||||
require("Polydev").language.setup({
|
||||
project_root = "~/Home/..." -- Default: ~/Projects/Language
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## ⌨ Keybinds Customization
|
||||
Polydev allows you to easily manage keybinds, providing a uniform way to interact with different languages. Most keybinds are the same across languages, while some have language-specific ones (e.g., Python's pip keybind).
|
||||
|
||||
### Keybind Categories
|
||||
| Keybind Type | Description |
|
||||
|-------------------|--------------------------------------------------|
|
||||
| **Universal** | Cannot be changed through specific language settings (e.g., `<leader>nf` for a new file). |
|
||||
| **Per-language** | Can be customized per language (e.g., `<leader>pb` for language build). |
|
||||
|
||||
### LazyVim Example
|
||||
|
||||
```lua
|
||||
return {
|
||||
...
|
||||
opts = {
|
||||
<language> = {
|
||||
["<Esc>"] = "CloseTerminal", -- Universal, can be changed per language for now
|
||||
["<leader>pb"] = "languageBuild", -- Per-language
|
||||
["<leader>pr"] = "languageRun", -- Per-language
|
||||
["<leader>nf"] = "NewLanguageFile", -- Universal
|
||||
["<leader>nh"] = "NewLanguageSecondaryFile", -- Universal
|
||||
}
|
||||
}
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### Packer Example
|
||||
|
||||
```lua
|
||||
require("Polydev").language.setup({
|
||||
keybinds = {
|
||||
["<Esc>"] = "CloseTerminal", -- Universal, can be changed per language for now
|
||||
["<leader>pb"] = "languageBuild", -- Per-language
|
||||
["<leader>pr"] = "languageRun", -- Per-language
|
||||
["<leader>nf"] = "NewLanguageFile", -- Universal
|
||||
["<leader>nh"] = "NewLanguageSecondaryFile", -- Universal
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🖥 Terminal Customization
|
||||
You can further tweak the terminal settings to suit your preferences! These options allow you to adjust padding, borders, numbers, and scrolling behavior.
|
||||
|
||||
### Available Terminal Settings
|
||||
| Setting | Default Value | Description |
|
||||
|------------------|-----------------|---------------------------------------------------------|
|
||||
| **right_padding** | `0` | Padding for the right width of the terminal. |
|
||||
| **left_padding** | `0` | Padding for the left width of the terminal. |
|
||||
| **top_padding** | `0` | Padding for the top height of the terminal. |
|
||||
| **bottom_padding**| `0` | Padding for the bottom height of the terminal. |
|
||||
| **border** | `true` | Adds a rounded border to the window. |
|
||||
| **number** | `true` | Displays line numbers in the terminal. |
|
||||
| **relativenumber**| `true` | Displays relative numbers based on cursor position. |
|
||||
| **scroll** | `true` | Enables scroll functionality in the terminal. |
|
||||
|
||||
> **Note:** These terminal settings allow you to personalize the terminal view and improve usability. You can easily adjust the padding, borders, and other aspects to your preference.
|
||||
|
||||
---
|
||||
### LazyVim Example
|
||||
|
||||
```lua
|
||||
return {
|
||||
...
|
||||
opts = {
|
||||
terminal = {
|
||||
right_padding = 0,
|
||||
bottom_padding = 0,
|
||||
left_padding = 0,
|
||||
top_padding = 0,
|
||||
border = true,
|
||||
number = true,
|
||||
relativenumber = true,
|
||||
scroll = true,
|
||||
}
|
||||
}
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### Packer Example
|
||||
|
||||
```lua
|
||||
require("Polydev").setup({
|
||||
terminal = {
|
||||
right_padding = 0,
|
||||
bottom_padding = 0,
|
||||
left_padding = 0,
|
||||
top_padding = 0,
|
||||
border = true,
|
||||
number = true,
|
||||
relativenumber = true,
|
||||
scroll = true,
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## 🚀 Final Thoughts and Customizations
|
||||
This guide provided you with the basic configuration steps for setting up Polydev with your preferred package manager and customizing key aspects like project names, keybinds, and terminal settings.
|
||||
|
||||
You can further explore other Polydev features and modify the configuration to suit your development workflow.
|
||||
+44
-64
@@ -1,101 +1,81 @@
|
||||
local M = {}
|
||||
|
||||
---@class Keybinds
|
||||
---@field [string] string
|
||||
---
|
||||
---@class ConfigsLanguage
|
||||
---@field project_root? string
|
||||
---@field keybinds? Keybinds -- ? makes fields optional
|
||||
---@field build_attributes? string
|
||||
---
|
||||
---@class Terminal
|
||||
---@field right_padding integer
|
||||
---@field left_padding integer
|
||||
---@field bottom_padding integer
|
||||
---@field top_padding integer
|
||||
---@field border boolean
|
||||
---@field number boolean
|
||||
---@field relativenumber boolean
|
||||
---
|
||||
---@class Defaults
|
||||
---@field html ConfigsLanguage
|
||||
---@field rust ConfigsLanguage
|
||||
---@field java ConfigsLanguage
|
||||
---@field python ConfigsLanguage
|
||||
---@field lua ConfigsLanguage
|
||||
---@field c ConfigsLanguage
|
||||
---@field cpp ConfigsLanguage
|
||||
---@field terminal Terminal
|
||||
M.user_config = {}
|
||||
|
||||
---@type Defaults
|
||||
M.defaults = {
|
||||
html = {
|
||||
project_root = "~/Projects/Html",
|
||||
},
|
||||
---@param user_opts table
|
||||
function M.setup(user_opts)
|
||||
user_opts = user_opts or {}
|
||||
local project_root = (user_opts.globals and user_opts.globals.project_root) or "~/personal/Projects"
|
||||
local defaults = {
|
||||
rust = {
|
||||
project_root = "~/Projects/Rust",
|
||||
project_root = project_root .. "/Rust",
|
||||
keybinds = {
|
||||
["<leader>pb"] = "RustBuild",
|
||||
["<leader>pr"] = "RustRun",
|
||||
},
|
||||
},
|
||||
javascript = {
|
||||
project_root = project_root .. "/Javascript",
|
||||
keybinds = {
|
||||
["<leader>pr"] = "JavascriptRun",
|
||||
},
|
||||
},
|
||||
java = {
|
||||
project_root = "~/Projects/Java",
|
||||
project_root = project_root .. "/Java",
|
||||
keybinds = {
|
||||
["<leader>pb"] = "JavaBuild",
|
||||
["<leader>pr"] = "JavaRun",
|
||||
},
|
||||
},
|
||||
python = {
|
||||
project_root = "~/Projects/Python",
|
||||
keybinds = {
|
||||
["<leader>pr"] = "PythonRun",
|
||||
["<leader>pb"] = "PythonPip",
|
||||
},
|
||||
},
|
||||
lua = {
|
||||
project_root = "~/Projects/Lua",
|
||||
project_root = project_root .. "/Lua",
|
||||
keybinds = {
|
||||
["<leader>pr"] = "LuaRun",
|
||||
},
|
||||
},
|
||||
c = {
|
||||
project_root = "~/Projects/C",
|
||||
project_root = project_root .. "/C",
|
||||
keybinds = {
|
||||
["<leader>pb"] = "CBuild",
|
||||
["<leader>pr"] = "CRun",
|
||||
["<leader>nh"] = "NewCHeaderFile",
|
||||
},
|
||||
build_attributes = ""
|
||||
},
|
||||
cpp = {
|
||||
project_root = "~/Projects/Cpp",
|
||||
project_root = project_root .. "/CPP",
|
||||
keybinds = {
|
||||
["<leader>pb"] = "CppBuild",
|
||||
["<leader>pr"] = "CppRun",
|
||||
["<leader>nh"] = "NewCppHeaderFile",
|
||||
},
|
||||
build_attributes = "",
|
||||
},
|
||||
python = {
|
||||
project_root = project_root .. "/Python",
|
||||
keybinds = {
|
||||
["<leader>pr"] = "PythonRun",
|
||||
["<leader>pb"] = "PythonPip",
|
||||
},
|
||||
},
|
||||
html = {
|
||||
project_root = project_root .. "/Html",
|
||||
},
|
||||
globals = {
|
||||
project_root = project_root,
|
||||
keybinds = {
|
||||
["<leader>po"] = "PolydevOpen",
|
||||
},
|
||||
},
|
||||
terminal = {
|
||||
right_padding = 0,
|
||||
bottom_padding = 0,
|
||||
left_padding = 0,
|
||||
top_padding = 0,
|
||||
border = true,
|
||||
number = true,
|
||||
relativenumber = true,
|
||||
mode = "split",
|
||||
win = {
|
||||
type = "horizontal", anchor = "bottom", size = "20"
|
||||
},
|
||||
border = {
|
||||
enabled = true,
|
||||
type = "rounded",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
---@type string[]
|
||||
M.user_config = {}
|
||||
|
||||
function M.setup(user_opts)
|
||||
M.user_config = vim.tbl_deep_extend("force", {}, M.defaults, user_opts or {})
|
||||
M.user_config = vim.tbl_deep_extend("force", defaults, user_opts)
|
||||
end
|
||||
|
||||
---@param lang string
|
||||
---@return table
|
||||
function M.get(lang)
|
||||
return M.user_config[lang] or {}
|
||||
end
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
local ok, health = pcall(require, "vim.health")
|
||||
if not ok then
|
||||
health = nil
|
||||
end
|
||||
|
||||
local new_api = health ~= nil and type(health.start) == "function"
|
||||
|
||||
local function report_start(name)
|
||||
if new_api then health.start(name) else vim.health.report_start(name) end
|
||||
end
|
||||
|
||||
local function report_ok(msg)
|
||||
if new_api then health.ok(msg) else vim.health.report_ok(msg) end
|
||||
end
|
||||
|
||||
local function report_info(msg)
|
||||
if new_api then health.info(msg) else vim.health.report_info(msg) end
|
||||
end
|
||||
|
||||
local function report_warn(msg, advice)
|
||||
if new_api then
|
||||
health.warn(msg, advice)
|
||||
else
|
||||
vim.health.report_warn(msg, advice)
|
||||
end
|
||||
end
|
||||
|
||||
local function report_error(msg, advice)
|
||||
if new_api then
|
||||
health.error(msg, advice)
|
||||
else
|
||||
vim.health.report_error(msg, advice)
|
||||
end
|
||||
end
|
||||
|
||||
local M = {}
|
||||
|
||||
local function fmt_langs(langs)
|
||||
if type(langs) == "table" then
|
||||
return "[" .. table.concat(langs, ", ") .. "]"
|
||||
end
|
||||
return "[" .. tostring(langs) .. "]"
|
||||
end
|
||||
|
||||
local function check_nvim_version()
|
||||
if vim.fn.has("nvim-0.10") == 1 then
|
||||
report_ok(string.format("Neovim %s detected.", tostring(vim.version())))
|
||||
else
|
||||
report_error("Polydev requires Neovim 0.10 or newer.", "You are running " .. tostring(vim.version()))
|
||||
end
|
||||
end
|
||||
|
||||
local function check_setup()
|
||||
local ok_configs, configs = pcall(require, "Polydev.configs")
|
||||
if not ok_configs then
|
||||
report_error("Could not load Polydev.configs", tostring(configs))
|
||||
return nil
|
||||
end
|
||||
if next(configs.user_config or {}) == nil then
|
||||
report_warn("Polydev.setup() has not run.",
|
||||
"Add require('Polydev').setup() to your Neovim config, or make sure plugin/Polydev.lua is sourced by your plugin manager.")
|
||||
return nil
|
||||
end
|
||||
report_ok("Polydev.setup() ran and the config is loaded.")
|
||||
return configs
|
||||
end
|
||||
|
||||
local function check_project_root(configs)
|
||||
if not configs then return end
|
||||
local root = configs.get("globals").project_root
|
||||
local expanded = vim.fn.expand(root)
|
||||
if vim.fn.isdirectory(expanded) == 1 then
|
||||
if vim.fn.filewritable(expanded) == 2 then
|
||||
report_ok(string.format("project_root exists and is writable: %s", expanded))
|
||||
else
|
||||
report_warn(string.format("project_root exists but is not writable: %s", expanded))
|
||||
end
|
||||
else
|
||||
report_warn(string.format("project_root does not exist yet: %s", expanded),
|
||||
"It is created automatically the first time the manager is opened.")
|
||||
end
|
||||
end
|
||||
|
||||
local function check_ui_input()
|
||||
local ok_default, default = pcall(require, "vim.ui")
|
||||
if ok_default and default.input and vim.ui.input ~= default.input then
|
||||
report_warn("vim.ui.input has been overridden, likely by a UI plugin such as dressing.nvim or nui.nvim.",
|
||||
"An asynchronous override can break project/file creation from the manager. Polydev now uses callbacks, but report here if it still misbehaves.")
|
||||
else
|
||||
report_ok("vim.ui.input is Neovim's default (synchronous) implementation.")
|
||||
end
|
||||
end
|
||||
|
||||
local function check_tools()
|
||||
local tools = {
|
||||
{ name = "git", langs = "all" },
|
||||
{ name = "node", langs = "javascript" },
|
||||
{ name = "python3", langs = "python" },
|
||||
{ name = "pip3", langs = "python" },
|
||||
{ name = "javac", langs = "java" },
|
||||
{ name = "java", langs = "java" },
|
||||
{ name = "cmake", langs = { "c", "cpp" } },
|
||||
{ name = "cc", langs = { "c", "cpp" } },
|
||||
{ name = "clang", langs = { "c", "cpp" } },
|
||||
{ name = "clang-format", langs = { "c", "cpp" } },
|
||||
{ name = "clang-tidy", langs = { "c", "cpp" } },
|
||||
{ name = "cargo", langs = "rust" },
|
||||
{ name = "lua", langs = "lua" },
|
||||
{ name = "luajit", langs = "lua" },
|
||||
}
|
||||
for _, t in ipairs(tools) do
|
||||
if vim.fn.executable(t.name) == 1 then
|
||||
report_ok(string.format("%s is available for %s.", t.name, fmt_langs(t.langs)))
|
||||
else
|
||||
report_warn(string.format("%s was not found.", t.name),
|
||||
"Project templates for " .. fmt_langs(t.langs) .. " may fail without it.")
|
||||
end
|
||||
end
|
||||
|
||||
if vim.fn.executable("python3") == 1 then
|
||||
vim.fn.system("python3 -c 'import venv' 2>/dev/null")
|
||||
if vim.v.shell_error == 0 then
|
||||
report_ok("python3 venv module is available.")
|
||||
else
|
||||
report_warn("python3 venv module is missing.",
|
||||
"Python project creation sets up a virtualenv and needs python3 -m venv.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function check_walkup()
|
||||
local scripts = vim.api.nvim_get_runtime_file("bash_scripts/walkup.sh", false)
|
||||
if #scripts == 0 then
|
||||
report_error("bash_scripts/walkup.sh was not found on the runtimepath.",
|
||||
"Reinstall the plugin so bash_scripts/ sits next to lua/ and plugin/.")
|
||||
return
|
||||
end
|
||||
local script = scripts[1]
|
||||
if vim.fn.executable(script) == 1 then
|
||||
report_ok(string.format("bash_scripts/walkup.sh found and executable: %s", script))
|
||||
else
|
||||
report_warn(string.format("bash_scripts/walkup.sh is not executable: %s", script),
|
||||
"Run: chmod +x " .. script)
|
||||
end
|
||||
end
|
||||
|
||||
function M.check()
|
||||
report_start("Polydev")
|
||||
check_nvim_version()
|
||||
local configs = check_setup()
|
||||
check_project_root(configs)
|
||||
check_ui_input()
|
||||
check_tools()
|
||||
check_walkup()
|
||||
end
|
||||
|
||||
return M
|
||||
+35
-65
@@ -1,81 +1,51 @@
|
||||
---@module "Polydev.configs"
|
||||
local config = require("Polydev.configs")
|
||||
|
||||
---@module "Polydev.utils"
|
||||
local utils = require("Polydev.utils")
|
||||
|
||||
---@module "Polydev.templates"
|
||||
local templates = require("Polydev.templates")
|
||||
|
||||
---@type table
|
||||
local M = {}
|
||||
|
||||
---@type table
|
||||
M.loaded_languages = {}
|
||||
|
||||
---@param lang string
|
||||
---@param opts table?
|
||||
---@return boolean
|
||||
function M.load_language_module(lang, opts)
|
||||
if M.loaded_languages[lang] then return true end
|
||||
|
||||
local ok, lang_module = pcall(require, "Polydev.languages." .. lang)
|
||||
if ok and lang_module.setup then
|
||||
local lang_opts = opts and opts[lang] or {}
|
||||
lang_module.setup(lang_opts)
|
||||
M.loaded_languages[lang] = lang_module
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function M.create_project()
|
||||
local opts = {}
|
||||
vim.ui.input({ prompt = "Enter language for project: " }, function(lang)
|
||||
if not lang or lang == "" then return print("Project creation canceled.") end
|
||||
opts = vim.tbl_deep_extend("force", {}, config.get(lang), opts or {})
|
||||
if M.load_language_module(lang) and templates.projects[lang] and templates.projects[lang].run then
|
||||
templates.create_project(lang, opts.project_root)
|
||||
else
|
||||
print("Error: No project creation method for " .. lang)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function M.create_new_file()
|
||||
vim.ui.input({ prompt = "Enter language for new file: " }, function(lang)
|
||||
if not lang or lang == "" then return print("File creation canceled.") end
|
||||
|
||||
if M.load_language_module(lang) and M.loaded_languages[lang].create_new_file then
|
||||
M.loaded_languages[lang].create_new_file()
|
||||
else
|
||||
print("Error: No File creation method for " .. lang)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
---@param opts table
|
||||
function M.setup(opts)
|
||||
opts = opts or {}
|
||||
local config = require("Polydev.configs")
|
||||
if config == nil then
|
||||
return -1
|
||||
end
|
||||
config.setup(opts)
|
||||
utils.setup(opts)
|
||||
for lang, user_opts in pairs(opts) do
|
||||
local default = config.defaults[lang] or {}
|
||||
config.user_config[lang] = vim.tbl_deep_extend("force", default, user_opts)
|
||||
require("Polydev.utils").setup(opts)
|
||||
|
||||
vim.api.nvim_create_user_command("PolydevOpen", function() require("Polydev.ui").manager(config.get("globals").project_root) end, {})
|
||||
|
||||
local keys = vim.tbl_deep_extend("force", {}, config.get("globals").keybinds, opts.keybinds or {})
|
||||
for key, _ in pairs(keys) do
|
||||
vim.keymap.set("n", key, ":PolydevOpen<CR>")
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("NewProject", M.create_project, {})
|
||||
vim.api.nvim_create_user_command("NewFile", M.create_new_file, {})
|
||||
vim.keymap.set("n", "<leader>np", ":NewProject<CR>", { silent = true })
|
||||
vim.keymap.set("n", "<leader>nf", ":NewFile<CR>", { silent = true })
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
local filetype = vim.bo.filetype
|
||||
M.load_language_module(filetype, opts)
|
||||
require("Polydev.languages").load_language_module(filetype, opts)
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
callback = function()
|
||||
local function define(name, o)
|
||||
if vim.fn.hlexists(name) == 0 then
|
||||
vim.api.nvim_set_hl(0, name, o)
|
||||
end
|
||||
end
|
||||
define("PolydevNormal", {
|
||||
fg = vim.api.nvim_get_hl(0, { name = "NormalFloat", link = true }).fg,
|
||||
bg = vim.api.nvim_get_hl(0, { name = "Normal", link = true }).bg,
|
||||
})
|
||||
|
||||
define("PolydevBorder", {
|
||||
fg = vim.api.nvim_get_hl(0, { name = "FloatBorder", link = true }).fg,
|
||||
bg = vim.api.nvim_get_hl(0, { name = "Normal", link = true }).bg,
|
||||
})
|
||||
|
||||
define("PolydevTitle", {
|
||||
fg = vim.api.nvim_get_hl(0, { name = "FloatTitle", link = true }).fg, bold = true,
|
||||
bg = vim.api.nvim_get_hl(0, { name = "Normal", link = true }).bg,
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
---@return table
|
||||
return M
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
local utils = require("Polydev.utils")
|
||||
local configs = require("Polydev.configs")
|
||||
local M = {}
|
||||
|
||||
local loaded_languages = {}
|
||||
|
||||
---@param lang string
|
||||
---@param opts? table
|
||||
---@return boolean
|
||||
function M.load_language_module(lang, opts)
|
||||
if loaded_languages[lang] then return true end
|
||||
|
||||
local ok, mod = pcall(require, "Polydev.languages")
|
||||
if not ok or type(mod.languages) ~= "table" then return false end
|
||||
|
||||
local lang_mod = mod.languages[lang]
|
||||
if type(lang_mod) ~= "table" or type(lang_mod.setup) ~= "function" then return false end
|
||||
|
||||
lang_mod:setup(opts and opts[lang] or {})
|
||||
loaded_languages[lang] = lang_mod
|
||||
return true
|
||||
end
|
||||
|
||||
M.languages = {
|
||||
javascript = {
|
||||
setup = function(self, user_opts)
|
||||
local opts = vim.tbl_deep_extend("force", {}, configs.get("javascript"), user_opts or {})
|
||||
vim.api.nvim_create_user_command("JavascriptRun", function() self:run() end, {})
|
||||
for key, _ in pairs(opts.keybinds) do
|
||||
vim.keymap.set("n", key, ":JavascriptRun<CR>", { silent = true })
|
||||
end
|
||||
end,
|
||||
run = function()
|
||||
local root = utils.get_project_root()
|
||||
|
||||
local cmd = string.format("node " .. root .. "/main.js")
|
||||
local output = vim.fn.system(cmd)
|
||||
|
||||
if not vim.v.shell_error == 0 then
|
||||
local term_buf = utils.terminal({ cmd })
|
||||
vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf })
|
||||
vim.api.nvim_buf_set_lines(term_buf, 0, -1, false,
|
||||
vim.list_extend({ "Error during compilation:" },
|
||||
vim.split(output, "\n", { trimempty = true }))
|
||||
)
|
||||
vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf })
|
||||
else
|
||||
utils.terminal({ "node " .. root .. "/main.js" })
|
||||
end
|
||||
end
|
||||
},
|
||||
java = {
|
||||
setup = function(self, user_opts)
|
||||
local opts = vim.tbl_deep_extend("force", {}, configs.get("java"), user_opts or {})
|
||||
vim.api.nvim_create_user_command("JavaRun", function() self:run() end, {})
|
||||
for key, _ in pairs(opts.keybinds) do
|
||||
vim.keymap.set("n", key, ":JavaRun<CR>", { silent = true })
|
||||
end
|
||||
end,
|
||||
run = function()
|
||||
local root = utils.get_project_root()
|
||||
|
||||
local cmd = string.format("javac -d %s %s", root .. "/build", root .. "/src/*.java")
|
||||
local output = vim.fn.system(cmd)
|
||||
|
||||
if not vim.v.shell_error == 0 then
|
||||
local term_buf = utils.terminal({ cmd })
|
||||
vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf })
|
||||
vim.api.nvim_buf_set_lines(term_buf, 0, -1, false,
|
||||
vim.list_extend({ "Error during compilation:" },
|
||||
vim.split(output, "\n", { trimempty = true }))
|
||||
)
|
||||
vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf })
|
||||
else
|
||||
utils.terminal({ "java -cp " .. root, "build" .. " Main" })
|
||||
end
|
||||
end
|
||||
},
|
||||
c = {
|
||||
setup = function(self, user_opts)
|
||||
local opts = vim.tbl_deep_extend("force", {}, configs.get("c"), user_opts or {})
|
||||
vim.api.nvim_create_user_command("CRun", function() self:run() end, {})
|
||||
for key, _ in pairs(opts.keybinds) do
|
||||
vim.keymap.set("n", key, ":CRun<CR>", { silent = true })
|
||||
end
|
||||
end,
|
||||
run = function()
|
||||
local root = utils.get_project_root()
|
||||
local build_dir = root .. "/build"
|
||||
|
||||
local cmd = "cd '" .. build_dir .. "' && cmake --build ."
|
||||
local output = vim.fn.system(cmd)
|
||||
local success = vim.v.shell_error == 0
|
||||
|
||||
if not success then
|
||||
local term_buf = utils.terminal({ cmd })
|
||||
vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf })
|
||||
vim.api.nvim_buf_set_lines(term_buf, 0, -1, false,
|
||||
vim.list_extend({ "Error during compilation:" },
|
||||
vim.split(output, "\n", { trimempty = true }))
|
||||
)
|
||||
vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf })
|
||||
end
|
||||
if success then
|
||||
local run_cmd = "cd '" .. build_dir .. "' && ./" .. utils.get_project_name()
|
||||
utils.terminal({ run_cmd })
|
||||
end
|
||||
end
|
||||
},
|
||||
cpp = {
|
||||
setup = function(self, user_opts)
|
||||
local opts = vim.tbl_deep_extend("force", {}, configs.get("cpp"), user_opts or {})
|
||||
vim.api.nvim_create_user_command("CppRun", function() self:run() end, {})
|
||||
for key, _ in pairs(opts.keybinds) do
|
||||
vim.keymap.set("n", key, ":CppRun<CR>", { silent = true })
|
||||
end
|
||||
end,
|
||||
run = function()
|
||||
local root = utils.get_project_root()
|
||||
local build_dir = root .. "/build"
|
||||
|
||||
local cmd = "cd '" .. build_dir .. "' && cmake --build ."
|
||||
local output = vim.fn.system(cmd)
|
||||
local success = vim.v.shell_error == 0
|
||||
|
||||
if not success then
|
||||
local term_buf = utils.terminal({ cmd })
|
||||
|
||||
vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf })
|
||||
vim.api.nvim_buf_set_lines(term_buf, 0, -1, false,
|
||||
vim.list_extend({ "Error during compilation:" },
|
||||
vim.split(output, "\n", { trimempty = true }))
|
||||
)
|
||||
vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf })
|
||||
end
|
||||
if success then
|
||||
local run_cmd = "cd '" .. build_dir .. "' && ./" .. utils.get_project_name()
|
||||
utils.terminal({ run_cmd })
|
||||
end
|
||||
end
|
||||
},
|
||||
html = {
|
||||
setup = function(user_opts)
|
||||
vim.tbl_deep_extend("force", {}, configs.get("html"), user_opts or {})
|
||||
end
|
||||
},
|
||||
rust = {
|
||||
setup = function(self, user_opts)
|
||||
local opts = vim.tbl_deep_extend("force", {}, configs.get("rust"), user_opts or {})
|
||||
vim.api.nvim_create_user_command("RustRun", function() self:run() end, {})
|
||||
for key, _ in pairs(opts.keybinds) do
|
||||
vim.keymap.set("n", key, ":RustRun<CR>", { silent = true })
|
||||
end
|
||||
end,
|
||||
run = function()
|
||||
local root = utils.get_project_root()
|
||||
if not root then return print("Error: Project root not found.") end
|
||||
|
||||
local cmd = { "cargo build" }
|
||||
local output = vim.fn.system(table.concat(cmd))
|
||||
|
||||
if not vim.v.shell_error == 0 then
|
||||
local term_buf = utils.terminal(cmd)
|
||||
vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf })
|
||||
vim.api.nvim_buf_set_lines(term_buf, 0, -1, false,
|
||||
vim.list_extend({ "Error during compilation:" },
|
||||
vim.split(output, "\n", { trimempty = true }))
|
||||
)
|
||||
vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf })
|
||||
else
|
||||
utils.terminal({ "cargo run" })
|
||||
end
|
||||
end
|
||||
},
|
||||
python = {
|
||||
setup = function(self, user_opts)
|
||||
local opts = vim.tbl_deep_extend("force", {}, configs.get("python"), user_opts or {})
|
||||
vim.api.nvim_create_user_command("PythonPip", function() self:install_dependency() end, {})
|
||||
vim.api.nvim_create_user_command("PythonRun", function() self:run() end, {})
|
||||
for key, command in pairs(opts.keybinds) do
|
||||
if command == "PythonRun" then
|
||||
vim.keymap.set("n", key, ":PythonRun<CR>", { silent = true })
|
||||
end
|
||||
if command == "PythonPip" then
|
||||
vim.keymap.set("n", key, ":PythonPip<CR>", { silent = true })
|
||||
end
|
||||
end
|
||||
|
||||
local root = utils.get_project_root()
|
||||
if root then
|
||||
local venv_path = root .. "/venv/bin/activate"
|
||||
if vim.fn.filereadable(venv_path) == 1 then
|
||||
vim.env.VIRTUAL_ENV = venv_path
|
||||
vim.env.PATH = root .. "/venv/bin:" .. vim.env.PATH
|
||||
end
|
||||
end
|
||||
end,
|
||||
install_dependency = function()
|
||||
vim.ui.input({ prompt = "Enter pip module: " }, function(pip_module)
|
||||
if not pip_module or pip_module == "" then return print("Pip canceled") end
|
||||
utils.terminal({ "pip install " .. pip_module })
|
||||
end)
|
||||
end,
|
||||
run = function()
|
||||
utils.terminal({ "python3 " .. utils.get_project_root(), "main.py" })
|
||||
end
|
||||
},
|
||||
lua = {
|
||||
setup = function(self, user_opts)
|
||||
local opts = vim.tbl_deep_extend("force", {}, configs.get("lua"), user_opts or {})
|
||||
vim.api.nvim_create_user_command("LuaRun", function() self:run() end, {})
|
||||
for key, _ in pairs(opts.keybinds) do
|
||||
vim.keymap.set("n", key, ":LuaRun<CR>", { silent = true })
|
||||
end
|
||||
end,
|
||||
run = function()
|
||||
local init_lua_path = utils.get_project_root() ..
|
||||
"/lua/" .. utils.get_project_name() .. "/init.lua"
|
||||
if vim.fn.filereadable(init_lua_path) == 1 then
|
||||
utils.terminal({ "lua " .. init_lua_path })
|
||||
end
|
||||
end
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
||||
@@ -1,170 +0,0 @@
|
||||
local utils = require("Polydev.utils")
|
||||
local M = {}
|
||||
|
||||
M.keybinds = {}
|
||||
M.opts = nil
|
||||
|
||||
function M.setup(opts)
|
||||
M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("c"), opts or {})
|
||||
for key, command in pairs(M.opts.keybinds) do
|
||||
M.keybinds[command] = key
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("NewCHeaderFile", M.create_new_header_file, {})
|
||||
vim.api.nvim_create_user_command("CBuild", M.build, {})
|
||||
vim.api.nvim_create_user_command("CRun", M.run, {})
|
||||
|
||||
if M.keybinds.CBuild then
|
||||
vim.keymap.set("n", M.keybinds.CBuild, ":CBuild<CR>", { silent = true })
|
||||
end
|
||||
if M.keybinds.CRun then
|
||||
vim.keymap.set("n", M.keybinds.CRun, ":CRun<CR>", { silent = true })
|
||||
end
|
||||
if M.keybinds.NewCHeaderFile then
|
||||
vim.keymap.set("n", M.keybinds.NewCHeaderFile, ":NewCHeaderFile<CR>", { silent = true })
|
||||
end
|
||||
end
|
||||
|
||||
function M.create_project()
|
||||
vim.ui.input({ prompt = "Enter project name: " }, function(project_name)
|
||||
if not project_name or project_name == "" then
|
||||
print("Project creation canceled.")
|
||||
return
|
||||
end
|
||||
|
||||
local project_root = vim.fn.expand(M.opts.project_root) .. "/" .. project_name
|
||||
for _, path in ipairs({ "/src", "/build", "/include" }) do
|
||||
vim.fn.mkdir(project_root .. path, "p")
|
||||
end
|
||||
|
||||
utils.write_file(project_root .. "/build/" .. project_name .. ".polydev", project_name)
|
||||
utils.write_file(project_root .. "/src/main.c", [[
|
||||
/* If you have vcpkg and want to use it:
|
||||
vcpkg new --application
|
||||
vcpkg add port <package_name>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("%s", "Hello World");
|
||||
return 0;
|
||||
}
|
||||
]])
|
||||
|
||||
utils.write_file(project_root .. "/CMakeLists.txt", string.format([[
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(%s)
|
||||
include_directories(include)
|
||||
set(SOURCES src/main.c)
|
||||
add_executable(%s ${SOURCES})
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(CMAKE_C_STANDARD 23)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
|
||||
# find_package(SDL3 CONFIG REQUIRED) # An example of how to import libraries from vcpkg
|
||||
# target_link_libraries(Game PRIVATE SDL3::SDL3)
|
||||
]], project_name, project_name))
|
||||
|
||||
|
||||
utils.write_file(project_root .. "/CMakePresets.json", string.format([[
|
||||
# For the purposes of vcpkg, DO NOT REMOVE, but feel free to change as needed
|
||||
{
|
||||
"version": 2,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "vcpkg",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"cacheVariables": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]]))
|
||||
|
||||
utils.write_file(project_root .. "/CMakeUserPresets.json", string.format([[
|
||||
{
|
||||
"version": 2,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"inherits": "vcpkg",
|
||||
"environment": {
|
||||
"VCPKG_ROOT": "/Users/<USER>/vcpkg"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]]))
|
||||
vim.cmd("edit " .. project_root .. "/src/main.c")
|
||||
vim.fn.system(string.format("cd %s/build/ && cmake .. && cmake --build .", project_root))
|
||||
end)
|
||||
end
|
||||
|
||||
function M.create_new_file()
|
||||
vim.ui.input({ prompt = "Enter file name: " }, function(class_name)
|
||||
if not class_name or class_name == "" then return print("File creation canceled.") end
|
||||
local root_dir = M.get_project_root()
|
||||
if not root_dir then return print("Error: Project root not found.") end
|
||||
utils.write_file(root_dir .. "/src/" .. class_name .. ".c", "")
|
||||
end)
|
||||
end
|
||||
|
||||
function M.create_new_header_file()
|
||||
vim.ui.input({ prompt = "Enter header file name: " }, function(header_name)
|
||||
if not header_name then return print("Header file creation canceled.") end
|
||||
local root_dir = M.get_project_root()
|
||||
if not root_dir then return print("Error: Project root not found.") end
|
||||
local guard_macro = header_name:upper():gsub("[^A-Z0-9]", "_") .. "_H"
|
||||
local content = string.format([[
|
||||
#ifndef %s
|
||||
#define %s
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// Function prototypes
|
||||
void example_function();
|
||||
|
||||
#endif // %s
|
||||
]], guard_macro, guard_macro, guard_macro)
|
||||
utils.write_file(root_dir .. "/include/" .. header_name .. ".h", content)
|
||||
end)
|
||||
end
|
||||
|
||||
function M.get_project_root()
|
||||
local dir = vim.fn.expand("%:p:h")
|
||||
while dir ~= "/" do
|
||||
if vim.fn.isdirectory(dir .. "/src") == 1 or vim.fn.filereadable(dir .. "/CMakeLists.txt") == 1 then
|
||||
return dir
|
||||
end
|
||||
dir = vim.fn.fnamemodify(dir, ":h")
|
||||
end
|
||||
end
|
||||
|
||||
function M.build()
|
||||
local root = M.get_project_root()
|
||||
if not root then return print("Error: Project root not found.") end
|
||||
local build_dir = root .. "/build"
|
||||
|
||||
local cmd = "cd " .. build_dir .. " && cmake --build ."
|
||||
local term_buf = utils.open_float_terminal(cmd)
|
||||
vim.api.nvim_buf_set_option(term_buf, "modifiable", true)
|
||||
local output = vim.fn.system(cmd)
|
||||
local success = vim.v.shell_error == 0
|
||||
vim.api.nvim_buf_set_lines(term_buf, 0, -1, false, vim.list_extend({ success and "Compilation successful!" or "Error during compilation:" }, vim.split(output, "\n", { trimempty = true })))
|
||||
vim.api.nvim_buf_set_option(term_buf, "modifiable", false)
|
||||
end
|
||||
|
||||
function M.run()
|
||||
local root = M.get_project_root()
|
||||
if not root then return print("Error: Project root not found.") end
|
||||
local build_dir = root .. "/build"
|
||||
local files = vim.fn.glob(build_dir .. "/*.polydev", true, true)
|
||||
if #files == 0 then return print("Error: No .polydev file found in build directory.") end
|
||||
utils.open_float_terminal("cd " .. build_dir .. " && ./" .. files[1]:match("([^/]+)%.polydev$"))
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,171 +0,0 @@
|
||||
local utils = require("Polydev.utils")
|
||||
local M = {}
|
||||
|
||||
M.keybinds = {}
|
||||
M.opts = nil
|
||||
|
||||
function M.setup(opts)
|
||||
M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("cpp"), opts or {})
|
||||
for key, command in pairs(M.opts.keybinds) do
|
||||
M.keybinds[command] = key
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("NewCppHeaderFile", M.create_new_header_file, {})
|
||||
vim.api.nvim_create_user_command("CppBuild", M.build, {})
|
||||
vim.api.nvim_create_user_command("CppRun", M.run, {})
|
||||
|
||||
if M.keybinds.CppBuild then
|
||||
vim.keymap.set("n", M.keybinds.CppBuild, ":CppBuild<CR>", { silent = true })
|
||||
end
|
||||
if M.keybinds.CppRun then
|
||||
vim.keymap.set("n", M.keybinds.CppRun, ":CppRun<CR>", { silent = true })
|
||||
end
|
||||
if M.keybinds.NewCppHeaderFile then
|
||||
vim.keymap.set("n", M.keybinds.NewCppHeaderFile, ":NewCppHeaderFile<CR>", { silent = true })
|
||||
end
|
||||
end
|
||||
|
||||
function M.create_project()
|
||||
vim.ui.input({ prompt = "Enter project name: " }, function(project_name)
|
||||
if not project_name or project_name == "" then
|
||||
print("Project creation canceled.")
|
||||
return
|
||||
end
|
||||
|
||||
local project_root = vim.fn.expand(M.opts.project_root) .. "/" .. project_name
|
||||
for _, path in ipairs({ "/src", "/build", "/include" }) do
|
||||
vim.fn.mkdir(project_root .. path, "p")
|
||||
end
|
||||
|
||||
utils.write_file(project_root .. "/build/" .. project_name .. ".polydev", project_name)
|
||||
utils.write_file(project_root .. "/src/main.cpp", [[
|
||||
/* If you have vcpkg and want to use it:
|
||||
vcpkg new --application
|
||||
vcpkg add port <package_name>
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello World" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
]])
|
||||
|
||||
utils.write_file(project_root .. "/CMakeLists.txt", string.format([[
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(%s)
|
||||
include_directories(include)
|
||||
set(SOURCES src/main.cpp)
|
||||
add_executable(%s ${SOURCES})
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(CMAKE_C_STANDARD 23)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
|
||||
# find_package(SDL3 CONFIG REQUIRED) # An example of how to import libraries from vcpkg
|
||||
# target_link_libraries(Game PRIVATE SDL3::SDL3)
|
||||
]], project_name, project_name))
|
||||
|
||||
|
||||
utils.write_file(project_root .. "/CMakePresets.json", string.format([[
|
||||
# For the purposes of vcpkg, DO NOT REMOVE, but feel free to change as needed
|
||||
{
|
||||
"version": 2,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "vcpkg",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"cacheVariables": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]]))
|
||||
|
||||
utils.write_file(project_root .. "/CMakeUserPresets.json", string.format([[
|
||||
{
|
||||
"version": 2,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"inherits": "vcpkg",
|
||||
"environment": {
|
||||
"VCPKG_ROOT": "/Users/<USER>/vcpkg"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]]))
|
||||
vim.fn.system(string.format("cd %s/build/ && cmake .. && cmake --build .", project_root))
|
||||
|
||||
vim.cmd("edit " .. project_root .. "/src/main.cpp")
|
||||
end)
|
||||
end
|
||||
|
||||
function M.create_new_file()
|
||||
vim.ui.input({ prompt = "Enter file name: " }, function(class_name)
|
||||
if not class_name or class_name == "" then return print("File creation canceled.") end
|
||||
local root_dir = M.get_project_root()
|
||||
if not root_dir then return print("Error: Project root not found.") end
|
||||
utils.write_file(root_dir .. "/src/" .. class_name .. ".cpp", "")
|
||||
end)
|
||||
end
|
||||
|
||||
function M.create_new_header_file()
|
||||
vim.ui.input({ prompt = "Enter header file name: " }, function(header_name)
|
||||
if not header_name then return print("Header file creation canceled.") end
|
||||
local root_dir = M.get_project_root()
|
||||
if not root_dir then return print("Error: Project root not found.") end
|
||||
local guard_macro = header_name:upper():gsub("[^A-Z0-9]", "_") .. "_HPP"
|
||||
local content = string.format([[
|
||||
#ifndef %s
|
||||
#define %s
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// Function prototypes
|
||||
void example_function();
|
||||
|
||||
#endif // %s
|
||||
]], guard_macro, guard_macro, guard_macro)
|
||||
utils.write_file(root_dir .. "/include/" .. header_name .. ".hpp", content)
|
||||
end)
|
||||
end
|
||||
|
||||
function M.get_project_root()
|
||||
local dir = vim.fn.expand("%:p:h")
|
||||
while dir ~= "/" do
|
||||
if vim.fn.isdirectory(dir .. "/src") == 1 or vim.fn.filereadable(dir .. "/CMakeLists.txt") == 1 then
|
||||
return dir
|
||||
end
|
||||
dir = vim.fn.fnamemodify(dir, ":h")
|
||||
end
|
||||
end
|
||||
|
||||
function M.build()
|
||||
local root = M.get_project_root()
|
||||
if not root then return print("Error: Project root not found.") end
|
||||
local build_dir = root .. "/build"
|
||||
|
||||
local cmd = "cd " .. build_dir .. " && cmake --build ."
|
||||
local term_buf = utils.open_float_terminal(cmd)
|
||||
vim.api.nvim_buf_set_option(term_buf, "modifiable", true)
|
||||
local output = vim.fn.system(cmd)
|
||||
local success = vim.v.shell_error == 0
|
||||
vim.api.nvim_buf_set_lines(term_buf, 0, -1, false, vim.list_extend({ success and "Compilation successful!" or "Error during compilation:" }, vim.split(output, "\n", { trimempty = true })))
|
||||
vim.api.nvim_buf_set_option(term_buf, "modifiable", false)
|
||||
end
|
||||
|
||||
function M.run()
|
||||
local root = M.get_project_root()
|
||||
if not root then return print("Error: Project root not found.") end
|
||||
local build_dir = root .. "/build"
|
||||
local files = vim.fn.glob(build_dir .. "/*.polydev", true, true)
|
||||
if #files == 0 then return print("Error: No .polydev file found in build directory.") end
|
||||
utils.open_float_terminal("cd " .. build_dir .. " && ./" .. files[1]:match("([^/]+)%.polydev$"))
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,55 +0,0 @@
|
||||
local utils = require("Polydev.utils")
|
||||
local M = {}
|
||||
|
||||
M.opts = nil
|
||||
|
||||
function M.setup(opts)
|
||||
M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("html"), opts or {})
|
||||
end
|
||||
|
||||
function M.create_project()
|
||||
vim.ui.input({ prompt = "Enter project name: " }, function(project_name)
|
||||
if not project_name or project_name == "" then return print("Project creation canceled.") end
|
||||
local project_root = vim.fn.expand(M.opts.project_root) .. "/" .. project_name
|
||||
|
||||
local main_html_content = [[
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
]]
|
||||
utils.write_file(project_root .. "index.html", main_html_content)
|
||||
end)
|
||||
end
|
||||
|
||||
function M.create_new_file()
|
||||
vim.ui.input({ prompt = "Enter page name: " }, function(page)
|
||||
if not page or page == "" then return print("Class creation canceled.") end
|
||||
local html_content = string.format([[
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
]])
|
||||
|
||||
utils.write_file("./" .. page .. ".html", html_content)
|
||||
end)
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,65 +0,0 @@
|
||||
local utils = require("Polydev.utils")
|
||||
local M = {}
|
||||
|
||||
M.keybinds = {}
|
||||
M.opts = nil
|
||||
|
||||
function M.setup(opts)
|
||||
M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("java"), opts or {})
|
||||
for key, command in pairs(M.opts.keybinds) do
|
||||
M.keybinds[command] = key
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("JavaBuild", M.build, {})
|
||||
vim.api.nvim_create_user_command("JavaRun", M.run, {})
|
||||
|
||||
if M.keybinds.JavaRun then
|
||||
vim.keymap.set("n", M.keybinds.JavaRun, ":JavaRun<CR>", { silent = true })
|
||||
end
|
||||
if M.keybinds.JavaBuild then
|
||||
vim.keymap.set("n", M.keybinds.JavaBuild, ":JavaBuild<CR>", { silent = true })
|
||||
end
|
||||
end
|
||||
|
||||
function M.create_new_file()
|
||||
vim.ui.input({ prompt = "Enter class name: " }, function(class_name)
|
||||
if not class_name or class_name == "" then return print("Class creation canceled.") end
|
||||
local root_dir = vim.fn.expand("%:p:h"):match("(.*)/src")
|
||||
if not root_dir then return print("Error: src directory not found.") end
|
||||
local java_content = string.format([[
|
||||
public class %s {
|
||||
// New File
|
||||
}
|
||||
]], class_name)
|
||||
|
||||
utils.write_file(root_dir .. "/src/" .. class_name .. ".java", java_content)
|
||||
end)
|
||||
end
|
||||
|
||||
function M.build()
|
||||
local project_root = vim.fn.expand("%:p:h"):match("(.*)/src")
|
||||
if not project_root then return print("Error: Could not detect project root directory.") end
|
||||
local out_dir = project_root .. "/build"
|
||||
|
||||
vim.fn.mkdir(out_dir, "p")
|
||||
local compile_command = string.format("javac -d %s %s/*.java", out_dir, project_root .. "/src")
|
||||
local compile_status = vim.fn.system(compile_command)
|
||||
|
||||
if vim.v.shell_error == 0 then
|
||||
print("Compilation successful!")
|
||||
else
|
||||
print("Error during compilation. Opening terminal for details...")
|
||||
local term_buf = utils.open_float_terminal(compile_command)
|
||||
vim.api.nvim_buf_set_option(term_buf, "modifiable", true)
|
||||
vim.api.nvim_buf_set_lines(term_buf, 0, -1, false, vim.split(compile_status, "\n", { trimempty = true }))
|
||||
vim.api.nvim_buf_set_option(term_buf, "modifiable", false)
|
||||
end
|
||||
end
|
||||
|
||||
function M.run()
|
||||
local project_root = vim.fn.expand("%:p:h"):match("(.*)/src")
|
||||
if not project_root then return print("Error: Must be inside the 'src' directory.") end
|
||||
utils.open_float_terminal("java -cp " .. project_root .. "/build" .. " Main")
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,75 +0,0 @@
|
||||
local utils = require("Polydev.utils")
|
||||
local M = {}
|
||||
|
||||
M.keybinds = {}
|
||||
M.opts = nil
|
||||
|
||||
function M.setup(opts)
|
||||
M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("lua"), opts or {})
|
||||
for key, command in pairs(M.opts.keybinds) do
|
||||
M.keybinds[command] = key
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("LuaRun", M.run, {})
|
||||
|
||||
if M.keybinds.LuaRun then
|
||||
vim.keymap.set("n", M.keybinds.LuaRun, ":LuaRun<CR>", { silent = true })
|
||||
end
|
||||
end
|
||||
|
||||
function M.get_project_root()
|
||||
local dir = vim.fn.expand("%:p:h")
|
||||
while dir ~= "/" do
|
||||
local polydev_file = vim.fn.glob(dir .. "/*.polydev")
|
||||
if polydev_file ~= "" then return dir end
|
||||
dir = vim.fn.fnamemodify(dir, ":h")
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function M.get_project_name()
|
||||
local polydev_file = vim.fn.glob((M.get_project_root() or "") .. "/*.polydev")
|
||||
return polydev_file:match("([^/]+)%.polydev$")
|
||||
end
|
||||
|
||||
function M.create_project()
|
||||
vim.ui.input({ prompt = "Enter project name: " },
|
||||
function(project_name)
|
||||
if not project_name or project_name == "" then return print("Project creation canceled.") end
|
||||
local project_root = vim.fn.expand(M.opts.project_root) .. "/" .. project_name
|
||||
for _, path in ipairs({ "/lua/" .. project_name }) do vim.fn.mkdir(project_root .. path, "p") end
|
||||
|
||||
utils.write_file(project_root .. "/lua/" .. project_name .. "/init.lua", [[
|
||||
local M = {}
|
||||
|
||||
return M
|
||||
]])
|
||||
|
||||
utils.write_file(project_root .. "/" .. project_name .. ".polydev", "[[DO NOT REMOVE THIS FILE]]")
|
||||
vim.cmd("edit " .. project_root .. "/lua/" .. project_name .. "/init.lua")
|
||||
end)
|
||||
end
|
||||
|
||||
function M.create_new_file()
|
||||
vim.ui.input({ prompt = "Enter file name: " }, function(class_name)
|
||||
if not class_name or class_name == "" then return print("File creation canceled.") end
|
||||
local root_dir = M.get_project_root()
|
||||
local project_name = M.get_project_name()
|
||||
if not root_dir or not project_name then return print("Error: Project root not found.") end
|
||||
utils.write_file(root_dir .. "/lua/" .. project_name .. "/" .. class_name .. ".lua", "")
|
||||
end)
|
||||
end
|
||||
|
||||
function M.run()
|
||||
local root = M.get_project_root()
|
||||
local project_name = M.get_project_name()
|
||||
if not root or not project_name then return print("Error: Project root not found.") end
|
||||
local init_lua_path = root .. "/lua/" .. project_name .. "/init.lua"
|
||||
if vim.fn.filereadable(init_lua_path) == 1 then
|
||||
utils.open_float_terminal("lua " .. init_lua_path)
|
||||
else
|
||||
print("Error: " .. init_lua_path .. " not found in " .. root)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,101 +0,0 @@
|
||||
local utils = require("Polydev.utils")
|
||||
local config = require("Polydev.configs")
|
||||
local M = {}
|
||||
|
||||
M.keybinds = {}
|
||||
M.opts = nil
|
||||
|
||||
function M.setup(opts)
|
||||
M.opts = vim.tbl_deep_extend("force", {}, config.get("python"), opts or {})
|
||||
for key, command in pairs(M.opts.keybinds) do
|
||||
M.keybinds[command] = key
|
||||
end
|
||||
|
||||
local root = M.get_project_root()
|
||||
if root then
|
||||
local venv_path = root .. "/venv/bin/activate"
|
||||
if vim.fn.filereadable(venv_path) == 1 then
|
||||
vim.env.VIRTUAL_ENV = venv_path
|
||||
vim.env.PATH = root .. "/venv/bin:" .. vim.env.PATH
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("PythonPip", M.install_dependency, {})
|
||||
vim.api.nvim_create_user_command("PythonRun", M.run, {})
|
||||
|
||||
if M.keybinds.PythonRun then
|
||||
vim.keymap.set("n", M.keybinds.PythonRun, ":PythonRun<CR>", { silent = true })
|
||||
end
|
||||
if M.keybinds.PythonPip then
|
||||
vim.keymap.set("n", M.keybinds.PythonPip, ":PythonPip<CR>", { silent = true })
|
||||
end
|
||||
end
|
||||
|
||||
function M.get_project_root()
|
||||
local dir = vim.fn.expand("%:p:h")
|
||||
while dir ~= "/" do
|
||||
if vim.fn.isdirectory(dir .. "/venv") == 1 or vim.fn.filereadable(dir .. "/main.py") == 1 then
|
||||
return dir
|
||||
end
|
||||
dir = vim.fn.fnamemodify(dir, ":h")
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function M.create_new_file()
|
||||
vim.ui.input({ prompt = "Enter file name: " }, function(file_name)
|
||||
if not file_name or file_name == "" then
|
||||
return print("File creation canceled.")
|
||||
end
|
||||
|
||||
if not file_name:match("%.py$") then
|
||||
file_name = file_name .. ".py"
|
||||
end
|
||||
|
||||
local root_dir = M.get_project_root()
|
||||
if not root_dir then
|
||||
return print("Error: Project root not found.")
|
||||
end
|
||||
|
||||
local file_path = root_dir .. "/include/" .. file_name
|
||||
utils.write_file(file_path, "")
|
||||
end)
|
||||
end
|
||||
|
||||
function M.install_dependency()
|
||||
vim.ui.input({ prompt = "Enter pip module: " }, function(pip_module)
|
||||
if not pip_module or pip_module == "" then
|
||||
return print("Pip canceled")
|
||||
end
|
||||
|
||||
utils.open_float_terminal("pip install " .. pip_module)
|
||||
end)
|
||||
end
|
||||
|
||||
function M.run()
|
||||
local root = M.get_project_root()
|
||||
if not root then
|
||||
return print("Error: Project root not found.")
|
||||
end
|
||||
|
||||
local main_file = root .. "/main.py"
|
||||
if vim.fn.filereadable(main_file) == 0 then
|
||||
return print("Error: main.py not found in project root.")
|
||||
end
|
||||
|
||||
-- Detect current shell
|
||||
local shell = vim.fn.getenv("SHELL") or ""
|
||||
local venv_cmd
|
||||
|
||||
if shell:match("fish") then
|
||||
local venv_fish = root .. "/venv/bin/activate.fish"
|
||||
venv_cmd = vim.fn.filereadable(venv_fish) == 1 and "source " .. venv_fish .. " && " or ""
|
||||
else
|
||||
local venv_bash = root .. "/venv/bin/activate"
|
||||
venv_cmd = vim.fn.filereadable(venv_bash) == 1 and "source " .. venv_bash .. " && " or ""
|
||||
end
|
||||
|
||||
utils.open_float_terminal(venv_cmd .. "python3 " .. main_file)
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,70 +0,0 @@
|
||||
local utils = require("Polydev.utils")
|
||||
local M = {}
|
||||
|
||||
M.keybinds = {}
|
||||
M.opts = nil
|
||||
|
||||
function M.setup(opts)
|
||||
M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("rust"), opts or {})
|
||||
for key, command in pairs(M.opts.keybinds) do
|
||||
M.keybinds[command] = key
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("RustBuild", M.build, {})
|
||||
vim.api.nvim_create_user_command("RustRun", M.run, {})
|
||||
|
||||
if M.keybinds.RustRun then
|
||||
vim.keymap.set("n", M.keybinds.RustRun, ":RustRun<CR>", { silent = true })
|
||||
end
|
||||
if M.keybinds.RustBuild then
|
||||
vim.keymap.set("n", M.keybinds.RustBuild, ":RustBuild<CR>", { silent = true })
|
||||
end
|
||||
end
|
||||
|
||||
function M.create_project()
|
||||
vim.ui.input({ prompt = "Enter project name: " }, function(project_name)
|
||||
if not project_name or project_name == "" then return print("Project creation canceled.") end
|
||||
local project_root = vim.fn.expand(M.config.project_root) .. "/" .. project_name
|
||||
vim.fn.system("cargo new " .. project_root)
|
||||
vim.cmd("edit " .. project_root .. "/src/main.rs")
|
||||
end)
|
||||
end
|
||||
|
||||
function M.create_new_file()
|
||||
vim.ui.input({ prompt = "Enter file name: " }, function(class_name)
|
||||
if not class_name or class_name == "" then return print("File creation canceled.") end
|
||||
local root_dir = M.get_project_root()
|
||||
if not root_dir then return print("Error: Project root not found.") end
|
||||
utils.write_file(root_dir .. "/src/" .. class_name .. ".rs", "")
|
||||
end)
|
||||
end
|
||||
|
||||
function M.get_project_root()
|
||||
local dir = vim.fn.expand("%:p:h")
|
||||
while dir ~= "/" do
|
||||
if vim.fn.isdirectory(dir .. "/src") == 1 then
|
||||
return dir
|
||||
end
|
||||
dir = vim.fn.fnamemodify(dir, ":h")
|
||||
end
|
||||
end
|
||||
|
||||
function M.build()
|
||||
local root = M.get_project_root()
|
||||
if not root then return print("Error: Project root not found.") end
|
||||
local cmd = "cargo build"
|
||||
local term_buf = utils.open_float_terminal(cmd)
|
||||
vim.api.nvim_buf_set_option(term_buf, "modifiable", true)
|
||||
local output = vim.fn.system(cmd)
|
||||
local success = vim.v.shell_error == 0
|
||||
vim.api.nvim_buf_set_lines(term_buf, 0, -1, false, vim.list_extend({ success and "Compilation successful!" or "Error during compilation:" }, vim.split(output, "\n", { trimempty = true })))
|
||||
vim.api.nvim_buf_set_option(term_buf, "modifiable", false)
|
||||
end
|
||||
|
||||
function M.run()
|
||||
local root = M.get_project_root()
|
||||
if not root then return print("Error: Project root not found.") end
|
||||
utils.open_float_terminal("cargo run")
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -0,0 +1,26 @@
|
||||
local M = {}
|
||||
|
||||
local presets = {
|
||||
right = {
|
||||
left = 100,
|
||||
right = 0,
|
||||
top = 0,
|
||||
bottom = 0,
|
||||
},
|
||||
corner = {
|
||||
left = 100,
|
||||
right = 0,
|
||||
top = 25,
|
||||
bottom = 0,
|
||||
}
|
||||
}
|
||||
|
||||
---@param preset string
|
||||
---@return table|nil
|
||||
function M.getPresets(preset)
|
||||
if presets[preset] then
|
||||
return presets[preset]
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
+315
-43
@@ -1,52 +1,80 @@
|
||||
---@module 'Polydev.utils'
|
||||
local utils = require("Polydev.utils")
|
||||
---
|
||||
---@type table
|
||||
|
||||
local M = {}
|
||||
|
||||
---@class TemplateLanguage
|
||||
---@field run fun(project_name: string, project_root: string): nil
|
||||
local function extras(guard, file_type, file_name)
|
||||
if not file_name then return print("Header file creation canceled") end
|
||||
local guard_macro = file_name:upper():gsub("[^A-Z0-9]", "_") .. guard
|
||||
local content = string.format([[
|
||||
#ifndef %s
|
||||
#define %s
|
||||
|
||||
---@class Projects
|
||||
---@field java TemplateLanguage
|
||||
---@field python TemplateLanguage
|
||||
---@field lua TemplateLanguage
|
||||
---@alias TemplatesLanguageName "java" | "python" | "lua"
|
||||
// Add code here
|
||||
|
||||
#endif
|
||||
]], guard_macro, guard_macro)
|
||||
utils.write_file({ utils.get_project_root(), "include", file_name .. file_type }, content)
|
||||
end
|
||||
|
||||
---@type Projects
|
||||
M.projects = {
|
||||
javascript = {
|
||||
run = function(project_name, project_root)
|
||||
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||
vim.fn.mkdir(full_project_root, "p")
|
||||
utils.write_file({ full_project_root, "main.js" }, [[
|
||||
console.log("Hello World!");
|
||||
]])
|
||||
local gitignore = { "" }
|
||||
utils.init_git(full_project_root, gitignore)
|
||||
vim.cmd("edit " .. full_project_root .. "/main.js")
|
||||
end
|
||||
},
|
||||
lua = {
|
||||
run = function(project_name, project_root)
|
||||
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||
vim.fn.mkdir(full_project_root .. "/lua/" .. project_name, "p")
|
||||
utils.write_file({ full_project_root, "lua", project_name, "init.lua" }, [[
|
||||
local M = {}
|
||||
|
||||
return M
|
||||
]])
|
||||
local gitignore = { "" }
|
||||
utils.init_git(full_project_root, gitignore)
|
||||
vim.cmd("edit " .. full_project_root .. "/lua/" .. project_name .. "/init.lua")
|
||||
end
|
||||
},
|
||||
java = {
|
||||
run = function(project_name, project_root)
|
||||
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||
for _, path in ipairs({ "/src", "/build" }) do vim.fn.mkdir(full_project_root .. path, "p") end
|
||||
|
||||
local main_java_content = [[
|
||||
local content = [[
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello, World!");
|
||||
}
|
||||
}
|
||||
]]
|
||||
utils.write_file(full_project_root .. "/src/Main.java", main_java_content)
|
||||
return nil
|
||||
local gitignore = {
|
||||
"build/"
|
||||
}
|
||||
utils.init_git(full_project_root, gitignore)
|
||||
utils.write_file({ full_project_root, "src", "Main.java" }, content)
|
||||
end
|
||||
},
|
||||
python = {
|
||||
run = function(project_name, project_root)
|
||||
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||
vim.fn.mkdir(full_project_root .. "/include", "p")
|
||||
|
||||
utils.write_file(full_project_root .. "/main.py", [[
|
||||
utils.write_file({ full_project_root, "main.py" }, [[
|
||||
def main():
|
||||
print("Hello, World!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
]])
|
||||
|
||||
utils.write_file(full_project_root .. "/include/__init__.py", "")
|
||||
utils.write_file(full_project_root .. "/requirements.txt", "")
|
||||
utils.write_file(full_project_root .. "/setup.py", string.format([[
|
||||
utils.write_file({ full_project_root, "include/__init__.py" }, "")
|
||||
utils.write_file({ full_project_root, "requirements.txt" }, "")
|
||||
utils.write_file({ full_project_root, "setup.py" }, string.format([[
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
@@ -57,43 +85,287 @@ setup(
|
||||
python_requires=">=3.6",
|
||||
)
|
||||
]], project_name))
|
||||
|
||||
local gitignore = {
|
||||
"venv/"
|
||||
}
|
||||
utils.init_git(full_project_root, gitignore)
|
||||
vim.cmd("edit " .. full_project_root .. "/main.py")
|
||||
local venv_path = full_project_root .. "/venv"
|
||||
vim.fn.system("python3 -m venv " .. venv_path)
|
||||
vim.g.python3_host_prog = venv_path .. "/bin/python"
|
||||
vim.fn.setenv("VIRTUAL_ENV", venv_path)
|
||||
vim.fn.setenv("PATH", venv_path .. "/bin:" .. vim.fn.getenv("PATH"))
|
||||
|
||||
print("Virtual environment activated for " .. project_name)
|
||||
return nil
|
||||
end
|
||||
},
|
||||
lua = {
|
||||
c = {
|
||||
run = function(project_name, project_root)
|
||||
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||
for _, path in ipairs({ "/lua/" .. project_name }) do vim.fn.mkdir(full_project_root .. path, "p") end
|
||||
|
||||
utils.write_file(full_project_root .. "/lua/" .. project_name .. "/init.lua", [[
|
||||
local M = {}
|
||||
|
||||
return M
|
||||
for _, path in ipairs({ "/src", "/build", "/include" }) do
|
||||
vim.fn.mkdir(
|
||||
full_project_root .. path, "p")
|
||||
end
|
||||
utils.write_file({ full_project_root, ".clang-format" }, [[
|
||||
---
|
||||
BasedOnStyle: Google
|
||||
Standard: Latest
|
||||
UseTab: Always
|
||||
TabWidth: 8
|
||||
IndentWidth: 8
|
||||
BreakBeforeBraces: Allman
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SeparateDefinitionBlocks: Always
|
||||
Cpp11BracedListStyle: false
|
||||
BreakAfterReturnType: TopLevel
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
ReflowComments: Always
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
IndentAccessModifiers: false # Indent access specifiers by one level
|
||||
AccessModifierOffset: -4 # Optional: adjust offset relative to the class indentation level
|
||||
]])
|
||||
utils.write_file(full_project_root .. "/" .. project_name .. ".polydev", "[[DO NOT REMOVE THIS FILE]]")
|
||||
vim.cmd("edit " .. full_project_root .. "/lua/" .. project_name .. "/init.lua")
|
||||
return nil
|
||||
utils.write_file({ full_project_root, "src/main.c" }, [[
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("%s", "Hello World");
|
||||
return 0;
|
||||
}
|
||||
]])
|
||||
|
||||
utils.write_file({ full_project_root, ".clang-tidy" }, string.format([[
|
||||
---
|
||||
Checks: >
|
||||
-*,
|
||||
bugprone-*,
|
||||
concurrency-*,
|
||||
misc-*,
|
||||
modernize-*,
|
||||
performance-*,
|
||||
readability-*,
|
||||
portability-*,
|
||||
-readability-braces-around-statements,
|
||||
-readability-implicit-bool-conversion
|
||||
|
||||
WarningsAsErrors: ""
|
||||
|
||||
CheckOptions:
|
||||
- key: readability-identifier-naming.VariableCase
|
||||
value: lower_case
|
||||
- key: readability-identifier-naming.FunctionCase
|
||||
value: lower_case
|
||||
---
|
||||
]]))
|
||||
utils.write_file({ full_project_root, "CMakeLists.txt" }, string.format([[
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
set(CMAKE_C_STANDARD 23)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
include_directories(include)
|
||||
project(%s LANGUAGES C)
|
||||
|
||||
set(SOURCES
|
||||
src/main.c
|
||||
)
|
||||
|
||||
add_executable(%s ${SOURCES})
|
||||
]], project_name, project_name, project_name))
|
||||
local gitignore = { "build/", ".cache/" }
|
||||
utils.init_git(full_project_root, gitignore)
|
||||
vim.fn.system(string.format(
|
||||
"cd %s/build && cmake -S .. -B . && cmake --build . && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..",
|
||||
full_project_root))
|
||||
vim.cmd("edit " .. full_project_root .. "/src/main.c")
|
||||
end
|
||||
},
|
||||
cpp = {
|
||||
run = function(project_name, project_root)
|
||||
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||
for _, path in ipairs({ "/src", "/build", "/include" }) do
|
||||
vim.fn.mkdir(full_project_root .. path, "p")
|
||||
end
|
||||
utils.write_file({ full_project_root, ".clang-format" }, [[
|
||||
---
|
||||
BasedOnStyle: Google
|
||||
Standard: Latest
|
||||
UseTab: Always
|
||||
TabWidth: 8
|
||||
IndentWidth: 8
|
||||
BreakBeforeBraces: Allman
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SeparateDefinitionBlocks: Always
|
||||
Cpp11BracedListStyle: false
|
||||
BreakAfterReturnType: TopLevel
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
ReflowComments: Always
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
IndentAccessModifiers: false # Indent access specifiers by one level
|
||||
AccessModifierOffset: -4 # Optional: adjust offset relative to the class indentation level
|
||||
]])
|
||||
|
||||
utils.write_file({ full_project_root, "src/main.cpp" }, [[
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello World\n";
|
||||
return 0;
|
||||
}
|
||||
]])
|
||||
|
||||
utils.write_file({ full_project_root, ".clang-tidy" }, string.format([[
|
||||
---
|
||||
Checks: >
|
||||
-*,
|
||||
bugprone-*,
|
||||
concurrency-*,
|
||||
misc-*,
|
||||
modernize-*,
|
||||
performance-*,
|
||||
readability-*,
|
||||
portability-*,
|
||||
-readability-braces-around-statements,
|
||||
-readability-implicit-bool-conversion
|
||||
|
||||
WarningsAsErrors: ""
|
||||
|
||||
CheckOptions:
|
||||
- key: readability-identifier-naming.VariableCase
|
||||
value: lower_case
|
||||
- key: readability-identifier-naming.FunctionCase
|
||||
value: lower_case
|
||||
---
|
||||
]]))
|
||||
|
||||
utils.write_file({ full_project_root, "CMakeLists.txt" }, string.format([[
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
project(%s LANGUAGES CXX)
|
||||
|
||||
|
||||
set(SOURCES
|
||||
src/main.cpp
|
||||
)
|
||||
|
||||
add_executable(%s ${SOURCES})
|
||||
]], project_name, project_name))
|
||||
|
||||
local gitignore = { "build/", ".cache/" }
|
||||
utils.init_git(full_project_root, gitignore)
|
||||
vim.fn.system(string.format(
|
||||
"cd %s/build && cmake -S .. -B . && cmake --build . && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..",
|
||||
full_project_root))
|
||||
vim.cmd("edit " .. full_project_root .. "/src/main.cpp")
|
||||
end
|
||||
},
|
||||
rust = {
|
||||
run = function(project_name, project_root)
|
||||
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||
vim.fn.system("cargo new " .. full_project_root)
|
||||
vim.cmd("edit " .. full_project_root .. "/src/main.rs")
|
||||
end
|
||||
},
|
||||
html = {
|
||||
run = function(project_name, project_root)
|
||||
local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name
|
||||
if vim.fn.isdirectory(full_project_root) == 0 then
|
||||
vim.fn.mkdir(full_project_root, "p") -- Create directory with parent directories
|
||||
end
|
||||
local main_html_content = [[
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
]]
|
||||
utils.write_file({ full_project_root, "index.html" }, main_html_content)
|
||||
end
|
||||
},
|
||||
}
|
||||
|
||||
---@param lang TemplatesLanguageName
|
||||
---@param project_root string
|
||||
function M.create_project(lang, project_root)
|
||||
vim.ui.input({ prompt = "Enter project name: " }, function(project_name)
|
||||
if not project_name or project_name == "" then return print("Project creation canceled.") end
|
||||
M.projects[lang].run(project_name, project_root)
|
||||
end)
|
||||
end
|
||||
M.files = {
|
||||
lua = {
|
||||
run = function(file_name)
|
||||
utils.write_file(
|
||||
{ utils.get_project_root(), "lua", utils.get_project_name(), file_name .. ".lua" }, "")
|
||||
end
|
||||
},
|
||||
java = {
|
||||
run = function(file_name)
|
||||
utils.write_file({ utils.get_project_root(), "src", file_name .. ".java" }, string.format([[
|
||||
public class %s {
|
||||
// New File
|
||||
}
|
||||
]], file_name))
|
||||
end
|
||||
},
|
||||
python = {
|
||||
run = function(file_name)
|
||||
utils.write_file({ utils.get_project_root(), "include", file_name .. ".py" }, "")
|
||||
end
|
||||
},
|
||||
c = {
|
||||
run = function(file_name)
|
||||
utils.write_file({ utils.get_project_root(), "src", file_name .. ".c" }, "")
|
||||
end
|
||||
|
||||
},
|
||||
cpp = {
|
||||
run = function(file_name)
|
||||
utils.write_file({ utils.get_project_root(), "src", file_name .. ".cpp" }, "")
|
||||
end
|
||||
},
|
||||
rust = {
|
||||
run = function(file_name)
|
||||
utils.write_file({ utils.get_project_root(), "src", file_name .. ".rs" }, "")
|
||||
end
|
||||
},
|
||||
html = {
|
||||
run = function(file_name)
|
||||
utils.write_file({ ".", file_name .. ".html" }, string.format([[
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>My First Heading</h1>
|
||||
<p>My first paragraph.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
]]))
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
M.extras = {
|
||||
run = function(lang, file_name)
|
||||
if lang == "c" then
|
||||
extras("_H", ".h", file_name)
|
||||
print("Successful creation of " .. file_name .. ".h")
|
||||
elseif lang == "cpp" then
|
||||
extras("_HPP", ".hpp", file_name)
|
||||
print("Successful creation of " .. file_name .. ".hpp")
|
||||
else
|
||||
print("Extras language is not found: enter cpp or c")
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
---@return any
|
||||
return M
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
local M = {}
|
||||
|
||||
---@param path string
|
||||
---@return table
|
||||
local function get_entries(path)
|
||||
local result = {}
|
||||
local handle = vim.uv.fs_scandir(path)
|
||||
if not handle then return result end
|
||||
while true do
|
||||
local name, type = vim.uv.fs_scandir_next(handle)
|
||||
if not name then break end
|
||||
table.insert(result, {
|
||||
name = name .. (type == "directory" and "/" or ""),
|
||||
type = type,
|
||||
full_path = path .. "/" .. name,
|
||||
})
|
||||
end
|
||||
table.sort(result, function(a, b)
|
||||
if a.type == "directory" and b.type ~= "directory" then return true end
|
||||
if b.type == "directory" and a.type ~= "directory" then return false end
|
||||
return a.name < b.name
|
||||
end)
|
||||
return result
|
||||
end
|
||||
|
||||
---@param project_root string
|
||||
function M.manager(project_root)
|
||||
local templates = require("Polydev.templates")
|
||||
local width, height = math.floor(vim.o.columns * 0.40), math.floor(vim.o.lines * 0.4)
|
||||
local row, col = math.floor((vim.o.lines - height) / 3), math.floor((vim.o.columns - width) / 2)
|
||||
local content_row = row + 2
|
||||
local content_height = height - 3
|
||||
|
||||
local cwd = vim.fn.getcwd()
|
||||
local current_view = {}
|
||||
|
||||
local content_buf = vim.api.nvim_create_buf(false, true)
|
||||
local content_win = vim.api.nvim_open_win(content_buf, true, {
|
||||
relative = "editor",
|
||||
width = width,
|
||||
height = content_height,
|
||||
row = content_row,
|
||||
col = col,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
})
|
||||
|
||||
local function close_all_windows()
|
||||
if vim.api.nvim_win_is_valid(content_win) then
|
||||
pcall(vim.api.nvim_win_close, content_win, true)
|
||||
end
|
||||
end
|
||||
|
||||
local function update_screen()
|
||||
local root = vim.fn.expand(project_root)
|
||||
if vim.fn.isdirectory(root) == 0 then
|
||||
vim.fn.mkdir(root, "p")
|
||||
end
|
||||
local entries = get_entries(cwd)
|
||||
if not cwd:find(root, 1, true) then
|
||||
cwd = root
|
||||
entries = get_entries(cwd)
|
||||
end
|
||||
if cwd ~= root then
|
||||
table.insert(entries, 1, {
|
||||
name = "../",
|
||||
type = "directory",
|
||||
full_path = vim.fn.fnamemodify(cwd, ":h"),
|
||||
is_up = true,
|
||||
})
|
||||
end
|
||||
current_view = vim.deepcopy(entries)
|
||||
|
||||
local lines = {}
|
||||
if #current_view == 0 then
|
||||
table.insert(lines, "No projects found in " .. cwd)
|
||||
table.insert(lines, "Press d to create a project, or a to add a folder.")
|
||||
else
|
||||
for i, item in ipairs(current_view) do
|
||||
table.insert(lines, string.format("%-2d | %-27s | %-6s", i, item.name, item.type))
|
||||
end
|
||||
end
|
||||
vim.api.nvim_buf_set_lines(content_buf, 0, -1, false, lines)
|
||||
end
|
||||
|
||||
local function get_selected_entry()
|
||||
local win = content_win
|
||||
if not win or not vim.api.nvim_win_is_valid(win) then return end
|
||||
local row = vim.api.nvim_win_get_cursor(win)[1]
|
||||
return current_view[row], row
|
||||
end
|
||||
|
||||
---@param type string
|
||||
---@param callback fun(lang: string, name: string)
|
||||
local function get_inputs(type, callback)
|
||||
vim.ui.input({ prompt = "Enter language for new " .. type .. ": " }, function(lang)
|
||||
if not lang or lang == "" then return end
|
||||
vim.ui.input({ prompt = "Enter " .. type .. " name: " }, function(name)
|
||||
if not name or name == "" then return end
|
||||
callback(lang, name)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
update_screen()
|
||||
|
||||
local buf = content_buf
|
||||
vim.keymap.set("n", "<ESC>", function()
|
||||
if vim.api.nvim_win_is_valid(content_win) then
|
||||
pcall(vim.api.nvim_win_close, content_win, true)
|
||||
end
|
||||
end, { buffer = buf })
|
||||
vim.keymap.set("n", "a", function ()
|
||||
vim.ui.input({ prompt = "New folder name: " }, function(input)
|
||||
if input then
|
||||
vim.fn.mkdir(cwd .. "/" .. input, "p")
|
||||
update_screen()
|
||||
end
|
||||
end)
|
||||
end, { buffer = buf })
|
||||
vim.keymap.set("n", "R", function ()
|
||||
local entry = get_selected_entry()
|
||||
if entry ~= nil and not entry.is_up then
|
||||
vim.ui.input({ prompt = "Rename: ", default = entry.name }, function(input)
|
||||
if input then
|
||||
local new_path = cwd .. "/" .. input
|
||||
vim.fn.rename(entry.full_path, new_path)
|
||||
update_screen()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end, { buffer = buf })
|
||||
vim.keymap.set("n", "D", function()
|
||||
local entry = get_selected_entry()
|
||||
if entry ~= nil and not entry.is_up then
|
||||
vim.ui.input({ prompt = "Deletion of " .. entry.name .. ": (y/N) Defaults to N: " }, function(input)
|
||||
if input == "y" or input == "Y" then
|
||||
vim.fn.delete(entry.full_path, "rf")
|
||||
update_screen()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end, { buffer = buf })
|
||||
vim.keymap.set("n", "%", function()
|
||||
get_inputs("file", function(lang, name)
|
||||
local file = templates.files[lang]
|
||||
if not file or not file.run then
|
||||
return print("Error: No file creation method for " .. lang)
|
||||
end
|
||||
close_all_windows()
|
||||
file.run(name)
|
||||
end)
|
||||
end, { buffer = buf })
|
||||
vim.keymap.set("n", "x", function()
|
||||
get_inputs("aux file", function(lang, name)
|
||||
close_all_windows()
|
||||
templates.extras.run(lang, name)
|
||||
end)
|
||||
end, { buffer = buf })
|
||||
vim.keymap.set("n", "d", function()
|
||||
get_inputs("project", function(lang, name)
|
||||
local project = templates.projects[lang]
|
||||
if not project or not project.run then
|
||||
return print("Error: No project creation method for " .. lang)
|
||||
end
|
||||
local opts = require("Polydev.configs").get(lang)
|
||||
local run_root = opts.project_root or project_root
|
||||
close_all_windows()
|
||||
project.run(name, run_root)
|
||||
end)
|
||||
end, { buffer = buf })
|
||||
vim.keymap.set("n", "<CR>", function()
|
||||
local entry = get_selected_entry()
|
||||
if not entry then return end
|
||||
|
||||
if entry.type == "file" then
|
||||
close_all_windows()
|
||||
vim.cmd("edit " .. vim.fn.fnameescape(entry.full_path))
|
||||
elseif entry.type == "directory" then
|
||||
cwd = entry.full_path
|
||||
vim.cmd("cd " .. cwd)
|
||||
update_screen()
|
||||
else
|
||||
print("Error")
|
||||
end
|
||||
end, { buffer = buf })
|
||||
end
|
||||
|
||||
return M
|
||||
+85
-23
@@ -1,27 +1,70 @@
|
||||
local M = {}
|
||||
|
||||
M.opts = {}
|
||||
|
||||
function M.setup(opts)
|
||||
M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("terminal"), opts or {})
|
||||
end
|
||||
|
||||
function M.write_file(path, content)
|
||||
function M.exists(path)
|
||||
return (io.open(path, "r") ~= nil)
|
||||
end
|
||||
|
||||
---@return string
|
||||
function M.get_project_root()
|
||||
local plugin_dir = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":h:h:h")
|
||||
|
||||
local dir = vim.fn.system(plugin_dir .. "/bash_scripts/walkup.sh"):gsub("%s+$", "")
|
||||
return dir
|
||||
end
|
||||
|
||||
---@return string
|
||||
function M.get_project_name()
|
||||
return vim.fn.fnamemodify(M.get_project_root(), ":t")
|
||||
end
|
||||
|
||||
---@param path_segments table
|
||||
---@param content string
|
||||
function M.write_file(path_segments, content)
|
||||
local path = table.concat(path_segments, "/")
|
||||
local file = assert(io.open(path, "w"), "Error creating file: " .. path)
|
||||
file:write(content)
|
||||
file:close()
|
||||
vim.cmd("edit " .. path)
|
||||
print(path .. " created successfully!")
|
||||
end
|
||||
|
||||
function M.open_float_terminal(cmd)
|
||||
---@param path string
|
||||
---@param gitignore_lines table
|
||||
function M.init_git(path, gitignore_lines)
|
||||
vim.fn.mkdir(path, "p")
|
||||
vim.fn.system({ "git", "-C", path, "init" })
|
||||
|
||||
if gitignore_lines and #gitignore_lines > 0 then
|
||||
local contents = table.concat(gitignore_lines, "\n")
|
||||
M.write_file({ path, ".gitignore" }, contents)
|
||||
end
|
||||
end
|
||||
|
||||
---@param cmd table
|
||||
---@return integer, integer?
|
||||
function M.terminal(cmd)
|
||||
if M.opts.mode == "floating" then
|
||||
local opts = require("Polydev.presets").getPresets(M.opts.win.anchor)
|
||||
|
||||
local ui = vim.api.nvim_list_uis()[1]
|
||||
local width, height, row, col
|
||||
|
||||
local width = math.max(1, math.floor(ui.width * 0.9) - M.opts.left_padding or 0 - M.opts.right_padding or 0)
|
||||
local height = math.max(1, math.floor(ui.height * 0.9) - M.opts.top_padding or 0 - M.opts.bottom_padding or 0)
|
||||
local row = math.max(1, math.floor((ui.height - height) / 2) + (M.opts.top_padding or 0))
|
||||
local col = math.max(1, math.floor((ui.width - width) / 2) + (M.opts.left_padding or 0))
|
||||
|
||||
if opts ~= nil then
|
||||
width = math.max(1, math.floor(ui.width * 0.9) - opts.left - opts.right)
|
||||
height = math.max(1, math.floor(ui.height * 0.9) - opts.top - opts.bottom)
|
||||
row = math.floor((ui.height - height) / 2) + opts.top
|
||||
col = math.floor((ui.width - width) / 2) + opts.left
|
||||
end
|
||||
if opts == nil then
|
||||
width = math.max(1, math.floor(ui.width * 0.9))
|
||||
height = math.max(1, math.floor(ui.height * 0.9))
|
||||
row = math.floor((ui.height - height) / 2)
|
||||
col = math.floor((ui.width - width) / 2)
|
||||
end
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
local win = vim.api.nvim_open_win(buf, true, {
|
||||
relative = "editor",
|
||||
@@ -30,23 +73,42 @@ function M.open_float_terminal(cmd)
|
||||
row = row,
|
||||
col = col,
|
||||
style = "minimal",
|
||||
border = M.opts.border and "rounded" or "none",
|
||||
border = M.opts.border.enabled and M.opts.border.type,
|
||||
})
|
||||
|
||||
vim.api.nvim_win_set_option(win, "winblend", vim.o.pumblend)
|
||||
vim.api.nvim_win_set_option(win, "winhighlight", "Normal:Pmenu,FloatBorder:Pmenu")
|
||||
vim.api.nvim_win_set_option(win, "cursorline", true)
|
||||
vim.api.nvim_win_set_option(win, "scrolloff", 5)
|
||||
if(M.opts.number == true) then
|
||||
vim.api.nvim_win_set_option(win, "number", true)
|
||||
if(M.opts.relativenumber == true) then
|
||||
vim.api.nvim_win_set_option(win, "relativenumber", true)
|
||||
end
|
||||
end
|
||||
|
||||
vim.fn.termopen(cmd)
|
||||
vim.api.nvim_set_option_value("winhighlight", "Normal:PolydevNormal,FloatBorder:PolydevBorder",
|
||||
{ win = win })
|
||||
vim.fn.jobstart(table.concat(cmd, "/"), { term = true })
|
||||
vim.api.nvim_buf_set_keymap(buf, "n", "<ESC>", "i<C-\\><C-n>:q<CR>", { noremap = true, silent = true })
|
||||
return buf, win
|
||||
end
|
||||
if M.opts.mode == "split" then
|
||||
if M.opts.win.type == "vertical" then
|
||||
if M.opts.win.anchor == "right" then
|
||||
vim.cmd("set splitright")
|
||||
end
|
||||
end
|
||||
if M.opts.win.type == "horizontal" then
|
||||
if M.opts.win.anchor == "bottom" then
|
||||
vim.cmd("set splitbelow")
|
||||
end
|
||||
end
|
||||
|
||||
if M.opts.win.type == "vertical" then
|
||||
vim.cmd(M.opts.win.size .. " vsplit")
|
||||
end
|
||||
if M.opts.win.type == "horizontal" then
|
||||
vim.cmd(M.opts.win.size .. " split")
|
||||
end
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
|
||||
vim.api.nvim_win_set_buf(0, buf)
|
||||
|
||||
vim.fn.jobstart(table.concat(cmd, "/"), { term = true })
|
||||
vim.api.nvim_buf_set_keymap(buf, "n", "<ESC>", "i<C-\\><C-n>:q<CR>", { noremap = true, silent = true })
|
||||
return buf, win
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
site_name: Polydev
|
||||
nav:
|
||||
- Home: index.md
|
||||
- Installation: installation.md
|
||||
- Setup: setup.md
|
||||
- Language Specific Docs:
|
||||
- Java: languages/java.md
|
||||
- C: languages/c.md
|
||||
- Cpp: languages/cpp.md
|
||||
- Lua: languages/lua.md
|
||||
- Python: languages/python.md
|
||||
theme:
|
||||
name: material
|
||||
features:
|
||||
- navigation.tabs
|
||||
- navigation.sections
|
||||
- toc.integrate
|
||||
- navigation.top
|
||||
- search.suggest
|
||||
- search.highlight
|
||||
- content.tabs.link
|
||||
- content.code.annotation
|
||||
- content.code.copy
|
||||
language: en
|
||||
palette:
|
||||
- scheme: slate
|
||||
primary: slate
|
||||
accent: teal
|
||||
|
||||
extra:
|
||||
social:
|
||||
- icon: fontawesome/brands/github-alt
|
||||
link: https://github.com/DarthMooMancer
|
||||
|
||||
markdown_extensions:
|
||||
- pymdownx.highlight:
|
||||
anchor_linenums: true
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.snippets
|
||||
- admonition
|
||||
- pymdownx.arithmatex:
|
||||
generic: true
|
||||
- footnotes
|
||||
- pymdownx.details
|
||||
- pymdownx.superfences
|
||||
- pymdownx.mark
|
||||
- attr_list
|
||||
- pymdownx.emoji:
|
||||
emoji_index: !!python/name:materialx.emoji.twemoji
|
||||
emoji_generator: !!python/name:materialx.emoji.to_svg
|
||||
|
||||
copyright: |
|
||||
© 2025 <a href="https://github.com/DarthMooMancer" target="_blank" rel="noopener">DarthMooMancer</a>
|
||||
@@ -0,0 +1 @@
|
||||
require("Polydev").setup()
|
||||
Reference in New Issue
Block a user