Added presets and updated documentation
This commit is contained in:
+11
-3
@@ -1,4 +1,3 @@
|
||||
|
||||
# Setup and Customizing Polydev
|
||||
|
||||
## 🔧 Project Name Customization
|
||||
@@ -29,7 +28,6 @@ require("Polydev").language.setup({
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## ⌨ 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).
|
||||
|
||||
@@ -79,6 +77,7 @@ You can further tweak the terminal settings to suit your preferences! These opti
|
||||
### Available Terminal Settings
|
||||
| Setting | Default Value | Description |
|
||||
|------------------|-----------------|---------------------------------------------------------|
|
||||
| **presets** | `centered` | Presets for where the terminal is placed in the buffer |
|
||||
| **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. |
|
||||
@@ -90,6 +89,14 @@ You can further tweak the terminal settings to suit your preferences! These opti
|
||||
|
||||
> **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.
|
||||
|
||||
### Available Presets
|
||||
| Preset | Placement |
|
||||
|--------|-----------|
|
||||
| **center** | `completely centerd in the screen with a small amount of padding on each side of the buffer` |
|
||||
| **right_panel** | `takes up about a third of the right side from top to bottom with a small amount of padding` |
|
||||
| **center_panel** | `takes up about a third of the center from top to bottom with a small amount of padding` |
|
||||
| **corner** | `takes up about a fourth of the bottom right corner with a small amount of padding` |
|
||||
|
||||
---
|
||||
### LazyVim Example
|
||||
|
||||
@@ -98,6 +105,7 @@ return {
|
||||
...
|
||||
opts = {
|
||||
terminal = {
|
||||
presets = "centered"
|
||||
right_padding = 0,
|
||||
bottom_padding = 0,
|
||||
left_padding = 0,
|
||||
@@ -117,6 +125,7 @@ return {
|
||||
```lua
|
||||
require("Polydev").setup({
|
||||
terminal = {
|
||||
presets = "centered"
|
||||
right_padding = 0,
|
||||
bottom_padding = 0,
|
||||
left_padding = 0,
|
||||
@@ -129,7 +138,6 @@ require("Polydev").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.
|
||||
|
||||
|
||||
+11
-11
@@ -1,7 +1,7 @@
|
||||
---@type table
|
||||
local M = {}
|
||||
|
||||
---@type table|nil
|
||||
---@type table
|
||||
local opts = {}
|
||||
|
||||
---@class Preset
|
||||
@@ -11,7 +11,7 @@ local opts = {}
|
||||
---@field bottom_padding integer
|
||||
|
||||
---@type Preset
|
||||
local centered = {
|
||||
local center = {
|
||||
left_padding = 0,
|
||||
right_padding = 0,
|
||||
top_padding = 0,
|
||||
@@ -19,7 +19,7 @@ local centered = {
|
||||
}
|
||||
|
||||
---@type Preset
|
||||
local center_paneled = {
|
||||
local center_panel = {
|
||||
left_padding = 0,
|
||||
right_padding = 100,
|
||||
top_padding = 0,
|
||||
@@ -35,7 +35,7 @@ local right_panel = {
|
||||
}
|
||||
|
||||
---@type Preset
|
||||
local cornered = {
|
||||
local corner = {
|
||||
left_padding = 100,
|
||||
right_padding = 0,
|
||||
top_padding = 25,
|
||||
@@ -44,18 +44,18 @@ local cornered = {
|
||||
}
|
||||
|
||||
---@param preset string
|
||||
---@return table|nil
|
||||
---@return table
|
||||
function M.getPresets(preset)
|
||||
if preset == "custom" then
|
||||
opts = nil
|
||||
elseif preset == "centered" then
|
||||
opts = centered
|
||||
-- if preset == "custom" then
|
||||
-- opts = nil
|
||||
if preset == "centered" then
|
||||
opts = center
|
||||
elseif preset == "center_panel" then
|
||||
opts = center_paneled
|
||||
opts = center_panel
|
||||
elseif preset == "right_panel" then
|
||||
opts = right_panel
|
||||
elseif preset == "cornered" then
|
||||
opts = cornered
|
||||
opts = corner
|
||||
else
|
||||
print("Preset option: " .. preset .. " does not exist")
|
||||
end
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
local pickers = require "telescope.pickers"
|
||||
local finders = require "telescope.finders"
|
||||
local conf = require("telescope.config").values
|
||||
local actions = require "telescope.actions"
|
||||
local action_state = require "telescope.actions.state"
|
||||
|
||||
-- our picker function: colors
|
||||
local colors = function(opts)
|
||||
opts = opts or {}
|
||||
pickers.new(opts, {
|
||||
prompt_title = "colors",
|
||||
finder = finders.new_table {
|
||||
results = { "red", "green", "blue" }
|
||||
},
|
||||
sorter = conf.generic_sorter(opts),
|
||||
attach_mappings = function(prompt_bufnr, map)
|
||||
actions.select_default:replace(function()
|
||||
actions.close(prompt_bufnr)
|
||||
local selection = action_state.get_selected_entry()
|
||||
-- print(vim.inspect(selection))
|
||||
vim.api.nvim_put({ selection[1] }, "", false, true)
|
||||
end)
|
||||
return true
|
||||
end,
|
||||
}):find()
|
||||
end
|
||||
|
||||
-- to execute the function
|
||||
colors(require("telescope.themes").get_dropdown{})
|
||||
+4
-10
@@ -7,7 +7,7 @@ local M = {}
|
||||
---@type table
|
||||
M.opts = {}
|
||||
|
||||
---@type table|nil
|
||||
---@type table
|
||||
local presets_opts = {}
|
||||
|
||||
---@param opts table
|
||||
@@ -25,18 +25,12 @@ function M.write_file(path, content)
|
||||
print(path .. " created successfully!")
|
||||
end
|
||||
|
||||
local function set_presets_opts()
|
||||
if presets.getPresets(M.opts.presets) ~= nil then
|
||||
presets_opts = presets.getPresets(M.opts.presets)
|
||||
else
|
||||
presets_opts = M.opts
|
||||
end
|
||||
end
|
||||
|
||||
---@param cmd string
|
||||
---@return boolean, table
|
||||
function M.open_float_terminal(cmd)
|
||||
set_presets_opts()
|
||||
if presets.getPresets(M.opts.presets) ~= nil then
|
||||
presets_opts = presets.getPresets(M.opts.presets)
|
||||
end
|
||||
local ui = vim.api.nvim_list_uis()[1]
|
||||
|
||||
local width = math.max(1, math.floor(ui.width * 0.9) - presets_opts.left_padding - presets_opts.right_padding)
|
||||
|
||||
Reference in New Issue
Block a user