A Neovim plugin that detects multiple FROM instructions in Dockerfiles and automatically adds separator lines to improve readability of multi-stage builds.
中文版本: README.md
- 🔍 Automatically detects multiple FROM instructions in Dockerfiles
- 📏 Adds configurable separator lines between multiple FROM instructions
- 🎨 Supports custom separator characters and lengths
- 🌈 Highlights separator lines
- 🔄 Supports adding/removing/toggling separator lines
- 📊 Shows detailed FROM instruction information
- ⚡ Auto mode: automatically applies when opening Dockerfile
- 🎯 Virtual text mode: doesn't modify file content, only shows visual effects
- 🔧 Debug mode: controls notification display levels
use {
'mingming-cn/dockerfile-enhance.nvim',
config = function()
require('dockerfile-enhance').setup()
end
}{
'mingming-cn/dockerfile-enhance.nvim',
config = true,
event = { "BufReadPost Dockerfile*", "BufReadPost *.dockerfile", "BufEnter Dockerfile*", "BufEnter *.dockerfile" }
}Plug 'mingming-cn/dockerfile-enhance.nvim'require('dockerfile-enhance').setup({
separator_char = "─", -- Separator character
separator_length = 80, -- Separator length
highlight_group = "Comment", -- Highlight group
auto_enhance = true, -- Whether to auto-enhance
enable_highlights = true, -- Whether to enable highlights
enable_virtual_text = true, -- Whether to enable virtual text (recommended)
virtual_highlight_group = "Comment", -- Virtual text highlight group
debug = false, -- Debug mode (set to true to show all notifications)
})| Option | Type | Default | Description |
|---|---|---|---|
separator_char |
string | "─" |
Separator character |
separator_length |
number | 80 |
Separator length |
highlight_group |
string | "Comment" |
Highlight group name |
auto_enhance |
boolean | true |
Whether to auto-enhance |
enable_highlights |
boolean | true |
Whether to enable highlights |
enable_virtual_text |
boolean | true |
Whether to enable virtual text (recommended) |
virtual_highlight_group |
string | "Comment" |
Virtual text highlight group |
debug |
boolean | false |
Debug mode (set to true to show all notifications) |
The plugin provides the following commands:
:DockerfileEnhance- Add separator lines to current Dockerfile:DockerfileRemoveSeparators- Remove all separator lines:DockerfileToggleSeparators- Toggle separator line display:DockerfileShowInfo- Show FROM instruction information
When debug = true, the plugin will show detailed notification information, including:
- Plugin loading status
- Dockerfile enhancement results
- FROM instruction detection information
- Separator line operation status
-- Enable debug mode
require('dockerfile-enhance').setup({
debug = true, -- Show all notifications
-- Other configurations...
})
-- Temporarily enable debug mode
:lua require('dockerfile-enhance').setup({debug = true})FROM node:18-alpine AS base
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
FROM base AS development
RUN npm ci
COPY . .
CMD ["npm", "run", "dev"]
FROM base AS production
COPY . .
RUN npm run build
CMD ["npm", "start"]FROM node:18-alpine AS base
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
────────────────────────────────────────────────────────────────────────────────
FROM base AS development
RUN npm ci
COPY . .
CMD ["npm", "run", "dev"]
────────────────────────────────────────────────────────────────────────────────
FROM base AS production
COPY . .
RUN npm run build
CMD ["npm", "start"]- When opening a Dockerfile file, the plugin automatically detects and adds separator lines
- Reapplies highlights when saving files
- Supported file types:
Dockerfile*and*.dockerfile - Automatically adds empty lines between FROM instructions (if they don't exist)
- Uses virtual text mode, doesn't modify file content
You can customize the separator line highlighting styles:
-- Define custom highlight group in colorscheme
vim.api.nvim_set_hl(0, "DockerfileSeparator", {
fg = "#ff6b6b",
bold = true
})
-- Use in plugin configuration
require('dockerfile-enhance').setup({
highlight_group = "DockerfileSeparator",
virtual_highlight_group = "DockerfileSeparator" -- Virtual text highlight
})require('dockerfile-enhance').setup({
debug = false, -- Reduce notification interference
enable_virtual_text = true, -- Use virtual text mode
auto_enhance = true, -- Auto-enhance
})require('dockerfile-enhance').setup({
debug = true, -- Show detailed notifications
enable_virtual_text = true, -- Use virtual text mode
auto_enhance = true, -- Auto-enhance
})Issues and Pull Requests are welcome!
MIT License