Skip to content

Commit abf28a0

Browse files
committed
Updated setup scripts
1 parent b468ad0 commit abf28a0

File tree

4 files changed

+128
-42
lines changed

4 files changed

+128
-42
lines changed

.vimrc

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
22
" Marciovmf (N)VIM config
33
" https://github.com/marciovmf/vimstuff
4+
" v2.0
45
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
56
" -NEOVIDE---------------------------------------------------------------------
67

ginit.vim

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
GuiPopupmenu 0
1+
" https://github.com/marciovmf/vimstuff/ginit.vim
2+

link.bat

+104-41
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,123 @@
11
@echo off
2-
3-
REM ----------------------.vimrc---------------------------
2+
setlocal
43
pushd %~dp0
5-
fsutil hardlink list .vimrc|findstr "%HOMEPATH%" 2>&1>nul
6-
IF %ERRORLEVEL% == 0 (
7-
echo .vimrc was already linked
8-
) ELSE (
9-
IF EXIST "%USERPROFILE%\\\.vimrc" (
4+
5+
REM ------------------------python-------------------------
6+
py --version 2>&1>nul
7+
if not errorlevel 0 (
8+
winget install Python -e --source winget
9+
if errorlevel == 1 (
10+
echo [FAIL] Python not found and could not be installed
11+
set FAIL=1
12+
) else (
13+
echo [ OK ] Python not found and could not be installed
14+
)
15+
) else (
16+
echo [ OK ] Python ok
17+
)
18+
19+
REM -------------------------git---------------------------
20+
where git | find "git.exe" 2>&1>nul
21+
if errorlevel == 1 (
22+
winget install --id Git.Git -e --source winget
23+
if errorlevel == 1 (
24+
echo [FAIL] Git not found and could not be installed
25+
set FAIL=1
26+
) else (
27+
echo [ OK ] Git not found and could not be installed
28+
)
29+
) else (
30+
echo [ OK ] Git ok
31+
)
32+
33+
34+
REM --------------------- .vimrc --------------------------
35+
set TARGET=%HOMEPATH%\.vimrc
36+
fsutil hardlink list .vimrc | find "%TARGET%" 2>&1>nul
37+
if errorlevel == 1 (
38+
if EXIST %TARGET% (
1039
set BKPFILENAME=.vimrc-backup-%DATE:/=-%-%TIME::=.%
11-
echo The file ' %USERPROFILE%\.vimrc' exists and is not linked to %CD%\.vimrc
12-
echo Renaming it to '%BKPFILENAME%' up the existing file before creating the link
13-
ren %USERPROFILE%\.vimrc %BKPFILENAME%
40+
echo The file '%TARGET%' already exists and will be renamed to '%BKPFILENAME%'
41+
ren "%TARGET%" "%BKPFILENAME%"
42+
)
43+
44+
mklink /h "%TARGET%" .vimrc 2>&1>nul
45+
if errorlevel == 0 (
46+
echo [ OK ] %TARGET% [link created]
47+
) else (
48+
echo [FAIL] %TARGET% link could not be created
49+
set FAIL=1
1450
)
15-
mklink /h %USERPROFILE%\.vimrc .vimrc
51+
) else (
52+
echo [ OK ] %TARGET%
1653
)
1754

18-
if NOT EXIST %LOCALAPPDATA%\nvim mkdir %LOCALAPPDATA%\nvim
1955

2056
REM ---------------------init.vim--------------------------
21-
fsutil hardlink list init.vim|findstr "%LOCALAPPDATA:~2%\nvim\init\.vim" 2>&1>NUL
22-
IF %ERRORLEVEL% == 0 (
23-
echo init.vim was already linked
24-
) ELSE (
25-
IF EXIST "%LOCALAPPDATA%\nvim\init.vim" (
57+
if NOT EXIST %LOCALAPPDATA%\nvim mkdir %LOCALAPPDATA%\nvim
58+
set TARGET=%LOCALAPPDATA:~2%\nvim\init.vim
59+
fsutil hardlink list init.vim | find "%TARGET%" 2>&1>NUL
60+
if errorlevel == 1 (
61+
if EXIST %TARGET% (
2662
set BKPFILENAME=init.vim-backup-%DATE:/=-%-%TIME::=.%
27-
echo The file ' %LOCALAPPDATA%\nvim\init.vim' exists and is not linked to %CD%\init.vim
28-
echo Renaming it to '%BKPFILENAME%' up the existing file before creating the link
29-
ren %LOCALAPPDATA%\nvim\init.vim %BKPFILENAME%
63+
echo The file '%TARGET%' already exists and will be renamed to '%BKPFILENAME%'
64+
ren "%TARGET%" "%BKPFILENAME%"
3065
)
31-
mklink /h %LOCALAPPDATA%\nvim\init.vim init.vim
66+
67+
mklink /h "%TARGET%" init.vim 2>&1>nul
68+
if errorlevel == 0 (
69+
echo [ OK ] %TARGET% [link created]
70+
) else (
71+
echo [FAIL] %TARGET% link could not be created
72+
set FAIL=1
73+
)
74+
) else (
75+
echo [ OK ] %TARGET%
3276
)
3377

34-
REM ---------------------ginit.vim-------------------------
35-
fsutil hardlink list ginit.vim|findstr "%LOCALAPPDATA:~2%\nvim\ginit\.vim" 2>&1>NUL
36-
IF %ERRORLEVEL% == 0 (
37-
echo ginit.vim was already linked
38-
) ELSE (
39-
IF EXIST "%LOCALAPPDATA%\nvim\ginit.vim" (
78+
REM ---------------------ginit.vim--------------------------
79+
set TARGET=%LOCALAPPDATA:~2%\nvim\ginit.vim
80+
fsutil hardlink list ginit.vim | find "%TARGET%" 2>&1>NUL
81+
if errorlevel == 1 (
82+
if EXIST %TARGET% (
4083
set BKPFILENAME=ginit.vim-backup-%DATE:/=-%-%TIME::=.%
41-
echo The file ' %LOCALAPPDATA%\nvim\ginit.vim' exists and is not linked to %CD%\ginit.vim
42-
echo Renaming it to '%BKPFILENAME%' up the existing file before creating the link
43-
ren %LOCALAPPDATA%\nvim\ginit.vim %BKPFILENAME%
84+
echo The file '%TARGET%' already exists and will be renamed to '%BKPFILENAME%'
85+
ren "%TARGET%" "%BKPFILENAME%"
86+
)
87+
88+
mklink /h "%TARGET%" ginit.vim 2>&1>nul
89+
if errorlevel == 0 (
90+
echo [ OK ] %TARGET% [link created]
91+
) else (
92+
echo [FAIL] %TARGET% link could not be created
93+
set FAIL=1
4494
)
45-
mklink /h %LOCALAPPDATA%\nvim\ginit.vim ginit.vim
95+
) else (
96+
echo [ OK ] %TARGET%
4697
)
4798

48-
REM ------------------------.vim---------------------------
49-
dir /AL %USERPROFILE%\ | findstr %CD%\\\.vim 2>&1>NUL
50-
IF %ERRORLEVEL% == 0 (
51-
echo .vim folder was already linked
52-
) ELSE (
53-
IF EXIST "%USERPROFILE%\.vim" (
99+
REM ---------------------.vim folder------------------------
100+
set TARGET=%USERPROFILE:~2%\.vim
101+
dir /AL %USERPROFILE%\ | find "%CD%\.vim" 2>&1>NUL
102+
if errorlevel == 1 (
103+
if EXIST %TARGET% (
54104
set BKPFILENAME=.vim-backup-%DATE:/=-%-%TIME::=.%
55-
echo The fodler ' %USERPROFILE%\.vim' exists and is not linked to %CD%\.vim
56-
echo Renaming it to '%BKPFILENAME%' up the existing file before creating the link
57-
ren %USERPROFILE%\.vim %BKPFILENAME%
105+
echo The folder '%TARGET%' already exists and will be renamed to '%BKPFILENAME%'
106+
ren "%TARGET%" "%BKPFILENAME%"
107+
)
108+
109+
mklink /j "%TARGET%" "%CD%\.vim"
110+
if errorlevel == 0 (
111+
echo [ OK ] %TARGET% [link created]
112+
) else (
113+
echo [FAIL] %TARGET% link could not be created
114+
set FAIL=1
58115
)
59-
mklink /j %USERPROFILE%\.vim %CD%\.vim
116+
) else (
117+
echo [ OK ] %TARGET%
118+
)
119+
120+
if not defined FAIL (
121+
echo "Vim will open to install packages..."
122+
nvim-qt -- -c PlugInstall
60123
)

setup.bat

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@echo off
2+
:: Check if the script is already elevated
3+
:: If not elevated, request elevation and set a flag to prevent looping
4+
5+
if "%ADMIN_ELEVATED%" NEQ "1" (
6+
:: Attempt to perform a task that requires admin privileges to check if already elevated
7+
>nul 2>&1 "%SystemRoot%\system32\cacls.exe %SystemRoot%\system32\config\system"
8+
9+
:: If not elevated, restart with admin rights
10+
if '%errorlevel%' NEQ '0' (
11+
echo Requesting Administrator permissions...
12+
set "ADMIN_ELEVATED=1"
13+
powershell -Command "Start-Process '%~f0' -Verb RunAs -ArgumentList 'ADMIN_ELEVATED=1'"
14+
exit /b
15+
)
16+
)
17+
18+
:: If already running as administrator, proceed to call the child script
19+
echo Running link.bat with Administrator privileges...
20+
call "%~dp0link.bat"
21+
pause

0 commit comments

Comments
 (0)