fix(vim): make windows compatible

This commit is contained in:
2025-10-31 09:18:34 +01:00
parent 0f72c8a7d7
commit 901df5cef4
+56 -18
View File
@@ -1,4 +1,9 @@
" vim: set foldmethod=marker: " vim: set foldmethod=marker:
" {{{1 Platform Detection
let s:is_windows = has('win32') || has('win64')
let s:is_unix = has('unix')
" {{{1 Global Variables " {{{1 Global Variables
let g:skip_defaults_vim = 1 let g:skip_defaults_vim = 1
@@ -18,11 +23,15 @@ let g:netrw_sort_options = 'i'
let g:netrw_sort_sequence = '[\/]\s*,*' let g:netrw_sort_sequence = '[\/]\s*,*'
let g:netrw_special_syntax = v:true let g:netrw_special_syntax = v:true
let g:netrw_timefmt = '%d-%m-%Y %H:%M' let g:netrw_timefmt = '%d-%m-%Y %H:%M'
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum" " Terminal codes (Unix/Linux only)
let &t_SI = "\e[6 q" if s:is_unix
let &t_EI = "\e[2 q" let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_SR = "\e[4 q" let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
let &t_SI = "\e[6 q"
let &t_EI = "\e[2 q"
let &t_SR = "\e[4 q"
endif
" {{{1 Options " {{{1 Options
@@ -44,7 +53,11 @@ set nosmarttab
set foldlevelstart=99 set foldlevelstart=99
set foldmethod=indent set foldmethod=indent
set foldignore= set foldignore=
set guifont=Iosevka\ Custom\ 12 if s:is_windows
set guifont=Iosevka_Custom:h12
else
set guifont=Iosevka\ Custom\ 12
endif
set completeopt=menu,menuone,preview,noinsert,noselect set completeopt=menu,menuone,preview,noinsert,noselect
set matchpairs=(:),{:},[:],<:> set matchpairs=(:),{:},[:],<:>
set linebreak set linebreak
@@ -108,9 +121,11 @@ imap <C-a> <C-o>^
imap <C-e> <C-o>$ imap <C-e> <C-o>$
imap <C-k> <C-o>C imap <C-k> <C-o>C
imap <C-d> <C-o>x imap <C-d> <C-o>x
execute "set <M-f>=\ef" if !s:is_windows
execute "set <M-b>=\eb" execute "set <M-f>=\ef"
execute "set <M-d>=\ed" execute "set <M-b>=\eb"
execute "set <M-d>=\ed"
endif
imap <M-f> <C-o>w imap <M-f> <C-o>w
imap <M-b> <C-o>b imap <M-b> <C-o>b
imap <M-d> <C-o>dw imap <M-d> <C-o>dw
@@ -252,8 +267,13 @@ let g:NERDTreeShowHidden = 1
let g:NERDTreeWinSize = 50 let g:NERDTreeWinSize = 50
let g:NERDTreeMinimalUI = 1 let g:NERDTreeMinimalUI = 1
let g:NERDTreeCascadeSingleChildDir = 0 let g:NERDTreeCascadeSingleChildDir = 0
let g:NERDTreeRemoveFileCmd = "gio trash " if s:is_windows
let g:NERDTreeRemoveDirCmd = "gio trash " let g:NERDTreeRemoveFileCmd = "del /q "
let g:NERDTreeRemoveDirCmd = "rmdir /s /q "
else
let g:NERDTreeRemoveFileCmd = "gio trash "
let g:NERDTreeRemoveDirCmd = "gio trash "
endif
let g:NERDTreeMapActivateNode = "<C-l>" let g:NERDTreeMapActivateNode = "<C-l>"
let g:NERDTreeMapCloseDir = "<C-h>" let g:NERDTreeMapCloseDir = "<C-h>"
@@ -304,7 +324,11 @@ augroup END
" {{{3 Undotree " {{{3 Undotree
let g:undotree_WindowLayout = 2 let g:undotree_WindowLayout = 2
let g:undotree_DiffCommand = "diff -u" if s:is_windows
let g:undotree_DiffCommand = "FC"
else
let g:undotree_DiffCommand = "diff -u"
endif
let g:undotree_SplitWidth = 50 let g:undotree_SplitWidth = 50
let g:undotree_DiffpanelHeight = 20 let g:undotree_DiffpanelHeight = 20
@@ -371,14 +395,28 @@ let g:fuzzbox_window_layout = {
" {{{2 Install " {{{2 Install
let s:plug_file = expand('$HOME/.vim/autoload/plug.vim') if s:is_windows
if !filereadable(s:plug_file) let s:plug_file = expand('$HOME/vimfiles/autoload/plug.vim')
silent execute '!curl -fkLo ' . s:plug_file ' --create-dirs' let s:plug_dir = expand('$HOME/vimfiles/plugged')
\ ' https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' else
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC let s:plug_file = expand('$HOME/.vim/autoload/plug.vim')
let s:plug_dir = expand('$HOME/.vim/plugged')
endif endif
let s:plug_dir = expand('$HOME/.vim/plugged') if !filereadable(s:plug_file)
if s:is_windows
silent execute '!powershell -Command "'
\ . 'New-Item -ItemType Directory -Force -Path '
\ . fnamemodify(s:plug_file, ':h') . '; '
\ . 'Invoke-WebRequest -Uri '
\ . 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim '
\ . '-OutFile ' . s:plug_file . '"'
else
silent execute '!curl -fkLo ' . s:plug_file ' --create-dirs'
\ ' https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
endif
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin(s:plug_dir) call plug#begin(s:plug_dir)
Plug 'joshdick/onedark.vim' Plug 'joshdick/onedark.vim'
Plug 'tpope/vim-commentary' Plug 'tpope/vim-commentary'