Skip to content

Commit 682d405

Browse files
committed
vi dioxus support
1 parent c3fe31d commit 682d405

File tree

14 files changed

+494
-13
lines changed

14 files changed

+494
-13
lines changed

nix/doom.nix

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ in
3737
-file ${../bak/doom/CodeFX255NoFatsoNoArchvile.pk3} \
3838
-file ${../bak/doom/CodeFXFireNoLostSoul.pk3} \
3939
-file ${../bak/doom/CodeFXBlood.pk3} \
40-
-file "${../bak/doom/liquid}/Liquid Texture Pack/(GZDoom) Liquid Texture Pack V4.0.pk3" \
41-
-file "${../bak/doom/liquid}/Glowing Toxic Texture Pack/LTP V4.0 Glowing Toxic Texture Addon.pk3" \
42-
-file "${../bak/doom/liquid}/Shader Pack/LTP V4.0 Shader pack.pk3" \
43-
-file "${../bak/doom/liquid}/Shader Pack/LTP V4.0 Sky shader addon.pk3" \
40+
-file "${../bak/doom/ltp701}/Liquid Texture Pack V7.0.1/LTP V7.0.1.pk3" \
41+
-file "${../bak/doom/ltp701}/Liquid Texture Pack V7.0.1/LTP Reflection Add-on (Must Add To Play)/LTP 16x9 Real Time Reflections Add-on/LTP 16x9 RT Reflection 1920x1080 .pk3" \
42+
-file "${../bak/doom/ltp701}/Liquid Texture Pack V7.0.1/LTP Demo Map + Map Editing + Add-on Files/LTP Add-on Files/LTP - Doom Terrain Splashes.pk3" \
4443
-file ${../bak/doom/SimpleSlots.1.1.pk7} \
4544
-file ${../bak/doom/nashgore.pk3} \
4645
-file ${../bak/doom/cblood.pk3}
@@ -64,18 +63,16 @@ in
6463
${unst.gzdoom}/bin/gzdoom \
6564
-iwad ${../bak/doom/freedoom-0.13.0/freedoom2.wad} \
6665
-file ${../bak/doom/DMSF_ALX-R3.WAD} \
67-
-file ${../bak/doom/HD_Map_Enhancements.wad} \
68-
-file "${duhd}/1 lights2.wad" "${duhd}/8 DHTP Textures.pk3" "${duhd}/9 JFO.wad" "${duhd}/10 HD_SFX.wad" "${duhd}/12 Flashlight++.pk3" "${duhd}/13 Tilt++.pk3" "${duhd}/14 brightmaps2.wad" "${duhd}/16 d3snds.wad" "${duhd}/17 brutaldoom_stuff.wad" "${duhd}/19 SpriteShadow.wad" "${duhd}/20 WorldGamma.wad" "${duhd}/21 BloomBoost.wad" "${duhd}/22 MotionBlur.pk3" "${duhd}/23 hires_decals.wad" "${duhd}/24 Terrains.wad" "${duhd}/25 HD HUD.pk3" "${duhd}/26 Liquids.pk3" "${duhd}/27 marcelus_hd_sprites.pk3" "${duhd}/29 Universal Rain and Snow v3.pk3" "${duhd}/30 OST Remake.pk3" "${duhd}/31 texture_lights.wad" "${duhd}/0 Parallax PBR.pk3" \
6966
-file ${../bak/doom/CodeFX.pk3} \
7067
-file ${../bak/doom/CodeFXFire.pk3} \
7168
-file ${../bak/doom/CodeFXBlood.pk3} \
72-
-file "${../bak/doom/liquid}/Liquid Texture Pack/(GZDoom) Liquid Texture Pack V4.0.pk3" \
73-
-file "${../bak/doom/liquid}/Glowing Toxic Texture Pack/LTP V4.0 Glowing Toxic Texture Addon.pk3" \
74-
-file "${../bak/doom/liquid}/Shader Pack/LTP V4.0 Shader pack.pk3" \
75-
-file "${../bak/doom/liquid}/Shader Pack/LTP V4.0 Sky shader addon.pk3" \
69+
-file "${../bak/doom/ltp701}/Liquid Texture Pack V7.0.1/LTP V7.0.1.pk3" \
70+
-file "${../bak/doom/ltp701}/Liquid Texture Pack V7.0.1/LTP Reflection Add-on (Must Add To Play)/LTP 16x9 Real Time Reflections Add-on/LTP 16x9 RT Reflection 1920x1080 .pk3" \
71+
-file "${../bak/doom/ltp701}/Liquid Texture Pack V7.0.1/LTP Demo Map + Map Editing + Add-on Files/LTP Add-on Files/LTP - Doom Terrain Splashes.pk3" \
72+
-file ${../bak/doom/waterfix.pk3} \
7673
-file ${../bak/doom/AshesStandalone_V1_51/Resources/AshesSAMenu.pk3} \
7774
-file ${../bak/doom/AshesStandalone_V1_51/Resources/lightmodepatch.pk3} \
78-
-file ${../bak/doom/AshesStandalone_V1_51/Resources/Ashes2063Enriched2_23.pk3} \
75+
-file ${../bak/doom/Ashes_2063_Enriched_v2.23_RUS_v1.2.pk3} \
7976
-file ${../bak/doom/AshesStandalone_V1_51/Resources/Ashes2063EnrichedFDPatch.pk3} \
8077
-file ${../bak/doom/2063_Ash3sD.pk3} \
8178
-file ${../bak/doom/AshesMiniMods/AshesDMWstart.pk3} \

