12 Commits
17 changed files with 626 additions and 244 deletions
+1
View File
@@ -1,2 +1,3 @@
*.polydev
LICENSE
Lua_Annotation_CheatSheet/
+7 -4
View File
@@ -1,10 +1,7 @@
# Polydev
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/)
![Python-polydev-720](https://github.com/user-attachments/assets/b66f46e8-901f-4a46-8e79-10b688d4109a)
![Polydev-c](https://github.com/user-attachments/assets/365dd673-6b1f-4ccc-ac1f-c5131d055fd9)
### Quick Features
The ability to -
@@ -15,12 +12,18 @@ The ability to -
* Builtin terminal for running code
* And More!
Documentation is over at [Polydev Documentation](https://darthmoomancer.github.io/Polydev/)
### Currently Supported (And working) Languages
* Java
* Python
* C/C++
* Lua
* Rust
* Html
## Things planned
* The use of rust to speed up some aspects of the plugin
## 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.
-29
View File
@@ -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
View File
@@ -1,13 +1,56 @@
# Welcome to Polydev
# 🚀 Welcome to Polydev
![Python-polydev-720](https://github.com/user-attachments/assets/08232673-01a4-4464-9e98-5a94227e98f9)
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:
![Polydev-c](https://github.com/user-attachments/assets/365dd673-6b1f-4ccc-ac1f-c5131d055fd9)
* Creating New Projects
* Creating New Files
* Building Files
* Running Files
* Builtin Terminal
## ❓ 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.
---
+117 -22
View File
@@ -1,32 +1,127 @@
# Installation
!!! Polydev can be installed with any plugin installer or manually. These are just examples.
# 📦 Installation
* 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
require {
{
"DarthMooMancer/Polydev",
config = function()
require("Polydev").setup()
--require("Polydev").language.setup({
-- configs
--})
end
opts = {
lua = {
project_root = "~/Projects/Lua",
keybinds = {
["<leader>pr"] = "LuaRun",
},
},
terminal = {
border = true,
number = true,
},
},
}
```
## Mini.Deps
------------
```lua
MiniDeps.add({
source = 'DarthMooMancer/Polydev',
})
> ✅ Keep the `opts` key! It’s the modern way of setting up plugins in Lazy.
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
View File
@@ -1,19 +1,49 @@
## Key Notes
* 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.
### 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:
## Keybinds
```lua
require("Polydev").c.setup({
keybinds = {
["<Esc>"] = "CloseTerminal" -- Closes terminal, esc by default.
["<leader>pb"] = "CBuild", -- Building all C Files in src directory in.
["<leader>pr"] = "CRun", -- Runs <Project_name> in your build directory
["<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
["<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
---
#### 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/
@@ -27,3 +57,5 @@ Projects/
└── include/
└── *.h
```
---
+61
View File
@@ -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
View File
@@ -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
-- These are defaults, so no need to copy them
require("Polydev").java.setup({
keybinds = {
["<Esc>"] = "CloseTerminal" -- Closes terminal, esc by default.
["<leader>pb"] = "JavaBuild" -- Building all Java Files in src directory in.
["<leader>pr"] = "JavaRun" -- Runs Main.java in the out folder in your project_root
["<leader>nf"] = "NewJavaFile" -- Creates a new Java file in the current project src folder
["<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
}
})
```
## 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
Projects/
@@ -21,3 +54,5 @@ Projects/
└── build/
└── *.class
```
---
+50 -8
View File
@@ -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
-- These are the defaults for lua
-- These are the defaults for Lua, adjust as needed
require("Polydev").lua.setup({
keybinds = {
["<Esc>"] = "CloseTerminal",
["<leader>pr"] = "LuaRun",
["<leader>nf"] = "NewLuaFile",
["<leader>pr"] = "LuaRun", -- Run the Lua project
}
})
```
## 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
Projects/
└── Lua/
└── Project_Name/
├── <Project_name>.polydev
├── <Project_name>.polydev -- Polydev configuration file
└── lua/
└── Project_name/
└── init.lua
└── init.lua -- Main Lua file
```
---
+45 -10
View File
@@ -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
require("Polydev").python.setup({
keybinds = {
["<Esc>"] = "CloseTerminal",
["<leader>pr"] = "PythonRun",
["<leader>nf"] = "NewPythonFile",
["<leader>pb"] = "PythonPip"
["<leader>pr"] = "PythonRun", -- Run the Python project
["<leader>pb"] = "PythonPip" -- Install dependencies using pip
}
})
```
## 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
Projects/
└── Python/
@@ -24,5 +58,6 @@ Projects/
├── setup.py
├── tests/
└── venv/
```
---
+65 -49
View File
@@ -1,90 +1,102 @@
# Setup and Customizing
## Project Name
* 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.
# 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
### Lazy
```lua
return {
...
opts = {
<language> = {
project_root = "~/Home/..." -- Default: ~/Projects/Language
}
}
...
}
```
### Others
### Packer Example
```lua
require("Polydev").language.setup({
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
```
Key/
├── *Universal, cannot be changed through specific language settings
└── *Per-language, can be changed separately by language if wanted
```
## ⌨ 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
### Lazy
```lua
return {
...
opts = {
<language> = {
["<Esc>"] = "CloseTerminal", -- Planned to be *Universal -- However can be changed per language for now
["<leader>pb"] = "languageBuild", -- *Per-language
["<leader>pr"] = "languageRun", -- *Per-language
["<leader>nf"] = "NewLanguageFile", --*Universal -- such as .c files
["<leader>nh"] = "NewLanguageSecondaryFile", --*Universal -- such as .h files
["<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
}
}
...
}
```
### Others
### Packer Example
```lua
require("Polydev"}.language.setup({
keybinds = [
["<Esc>"] = "CloseTerminal", -- Planned to be *Universal -- However can be changed per language for now
["<leader>pb"] = "languageBuild", -- *Per-language
["<leader>pr"] = "languageRun", -- *Per-language
["<leader>nf"] = "NewLanguageFile", --*Universal -- such as .c files
["<leader>nh"] = "NewLanguageSecondaryFile", --*Universal -- such as .h files
}
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
* 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
- Each is set to 0 by default
* **_right_padding:_** Padding for the right width of the terminal
* **_left_padding:_** Padding for the left width of the terminal
* **_top_padding:_** Padding for the top height of the terminal
* **_bottom_padding:_** Padding for the bottom padding of the terminal
- Each is enabled by default
* **_border:_** Adds a rounded border to the window
* **_number:_** Adds numbers to side of terminal
* **_relativenumber:_** Relative numbers indicate distances from the cursor, only works if number is enabled
* **_scroll:_** Allows scrolling in terminal
---
## 🖥 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
### Lazy
```lua
return {
...
opts = {
<language> = {
terminal = {
right_padding = 0,
bottom_padding = 0,
@@ -96,16 +108,14 @@ return {
scroll = true,
}
}
}
...
}
```
### Others
### Packer Example
```lua
-- These are just defaults, so no need to copy them
require("Polydev").language.setup({
require("Polydev").setup({
terminal = {
right_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
View File
@@ -1,9 +1,10 @@
local M = {}
---@class Keybinds
---@field [string] string
---
---@class Language
---@field project_root string
---@class ConfigsLanguage
---@field project_root? string
---@field keybinds? Keybinds -- ? makes fields optional
---@field build_attributes? string
---
@@ -17,13 +18,13 @@ local M = {}
---@field relativenumber boolean
---
---@class Defaults
---@field html Language
---@field rust Language
---@field java Language
---@field python Language
---@field lua Language
---@field c Language
---@field cpp Language
---@field html ConfigsLanguage
---@field rust ConfigsLanguage
---@field java ConfigsLanguage
---@field python ConfigsLanguage
---@field lua ConfigsLanguage
---@field c ConfigsLanguage
---@field cpp ConfigsLanguage
---@field terminal Terminal
---@type Defaults
@@ -87,12 +88,14 @@ M.defaults = {
}
}
---@type string[]
M.user_config = {}
function M.setup(user_opts)
M.user_config = vim.tbl_deep_extend("force", {}, M.defaults, user_opts or {})
end
---@param lang string
function M.get(lang)
return M.user_config[lang] or {}
end
+24 -16
View File
@@ -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 = {}
---@type table
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)
if M.loaded_languages[lang] then return true end
@@ -25,11 +30,12 @@ function M.load_language_module(lang, opts)
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
if M.load_language_module(lang) and M.loaded_languages[lang].create_project then
M.loaded_languages[lang].create_project()
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
@@ -48,13 +54,14 @@ function M.create_new_file()
end)
end
---@param opts table
function M.setup(opts)
opts = opts or {}
M.config.setup(opts)
M.utils.setup(opts)
config.setup(opts)
utils.setup(opts)
for lang, user_opts in pairs(opts) do
local default = M.config.defaults[lang] or {}
M.config.user_config[lang] = vim.tbl_deep_extend("force", default, user_opts)
local default = config.defaults[lang] or {}
config.user_config[lang] = vim.tbl_deep_extend("force", default, user_opts)
end
vim.api.nvim_create_user_command("NewProject", M.create_project, {})
@@ -70,4 +77,5 @@ function M.setup(opts)
})
end
---@return table
return M
-17
View File
@@ -21,23 +21,6 @@ function M.setup(opts)
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()
vim.ui.input({ prompt = "Enter class name: " }, function(class_name)
if not class_name or class_name == "" then return print("Class creation canceled.") end
-45
View File
@@ -42,51 +42,6 @@ function M.get_project_root()
return nil
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()
vim.ui.input({ prompt = "Enter file name: " }, function(file_name)
if not file_name or file_name == "" then
+99
View File
@@ -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
View File
@@ -3,10 +3,10 @@ nav:
- Home: index.md
- Installation: installation.md
- Setup: setup.md
- Examples: examples.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: