Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c79c414859 | ||
|
|
2dbb367eb5 | ||
|
|
29643fe1d5 | ||
|
|
068a650e85 | ||
|
|
48322f04e1 | ||
|
|
1c8ec76875 | ||
|
|
156f92cc31 | ||
|
|
a882c3b30e | ||
|
|
838148bccb | ||
|
|
4b8300c9c0 | ||
|
|
cc61c9029d | ||
|
|
3f7c412d77 |
@@ -1,2 +1,3 @@
|
|||||||
*.polydev
|
*.polydev
|
||||||
LICENSE
|
LICENSE
|
||||||
|
Lua_Annotation_CheatSheet/
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
# Polydev
|
# Polydev
|
||||||
A multi-lingual plugin that adds some nice features to neovim for managing, creating, building and runnning projects all within neovim.
|
A multi-lingual plugin that adds some nice features to neovim for managing, creating, building and runnning projects all within neovim.
|
||||||
|
|
||||||
!!! Documentation is over at [Polydev Documentation](https://darthmoomancer.github.io/Polydev/)
|

|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
### Quick Features
|
### Quick Features
|
||||||
The ability to -
|
The ability to -
|
||||||
@@ -15,12 +12,18 @@ The ability to -
|
|||||||
* Builtin terminal for running code
|
* Builtin terminal for running code
|
||||||
* And More!
|
* And More!
|
||||||
|
|
||||||
|
Documentation is over at [Polydev Documentation](https://darthmoomancer.github.io/Polydev/)
|
||||||
|
|
||||||
### Currently Supported (And working) Languages
|
### Currently Supported (And working) Languages
|
||||||
* Java
|
* Java
|
||||||
* Python
|
* Python
|
||||||
* C/C++
|
* C/C++
|
||||||
* Lua
|
* Lua
|
||||||
|
* Rust
|
||||||
|
* Html
|
||||||
|
|
||||||
|
## Things planned
|
||||||
|
* The use of rust to speed up some aspects of the plugin
|
||||||
## Questions and Contributing
|
## Questions and Contributing
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
### Lazy and Config
|
|
||||||
```lua
|
|
||||||
-- There is no need to copy this. This is an example and it consists of the defaults. This is a c example
|
|
||||||
return {
|
|
||||||
'DarthMooMancer/Polydev',
|
|
||||||
opts = {
|
|
||||||
c = {
|
|
||||||
build_attributes = "-DBUILD_SHARED_LIBS=OFF"
|
|
||||||
project_root = "~/Projects/C",
|
|
||||||
keybinds = {
|
|
||||||
["<Esc>"] = "CloseTerminal",
|
|
||||||
["<leader>pb"] = "CBuild",
|
|
||||||
["<leader>pr"] = "CRun",
|
|
||||||
["<leader>nh"] = "NewCHeaderFile",
|
|
||||||
},
|
|
||||||
terminal = {
|
|
||||||
right_padding = 0,
|
|
||||||
bottom_padding = 0,
|
|
||||||
left_padding = 0,
|
|
||||||
top_padding = 0,
|
|
||||||
border = true,
|
|
||||||
number = true,
|
|
||||||
relativenumber = true,
|
|
||||||
scroll = true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
+53
-10
@@ -1,13 +1,56 @@
|
|||||||
# Welcome to Polydev
|
# 🚀 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 a simple plugin that gives neovim some nice functions while being extremely extensible for developers. It automatically detects your language and enables the module for that language. It is a standalone plugin that has no dependencies aside from getting file types. Below are a few features that are currently implemented:
|
|
||||||
|
|
||||||
* Creating New Projects
|
## ❓ What is Polydev?
|
||||||
* Creating New Files
|
|
||||||
* Building Files
|
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.
|
||||||
* Running Files
|
|
||||||
* Builtin Terminal
|
## 💡 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.
|
||||||
|
|
||||||
|
---
|
||||||
|
|||||||
+117
-22
@@ -1,32 +1,127 @@
|
|||||||
# Installation
|
# 📦 Installation
|
||||||
!!! Polydev can be installed with any plugin installer or manually. These are just examples.
|
|
||||||
|
|
||||||
* Side note: A lot of the languages require a <project_name>.polydev file. If you dont have it in a language that needs it, it will error out and yell at you.
|
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.
|
||||||
|
|
||||||
## Lazyvim
|
> ⚠️ **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
|
```lua
|
||||||
require {
|
{
|
||||||
"DarthMooMancer/Polydev",
|
"DarthMooMancer/Polydev",
|
||||||
config = function()
|
opts = {
|
||||||
require("Polydev").setup()
|
lua = {
|
||||||
--require("Polydev").language.setup({
|
project_root = "~/Projects/Lua",
|
||||||
-- configs
|
keybinds = {
|
||||||
--})
|
["<leader>pr"] = "LuaRun",
|
||||||
end
|
},
|
||||||
|
},
|
||||||
|
terminal = {
|
||||||
|
border = true,
|
||||||
|
number = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Mini.Deps
|
> ✅ Keep the `opts` key! It’s the modern way of setting up plugins in Lazy.
|
||||||
------------
|
|
||||||
```lua
|
|
||||||
MiniDeps.add({
|
|
||||||
source = 'DarthMooMancer/Polydev',
|
|
||||||
})
|
|
||||||
|
|
||||||
require("Polydev").setup()
|
---
|
||||||
--require("Polydev").language.setup({
|
|
||||||
-- configs
|
## 🧸 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,
|
||||||
|
},
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|||||||
+41
-9
@@ -1,19 +1,49 @@
|
|||||||
## Key Notes
|
### C Setup for Polydev 🛠️
|
||||||
* Currently with the way I have it work, the first time you build a project, it will error out no matter what. Just rerun the build and then if there are errors it is most likely a you issue more than a me issue.
|
|
||||||
|
#### 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:
|
||||||
|
|
||||||
## Keybinds
|
|
||||||
```lua
|
```lua
|
||||||
require("Polydev").c.setup({
|
require("Polydev").c.setup({
|
||||||
keybinds = {
|
keybinds = {
|
||||||
["<Esc>"] = "CloseTerminal" -- Closes terminal, esc by default.
|
["<leader>pb"] = "CBuild", -- Build all C files in the src directory
|
||||||
["<leader>pb"] = "CBuild", -- Building all C Files in src directory in.
|
["<leader>pr"] = "CRun", -- Run <Project_name> in your build directory
|
||||||
["<leader>pr"] = "CRun", -- Runs <Project_name> in your build directory
|
["<leader>nh"] = "NewCHeaderFile" -- Create a new header file in the current project’s src folder
|
||||||
["<leader>nf"] = "NewCFile", -- Creates a new c file in the current project src folder
|
}
|
||||||
["<leader>nh"] = "NewCHeaderFile", -- Creates a new header file in the current project src folder
|
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## File Structure
|
---
|
||||||
|
|
||||||
|
#### 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
|
```md
|
||||||
Projects/
|
Projects/
|
||||||
└── C/
|
└── C/
|
||||||
@@ -27,3 +57,5 @@ Projects/
|
|||||||
└── include/
|
└── include/
|
||||||
└── *.h
|
└── *.h
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
### 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
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
+41
-6
@@ -1,16 +1,49 @@
|
|||||||
## Keybinds
|
### 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
|
```lua
|
||||||
-- These are defaults, so no need to copy them
|
-- These are defaults, so no need to copy them
|
||||||
require("Polydev").java.setup({
|
require("Polydev").java.setup({
|
||||||
keybinds = {
|
keybinds = {
|
||||||
["<Esc>"] = "CloseTerminal" -- Closes terminal, esc by default.
|
["<leader>pb"] = "JavaBuild", -- Build all Java files in the src directory
|
||||||
["<leader>pb"] = "JavaBuild" -- Building all Java Files in src directory in.
|
["<leader>pr"] = "JavaRun", -- Run Main.java in the out folder
|
||||||
["<leader>pr"] = "JavaRun" -- Runs Main.java in the out folder in your project_root
|
["<leader>nf"] = "NewJavaFile" -- Create a new Java file in the src folder
|
||||||
["<leader>nf"] = "NewJavaFile" -- Creates a new Java file in the current project src folder
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
## File Structure
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### 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
|
```md
|
||||||
Projects/
|
Projects/
|
||||||
@@ -21,3 +54,5 @@ Projects/
|
|||||||
└── build/
|
└── build/
|
||||||
└── *.class
|
└── *.class
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|||||||
+50
-8
@@ -1,22 +1,64 @@
|
|||||||
## Keybinds
|
### 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
|
```lua
|
||||||
-- These are the defaults for lua
|
-- These are the defaults for Lua, adjust as needed
|
||||||
require("Polydev").lua.setup({
|
require("Polydev").lua.setup({
|
||||||
keybinds = {
|
keybinds = {
|
||||||
["<Esc>"] = "CloseTerminal",
|
["<leader>pr"] = "LuaRun", -- Run the Lua project
|
||||||
["<leader>pr"] = "LuaRun",
|
|
||||||
["<leader>nf"] = "NewLuaFile",
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## File Structure
|
---
|
||||||
|
|
||||||
|
#### 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
|
```md
|
||||||
Projects/
|
Projects/
|
||||||
└── Lua/
|
└── Lua/
|
||||||
└── Project_Name/
|
└── Project_Name/
|
||||||
├── <Project_name>.polydev
|
├── <Project_name>.polydev -- Polydev configuration file
|
||||||
└── lua/
|
└── lua/
|
||||||
└── Project_name/
|
└── Project_name/
|
||||||
└── init.lua
|
└── init.lua -- Main Lua file
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|||||||
+45
-10
@@ -1,20 +1,54 @@
|
|||||||
## Keybinds
|
### 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
|
```lua
|
||||||
require("Polydev").python.setup({
|
require("Polydev").python.setup({
|
||||||
keybinds = {
|
keybinds = {
|
||||||
["<Esc>"] = "CloseTerminal",
|
["<leader>pr"] = "PythonRun", -- Run the Python project
|
||||||
["<leader>pr"] = "PythonRun",
|
["<leader>pb"] = "PythonPip" -- Install dependencies using pip
|
||||||
["<leader>nf"] = "NewPythonFile",
|
|
||||||
["<leader>pb"] = "PythonPip"
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## Python Features
|
---
|
||||||
* A feature that is added to the python language for this plugin is to be able to install dependencies with pip within the terminal. You can even update pip. Just type your dependency you want and boom it is installed or not depending on if python likes you.
|
|
||||||
* Each project with python creates a new virtual environment and automatically uses it so you dont have to worry, just install modules as you like.
|
#### 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:
|
||||||
|
|
||||||
## File Structure
|
|
||||||
```md
|
```md
|
||||||
Projects/
|
Projects/
|
||||||
└── Python/
|
└── Python/
|
||||||
@@ -24,5 +58,6 @@ Projects/
|
|||||||
├── setup.py
|
├── setup.py
|
||||||
├── tests/
|
├── tests/
|
||||||
└── venv/
|
└── venv/
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|||||||
+64
-48
@@ -1,90 +1,102 @@
|
|||||||
# Setup and Customizing
|
|
||||||
|
|
||||||
## Project Name
|
# Setup and Customizing Polydev
|
||||||
* You can change the default directory for the project. The project can be made from anywhere you want.
|
|
||||||
* It will automatically make the new Root Directory, so you don't have to worry about making it.
|
## 🔧 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
|
||||||
|
|
||||||
### Lazy
|
|
||||||
```lua
|
```lua
|
||||||
return {
|
return {
|
||||||
...
|
...
|
||||||
opts = {
|
opts = {
|
||||||
<language> = {
|
<language> = {
|
||||||
project_root = "~/Home/..." -- Default: ~/Projects/Language
|
project_root = "~/Home/..." -- Default: ~/Projects/Language
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Others
|
### Packer Example
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
require("Polydev").language.setup({
|
require("Polydev").language.setup({
|
||||||
project_root = "~/Home/..." -- Default: ~/Projects/Language
|
project_root = "~/Home/..." -- Default: ~/Projects/Language
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## Keybinds
|
|
||||||
* Every language has the almost same keybinds so it is easy to remember keybinds and not have to remember thousands of keybinds.
|
|
||||||
* Some languages have separate functions (python has a pip keybind for example) adding more keybinds
|
|
||||||
|
|
||||||
```
|
## ⌨ Keybinds Customization
|
||||||
Key/
|
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).
|
||||||
├── *Universal, cannot be changed through specific language settings
|
|
||||||
└── *Per-language, can be changed separately by language if wanted
|
### 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
|
||||||
|
|
||||||
### Lazy
|
|
||||||
```lua
|
```lua
|
||||||
return {
|
return {
|
||||||
...
|
...
|
||||||
opts = {
|
opts = {
|
||||||
<language> = {
|
<language> = {
|
||||||
["<Esc>"] = "CloseTerminal", -- Planned to be *Universal -- However can be changed per language for now
|
["<Esc>"] = "CloseTerminal", -- Universal, can be changed per language for now
|
||||||
["<leader>pb"] = "languageBuild", -- *Per-language
|
["<leader>pb"] = "languageBuild", -- Per-language
|
||||||
["<leader>pr"] = "languageRun", -- *Per-language
|
["<leader>pr"] = "languageRun", -- Per-language
|
||||||
["<leader>nf"] = "NewLanguageFile", --*Universal -- such as .c files
|
["<leader>nf"] = "NewLanguageFile", -- Universal
|
||||||
["<leader>nh"] = "NewLanguageSecondaryFile", --*Universal -- such as .h files
|
["<leader>nh"] = "NewLanguageSecondaryFile", -- Universal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Others
|
### Packer Example
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
require("Polydev"}.language.setup({
|
require("Polydev").language.setup({
|
||||||
keybinds = [
|
keybinds = {
|
||||||
["<Esc>"] = "CloseTerminal", -- Planned to be *Universal -- However can be changed per language for now
|
["<Esc>"] = "CloseTerminal", -- Universal, can be changed per language for now
|
||||||
["<leader>pb"] = "languageBuild", -- *Per-language
|
["<leader>pb"] = "languageBuild", -- Per-language
|
||||||
["<leader>pr"] = "languageRun", -- *Per-language
|
["<leader>pr"] = "languageRun", -- Per-language
|
||||||
["<leader>nf"] = "NewLanguageFile", --*Universal -- such as .c files
|
["<leader>nf"] = "NewLanguageFile", -- Universal
|
||||||
["<leader>nh"] = "NewLanguageSecondaryFile", --*Universal -- such as .h files
|
["<leader>nh"] = "NewLanguageSecondaryFile", -- Universal
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## Terminal
|
---
|
||||||
* I plan on making the terminal settings a global setting instead of language specific, just need to figure out how
|
|
||||||
* The terminal has a couple of options that can be customized and with more to come
|
## 🖥 Terminal Customization
|
||||||
- Each is set to 0 by default
|
You can further tweak the terminal settings to suit your preferences! These options allow you to adjust padding, borders, numbers, and scrolling behavior.
|
||||||
* **_right_padding:_** Padding for the right width of the terminal
|
|
||||||
* **_left_padding:_** Padding for the left width of the terminal
|
### Available Terminal Settings
|
||||||
* **_top_padding:_** Padding for the top height of the terminal
|
| Setting | Default Value | Description |
|
||||||
* **_bottom_padding:_** Padding for the bottom padding of the terminal
|
|------------------|-----------------|---------------------------------------------------------|
|
||||||
- Each is enabled by default
|
| **right_padding** | `0` | Padding for the right width of the terminal. |
|
||||||
* **_border:_** Adds a rounded border to the window
|
| **left_padding** | `0` | Padding for the left width of the terminal. |
|
||||||
* **_number:_** Adds numbers to side of terminal
|
| **top_padding** | `0` | Padding for the top height of the terminal. |
|
||||||
* **_relativenumber:_** Relative numbers indicate distances from the cursor, only works if number is enabled
|
| **bottom_padding**| `0` | Padding for the bottom height of the terminal. |
|
||||||
* **_scroll:_** Allows scrolling in 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
|
||||||
|
|
||||||
### Lazy
|
|
||||||
```lua
|
```lua
|
||||||
return {
|
return {
|
||||||
...
|
...
|
||||||
opts = {
|
opts = {
|
||||||
<language> = {
|
|
||||||
terminal = {
|
terminal = {
|
||||||
right_padding = 0,
|
right_padding = 0,
|
||||||
bottom_padding = 0,
|
bottom_padding = 0,
|
||||||
@@ -96,16 +108,14 @@ return {
|
|||||||
scroll = true,
|
scroll = true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Others
|
### Packer Example
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- These are just defaults, so no need to copy them
|
require("Polydev").setup({
|
||||||
require("Polydev").language.setup({
|
|
||||||
terminal = {
|
terminal = {
|
||||||
right_padding = 0,
|
right_padding = 0,
|
||||||
bottom_padding = 0,
|
bottom_padding = 0,
|
||||||
@@ -118,3 +128,9 @@ require("Polydev").language.setup({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## 🚀 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.
|
||||||
|
|||||||
+12
-9
@@ -1,9 +1,10 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
---@class Keybinds
|
---@class Keybinds
|
||||||
---@field [string] string
|
---@field [string] string
|
||||||
---
|
---
|
||||||
---@class Language
|
---@class ConfigsLanguage
|
||||||
---@field project_root string
|
---@field project_root? string
|
||||||
---@field keybinds? Keybinds -- ? makes fields optional
|
---@field keybinds? Keybinds -- ? makes fields optional
|
||||||
---@field build_attributes? string
|
---@field build_attributes? string
|
||||||
---
|
---
|
||||||
@@ -17,13 +18,13 @@ local M = {}
|
|||||||
---@field relativenumber boolean
|
---@field relativenumber boolean
|
||||||
---
|
---
|
||||||
---@class Defaults
|
---@class Defaults
|
||||||
---@field html Language
|
---@field html ConfigsLanguage
|
||||||
---@field rust Language
|
---@field rust ConfigsLanguage
|
||||||
---@field java Language
|
---@field java ConfigsLanguage
|
||||||
---@field python Language
|
---@field python ConfigsLanguage
|
||||||
---@field lua Language
|
---@field lua ConfigsLanguage
|
||||||
---@field c Language
|
---@field c ConfigsLanguage
|
||||||
---@field cpp Language
|
---@field cpp ConfigsLanguage
|
||||||
---@field terminal Terminal
|
---@field terminal Terminal
|
||||||
|
|
||||||
---@type Defaults
|
---@type Defaults
|
||||||
@@ -87,12 +88,14 @@ M.defaults = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
---@type string[]
|
||||||
M.user_config = {}
|
M.user_config = {}
|
||||||
|
|
||||||
function M.setup(user_opts)
|
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", {}, M.defaults, user_opts or {})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param lang string
|
||||||
function M.get(lang)
|
function M.get(lang)
|
||||||
return M.user_config[lang] or {}
|
return M.user_config[lang] or {}
|
||||||
end
|
end
|
||||||
|
|||||||
+24
-16
@@ -1,16 +1,21 @@
|
|||||||
|
---@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 = {}
|
local M = {}
|
||||||
|
|
||||||
|
---@type table
|
||||||
M.loaded_languages = {}
|
M.loaded_languages = {}
|
||||||
M.config = require("Polydev.configs")
|
|
||||||
M.utils = require("Polydev.utils")
|
|
||||||
M.java = require("Polydev.languages.java")
|
|
||||||
M.c = require("Polydev.languages.c")
|
|
||||||
M.cpp = require("Polydev.languages.cpp")
|
|
||||||
M.lua = require("Polydev.languages.lua")
|
|
||||||
M.python = require("Polydev.languages.python")
|
|
||||||
M.rust = require("Polydev.languages.rust")
|
|
||||||
M.html = require("Polydev.languages.html")
|
|
||||||
|
|
||||||
|
---@param lang string
|
||||||
|
---@param opts table?
|
||||||
|
---@return boolean
|
||||||
function M.load_language_module(lang, opts)
|
function M.load_language_module(lang, opts)
|
||||||
if M.loaded_languages[lang] then return true end
|
if M.loaded_languages[lang] then return true end
|
||||||
|
|
||||||
@@ -25,11 +30,12 @@ function M.load_language_module(lang, opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.create_project()
|
function M.create_project()
|
||||||
|
local opts = {}
|
||||||
vim.ui.input({ prompt = "Enter language for project: " }, function(lang)
|
vim.ui.input({ prompt = "Enter language for project: " }, function(lang)
|
||||||
if not lang or lang == "" then return print("Project creation canceled.") end
|
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 M.loaded_languages[lang].create_project then
|
if M.load_language_module(lang) and templates.projects[lang] and templates.projects[lang].run then
|
||||||
M.loaded_languages[lang].create_project()
|
templates.create_project(lang, opts.project_root)
|
||||||
else
|
else
|
||||||
print("Error: No project creation method for " .. lang)
|
print("Error: No project creation method for " .. lang)
|
||||||
end
|
end
|
||||||
@@ -48,13 +54,14 @@ function M.create_new_file()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param opts table
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
M.config.setup(opts)
|
config.setup(opts)
|
||||||
M.utils.setup(opts)
|
utils.setup(opts)
|
||||||
for lang, user_opts in pairs(opts) do
|
for lang, user_opts in pairs(opts) do
|
||||||
local default = M.config.defaults[lang] or {}
|
local default = config.defaults[lang] or {}
|
||||||
M.config.user_config[lang] = vim.tbl_deep_extend("force", default, user_opts)
|
config.user_config[lang] = vim.tbl_deep_extend("force", default, user_opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("NewProject", M.create_project, {})
|
vim.api.nvim_create_user_command("NewProject", M.create_project, {})
|
||||||
@@ -70,4 +77,5 @@ function M.setup(opts)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@return table
|
||||||
return M
|
return M
|
||||||
|
|||||||
@@ -21,23 +21,6 @@ function M.setup(opts)
|
|||||||
end
|
end
|
||||||
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.opts.project_root) .. "/" .. project_name
|
|
||||||
for _, path in ipairs({ "/src", "/build" }) do vim.fn.mkdir(project_root .. path, "p") end
|
|
||||||
|
|
||||||
local main_java_content = [[
|
|
||||||
public class Main {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
System.out.println("Hello, World!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]]
|
|
||||||
utils.write_file(project_root .. "/src/Main.java", main_java_content)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.create_new_file()
|
function M.create_new_file()
|
||||||
vim.ui.input({ prompt = "Enter class name: " }, function(class_name)
|
vim.ui.input({ prompt = "Enter class name: " }, function(class_name)
|
||||||
if not class_name or class_name == "" then return print("Class creation canceled.") end
|
if not class_name or class_name == "" then return print("Class creation canceled.") end
|
||||||
|
|||||||
@@ -42,51 +42,6 @@ function M.get_project_root()
|
|||||||
return nil
|
return nil
|
||||||
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({ "/include" }) do
|
|
||||||
vim.fn.mkdir(project_root .. path, "p")
|
|
||||||
end
|
|
||||||
|
|
||||||
utils.write_file(project_root .. "/main.py", [[
|
|
||||||
def main():
|
|
||||||
print("Hello, World!")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
]])
|
|
||||||
|
|
||||||
utils.write_file(project_root .. "/include/__init__.py", "")
|
|
||||||
utils.write_file(project_root .. "/requirements.txt", "")
|
|
||||||
utils.write_file(project_root .. "/setup.py", string.format([[
|
|
||||||
from setuptools import setup, find_packages
|
|
||||||
|
|
||||||
setup(
|
|
||||||
name="%s",
|
|
||||||
version="0.1.0",
|
|
||||||
packages=find_packages(),
|
|
||||||
install_requires=[],
|
|
||||||
python_requires=">=3.6",
|
|
||||||
)
|
|
||||||
]], project_name))
|
|
||||||
|
|
||||||
vim.cmd("edit " .. project_root .. "/main.py")
|
|
||||||
local venv_path = 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)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.create_new_file()
|
function M.create_new_file()
|
||||||
vim.ui.input({ prompt = "Enter file name: " }, function(file_name)
|
vim.ui.input({ prompt = "Enter file name: " }, function(file_name)
|
||||||
if not file_name or file_name == "" then
|
if not file_name or file_name == "" then
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
---@module 'Polydev.utils'
|
||||||
|
local utils = require("Polydev.utils")
|
||||||
|
---
|
||||||
|
---@type table
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
---@class TemplateLanguage
|
||||||
|
---@field run fun(project_name: string, project_root: string): nil
|
||||||
|
|
||||||
|
---@class Projects
|
||||||
|
---@field java TemplateLanguage
|
||||||
|
---@field python TemplateLanguage
|
||||||
|
---@field lua TemplateLanguage
|
||||||
|
---@alias TemplatesLanguageName "java" | "python" | "lua"
|
||||||
|
|
||||||
|
---@type Projects
|
||||||
|
M.projects = {
|
||||||
|
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 = [[
|
||||||
|
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
|
||||||
|
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", [[
|
||||||
|
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([[
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="%s",
|
||||||
|
version="0.1.0",
|
||||||
|
packages=find_packages(),
|
||||||
|
install_requires=[],
|
||||||
|
python_requires=">=3.6",
|
||||||
|
)
|
||||||
|
]], project_name))
|
||||||
|
|
||||||
|
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 = {
|
||||||
|
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
|
||||||
|
]])
|
||||||
|
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
|
||||||
|
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
|
||||||
|
|
||||||
|
---@return any
|
||||||
|
return M
|
||||||
+1
-1
@@ -3,10 +3,10 @@ nav:
|
|||||||
- Home: index.md
|
- Home: index.md
|
||||||
- Installation: installation.md
|
- Installation: installation.md
|
||||||
- Setup: setup.md
|
- Setup: setup.md
|
||||||
- Examples: examples.md
|
|
||||||
- Language Specific Docs:
|
- Language Specific Docs:
|
||||||
- Java: languages/java.md
|
- Java: languages/java.md
|
||||||
- C: languages/c.md
|
- C: languages/c.md
|
||||||
|
- Cpp: languages/cpp.md
|
||||||
- Lua: languages/lua.md
|
- Lua: languages/lua.md
|
||||||
- Python: languages/python.md
|
- Python: languages/python.md
|
||||||
theme:
|
theme:
|
||||||
|
|||||||
Reference in New Issue
Block a user