pub/vi/src/dioxus.nvim/.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# dioxus.nvim
2+
/test/
3+
4+
# Compiled Lua sources
5+
luac.out
6+
7+
# luarocks build files
8+
*.src.rock
9+
*.zip
10+
*.tar.gz
11+
12+
# Object files
13+
*.o
14+
*.os
15+
*.ko
16+
*.obj
17+
*.elf
18+
19+
# Precompiled Headers
20+
*.gch
21+
*.pch
22+
23+
# Libraries
24+
*.lib
25+
*.a
26+
*.la
27+
*.lo
28+
*.def
29+
*.exp
30+
31+
# Shared objects (inc. Windows DLLs)
32+
*.dll
33+
*.so
34+
*.so.*
35+
*.dylib
36+
37+
# Executables
38+
*.exe
39+
*.out
40+
*.app
41+
*.i*86
42+
*.x86_64
43+
*.hex
44+

pub/vi/src/dioxus.nvim/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 YuKun Liu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

pub/vi/src/dioxus.nvim/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# dioxus.nvim
2+
3+
> Dioxus Neovim Plugin
4+
5+
## Features
6+
7+
- Translate HTML to rsx
8+
- Format rsx code block
9+
- Check Dioxus code
10+
11+
![Dioxus-Check-Buffer](./notes/check-buffer.png)
12+
13+
## Installation
14+
15+
### Lazy.nvim
16+
17+
```lua
18+
{
19+
"mrxiaozhuox/dioxus.nvim",
20+
opts = {
21+
format = {
22+
split_line_attributes = true,
23+
},
24+
},
25+
ft = "rust",
26+
},
27+
```
28+
29+
## Commands
30+
31+
- `DxFormatBuffer`
32+
- `DxFormatInline`
33+
- `DxTranslateInline`
34+
- `DxTranslatePrompt`
35+
- `DxCheckBuffer`
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
local M = {}
2+
3+
local cli = require("dioxus.cli")
4+
local utils = require("dioxus.utils")
5+
local float = require("dioxus.float")
6+
7+
-- dioxus-cli check file
8+
M.check_buffer = function()
9+
local buffer_path = utils.get_current_buffer_path()
10+
11+
if not buffer_path then
12+
vim.notify("Cannot check unnamed buffer", vim.log.levels.ERROR)
13+
return
14+
end
15+
16+
if not cli.check_dx_cli() then
17+
vim.notify("dx (dioxus-cli) not found. Please install it first.", vim.log.levels.ERROR)
18+
return
19+
end
20+
21+
local dx_cli = cli.dx_path or "dx"
22+
local command = dx_cli .. " check --file " .. vim.fn.shellescape(buffer_path) .. " --json-output"
23+
24+
local output = vim.fn.system(command)
25+
26+
local content = ""
27+
local lines = vim.split(output, "\n")
28+
for _, line in ipairs(lines) do
29+
local success, value = pcall(vim.json.decode, line)
30+
if success then
31+
local temp = value.message or value.error or ""
32+
if vim.startswith(temp, "No issues found") then
33+
vim.notify("No issue found.", vim.log.levels.INFO)
34+
else
35+
content = content .. temp .. "\n"
36+
end
37+
end
38+
end
39+
40+
content = content:gsub("\27%[[%d;]+m", "")
41+
42+
if #content > 0 then
43+
float.create_float_window("Dioxus Check # Buffer", content)
44+
end
45+
end
46+
47+
return M
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
local M = {}
2+
3+
-- check dioxus cli
4+
M.check_dx_cli = function()
5+
if vim.fn.executable("dx") == 1 then
6+
return true
7+
end
8+
9+
-- check other possible path
10+
local common_paths = {
11+
-- Unix-liks
12+
vim.env.HOME .. "/.cargo/bin/dx",
13+
"/usr/local/bin/dx",
14+
"/usr/bin/dx",
15+
-- Windows
16+
vim.env.USERPROFILE .. "\\.cargo\\bin\\dx.exe",
17+
}
18+
19+
for _, path in ipairs(common_paths) do
20+
if vim.fn.executable(path) == 1 then
21+
M.dx_path = path
22+
return true
23+
end
24+
end
25+
26+
return false
27+
end
28+
29+
M.execute = function(args)
30+
if not M.check_dx_cli() then
31+
vim.notify("dx (dioxus-cli) not found. Please install it first.", vim.log.levels.ERROR)
32+
return nil
33+
end
34+
35+
local cli = M.dx_path or "dx"
36+
local command = cli .. " " .. args
37+
38+
local result = vim.fn.system(command)
39+
if vim.v.shell_error ~= 0 then
40+
vim.notify("[dx] failed: " .. result, vim.log.levels.ERROR)
41+
return nil
42+
end
43+
44+
return result
45+
end
46+
47+
return M
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
local M = {}
2+
3+
function M.create_float_window(title, content)
4+
-- add buffer
5+
local buf = vim.api.nvim_create_buf(false, true)
6+
7+
-- set content
8+
if type(content) == "string" then
9+
content = vim.split(content, "\n")
10+
end
11+
vim.api.nvim_buf_set_lines(buf, 0, -1, false, content)
12+
13+
-- window size & location
14+
local width = 100
15+
local height = math.min(#content, vim.o.lines - 10)
16+
local win_height = vim.o.lines
17+
local win_width = vim.o.columns
18+
local row = math.floor((win_height - height) / 2)
19+
local col = math.floor((win_width - width) / 2)
20+
21+
-- window option
22+
local opts = {
23+
relative = "editor",
24+
width = width,
25+
height = height,
26+
row = row,
27+
col = col,
28+
style = "minimal",
29+
border = "rounded",
30+
title = title,
31+
title_pos = "center",
32+
}
33+
34+
local win = vim.api.nvim_open_win(buf, true, opts)
35+
36+
vim.api.nvim_set_option_value("winblend", 10, { win = win })
37+
vim.api.nvim_set_option_value("cursorline", true, { win = win })
38+
39+
vim.api.nvim_set_option_value("modifiable", false, { buf = buf })
40+
vim.api.nvim_set_option_value("bufhidden", "wipe", { buf = buf })
41+
42+
vim.api.nvim_buf_set_keymap(buf, "n", "q", ":close<CR>", { noremap = true, silent = true })
43+
44+
return buf, win
45+
end
46+
47+
return M
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
local M = {}
2+
3+
M.default_opts = {
4+
split_line_attributes = false,
5+
}
6+
7+
local cli = require("dioxus.cli")
8+
9+
M.setup = function(opts)
10+
M.opts = vim.tbl_deep_extend("force", {}, M.default_opts, opts or {})
11+
end
12+
13+
M.format_buffer = function()
14+
local bufnr = vim.api.nvim_get_current_buf()
15+
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
16+
local content = table.concat(lines, "\n")
17+
18+
local temp_file = vim.fn.tempname() .. ".rs"
19+
local file = io.open(temp_file, "w")
20+
if not file then
21+
vim.notify("Failed to create temporary file", vim.log.levels.ERROR)
22+
return
23+
end
24+
file:write(content)
25+
file:close()
26+
27+
local command = "fmt --file " .. vim.fn.shellescape(temp_file)
28+
29+
-- additonal args
30+
if M.opts and M.opts.split_line_attributes then
31+
command = command .. " --split-line-attributes"
32+
end
33+
34+
local output = cli.execute(command)
35+
36+
if not output then
37+
return
38+
end
39+
40+
file = io.open(temp_file, "r")
41+
if not file then
42+
vim.notify("Failed to read formatted file", vim.log.levels.ERROR)
43+
os.remove(temp_file)
44+
return
45+
end
46+
47+
local formatted_content = file:read("*all")
48+
file:close()
49+
os.remove(temp_file)
50+
51+
if formatted_content == content then
52+
return
53+
end
54+
55+
local formatted_lines = vim.split(formatted_content, "\n", { trimempty = true })
56+
57+
local cursor_pos = vim.api.nvim_win_get_cursor(0)
58+
59+
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, formatted_lines)
60+
61+
vim.api.nvim_win_set_cursor(0, cursor_pos)
62+
end
63+
64+
M.format_selection = function()
65+
local start_buf, start_row, start_col, _ = unpack(vim.fn.getpos("'<"))
66+
local _, end_row, end_col, _ = unpack(vim.fn.getpos("'>"))
67+
68+
local lines = vim.fn.getline(start_row, end_row)
69+
70+
local content = type(lines) == "table" and table.concat(lines, "\n") or tostring(lines)
71+
72+
local command = "fmt --raw " .. vim.fn.shellescape(content)
73+
74+
-- additonal args
75+
if M.opts and M.opts.split_line_attributes then
76+
command = command .. " --split-line-attributes"
77+
end
78+
79+
local output = cli.execute(command)
80+
if not output then
81+
return
82+
end
83+
84+
local end_line_text = vim.api.nvim_buf_get_lines(start_buf, end_row - 1, end_row, false)[1] or ""
85+
local actual_end_col = math.min(end_col, #end_line_text)
86+
87+
local output_lines = vim.split(output, "\n", { trimempty = true })
88+
89+
if #output_lines == 0 then
90+
output_lines = { "" }
91+
end
92+
93+
vim.api.nvim_buf_set_text(start_buf, start_row - 1, start_col - 1, end_row - 1, actual_end_col, output_lines)
94+
end
95+
96+
return M

0 commit comments

Comments
 (0)