aboutsummaryrefslogtreecommitdiff
path: root/linux/home
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2025-09-05 05:43:27 +0200
committersrdusr <trevorgray@srdusr.com>2025-09-05 05:43:27 +0200
commitea2ea8dfa5718766865feaecda8162cec40e6ca3 (patch)
tree8599ffb7efcf8c840561eaeb71938cdc84b820c2 /linux/home
parent68f64c067979cf24e5dbaeaa20e7b7cf53252f97 (diff)
downloaddotfiles-ea2ea8dfa5718766865feaecda8162cec40e6ca3.tar.gz
dotfiles-ea2ea8dfa5718766865feaecda8162cec40e6ca3.zip
New vim config
Diffstat (limited to 'linux/home')
-rw-r--r--linux/home/.vim/autoload/autoload/statusline.vim267
-rw-r--r--linux/home/.vim/autoload/statusline.vim312
-rw-r--r--linux/home/.vim/colors/colorscheme.vim247
-rw-r--r--linux/home/.vim/colors/default.vim175
-rw-r--r--linux/home/.vim/ftplugin/after/vim.vim12
-rw-r--r--linux/home/.vim/vimrc904
6 files changed, 1531 insertions, 386 deletions
diff --git a/linux/home/.vim/autoload/autoload/statusline.vim b/linux/home/.vim/autoload/autoload/statusline.vim
new file mode 100644
index 0000000..bf5f972
--- /dev/null
+++ b/linux/home/.vim/autoload/autoload/statusline.vim
@@ -0,0 +1,267 @@
+" statusline.vim
+
+if exists('g:loaded_statusline') | finish | endif
+let g:loaded_statusline = 1
+
+" --- Detect Nerd Fonts ---
+function! s:HasNerdFonts()
+ if exists('g:statusline_nerd_fonts')
+ return g:statusline_nerd_fonts
+ endif
+
+ if executable('fc-list')
+ let l:output = system('fc-list | grep -i nerd')
+ if len(split(l:output, '\n')) > 0
+ return 1
+ endif
+ endif
+
+ return 0
+endfunction
+
+let g:statusline_has_nerd_fonts = s:HasNerdFonts()
+
+" --- Color Palette ---
+let g:StslineColorGreen = '#2BBB4F'
+let g:StslineColorBlue = '#4799EB'
+let g:StslineColorViolet = '#986FEC'
+let g:StslineColorYellow = '#D7A542'
+let g:StslineColorOrange = '#EB754D'
+let g:StslineColorLight = '#C0C0C0'
+let g:StslineColorDark = '#080808'
+let g:StslineColorDark1 = '#181818'
+let g:StslineColorDark2 = 'NONE'
+let g:StslineColorDark3 = '#303030'
+
+let g:StslineBackColor = g:StslineColorDark2
+let g:StslineOnBackColor = g:StslineColorLight
+let g:StslinePriColor = g:StslineColorGreen
+let g:StslineOnPriColor = g:StslineColorDark
+let g:StslineSecColor = g:StslineColorDark3
+let g:StslineOnSecColor = g:StslineColorLight
+
+" --- Highlight Groups ---
+" Initial setup of highlight groups (will be updated by UpdateStslineColors)
+execute 'highlight StslinePriColorBG guifg=' . g:StslineOnPriColor . ' guibg=' . g:StslinePriColor
+execute 'highlight StslineSecColorFG guifg=' . g:StslineSecColor . ' guibg=' . g:StslineBackColor
+execute 'highlight StslineSecColorBG guifg=' . g:StslineColorLight . ' guibg=' . g:StslineSecColor
+execute 'highlight StslineBackColorBG guifg=' . g:StslineColorLight . ' guibg=' . g:StslineBackColor
+execute 'highlight StslineBackColorFGSecColorBG guifg=' . g:StslineBackColor . ' guibg=' . g:StslineSecColor
+execute 'highlight StslineSecColorFGBackColorBG guifg=' . g:StslineSecColor . ' guibg=' . g:StslineBackColor
+execute 'highlight StslineModColorFG guifg=' . g:StslineColorYellow . ' guibg=' . g:StslineBackColor
+execute 'highlight StslinePriColorBG_SecColorBG guifg=' . g:StslinePriColor . ' guibg=' . g:StslineSecColor
+execute 'highlight StslineModeSep guifg=' . g:StslinePriColor . ' guibg=' . g:StslineSecColor
+execute 'highlight StslineGitSep guifg=' . g:StslineSecColor . ' guibg=' . g:StslineColorDark2
+
+" --- Statusline Settings ---
+if has('nvim')
+ set laststatus=3
+else
+ set laststatus=2
+endif
+
+"set noshowmode
+"set termguicolors
+
+let space = ''
+
+" Get Statusline mode & also set primary color for that mode
+function! autoload#statusline#StslineMode() abort
+ let l:CurrentMode = mode()
+
+ if l:CurrentMode ==# 'n'
+ let g:StslinePriColor = g:StslineColorGreen
+ let b:CurrentMode = 'NORMAL '
+ elseif l:CurrentMode ==# 'i'
+ let g:StslinePriColor = g:StslineColorViolet
+ let b:CurrentMode = 'INSERT '
+ elseif l:CurrentMode ==# 'c'
+ let g:StslinePriColor = g:StslineColorYellow
+ let b:CurrentMode = 'COMMAND'
+ elseif l:CurrentMode ==# 'v'
+ let g:StslinePriColor = g:StslineColorBlue
+ let b:CurrentMode = 'VISUAL '
+ elseif l:CurrentMode ==# '\<C-v>'
+ let g:StslinePriColor = g:StslineColorBlue
+ let b:CurrentMode = 'V-BLOCK'
+ elseif l:CurrentMode ==# 'V'
+ let g:StslinePriColor = g:StslineColorBlue
+ let b:CurrentMode = 'V-LINE '
+ elseif l:CurrentMode ==# 'R'
+ let g:StslinePriColor = g:StslineColorViolet
+ let b:CurrentMode = 'REPLACE'
+ elseif l:CurrentMode ==# 's'
+ let g:StslinePriColor = g:StslineColorBlue
+ let b:CurrentMode = 'SELECT '
+ elseif l:CurrentMode ==# 't'
+ let g:StslinePriColor = g:StslineColorYellow
+ let b:CurrentMode = 'TERM '
+ elseif l:CurrentMode ==# '!'
+ let g:StslinePriColor = g:StslineColorYellow
+ let b:CurrentMode = 'SHELL '
+ else
+ let g:StslinePriColor = g:StslineColorGreen
+ endif
+
+ call autoload#statusline#UpdateStslineColors()
+
+ return b:CurrentMode
+endfunction
+
+function! autoload#statusline#UpdateStslineColors() abort
+ execute 'highlight StslinePriColorBG guifg=' . g:StslineOnPriColor . ' guibg=' . g:StslinePriColor
+ execute 'highlight StslinePriColorBGBold guifg=' . g:StslineOnPriColor . ' guibg=' . g:StslinePriColor . ' gui=bold'
+ execute 'highlight StslinePriColorFG guifg=' . g:StslinePriColor . ' guibg=' . g:StslineBackColor
+ execute 'highlight StslinePriColorFGSecColorBG guifg=' . g:StslinePriColor . ' guibg=' . g:StslineSecColor
+ execute 'highlight StslineModeSep guifg=' . g:StslinePriColor . ' guibg=' . g:StslineSecColor
+ execute 'highlight StslineGitSep guifg=' . g:StslineSecColor . ' guibg=' . g:StslineColorDark2
+ execute 'highlight StslineSecColorBG guifg=' . g:StslineColorLight . ' guibg=' . g:StslineSecColor
+ execute 'highlight StslineBackColorBG guifg=' . g:StslineColorLight . ' guibg=' . g:StslineBackColor
+ execute 'highlight StslineBackColorFGSecColorBG guifg=' . g:StslineBackColor . ' guibg=' . g:StslineSecColor
+ execute 'highlight StslineSecColorFGBackColorBG guifg=' . g:StslineSecColor . ' guibg=' . g:StslineBackColor
+ execute 'highlight StslineModColorFG guifg=' . g:StslineColorYellow . ' guibg=' . g:StslineBackColor
+ execute 'highlight StslinePriColorBG_SecColorBG guifg=' . g:StslinePriColor . ' guibg=' . g:StslineSecColor
+ execute 'highlight StslineSecColorFG guifg=' . g:StslineSecColor . ' guibg=' . g:StslineBackColor
+endfunction
+
+function! autoload#statusline#GetGitBranch() abort
+ let b:GitBranch = ''
+ try
+ let l:dir = expand('%:p:h')
+ let l:gitrevparse = system("git -C ".l:dir." rev-parse --abbrev-ref HEAD")
+ if !v:shell_error
+ let icon = g:statusline_has_nerd_fonts ? '  ' : ' [git] '
+ let b:GitBranch = icon . substitute(l:gitrevparse, '\n', '', 'g') . ' '
+ endif
+ catch
+ endtry
+endfunction
+
+function! autoload#statusline#GetFileType() abort
+ if !g:statusline_has_nerd_fonts
+ let b:FiletypeIcon = ''
+ return
+ endif
+ if &filetype ==# 'typescript' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'html' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'scss' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'css' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'javascript' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'javascriptreact' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'markdown' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'sh' || &filetype ==# 'zsh' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'vim' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'rust' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'ruby' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'cpp' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'c' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'go' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'lua' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'haskell' | let b:FiletypeIcon = ' '
+ else | let b:FiletypeIcon = ' '
+ endif
+endfunction
+
+function! autoload#statusline#ActivateStatusline() abort
+ call autoload#statusline#GetFileType()
+ call autoload#statusline#GetGitBranch() " Ensure git branch is updated
+
+ let current_mode_str = autoload#statusline#StslineMode()
+ call autoload#statusline#UpdateStslineColors()
+
+ let readonly_icon = g:statusline_has_nerd_fonts ? ' ' : '[RO] '
+ let modified_icon = g:statusline_has_nerd_fonts ? ' ' : '[+] '
+ let git_sep = g:statusline_has_nerd_fonts ? '' : ' '
+ let file_sep1 = g:statusline_has_nerd_fonts ? ' ' : ' '
+ let file_sep2 = g:statusline_has_nerd_fonts ? '' : ''
+
+ " Get dynamic parts as simple strings
+ let git_status_str = get(b:, "coc_git_status", get(b:, "GitBranch", ""))
+ let git_blame_str = get(b:, "coc_git_blame", "")
+ let filetype_icon_str = get(b:, "FiletypeIcon", "")
+ let file_encoding_str = ''
+ if &fenc != "utf-8"
+ let file_encoding_str = &fenc . ' '
+ endif
+
+ " Build the statusline as a static string
+ let l:statusline = ''
+
+ let l:statusline .= '%#StslinePriColorBG# ' . current_mode_str . ''
+ let l:statusline .= '%#StslineModeSep#' . git_sep
+ let l:statusline .= '%#StslineSecColorBG#' . git_status_str . git_blame_str
+ let l:statusline .= '%#StslineGitSep#' . git_sep
+
+ " File info (Readonly, Modified, Filename)
+ let l:statusline .= '%#StslinePriColorFG#'
+ if &readonly
+ let l:statusline .= readonly_icon
+ endif
+ let l:statusline .= ' %F '
+ if &modified
+ let l:statusline .= modified_icon
+ endif
+
+ " Right align everything after this
+ let l:statusline .= '%='
+
+ " Right side (Filetype, Encoding, Position)
+ let l:statusline .= '%#StslinePriColorFG# ' . filetype_icon_str . '%y'
+ let l:statusline .= '%#StslineSecColorFG#' . file_sep1
+ "let l:statusline .= '%#StslineSecColorBG# ' . file_encoding_str
+ let l:statusline .= '%#StslinePriColorFGSecColorBG#' . file_sep2
+ let l:statusline .= '%#StslinePriColorBG# %p%% %#StslinePriColorBGBold#%l%#StslinePriColorBG#/%L :%c '
+ let l:statusline .= '%#StslineBackColorBG#'
+
+ " Set the statusline for the current buffer
+ let &l:statusline = l:statusline
+endfunction
+
+function! autoload#statusline#DeactivateStatusline() abort
+ let git_sep = g:statusline_has_nerd_fonts ? '' : ''
+ let readonly_icon = g:statusline_has_nerd_fonts ? ' ' : '[RO] '
+ let modified_icon = g:statusline_has_nerd_fonts ? ' ' : '[+] '
+
+ " NOTE: This DeactivateStatusline function still uses %{} for dynamic parts.
+ " If you encounter general E518 or other issues related to %{} expressions,
+ " you will need to refactor this function to build a static string
+ " similar to how ActivateStatusline now does it.
+ if !exists("b:GitBranch") || b:GitBranch == ''
+ let statusline =
+ \ '%#StslineSecColorBG# INACTIVE ' .
+ \ '%{get(b:,"coc_git_statusline",b:GitBranch)}%{get(b:,"coc_git_blame","")}' .
+ \ '%#StslineBackColorFGSecColorBG#' . git_sep .
+ \ '%#StslineBackColorBG# %{&readonly?"' . readonly_icon . '":""}%F ' .
+ \ '%#StslineModColorFG#%{&modified?"' . modified_icon . '":""}' .
+ \ '%=%#StslineBackColorBG# %{b:FiletypeIcon}%{&filetype}' .
+ \ '%#StslineSecColorFGBackColorBG# | %p%% %l/%L :%c'
+ else
+ let statusline =
+ \ '%#StslineSecColorBG# %{get(b:,"coc_git_statusline",b:GitBranch)}%{get(b:,"coc_git_blame","")}' .
+ \ '%#StslineBackColorFGSecColorBG#' . git_sep .
+ \ '%#StslineBackColorBG# %{&readonly?"' . readonly_icon . '":""}%F ' .
+ \ '%#StslineModColorFG#%{&modified?"' . modified_icon . '":""}' .
+ \ '%=%#StslineBackColorBG# %{b:FiletypeIcon}%{&filetype}' .
+ \ '%#StslineSecColorFGBackColorBG# | %p%% %l/%L :%c'
+ endif
+
+ execute 'setlocal statusline=' . substitute(statusline, '"', '\\"', 'g')
+endfunction
+
+augroup StatuslineGit
+ autocmd!
+ autocmd BufEnter * call autoload#statusline#GetGitBranch()
+augroup END
+
+augroup SetStsline
+ autocmd!
+ autocmd BufEnter,WinEnter * call autoload#statusline#ActivateStatusline()
+ autocmd ModeChanged * call autoload#statusline#ActivateStatusline()
+augroup END
+
+augroup StatuslineAutoReload
+ autocmd!
+ autocmd BufWritePost statusline.vim source <afile> | call autoload#statusline#ActivateStatusline()
+augroup END
+
+"call autoload#statusline#ActivateStatusline()
diff --git a/linux/home/.vim/autoload/statusline.vim b/linux/home/.vim/autoload/statusline.vim
index 5e5a671..bf5f972 100644
--- a/linux/home/.vim/autoload/statusline.vim
+++ b/linux/home/.vim/autoload/statusline.vim
@@ -1,105 +1,69 @@
-"" This was made by Reddit user u/SamLovesNotion. Also with the help of - https://tdaly.co.uk/projects/vim-statusline-generator/ for learning the syntax. Sorry for English & grammar, this post was made in hurry.
-
-" Images - https://www.reddit.com/r/vim/comments/ld8h2j/i_made_a_status_line_from_scratch_no_plugins_used/
-" I have used Nerd icon fonts. Icons won't work without them. https://github.com/ryanoasis/nerd-fonts/
-
-" This statusline looks exactly like Vim Airline (even more customizable & powerful) & loads faster than Vim airline. Only take few ms to load.
-
-" STARTUP TIME - With Vim Airline - ~250ms. With this statusline - ~100ms. Without any statusline - ~98ms.
-
-" Add all of this at the end of your vimrc OR Create separate file like 'statusline.vim' & 'colorsgroup.vim' & source those files in your main vimrc.
-" e.g. source "~/.config/vim/statusline.vim"
-
-
-
-
" statusline.vim
-" NOTE: This has been edited to fit my needs and is intended to be autoloaded in the autoload directory: "~/.vim/autoload/statusline.vim"
-
if exists('g:loaded_statusline') | finish | endif
let g:loaded_statusline = 1
-" Color highlighting groups
-" Add this AFTER `colorscheme` option in your vimrc. Otherwise your colorscheme will clear these highlightings.
-" OR use ColorScheme autocommand. VERY IMPORTANT.
+" --- Detect Nerd Fonts ---
+function! s:HasNerdFonts()
+ if exists('g:statusline_nerd_fonts')
+ return g:statusline_nerd_fonts
+ endif
+
+ if executable('fc-list')
+ let l:output = system('fc-list | grep -i nerd')
+ if len(split(l:output, '\n')) > 0
+ return 1
+ endif
+ endif
+
+ return 0
+endfunction
-" Color pallet
-" Green - #2BBB4F (BG) - #080808 (FG)
-" Blue - #4799EB
-" Violet - #986FEC
-" Yellow - #D7A542
-" Orange - #EB754D
-" Grey1 - #202020
-" Grey - #303030
+let g:statusline_has_nerd_fonts = s:HasNerdFonts()
-" Define color variables
+" --- Color Palette ---
let g:StslineColorGreen = '#2BBB4F'
let g:StslineColorBlue = '#4799EB'
let g:StslineColorViolet = '#986FEC'
let g:StslineColorYellow = '#D7A542'
let g:StslineColorOrange = '#EB754D'
-
let g:StslineColorLight = '#C0C0C0'
let g:StslineColorDark = '#080808'
let g:StslineColorDark1 = '#181818'
-let g:StslineColorDark2 = '#202020'
+let g:StslineColorDark2 = 'NONE'
let g:StslineColorDark3 = '#303030'
-" Define colors
let g:StslineBackColor = g:StslineColorDark2
let g:StslineOnBackColor = g:StslineColorLight
-"let g:StslinePriColor = g:StslineColorGreen
+let g:StslinePriColor = g:StslineColorGreen
let g:StslineOnPriColor = g:StslineColorDark
let g:StslineSecColor = g:StslineColorDark3
let g:StslineOnSecColor = g:StslineColorLight
-" Create highlight groups
-execute 'highlight StslineSecColorFG guifg=' . g:StslineSecColor ' guibg=' . g:StslineBackColor
-execute 'highlight StslineSecColorBG guifg=' . g:StslineColorLight ' guibg=' . g:StslineSecColor
-execute 'highlight StslineBackColorBG guifg=' . g:StslineColorLight ' guibg=' . g:StslineBackColor
-execute 'highlight StslineBackColorFGSecColorBG guifg=' . g:StslineBackColor ' guibg=' . g:StslineSecColor
-execute 'highlight StslineSecColorFGBackColorBG guifg=' . g:StslineSecColor ' guibg=' . g:StslineBackColor
-execute 'highlight StslineModColorFG guifg=' . g:StslineColorYellow ' guibg=' . g:StslineBackColor
-
-" Statusline
-" Enable statusline
-set laststatus=2
-" Disable showmode - i.e. Don't show mode like --INSERT-- in current statusline.
-set noshowmode
-
-" Enable GUI colors for terminals (Some terminals may not support this, so you'll have to *manually* set color pallet for tui colors.)
-set termguicolors
-
-
-
-" Understand statusline elements
-
-" %{StslineMode()} = Output of a function
-" %#StslinePriColorBG# = Highlight group
-" %F, %c, etc. are variables which contain value like - current file path, current colums, etc.
-" %{&readonly?\"\ \":\"\"} = If file is readonly ? Then "Lock icon" Else : "Nothing"
-" %{get(b:,'coc_git_status',b:GitBranch)} = If b:coc_git_status efists, then it's value, else value of b:GitBranch
-" &filetype, things starting with & are also like variables with info.
-" \ - Is for escaping a space. \" is for escaping a double quote.
-" %{&fenc!='utf-8'?\"\ \":''} = If file encoding is NOT!= 'utf-8' ? THEN output a "Space" else : no character
-
-let space = ' '
-
-" Define active statusline
-function! autoload#statusline#ActivateStatusline() abort
- call autoload#statusline#GetFileType()
- setlocal statusline=%#StslinePriColorBG#\ \ %{autoload#statusline#StslineMode()}\ %#StslineSecColorBG#%{get(b:,'coc_git_status',b:GitBranch)}%{get(b:,'coc_git_blame','')}%#StslineBackColorFGPriColorBG#%#StslinePriColorFG#\ %{&readonly?\"\ \":\"\"}%F\ %#StslineModColorFG#%{&modified?\"\ \":\"\"}%=%#StslinePriColorFG#\ %{b:FiletypeIcon}%{&filetype}\ %#StslineSecColorFG#%#StslineSecColorBG#%{&fenc!='utf-8'?\"\ \":''}%{&fenc!='utf-8'?&fenc:''}%{&fenc!='utf-8'?\"\ \":''}%#StslinePriColorFGSecColorBG#%#StslinePriColorBG#\ %p\%%\ %#StslinePriColorBGBold#%l%#StslinePriColorBG#/%L\ :%c\ \ %#{space}
-endfunction
-
-" Define Inactive statusline
-function! autoload#statusline#DeactivateStatusline() abort
- if !exists("b:GitBranch") || b:GitBranch == ''
- setlocal statusline=%#StslineSecColorBG#\ INACTIVE\ %#StslineSecColorBG#%{get(b:,'coc_git_statusline',b:GitBranch)}%{get(b:,'coc_git_blame','')}%#StslineBackColorFGSecColorBG#%#StslineBackColorBG#\ %{&readonly?\"\ \":\"\"}%F\ %#StslineModColorFG#%{&modified?\"\ \":\"\"}%=%#StslineBackColorBG#\ %{b:FiletypeIcon}%{&filetype}\ %#StslineSecColorFGBackColorBG#%#StslineSecColorBG#\ %p\%%\ %l/%L\ :%c\
- else
- setlocal statusline=%#StslineSecColorBG#%{get(b:,'coc_git_statusline',b:GitBranch)}%{get(b:,'coc_git_blame','')}%#StslineBackColorFGSecColorBG#%#StslineBackColorBG#\ %{&readonly?\"\ \":\"\"}%F\ %#StslineModColorFG#%{&modified?\"\ \":\"\"}%=%#StslineBackColorBG#\ %{b:FiletypeIcon}%{&filetype}\ %#StslineSecColorFGBackColorBG#%#StslineSecColorBG#\ %p\%%\ %l/%L\ :%c\
- endif
-endfunction
+" --- Highlight Groups ---
+" Initial setup of highlight groups (will be updated by UpdateStslineColors)
+execute 'highlight StslinePriColorBG guifg=' . g:StslineOnPriColor . ' guibg=' . g:StslinePriColor
+execute 'highlight StslineSecColorFG guifg=' . g:StslineSecColor . ' guibg=' . g:StslineBackColor
+execute 'highlight StslineSecColorBG guifg=' . g:StslineColorLight . ' guibg=' . g:StslineSecColor
+execute 'highlight StslineBackColorBG guifg=' . g:StslineColorLight . ' guibg=' . g:StslineBackColor
+execute 'highlight StslineBackColorFGSecColorBG guifg=' . g:StslineBackColor . ' guibg=' . g:StslineSecColor
+execute 'highlight StslineSecColorFGBackColorBG guifg=' . g:StslineSecColor . ' guibg=' . g:StslineBackColor
+execute 'highlight StslineModColorFG guifg=' . g:StslineColorYellow . ' guibg=' . g:StslineBackColor
+execute 'highlight StslinePriColorBG_SecColorBG guifg=' . g:StslinePriColor . ' guibg=' . g:StslineSecColor
+execute 'highlight StslineModeSep guifg=' . g:StslinePriColor . ' guibg=' . g:StslineSecColor
+execute 'highlight StslineGitSep guifg=' . g:StslineSecColor . ' guibg=' . g:StslineColorDark2
+
+" --- Statusline Settings ---
+if has('nvim')
+ set laststatus=3
+else
+ set laststatus=2
+endif
+
+"set noshowmode
+"set termguicolors
+
+let space = ''
" Get Statusline mode & also set primary color for that mode
function! autoload#statusline#StslineMode() abort
@@ -113,28 +77,30 @@ function! autoload#statusline#StslineMode() abort
let b:CurrentMode = 'INSERT '
elseif l:CurrentMode ==# 'c'
let g:StslinePriColor = g:StslineColorYellow
- let b:CurrentMode = 'COMMAND '
+ let b:CurrentMode = 'COMMAND'
elseif l:CurrentMode ==# 'v'
let g:StslinePriColor = g:StslineColorBlue
let b:CurrentMode = 'VISUAL '
elseif l:CurrentMode ==# '\<C-v>'
let g:StslinePriColor = g:StslineColorBlue
- let b:CurrentMode = 'V-BLOCK '
+ let b:CurrentMode = 'V-BLOCK'
elseif l:CurrentMode ==# 'V'
let g:StslinePriColor = g:StslineColorBlue
let b:CurrentMode = 'V-LINE '
elseif l:CurrentMode ==# 'R'
let g:StslinePriColor = g:StslineColorViolet
- let b:CurrentMode = 'REPLACE '
+ let b:CurrentMode = 'REPLACE'
elseif l:CurrentMode ==# 's'
let g:StslinePriColor = g:StslineColorBlue
let b:CurrentMode = 'SELECT '
elseif l:CurrentMode ==# 't'
let g:StslinePriColor = g:StslineColorYellow
- let b:CurrentMode = 'TERM '
+ let b:CurrentMode = 'TERM '
elseif l:CurrentMode ==# '!'
let g:StslinePriColor = g:StslineColorYellow
- let b:CurrentMode = 'SHELL '
+ let b:CurrentMode = 'SHELL '
+ else
+ let g:StslinePriColor = g:StslineColorGreen
endif
call autoload#statusline#UpdateStslineColors()
@@ -142,86 +108,160 @@ function! autoload#statusline#StslineMode() abort
return b:CurrentMode
endfunction
-" Update colors. Recreate highlight groups with new Primary color value.
function! autoload#statusline#UpdateStslineColors() abort
execute 'highlight StslinePriColorBG guifg=' . g:StslineOnPriColor . ' guibg=' . g:StslinePriColor
execute 'highlight StslinePriColorBGBold guifg=' . g:StslineOnPriColor . ' guibg=' . g:StslinePriColor . ' gui=bold'
execute 'highlight StslinePriColorFG guifg=' . g:StslinePriColor . ' guibg=' . g:StslineBackColor
execute 'highlight StslinePriColorFGSecColorBG guifg=' . g:StslinePriColor . ' guibg=' . g:StslineSecColor
- execute 'highlight StslineSecColorFGPriColorBG guifg=' . g:StslineSecColor . ' guibg=' . g:StslinePriColor
-
- if !exists("b:GitBranch") || b:GitBranch == ''
- execute 'highlight StslineBackColorFGPriColorBG guifg=' . g:StslineBackColor . ' guibg=' . g:StslinePriColor
- endif
+ execute 'highlight StslineModeSep guifg=' . g:StslinePriColor . ' guibg=' . g:StslineSecColor
+ execute 'highlight StslineGitSep guifg=' . g:StslineSecColor . ' guibg=' . g:StslineColorDark2
+ execute 'highlight StslineSecColorBG guifg=' . g:StslineColorLight . ' guibg=' . g:StslineSecColor
+ execute 'highlight StslineBackColorBG guifg=' . g:StslineColorLight . ' guibg=' . g:StslineBackColor
+ execute 'highlight StslineBackColorFGSecColorBG guifg=' . g:StslineBackColor . ' guibg=' . g:StslineSecColor
+ execute 'highlight StslineSecColorFGBackColorBG guifg=' . g:StslineSecColor . ' guibg=' . g:StslineBackColor
+ execute 'highlight StslineModColorFG guifg=' . g:StslineColorYellow . ' guibg=' . g:StslineBackColor
+ execute 'highlight StslinePriColorBG_SecColorBG guifg=' . g:StslinePriColor . ' guibg=' . g:StslineSecColor
+ execute 'highlight StslineSecColorFG guifg=' . g:StslineSecColor . ' guibg=' . g:StslineBackColor
endfunction
-" Get git branch name
function! autoload#statusline#GetGitBranch() abort
- let b:GitBranch = ""
+ let b:GitBranch = ''
try
let l:dir = expand('%:p:h')
let l:gitrevparse = system("git -C ".l:dir." rev-parse --abbrev-ref HEAD")
if !v:shell_error
- let b:GitBranch = "  " . substitute(l:gitrevparse, '\n', '', 'g') . " "
- execute 'highlight StslineBackColorFGPriColorBG guifg=' . g:StslineBackColor . ' guibg=' . g:StslineSecColor
+ let icon = g:statusline_has_nerd_fonts ? '  ' : ' [git] '
+ let b:GitBranch = icon . substitute(l:gitrevparse, '\n', '', 'g') . ' '
endif
catch
endtry
endfunction
-" Get filetype & custom icon. Put your most used file types first for optimized performance.
function! autoload#statusline#GetFileType() abort
- if &filetype ==# 'typescript'
- let b:FiletypeIcon = ' '
- elseif &filetype ==# 'html'
- let b:FiletypeIcon = ' '
- elseif &filetype ==# 'scss'
- let b:FiletypeIcon = ' '
- elseif &filetype ==# 'css'
- let b:FiletypeIcon = ' '
- elseif &filetype ==# 'javascript'
- let b:FiletypeIcon = ' '
- elseif &filetype ==# 'javascriptreact'
- let b:FiletypeIcon = ' '
- elseif &filetype ==# 'markdown'
- let b:FiletypeIcon = ' '
- elseif &filetype ==# 'sh' || &filetype ==# 'zsh'
- let b:FiletypeIcon = ' '
- elseif &filetype ==# 'vim'
- let b:FiletypeIcon = ' '
- elseif &filetype ==# ''
+ if !g:statusline_has_nerd_fonts
let b:FiletypeIcon = ''
- elseif &filetype ==# 'rust'
- let b:FiletypeIcon = ' '
- elseif &filetype ==# 'ruby'
- let b:FiletypeIcon = ' '
- elseif &filetype ==# 'cpp'
- let b:FiletypeIcon = ' '
- elseif &filetype ==# 'c'
- let b:FiletypeIcon = ' '
- elseif &filetype ==# 'go'
- let b:FiletypeIcon = ' '
- elseif &filetype ==# 'lua'
- let b:FiletypeIcon = ' '
- elseif &filetype ==# 'haskel'
- let b:FiletypeIcon = ' '
+ return
+ endif
+ if &filetype ==# 'typescript' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'html' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'scss' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'css' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'javascript' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'javascriptreact' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'markdown' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'sh' || &filetype ==# 'zsh' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'vim' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'rust' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'ruby' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'cpp' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'c' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'go' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'lua' | let b:FiletypeIcon = ' '
+ elseif &filetype ==# 'haskell' | let b:FiletypeIcon = ' '
+ else | let b:FiletypeIcon = ' '
+ endif
+endfunction
+
+function! autoload#statusline#ActivateStatusline() abort
+ call autoload#statusline#GetFileType()
+ call autoload#statusline#GetGitBranch() " Ensure git branch is updated
+
+ let current_mode_str = autoload#statusline#StslineMode()
+ call autoload#statusline#UpdateStslineColors()
+
+ let readonly_icon = g:statusline_has_nerd_fonts ? ' ' : '[RO] '
+ let modified_icon = g:statusline_has_nerd_fonts ? ' ' : '[+] '
+ let git_sep = g:statusline_has_nerd_fonts ? '' : ' '
+ let file_sep1 = g:statusline_has_nerd_fonts ? ' ' : ' '
+ let file_sep2 = g:statusline_has_nerd_fonts ? '' : ''
+
+ " Get dynamic parts as simple strings
+ let git_status_str = get(b:, "coc_git_status", get(b:, "GitBranch", ""))
+ let git_blame_str = get(b:, "coc_git_blame", "")
+ let filetype_icon_str = get(b:, "FiletypeIcon", "")
+ let file_encoding_str = ''
+ if &fenc != "utf-8"
+ let file_encoding_str = &fenc . ' '
+ endif
+
+ " Build the statusline as a static string
+ let l:statusline = ''
+
+ let l:statusline .= '%#StslinePriColorBG# ' . current_mode_str . ''
+ let l:statusline .= '%#StslineModeSep#' . git_sep
+ let l:statusline .= '%#StslineSecColorBG#' . git_status_str . git_blame_str
+ let l:statusline .= '%#StslineGitSep#' . git_sep
+
+ " File info (Readonly, Modified, Filename)
+ let l:statusline .= '%#StslinePriColorFG#'
+ if &readonly
+ let l:statusline .= readonly_icon
+ endif
+ let l:statusline .= ' %F '
+ if &modified
+ let l:statusline .= modified_icon
+ endif
+
+ " Right align everything after this
+ let l:statusline .= '%='
+
+ " Right side (Filetype, Encoding, Position)
+ let l:statusline .= '%#StslinePriColorFG# ' . filetype_icon_str . '%y'
+ let l:statusline .= '%#StslineSecColorFG#' . file_sep1
+ "let l:statusline .= '%#StslineSecColorBG# ' . file_encoding_str
+ let l:statusline .= '%#StslinePriColorFGSecColorBG#' . file_sep2
+ let l:statusline .= '%#StslinePriColorBG# %p%% %#StslinePriColorBGBold#%l%#StslinePriColorBG#/%L :%c '
+ let l:statusline .= '%#StslineBackColorBG#'
+
+ " Set the statusline for the current buffer
+ let &l:statusline = l:statusline
+endfunction
+
+function! autoload#statusline#DeactivateStatusline() abort
+ let git_sep = g:statusline_has_nerd_fonts ? '' : ''
+ let readonly_icon = g:statusline_has_nerd_fonts ? ' ' : '[RO] '
+ let modified_icon = g:statusline_has_nerd_fonts ? ' ' : '[+] '
+
+ " NOTE: This DeactivateStatusline function still uses %{} for dynamic parts.
+ " If you encounter general E518 or other issues related to %{} expressions,
+ " you will need to refactor this function to build a static string
+ " similar to how ActivateStatusline now does it.
+ if !exists("b:GitBranch") || b:GitBranch == ''
+ let statusline =
+ \ '%#StslineSecColorBG# INACTIVE ' .
+ \ '%{get(b:,"coc_git_statusline",b:GitBranch)}%{get(b:,"coc_git_blame","")}' .
+ \ '%#StslineBackColorFGSecColorBG#' . git_sep .
+ \ '%#StslineBackColorBG# %{&readonly?"' . readonly_icon . '":""}%F ' .
+ \ '%#StslineModColorFG#%{&modified?"' . modified_icon . '":""}' .
+ \ '%=%#StslineBackColorBG# %{b:FiletypeIcon}%{&filetype}' .
+ \ '%#StslineSecColorFGBackColorBG# | %p%% %l/%L :%c'
else
- let b:FiletypeIcon = ' '
+ let statusline =
+ \ '%#StslineSecColorBG# %{get(b:,"coc_git_statusline",b:GitBranch)}%{get(b:,"coc_git_blame","")}' .
+ \ '%#StslineBackColorFGSecColorBG#' . git_sep .
+ \ '%#StslineBackColorBG# %{&readonly?"' . readonly_icon . '":""}%F ' .
+ \ '%#StslineModColorFG#%{&modified?"' . modified_icon . '":""}' .
+ \ '%=%#StslineBackColorBG# %{b:FiletypeIcon}%{&filetype}' .
+ \ '%#StslineSecColorFGBackColorBG# | %p%% %l/%L :%c'
endif
+
+ execute 'setlocal statusline=' . substitute(statusline, '"', '\\"', 'g')
endfunction
-" Automatically update git branch name when entering a buffer
-augroup GetGitBranch
+augroup StatuslineGit
autocmd!
autocmd BufEnter * call autoload#statusline#GetGitBranch()
augroup END
-" Set active / inactive statusline when entering or leaving a buffer
augroup SetStsline
- autocmd!
- autocmd BufEnter,WinEnter * call autoload#statusline#ActivateStatusline()
- autocmd BufLeave,WinLeave * call autoload#statusline#DeactivateStatusline()
+ autocmd!
+ autocmd BufEnter,WinEnter * call autoload#statusline#ActivateStatusline()
+ autocmd ModeChanged * call autoload#statusline#ActivateStatusline()
augroup END
-call autoload#statusline#ActivateStatusline()
+augroup StatuslineAutoReload
+ autocmd!
+ autocmd BufWritePost statusline.vim source <afile> | call autoload#statusline#ActivateStatusline()
+augroup END
+"call autoload#statusline#ActivateStatusline()
diff --git a/linux/home/.vim/colors/colorscheme.vim b/linux/home/.vim/colors/colorscheme.vim
new file mode 100644
index 0000000..ce0526e
--- /dev/null
+++ b/linux/home/.vim/colors/colorscheme.vim
@@ -0,0 +1,247 @@
+" Vim Colorscheme
+" Name: cherryblossom.vim
+" Author: Luo Boming
+" Version: 0.3
+" License: The MIT Licence
+
+"{{{ Pre-setting
+let g:colors_name = expand('<sfile>:t:r')
+
+"hi clear
+"if exists("syntax_on")
+" syntax reset
+"endif
+
+if ! exists("g:terminal_italics")
+ let g:terminal_italics = 0
+endif
+
+"if ! exists("g:switch_statusline_bg_in_insert")
+" let g:switch_statusline_bg_in_insert = 0
+"endif
+
+if ! exists("g:spell_undercurl")
+ let g:spell_undercurl = 0
+endif
+
+"}}}
+"{{{ Color Palette
+" Color Entity
+let s:black = { "gui": "#171717", "cterm": "16" }
+let s:white = { "gui": "#EAE8E7", "cterm": "231" }
+
+let s:gray = { "gui": "#3a3f52", "cterm": "247" }
+
+let s:green = { "gui": "#30B536", "cterm": "34" }
+let s:pink = { "gui": "#D36DD3", "cterm": "170" }
+let s:orange = { "gui": "#FC923F", "cterm": "208" }
+let s:purple = { "gui": "#B586E7", "cterm": "141" }
+let s:light_cyan = { "gui": "#D7FFFF", "cterm": "195" }
+let s:dark_cyan = { "gui": "#00AF87", "cterm": "36" }
+let s:ultramarine = { "gui": "#229EC0", "cterm": "38" }
+let s:skyblue = { "gui": "#9BE7F8", "cterm": "195" }
+
+let s:white_pink = { "gui": "#FEF7FE", "cterm": "231" }
+let s:white_pink_deep = { "gui": "#FEF0FE", "cterm": "255" }
+let s:black_green = { "gui": "#053703", "cterm": "235" }
+let s:black_green_bright = { "gui": "#074005", "cterm": "239" }
+let s:middle_gray = { "gui": "#8a8a8a", "cterm": "245" }
+
+let s:light_gray = { "gui": "#E1DCDA", "cterm": "253" }
+let s:light_green = { "gui": "#B7EFA5", "cterm": "157" }
+let s:light_pink = { "gui": "#FEDCFE", "cterm": "225" }
+let s:light_yellow = { "gui": "#EDE682", "cterm": "228" }
+let s:light_red = { "gui": "#EB5A7C", "cterm": "204" }
+
+let s:dark_gray = { "gui": "#4D4A48", "cterm": "241" }
+let s:dark_green = { "gui": "#09570A", "cterm": "22" }
+let s:dark_yellow = { "gui": "#BC922B", "cterm": "3" }
+let s:dark_pink = { "gui": "#B365A2", "cterm": "133" }
+let s:dark_red = { "gui": "#D9372D", "cterm": "160" }
+let s:NONE = { "gui": "NONE", "cterm": "NONE" }
+
+" Color Alias
+if &background == "light"
+ let s:norm = s:black
+ let s:bg = s:NONE
+ let s:bg_subtle = s:white_pink_deep
+ let s:gray_fg = s:middle_gray
+ let s:green_fg = s:green
+ let s:yellow_fg = s:dark_yellow
+ let s:pink_fg = s:dark_pink
+ let s:cyan_fg = s:dark_cyan
+ let s:blue_fg = s:ultramarine
+ let s:red_fg = s:dark_red
+ let s:gray_bg = s:light_gray
+ let s:green_bg = s:light_green
+ let s:yellow_bg = s:light_yellow
+ let s:pink_bg = s:light_pink
+ let s:cyan_bg = s:light_cyan
+ let s:blue_bg = s:skyblue
+ let s:red_bg = s:light_red
+endif
+
+if &background == "dark"
+ let s:norm = s:white
+ let s:bg = s:NONE
+ let s:bg_subtle = s:gray
+ let s:gray_fg = s:middle_gray
+ let s:green_fg = s:light_green
+ let s:yellow_fg = s:light_yellow
+ let s:pink_fg = s:light_pink
+ let s:cyan_fg = s:light_cyan
+ let s:blue_fg = s:skyblue
+ let s:red_fg = s:light_red
+ let s:gray_bg = s:dark_gray
+ let s:green_bg = s:green
+ let s:yellow_bg = s:dark_yellow
+ let s:pink_bg = s:pink
+ let s:cyan_bg = s:dark_cyan
+ let s:blue_bg = s:ultramarine
+ let s:red_bg = s:dark_red
+endif
+"}}}
+"{{{ Highlight Function
+" shamelessly stolen from pencil: https://github.com/reedes/vim-colors-pencil
+function! s:hi(group, style)
+ if g:terminal_italics == 0
+ if has_key(a:style, "cterm") && a:style["cterm"] == "italic"
+ unlet a:style.cterm
+ endif
+ if has_key(a:style, "term") && a:style["term"] == "italic"
+ unlet a:style.term
+ endif
+ endif
+ execute "highlight" a:group
+ \ "guifg=" (has_key(a:style, "fg") ? a:style.fg.gui : "NONE")
+ \ "guibg=" (has_key(a:style, "bg") ? a:style.bg.gui : "NONE")
+ \ "guisp=" (has_key(a:style, "sp") ? a:style.sp.gui : "NONE")
+ \ "gui=" (has_key(a:style, "gui") ? a:style.gui : "NONE")
+ \ "ctermfg=" (has_key(a:style, "fg") ? a:style.fg.cterm : "NONE")
+ \ "ctermbg=" (has_key(a:style, "bg") ? a:style.bg.cterm : "NONE")
+ \ "cterm=" (has_key(a:style, "cterm") ? a:style.cterm : "NONE")
+ \ "term=" (has_key(a:style, "term") ? a:style.term : "NONE")
+endfunction
+
+if g:spell_undercurl == 1
+ let s:attr_un = 'undercurl'
+else
+ let s:attr_un = 'underline'
+endif
+
+"}}}
+"{{{ Common Highlighting
+call s:hi("Normal", {"fg": s:norm, "bg": s:bg})
+call s:hi("Cursor", {})
+call s:hi("Comment", {"fg": s:gray_fg, "gui": "italic", "cterm": "italic", "term": "italic"})
+
+call s:hi("Constant", {"fg": s:pink_fg})
+hi! link String Constant
+hi! link Character Constant
+hi! link Number Constant
+hi! link Boolean Constant
+hi! link Float Constant
+
+call s:hi("Identifier", {"fg": s:red_fg})
+hi! link Function Identifier
+
+call s:hi("Statement", {"fg": s:green_fg})
+hi! link Conditonal Statement
+hi! link Repeat Statement
+hi! link Label Statement
+hi! link Operator Statement
+hi! link Keyword Statement
+hi! link Exception Statement
+
+call s:hi("PreProc", {"fg": s:blue_fg})
+hi! link Include PreProc
+hi! link Define PreProc
+hi! link Macro PreProc
+hi! link PreCondit PreProc
+
+call s:hi("Type", {"fg": s:yellow_fg})
+hi! link StorageClass Type
+hi! link Structure Type
+hi! link Typedef Type
+
+call s:hi("Special", {"fg": s:orange})
+hi! link SpecialChar Special
+hi! link Tag Special
+hi! link Delimiter Special
+hi! link SpecialComment Special
+hi! link Debug Special
+
+call s:hi("Underlined", {"gui": "underline", "cterm": "underline"})
+call s:hi("Ignore", {"fg": s:bg_subtle})
+call s:hi("Error", {"fg": s:white, "bg": s:red_fg , "gui": "bold", "cterm": "bold"})
+call s:hi("Todo", {"bg": s:yellow_bg, "gui": "bold", "cterm": "bold"})
+
+"}}}
+"{{{ Semi-Common Highlighting
+call s:hi("SpecialKey", {"fg": s:purple, "gui": "bold", "cterm": "bold", "term": "bold"})
+call s:hi("NonText", {"fg": s:cyan_bg, "gui": "bold", "cterm": "bold", "term": "bold"})
+call s:hi("Directory", {"fg": s:blue_fg, "gui": "bold", "cterm": "bold", "term": "bold"})
+call s:hi("ErrorMsg", {"fg": s:red_fg, "gui": "bold", "cterm": "bold", "term": "bold"})
+call s:hi("IncSearch", {"gui": "reverse", "cterm": "reverse", "term": "reverse"})
+call s:hi("Search", {"fg": s:norm, "bg": s:pink_bg})
+call s:hi("MoreMsg", {"fg": s:pink_fg, "gui": "bold", "cterm": "bold", "term": "bold"})
+call s:hi("ModeMsg", {"fg": s:pink_fg, "gui": "bold", "cterm": "bold", "term": "bold"})
+call s:hi("LineNr", {"fg": s:gray})
+call s:hi("CursorLineNr", {"fg": s:pink_fg, "gui": "bold", "cterm": "bold", "term": "bold"})
+call s:hi("Question", {"fg": s:purple, "gui": "bold", "cterm": "bold", "term": "bold"})
+"call s:hi("StatusLine", {"fg": s:norm, "bg": s:green_bg, "gui": "bold", "cterm": "bold", "term": "bold"})
+"call s:hi("StatusLineNC", {"fg": s:norm, "bg": s:gray_bg})
+call s:hi("Conceal", {"fg": s:yellow_fg})
+call s:hi("VertSplit", {"gui": "reverse", "cterm": "reverse", "term": "reverse"})
+call s:hi("Title", {"fg": s:pink_fg, "gui": "bold", "cterm": "bold", "term": "bold"})
+call s:hi("Visual", {"gui": "reverse", "cterm": "reverse", "term": "reverse"})
+call s:hi("VisualNOS", {"gui": "bold,underline", "cterm": "bold,underline", "term": "bold,underline"})
+call s:hi("WarningMsg", {"fg": s:orange, "gui": "bold", "cterm": "bold", "term": "bold"})
+call s:hi("WildMenu", {"fg": s:norm, "bg": s:blue_bg})
+call s:hi("Folded", {"fg": s:green_fg, "bg": s:gray_bg})
+call s:hi("FoldColumn", {"fg": s:green_fg, "bg": s:gray_bg})
+call s:hi("DiffAdd", {"bg": s:green_bg})
+call s:hi("DiffChange", {"bg": s:yellow_bg})
+call s:hi("DiffDelete", {"bg": s:red_bg})
+call s:hi("DiffText", {"bg": s:blue_bg, "gui": "bold", "cterm": "bold", "term": "bold"})
+call s:hi("SignColumn", {"fg": s:green_fg, "bg": s:gray})
+if has("gui_running")
+ call s:hi("SpellBad", {"gui": s:attr_un, "sp": s:red_bg})
+ call s:hi("SpellCap", {"gui": s:attr_un, "sp": s:yellow_bg})
+ call s:hi("SpellRare", {"gui": s:attr_un, "sp": s:blue_bg})
+ call s:hi("SpellLocal", {"gui": s:attr_un, "sp": s:green_bg})
+else
+ call s:hi("SpellBad", {"cterm": s:attr_un, "fg": s:red_fg})
+ call s:hi("SpellCap", {"cterm": s:attr_un, "fg": s:yellow_fg})
+ call s:hi("SpellRare", {"cterm": s:attr_un, "fg": s:blue_fg})
+ call s:hi("SpellLocal", {"cterm": s:attr_un, "fg": s:green_fg})
+endif
+call s:hi("Pmenu", {"bg": s:gray_bg})
+call s:hi("PmenuSel", {"bg": s:pink_bg})
+call s:hi("PmenuSbar", {"bg": s:gray_bg})
+call s:hi("PmenuThumb", {"bg": s:gray_bg})
+call s:hi("TabLine", {"bg": s:bg_subtle})
+call s:hi("TabLineSel", {"bg": s:pink_bg})
+call s:hi("TabLineFill", {"bg": s:bg_subtle})
+call s:hi("CursorColumn", {"bg": s:yellow_fg})
+call s:hi("CursorLine", {"bg": s:bg_subtle})
+call s:hi("ColorColumn", {"bg": s:bg_subtle})
+call s:hi("MatchParen", {"fg": s:pink_fg, "gui": "underline", "cterm": "underline"})
+call s:hi("qfLineNr", {"fg": s:gray})
+
+"}}}
+""{{{ Switching StatusLine bg
+"function! s:changebg(group, color)
+" execute "highlight" a:group "guibg=" a:color.gui "ctermbg=" a:color.cterm
+"endfunction
+"
+"if g:switch_statusline_bg_in_insert == 1
+" "" Change Color when entering Insert Mode
+" autocmd InsertEnter * call s:changebg("StatusLine", s:pink_bg)
+" "" Revert Color to default when leaving Insert Mode
+" autocmd InsertLeave * call s:changebg("StatusLine", s:green_bg)
+"endif
+
+"}}}
+" vim: set foldmethod=marker:
+
diff --git a/linux/home/.vim/colors/default.vim b/linux/home/.vim/colors/default.vim
new file mode 100644
index 0000000..ebc66e8
--- /dev/null
+++ b/linux/home/.vim/colors/default.vim
@@ -0,0 +1,175 @@
+"{{{ Pre-setting
+let g:colors_name = expand('<sfile>:t:r')
+
+if ! exists("g:terminal_italics")
+ let g:terminal_italics = 0
+endif
+
+if ! exists("g:spell_undercurl")
+ let g:spell_undercurl = 0
+endif
+"}}}
+
+"{{{ Color Palette (updated to match official Vim default colors)
+" Note: Hex colors chosen to reflect official Vim default colorscheme
+
+let s:black = { "gui": "#171717", "cterm": "16" }
+let s:white = { "gui": "#EAE8E7", "cterm": "231" }
+let s:gray = { "gui": "#808080", "cterm": "244" }
+
+" Reds
+let s:red_fg = { "gui": "#FFFFFF", "cterm": "231" } " White fg on red bg for errors
+let s:red_bg = { "gui": "#A40000", "cterm": "52" } " DarkRed bg (ErrorMsg bg)
+
+" Blues and Cyan
+let s:blue_fg = { "gui": "#6A5ACD", "cterm": "60" } " SlateBlue
+let s:dark_cyan = { "gui": "#008B8B", "cterm": "36" } " DarkCyan
+let s:cyan_bg = { "gui": "#00CED1", "cterm": "38" } " DarkTurquoise
+
+" Greens
+let s:green_fg = { "gui": "#008000", "cterm": "22" } " DarkGreen
+let s:green_bg = { "gui": "#90EE90", "cterm": "120" } " LightGreen
+
+" Yellows and Oranges
+let s:yellow_fg = { "gui": "#A52A2A", "cterm": "94" } " Brown (used in Vim default)
+let s:yellow_bg = { "gui": "#FFFF00", "cterm": "226" } " Yellow bg
+
+let s:orange = { "gui": "#FFA500", "cterm": "214" } " Orange
+
+" Purples
+let s:purple = { "gui": "#6A0DAD", "cterm": "90" } " DarkMagenta
+
+" Grays
+let s:light_gray = { "gui": "#D3D3D3", "cterm": "252" }
+let s:dark_gray = { "gui": "#4D4D4D", "cterm": "240" }
+
+" No color
+let s:NONE = { "gui": "NONE", "cterm": "NONE" }
+
+" Alias for Normal fg and background depending on background setting
+if &background == "light"
+ let s:norm = s:black
+ let s:bg = s:NONE
+ let s:bg_subtle = s:light_gray
+ let s:gray_fg = s:gray
+ let s:green_fg = s:green_fg
+ let s:yellow_fg = s:yellow_fg
+ let s:pink_fg = s:purple
+ let s:cyan_fg = s:dark_cyan
+ let s:blue_fg = s:blue_fg
+ let s:red_fg = s:red_bg
+ let s:gray_bg = s:light_gray
+ let s:green_bg = s:green_bg
+ let s:yellow_bg = s:yellow_bg
+ let s:pink_bg = s:orange
+ let s:cyan_bg = s:cyan_bg
+ let s:blue_bg = s:blue_fg
+ let s:red_bg = s:red_bg
+else
+ let s:norm = s:white
+ let s:bg = s:NONE
+ let s:bg_subtle = s:dark_gray
+ let s:gray_fg = s:gray
+ let s:green_fg = s:green_bg
+ let s:yellow_fg = s:yellow_bg
+ let s:pink_fg = s:orange
+ let s:cyan_fg = s:cyan_bg
+ let s:blue_fg = s:blue_bg
+ let s:red_fg = s:red_bg
+ let s:gray_bg = s:dark_gray
+ let s:green_bg = s:green_fg
+ let s:yellow_bg = s:yellow_fg
+ let s:pink_bg = s:purple
+ let s:cyan_bg = s:dark_cyan
+ let s:blue_bg = s:blue_fg
+ let s:red_bg = s:red_bg
+endif
+"}}}
+
+"{{{ Highlight Function (keep your existing function)
+function! s:hi(group, style)
+ if g:terminal_italics == 0
+ if has_key(a:style, "cterm") && a:style["cterm"] == "italic"
+ unlet a:style.cterm
+ endif
+ if has_key(a:style, "term") && a:style["term"] == "italic"
+ unlet a:style.term
+ endif
+ endif
+ execute "highlight" a:group
+ \ "guifg=" (has_key(a:style, "fg") ? a:style.fg.gui : "NONE")
+ \ "guibg=" (has_key(a:style, "bg") ? a:style.bg.gui : "NONE")
+ \ "guisp=" (has_key(a:style, "sp") ? a:style.sp.gui : "NONE")
+ \ "gui=" (has_key(a:style, "gui") ? a:style.gui : "NONE")
+ \ "ctermfg=" (has_key(a:style, "fg") ? a:style.fg.cterm : "NONE")
+ \ "ctermbg=" (has_key(a:style, "bg") ? a:style.bg.cterm : "NONE")
+ \ "cterm=" (has_key(a:style, "cterm") ? a:style.cterm : "NONE")
+ \ "term=" (has_key(a:style, "term") ? a:style.term : "NONE")
+endfunction
+
+if g:spell_undercurl == 1
+ let s:attr_un = 'undercurl'
+else
+ let s:attr_un = 'underline'
+endif
+"}}}
+
+"{{{ Common Highlighting updated to match official Vim default colorscheme
+
+call s:hi("Normal", {"fg": s:norm, "bg": s:bg})
+call s:hi("Cursor", {})
+call s:hi("Conceal", {"fg": s:yellow_fg})
+call s:hi("ErrorMsg", {"fg": s:red_fg, "bg": s:red_bg, "gui": "bold", "cterm": "bold"})
+call s:hi("IncSearch", {"gui": "reverse", "cterm": "reverse"})
+call s:hi("ModeMsg", {"gui": "bold", "cterm": "bold"})
+call s:hi("NonText", {"fg": s:blue_fg, "gui": "bold", "cterm": "bold"})
+call s:hi("PmenuSbar", {"bg": s:gray_bg})
+call s:hi("StatusLine", {"gui": "reverse,bold", "cterm": "reverse,bold"})
+call s:hi("StatusLineNC", {"gui": "reverse", "cterm": "reverse"})
+call s:hi("TabLineFill", {"gui": "reverse", "cterm": "reverse"})
+call s:hi("TabLineSel", {"gui": "bold", "cterm": "bold"})
+call s:hi("TermCursor", {"gui": "reverse", "cterm": "reverse"})
+call s:hi("WinBar", {"gui": "bold", "cterm": "bold"})
+call s:hi("WildMenu", {"fg": s:black, "bg": s:yellow_bg})
+
+call s:hi("VertSplit", {"link": "Normal"})
+call s:hi("WinSeparator", {"link": "VertSplit"})
+call s:hi("WinBarNC", {"link": "WinBar"})
+call s:hi("DiffTextAdd", {"link": "DiffText"})
+call s:hi("EndOfBuffer", {"link": "NonText"})
+call s:hi("LineNrAbove", {"link": "LineNr"})
+call s:hi("LineNrBelow", {"link": "LineNr"})
+call s:hi("QuickFixLine", {"link": "Search"})
+call s:hi("CursorLineSign", {"link": "SignColumn"})
+call s:hi("CursorLineFold", {"link": "FoldColumn"})
+call s:hi("CurSearch", {"link": "Search"})
+call s:hi("PmenuKind", {"link": "Pmenu"})
+call s:hi("PmenuKindSel", {"link": "PmenuSel"})
+call s:hi("PmenuMatch", {"link": "Pmenu"})
+call s:hi("PmenuMatchSel", {"link": "PmenuSel"})
+call s:hi("PmenuExtra", {"link": "Pmenu"})
+call s:hi("PmenuExtraSel", {"link": "PmenuSel"})
+call s:hi("ComplMatchIns", {})
+call s:hi("Substitute", {"link": "Search"})
+call s:hi("Whitespace", {"link": "NonText"})
+call s:hi("MsgSeparator", {"link": "StatusLine"})
+call s:hi("NormalFloat", {"link": "Pmenu"})
+call s:hi("FloatBorder", {"link": "WinSeparator"})
+call s:hi("FloatTitle", {"link": "Title"})
+call s:hi("FloatFooter", {"link": "Title"})
+
+call s:hi("Error", {"fg": s:red_fg, "bg": s:red_bg, "gui": "bold", "cterm": "bold"})
+call s:hi("Todo", {"fg": s:black, "bg": s:yellow_bg, "gui": "bold", "cterm": "bold"})
+
+call s:hi("String", {"link": "Constant"})
+call s:hi("Character", {"link": "Constant"})
+call s:hi("Number", {"link": "Constant"})
+call s:hi("Boolean", {"link": "Constant"})
+call s:hi("Float", {"link": "Number"})
+call s:hi("Function", {"link": "Identifier"})
+call s:hi("Conditional", {"link": "Statement"})
+call s:hi("Repeat", {"link": "Statement"})
+call s:hi("Label", {"link": "Statement"})
+call s:hi("Operator", {"link": "Statement"})
+call s:hi("Keyword", {"link": "Statement"})
+call s:hi("Exception",
diff --git a/linux/home/.vim/ftplugin/after/vim.vim b/linux/home/.vim/ftplugin/after/vim.vim
new file mode 100644
index 0000000..3548816
--- /dev/null
+++ b/linux/home/.vim/ftplugin/after/vim.vim
@@ -0,0 +1,12 @@
+" Enable Vim-specific options
+setlocal tabstop=4
+setlocal shiftwidth=4
+setlocal softtabstop=4
+setlocal expandtab
+setlocal foldmethod=marker
+setlocal keywordprg=:help
+setlocal iskeyword+=:
+
+" Spell-check off by default
+setlocal nospell
+
diff --git a/linux/home/.vim/vimrc b/linux/home/.vim/vimrc
index ce034e9..5b0f444 100644
--- a/linux/home/.vim/vimrc
+++ b/linux/home/.vim/vimrc
@@ -1,296 +1,700 @@
-"===============================================================================
-" Mappings/Keybindings/Commands
-"===============================================================================
-
-let mapleader = ";" " map leader to Semi colon
-
-inoremap jk <Esc> " Use <jk> to escape
-
-" Easier split navigations, just ctrl-j instead of ctrl-w then j
-nnoremap <C-J> <C-W><C-J>
-nnoremap <C-K> <C-W><C-K>
-nnoremap <C-L> <C-W><C-L>
-nnoremap <C-H> <C-W><C-H>
-
-" Recent files (MRU)
-nnoremap <leader>m :browse old<cr>
-" Search files by name
-"nnoremap <leader>p :find **/**<left>
-" browse files from same dir as current file
-nnoremap <leader>e :e %:p:h<CR>
-
-" Combine buffers list with buffer name
-"nnoremap <Leader>b :buffers<CR>:buffer<Space>
-
-" Jump to a buffer
-nnoremap <leader>b :ls t<cr>:b
-
-" Map buffer next, prev and delete to <leader+(n/p/d)>
-map <leader>n :bn<cr>
-map <leader>p :bp<cr>
-map <leader>d :bd<cr>
-
-" tab navigation
-noremap <C-t>h :tabprevious<CR>
-noremap <C-t>l :tabnext<CR>
-noremap <C-t>k :tabfirst<CR>
-noremap <C-t>j :tablast<CR>
-noremap <C-t>n :tabnew<CR>
-noremap <C-t>e :tabedit<Space>
-noremap <C-t>c :tabclose<CR>
-noremap <C-t>m :tabm<Space>
-
-" Swap two pieces of text, use x to cut in visual mode, then use Ctrl-x in
-" visual mode to select text to swap with
-:vnoremap <C-X> <Esc>`.``gvP``P
-
-" To resize in different steps, you can create maps that will adjust the window
-" size differently. For example to increase the window size by a factor of 1.5
-" and decrease the window size by 0.67, you can map this:
-"nnoremap <silent> <Leader>+ :exe "resize " . (winheight(0) * 3/2)<CR>
-"nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>
-nnoremap <Leader>+ :resize +5<CR>
-nnoremap <Leader>- :resize -5<CR>
-nnoremap <Leader>> :vertical resize +5<CR>
-nnoremap <Leader>< :vertical resize -5<CR>
-
-" Toggle set number
-"nnoremap <leader>$ :NumbersToggle<CR>
-"nnoremap <leader>% :NumbersOnOff<CR>
-
-" Copy and Paste with <C-c> and <C-v>
-"vmap <C-c> y:call system("xclip -i -selection clipboard", getreg("\""))<CR>:call system("xclip -i", getreg("\""))<CR>
-"nmap <C-v> :call setreg("\"",system("xclip -o -selection clipboard"))<CR>p
-nnoremap <expr> p (v:register == '"' && &clipboard =~ 'unnamed' ? '"*p' : '"' . v:register . 'p')
-
-" Use command :Vb for Visual Block or <C-q> since <C-v> is used for Copy
-command! Vb normal! <C-v>
-
-" Map <w!!> to save/edit a root permission/read-only file, only works in
-" traditional vim and not neovim
-cmap w!! %!sudo tee > /dev/null
-
-nnoremap <leader>x :silent !chmod +x %<CR>
-
-"nnoremap <[-p> m`o<ESC>p``
-" Paste on next line
-"nnoremap <]-p> m`O<ESC>p``
-
-"inoremap <C-CR> <C-R>"
-"set keywordprg=:help
-"runtime ftplugin/man.vim
-
-
-"===============================================================================
-" Settings
-"===============================================================================
-
-" Neovim requires xclip, check if normal vim has +clipboard by
-" <:echo has('clipboard')> from within Vim (if the output is 1, good to
-" go otherwise 0 then need a build that has it
-" Next two commands make vim use X11 clipboard
-set clipboard+=unnamedplus
-let g:clipbrdDefaultReg = '+'
-
-"let g:loaded_clipboard_provider = 1
-" <:e %:h/filename> will create a new file named filename in the same
-" directory as the currently open file, and write it.
-set autochdir " or use this to use <:e> to create a file in current directory
-set splitright " make vsplit put the new buffer on the right of the current buffer
-set splitbelow " make split put the new buffer below the current buffer
-" :Bclose script (delete a buffer without closing the window) sourced as a
-" plugin in ~/.config/nvim/plugin/bclose.vim | keymap: <leader>bd
-"let bclose_multiple = 1
-"set syntax
-" Compute syntax highlighting from beginning of file. (By default, vim only
-" looks 200 lines back, which can make it highlight code incorrectly in some
-" long files.)
-autocmd BufEnter * :syntax sync fromstart
-" Don't syntax highlight markdown because it's often wrong
-autocmd! FileType mkd setlocal syn=off
+" ============================================================================
+" Vim Configuration
+" Maintainer: srdusr
+" ============================================================================
+
+" ============================================================================
+" Core Settings
+" ============================================================================
+set nocompatible
+set encoding=utf-8
+set fileencoding=utf-8
+scriptencoding utf-8
+set termguicolors
+set mouse=a
+set clipboard=unnamedplus
+set hidden
+set updatetime=300
+set timeoutlen=500
+set ttimeoutlen=10
+
+" Performance
set ttyfast
set lazyredraw
-" Set lazyredraw to false
-"let &lazyredraw = 0
-set timeout timeoutlen=1000 ttimeoutlen=100 " fix slow O inserts
-set scrolloff=8 sidescrolloff=8
-set tabstop=4 softtabstop=4 shiftwidth=4 expandtab
-set autoindent
-set smartindent
-" Also load indent files, to automatically do language-dependent indenting.
-filetype plugin indent on
-set exrc
+set ttyscroll=3
+
+" ============================================================================
+" Display and UI Settings
+" ============================================================================
+set number
set relativenumber
-set hidden
-set noerrorbells
+set cursorline
+set signcolumn=no
+set showcmd
+set showmode
+set showmatch
+set matchtime=2
+set laststatus=2
+set cmdheight=1
+set scrolloff=8
+set sidescrolloff=8
+set sidescroll=1
+set display=lastline
set nowrap
+set linebreak
+set showbreak=↪\
+
+" Window behavior
+set splitright
+set splitbelow
+set winminwidth=1
+set winwidth=5
+
+" ============================================================================
+" Formatting and Indentation Settings
+" ============================================================================
+set autoindent
+set smartindent
+set expandtab
+set tabstop=2
+set shiftwidth=2
+set softtabstop=2
+set shiftround
+set textwidth=80
+set formatoptions+=j
+" set colorcolumn=+1
+
+" File-specific formatting
+setlocal tabstop=4
+setlocal shiftwidth=4
+setlocal softtabstop=4
+setlocal foldmethod=marker
+
+" ============================================================================
+" Search and Matching Settings
+" ============================================================================
+set hlsearch
+set incsearch
set ignorecase
set smartcase
-set noswapfile
-set nobackup
-set incsearch
-"set cursorline
set showmatch
-set showcmd
-set incsearch
-set hlsearch
-set laststatus=2
-let g:python3_host_prog = '/usr/bin/python3'
-"let g:loaded_python3_provider = 1
-let g:sh_noisk=1
-set modeline
-set modelines=3 " modelines (comments that set vim options on a per-file basis)
-set foldmethod=manual
-set nofoldenable " turn folding off
-" Insert only one space when joining lines that contain sentence-terminating
-" punctuation like `.`.
-set nojoinspaces
-set autoread " if a file is changed outside of vim, automatically reload it without asking
-set diffopt=vertical " diffs are shown side-by-side not above/below
-set signcolumn=no " always show the sign column
-set textwidth=80
-set mouse=a
+" set inccommand=split
+
+" ============================================================================
+" File Handling and Backup Settings
+" ============================================================================
+set autoread
+set autowrite
+set autochdir
+set confirm
+set fileformats=unix,dos,mac
+
+" Backup and undo configuration
+set backup
+set writebackup
+set backupcopy=yes
+set undofile
+set noswapfile
+set backupdir=~/.cache/vim/backup//
+set directory=~/.cache/vim/swap//
+set undodir=~/.cache/vim/undo//
+set undolevels=10000
+set undoreload=10000
+
+" Create necessary directories
+let s:config_dir = expand('~/.vim')
+let s:cache_dir = expand('~/.cache/vim')
+let s:dirs = [
+ \ s:cache_dir . '/backup',
+ \ s:cache_dir . '/swap',
+ \ s:cache_dir . '/undo',
+ \ s:cache_dir . '/shada',
+ \ s:config_dir . '/sessions',
+ \ ]
+
+for s:dir in s:dirs
+ if !isdirectory(s:dir)
+ call mkdir(s:dir, 'p', 0700)
+ endif
+endfor
+
+" ============================================================================
+" Completion and Command Line Settings
+" ============================================================================
+set omnifunc=syntaxcomplete#Complete
+set complete=.,w,b,u,t,i,kspell
+set completeopt=menu,menuone,noselect
+
+" Wildmenu configuration
+set wildmenu
+set wildmode=longest:full,full
+set wildignorecase
+set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
+set wildignore+=.git,.hg,.svn
+set wildignore+=*.swp,*.swo
+set wildignore+=*.DS_Store
+set wildignore+=*.class
+
+" ============================================================================
+" Leader Keys
+" ============================================================================
+let mapleader = ";"
+let maplocalleader = "\\"
+
+" ============================================================================
+" Navigation and Movement Mappings
+" ============================================================================
+
+" Tmux/Vim Navigation Function
+function! SmartMove(direction, tmux_flag)
+ let curwin = win_getid()
+ execute 'wincmd ' . a:direction
+ if win_getid() == curwin
+ call system('tmux select-pane ' . a:tmux_flag)
+ endif
+endfunction
+
+" Window navigation
+nnoremap <silent> <C-h> :call SmartMove('h', '-L')<CR>
+nnoremap <silent> <C-j> :call SmartMove('j', '-D')<CR>
+nnoremap <silent> <C-k> :call SmartMove('k', '-U')<CR>
+nnoremap <silent> <C-l> :call SmartMove('l', '-R')<CR>
+
+" Split window horizontally
+nnoremap <leader>- :split<CR>
+
+" Split window vertically
+nnoremap <leader>\ :vsplit<CR>
+
+" Close the current window
+nnoremap <leader>c <C-w>c
+
+" Buffer navigation
+nnoremap <silent> <leader>bn :bnext<CR>
+nnoremap <silent> <leader>bp :bprevious<CR>
+nnoremap <silent> <leader>bd :bdelete<CR>
+nnoremap <silent> <leader>ba :%bdelete<CR>
+nnoremap <silent> <leader>bl :ls<CR>:b<Space>
+
+" Quickfix and location list
+nnoremap ]q :cnext<CR>zz
+nnoremap [q :cprev<CR>zz
+nnoremap ]l :lnext<CR>zz
+nnoremap [l :lprev<CR>zz
+
+" ============================================================================
+" File and Buffer Management Mappings
+" ============================================================================
+nnoremap <silent> <leader>w :w<CR>
+nnoremap <silent> <leader>q :q<CR>
+nnoremap <silent> <leader>wq :wq<CR>
+nnoremap <silent> <leader>Q :qa!<CR>
+
+" File operations
+nnoremap <leader>f :Lex<CR>
+noremap <leader>o :Explore<CR>
+nnoremap <leader>rf :browse old<cr>
+
+" Utility mappings
+nnoremap <silent> <leader>r :registers<CR>
+nnoremap <silent> <leader>m :redir @+<CR>:silent messages<CR>:redir END<CR>
+nnoremap <silent> <leader>hx :call HexState()<CR>
+nnoremap <buffer> <leader>h :help <C-R><C-W><CR>
+
+" Format disable
+cnoremap F! :noautocmd w<CR>
+
+" ============================================================================
+" Window and Terminal Mappings
+" ============================================================================
+
+" Window resizing
+nnoremap <M-Up> :resize -2<CR>
+noremap <M-Down> :resize +2<CR>
+noremap <M-Left> :vertical resize -2<CR>
+noremap <M-Right> :vertical resize +2<CR>
+
+" Terminal mode
+nnoremap <silent> <C-t> :terminal<CR>
+tnoremap <C-t> <C-\><C-n>:q!<CR>
+tnoremap <Esc> <C-\><C-n>
+tnoremap <C-h> <C-\><C-n><C-w>h
+tnoremap <C-j> <C-\><C-n><C-w>j
+tnoremap <C-k> <C-\><C-n><C-w>k
+tnoremap <C-l> <C-\><C-n><C-w>l
+
+" ============================================================================
+" Text Editing and Visual Mode Mappings
+" ============================================================================
+
+" Insert mode shortcuts
+inoremap jk <ESC>
+
+" Visual mode operations
+vnoremap J :m '>+1<CR>gv=gv
+vnoremap K :m '>-2<CR>gv=gv
+vnoremap < <gv
+vnoremap > >gv
+
+" Text formatting
+nnoremap Q gqap
+
+" Auto-closing pairs
+inoremap [ []<left>
+inoremap ( ()<left>
+inoremap { {}<left>
+inoremap /* /**/<left><left>
+
+" ============================================================================
+" Tab and Completion Functions
+" ============================================================================
+
+" Smart Tab Function
+function! SmartIndentTab()
+ let line = getline('.')
+ let col = col('.') - 1
+
+ if col == 0 || line[col - 1] =~ '^\s*$'
+ return "\<C-T>"
+ else
+ return "\<tab>"
+ endif
+endfunction
+
+" Tab mappings
+silent! iunmap <tab>
+inoremap <silent><expr> <tab> SmartIndentTab()
+inoremap <expr> <CR> pumvisible() ? "\<C-Y>" : "\<CR>"
+
+" Auto-completion function
+function! AutoComplete()
+ let skip_filetypes = ['netrw', 'help', 'startify', 'qf', 'man', 'gitcommit']
+
+ if index(skip_filetypes, &filetype) >= 0
+ return
+ endif
+
+ let col = col('.')
+ if col < 4
+ return
+ endif
+
+ let line = getline('.')
+ let prev3 = line[col - 4]
+ let prev2 = line[col - 3]
+ let prev1 = line[col - 2]
+ let curr = v:char
+
+ if curr =~ '\k' && prev3 !~ '\k' && prev2 =~ '\k' && prev1 =~ '\k'
+ call feedkeys("\<C-n>", 'n')
+ endif
+endfunction
+
+" ============================================================================
+" Spell Checking
+" ============================================================================
+noremap <silent> <C-z> :setlocal spell!<CR>
+setlocal nospell
+
+function! SpellCheckStatus()
+ return &spell ? ' [SPELL]' : ''
+endfunction
-" FILE BROWSING:
-let g:netrw_banner=0 " disable annoying banner
-let g:netrw_browse_split=4 " open in prior window
-let g:netrw_altv=1 " open splits to the right
-let g:netrw_liststyle=3 " tree view
+" ============================================================================
+" File Explorer Configuration
+" ============================================================================
+let g:netrw_banner=0
+let g:netrw_browse_split=4
+let g:netrw_altv=1
+let g:netrw_liststyle=3
let g:netrw_fastbrowse = 0
-autocmd FileType netrw setl bufhidden=wipe
+let g:netrw_winsize=20
-" Faster vimgrep/grep via ripgrep
+" ============================================================================
+" Search Tools Configuration
+" ============================================================================
if executable("rg")
- set grepprg=rg\ --vimgrep\ --no-heading
- set grepformat=%f:%l:%c:%m,%f:%l:%m
+ set grepprg=rg\ --vimgrep\ --no-heading
+ set grepformat=%f:%l:%c:%m,%f:%l:%m
endif
+" ============================================================================
+" Clipboard Configuration
+" ============================================================================
+
+" OS Detection
+let s:uname = substitute(system('uname'), '\n', '', '')
+let g:is_mac = has('mac')
+let g:is_linux = s:uname ==# 'Linux'
+let g:is_windows = has('win32') || has('win64') || s:uname =~? 'Windows'
+let g:is_wsl = has('wsl') || (g:is_linux && !empty($WSL_DISTRO_NAME))
+let g:is_termux = has('termux') || (!empty($PREFIX) && $PREFIX =~# 'com.termux')
+let g:is_wayland = !empty($WAYLAND_DISPLAY)
+let g:is_x11 = !empty($DISPLAY) && empty($WAYLAND_DISPLAY)
+
+" Clipboard configuration
+if has('unnamedplus')
+ set clipboard=unnamed,unnamedplus
+else
+ set clipboard=unnamed
+endif
-"===============================================================================
-" Colorscheme
-"===============================================================================
+if has('clipboard')
+ " Linux: Wayland/X11 providers
+ if g:is_wayland && executable('wl-copy') && executable('wl-paste')
+ let g:clipboard = {
+ \ 'name': 'wl-clipboard',
+ \ 'copy': {
+ \ '+': ['wl-copy', '--trim-newline'],
+ \ '*': ['wl-copy', '--trim-newline', '--primary'],
+ \ },
+ \ 'paste': {
+ \ '+': ['wl-paste', '--no-newline'],
+ \ '*': ['wl-paste', '--no-newline', '--primary'],
+ \ },
+ \ 'cache_enabled': 1,
+ \ }
+ elseif g:is_x11 && executable('xclip')
+ let g:clipboard = {
+ \ 'name': 'xclip',
+ \ 'copy': {
+ \ '+': ['xclip', '-selection', 'clipboard'],
+ \ '*': ['xclip', '-selection', 'primary'],
+ \ },
+ \ 'paste': {
+ \ '+': ['xclip', '-selection', 'clipboard', '-o'],
+ \ '*': ['xclip', '-selection', 'primary', '-o'],
+ \ },
+ \ 'cache_enabled': 1,
+ \ }
+ elseif g:is_x11 && executable('xsel')
+ let g:clipboard = {
+ \ 'name': 'xsel',
+ \ 'copy': {
+ \ '+': ['xsel', '--clipboard', '--input'],
+ \ '*': ['xsel', '--primary', '--input'],
+ \ },
+ \ 'paste': {
+ \ '+': ['xsel', '--clipboard', '--output'],
+ \ '*': ['xsel', '--primary', '--output'],
+ \ },
+ \ 'cache_enabled': 1,
+ \ }
+ " macOS: pbcopy/pbpaste
+ elseif g:is_mac && executable('pbcopy') && executable('pbpaste')
+ let g:clipboard = {
+ \ 'name': 'macOS-clipboard',
+ \ 'copy': { '+': ['pbcopy'], '*': ['pbcopy'] },
+ \ 'paste': { '+': ['pbpaste'], '*': ['pbpaste'] },
+ \ 'cache_enabled': 1,
+ \ }
+ " WSL: prefer win32yank, fallback to clip.exe + PowerShell
+ elseif g:is_wsl && executable('win32yank.exe')
+ let g:clipboard = {
+ \ 'name': 'win32yank-wsl',
+ \ 'copy': { '+': ['win32yank.exe', '-i', '--crlf'],
+ \ '*': ['win32yank.exe', '-i', '--crlf'] },
+ \ 'paste': { '+': ['win32yank.exe', '-o', '--lf'],
+ \ '*': ['win32yank.exe', '-o', '--lf'] },
+ \ 'cache_enabled': 1,
+ \ }
+ elseif g:is_wsl && executable('clip.exe') && executable('powershell.exe')
+ let g:clipboard = {
+ \ 'name': 'wsl-clip',
+ \ 'copy': {
+ \ '+': ['clip.exe'],
+ \ '*': ['clip.exe'],
+ \ },
+ \ 'paste': {
+ \ '+': ['powershell.exe', '-NoProfile', '-Command',
+ \ '[Console]::Out.Write((Get-Clipboard -Raw) -replace "`r","")'],
+ \ '*': ['powershell.exe', '-NoProfile', '-Command',
+ \ '[Console]::Out.Write((Get-Clipboard -Raw) -replace "`r","")'],
+ \ },
+ \ 'cache_enabled': 0,
+ \ }
+ " Native Windows
+ elseif g:is_windows && !g:is_wsl && executable('win32yank.exe')
+ let g:clipboard = {
+ \ 'name': 'win32yank',
+ \ 'copy': { '+': ['win32yank.exe', '-i', '--crlf'],
+ \ '*': ['win32yank.exe', '-i', '--crlf'] },
+ \ 'paste': { '+': ['win32yank.exe', '-o', '--lf'],
+ \ '*': ['win32yank.exe', '-o', '--lf'] },
+ \ 'cache_enabled': 1,
+ \ }
+ elseif g:is_windows && !g:is_wsl && executable('powershell.exe')
+ let g:clipboard = {
+ \ 'name': 'powershell-clipboard',
+ \ 'copy': {
+ \ '+': ['powershell.exe', '-NoProfile', '-Command',
+ \ 'Set-Clipboard ([Console]::In.ReadToEnd())'],
+ \ '*': ['powershell.exe', '-NoProfile', '-Command',
+ \ 'Set-Clipboard ([Console]::In.ReadToEnd())'],
+ \ },
+ \ 'paste': {
+ \ '+': ['powershell.exe', '-NoProfile', '-Command',
+ \ '[Console]::Out.Write((Get-Clipboard -Raw) -replace "`r","")'],
+ \ '*': ['powershell.exe', '-NoProfile', '-Command',
+ \ '[Console]::Out.Write((Get-Clipboard -Raw) -replace "`r","")'],
+ \ },
+ \ 'cache_enabled': 0,
+ \ }
+ endif
+endif
-" enable syntax, plugins (for netrw) and indentation
+" ============================================================================
+" Colorscheme and Appearance
+" ============================================================================
syntax enable
-
-"set shell=zsh
set termguicolors
set guicursor=
let &t_SI = "\e[6 q"
let &t_EI = "\e[2 q"
-
-"colorscheme desert
-"colorscheme city-lights
set background=dark
-highlight Normal guibg=NONE ctermbg=NONE
-highlight EndOfBuffer ctermfg=NONE ctermbg=NONE
+" Window title
+let progname = substitute($VIM, '.*[/\\]', '', '')
+set title titlestring=%{progname}\ %f\ +%l\ #%{tabpagenr()}.%{winnr()}
+if &term =~ '^screen' && !has('vim')
+ exe "set t_ts=\e]2; t_fs=\7"
+endif
-"-------------------------------------------------------------------------------
-
+colorscheme colorscheme
-"===============================================================================
-" Functions/Scripts
-"===============================================================================
+" ============================================================================
+" Custom Functions
+" ============================================================================
-" Enable mouse scrollback
-"---------------------------------------
-set mouse=a
-tnoremap <Esc> <C-\><C-n>
-tnoremap <c-b> <c-\><c-n>
+" Clear Terminal Buffer
function! ClearTerminal()
- set scrollback=1
- let &g:scrollback=1
- echo &scrollback
- call feedkeys("\i")
- call feedkeys("clear\<CR>")
- call feedkeys("\<C-\>\<C-n>")
- call feedkeys("\i")
- sleep 100m
- let &scrollback=s:scroll_value
+ if &buftype == 'terminal'
+ let s:scroll_value = &scrollback
+ set scrollback=1
+ call feedkeys("\<C-\\>\<C-n>i")
+ call feedkeys("clear\<CR>")
+ call timer_start(100, {-> execute('let &scrollback=' . s:scroll_value)})
+ endif
endfunction
-"-------------------------------------------------------------------------------
-
-" :Rename {newname}
-"---------------------------------------
+" Rename Current File
function! RenameFile()
let old_name = expand('%')
- let new_name = input('New file name: ', expand('%'), 'file')
+ let new_name = input('New file name: ', old_name, 'file')
if new_name != '' && new_name != old_name
- exec ':saveas ' . new_name
- exec ':silent !rm ' . old_name
- redraw!
+ try
+ execute 'saveas ' . fnameescape(new_name)
+ if filereadable(old_name) && !filereadable(new_name)
+ call delete(old_name)
+ endif
+ redraw!
+ catch /^Vim\%(\w\+\).*/
+ echohl ErrorMsg | echo 'Error renaming file: ' . v:exception | echohl None
+ endtry
+ endif
+endfunction
+
+" Format with cursor preservation
+function! PreserveCursorFormat()
+ let l:pos = getpos(".")
+ silent! normal! gg=G
+ call setpos('.', l:pos)
+endfunction
+
+" File/URL opener
+function! OpenFileOrUrl(path) abort
+ if !exists('g:os_name')
+ echohl WarningMsg | echom 'OS detection not available' | echohl None
+ return
+ endif
+
+ let cmd = ''
+ if g:os_name ==# 'mac'
+ let cmd = 'open ' . shellescape(a:path)
+ elseif g:os_name ==# 'linux'
+ let cmd = 'xdg-open ' . shellescape(a:path) . ' >/dev/null 2>&1 &'
+ elseif g:os_name ==# 'wsl'
+ let cmd = 'wslview ' . shellescape(a:path) . ' >/dev/null 2>&1 &'
+ elseif g:os_name ==# 'windows'
+ let cmd = 'start "" ' . shellescape(a:path)
+ elseif g:os_name ==# 'termux'
+ let cmd = 'am start -a android.intent.action.VIEW -d ' . shellescape(a:path)
+ else
+ echohl WarningMsg | echom 'No file opener for OS: ' . g:os_name | echohl None
+ return
+ endif
+
+ call system(cmd)
+ if v:shell_error
+ echohl ErrorMsg | echom 'Failed to open: ' . a:path | echohl None
+ endif
+endfunction
+
+" ============================================================================
+" Hex Editing Functions
+" ============================================================================
+
+" Convert to hex
+function! DoHex() abort
+ let current_file = expand('%:p')
+ if empty(current_file)
+ echohl ErrorMsg | echo 'No file name' | echohl None
+ return
endif
+
+ let new_file = current_file . '.hex'
+ try
+ execute 'w !xxd > ' . fnameescape(new_file)
+ echohl Directory | echo 'Hex file created: ' . new_file | echohl None
+ catch /^Vim\%(\w\+\):/
+ echohl ErrorMsg | echo 'Error creating hex file: ' . v:exception | echohl None
+ endtry
endfunction
-map <leader>r :call RenameFile()<cr>
-
-"-------------------------------------------------------------------------------
-
-" Return to the same line when we reopen a file
-"---------------------------------------
- augroup line_return
- au!
- au BufReadPost *
- \ if line("'\"") > 0 && line("'\"") <= line("$") |
- \ execute 'normal! g`"zvzz' |
- \ endif
- augroup END
-
-"-------------------------------------------------------------------------------
-"
-" Function to update tmux status and .vi-mode file
-"---------------------------------------
-function! UpdateTmuxStatus() abort
- " Check if the current buffer has a man filetype
- if &filetype ==# 'man'
- return
- endif
-
- " Determine the mode name based on the mode value
- let mode = mode()
- let mode_name = ''
- if mode ==# 'n'
- let mode_name = '-- NORMAL --'
- elseif mode ==# 'i' || mode ==# 'ic'
- let mode_name = '-- INSERT --'
- else
- let mode_name = '-- NORMAL --'
- endif
-
- " Write the mode name to the file
- call writefile([mode_name], expand('$HOME') . '/.vi-mode')
+" Convert from hex
+function! UndoHex() abort
+ let current_file = expand('%:p')
+ if empty(current_file)
+ echohl ErrorMsg | echo 'No file name' | echohl None
+ return
+ endif
+
+ let new_file = substitute(current_file, '\.hex$', '', '')
+ if new_file ==# current_file
+ echohl WarningMsg | echo 'Not a .hex file' | echohl None
+ return
+ endif
+
+ try
+ execute '%!xxd -r'
+ execute 'w ' . fnameescape(new_file)
+ echohl Directory | echo 'Binary file restored: ' . new_file | echohl None
+ catch /^Vim\%(\w\+\):/
+ echohl ErrorMsg | echo 'Error converting hex file: ' . v:exception | echohl None
+ endtry
endfunction
-" Function to refresh tmux status
-function! s:UpdateTmux() abort
- call system('tmux refresh-client -S')
+" Hex state switcher
+function! HexState() abort
+ let choices = [
+ \ '1. Convert to hex',
+ \ '2. Convert from hex',
+ \ '3. Cancel'
+ \ ]
+
+ let choice = inputlist(choices)
+ if choice == 1
+ call DoHex()
+ elseif choice == 2
+ call UndoHex()
+ else
+ echo 'Operation cancelled.'
+ endif
endfunction
-" Set up autocommands for tmux status update
-if !empty($TMUX) && system('command -v tmux >/dev/null 2>&1') == 0
-augroup TmuxStatus
- autocmd!
- autocmd ModeChanged * call UpdateTmuxStatus() | call s:UpdateTmux()
+" ============================================================================
+" Commands
+" ============================================================================
+command! -nargs=0 OpenFile call OpenFileOrUrl(expand('%:p'))
+
+" ============================================================================
+" Auto Commands
+" ============================================================================
+
+" Return to last position
+augroup line_return
+ au!
+ au BufReadPost *
+ \ if line("'\"") > 0 && line("'\"") <= line("$") |
+ \ execute 'normal! g`"zvzz' |
+ \ endif
augroup END
-endif
-"-------------------------------------------------------------------------------
+" Auto-completion
+augroup AutoCompleteWordStart
+ autocmd!
+ autocmd InsertCharPre * call AutoComplete()
+augroup END
+" Relative numbers in insert mode
+autocmd InsertEnter * set norelativenumber
+autocmd InsertLeave * set relativenumber
-"===============================================================================
-" Statusline Configuration
-"===============================================================================
+" Netrw cleanup
+autocmd FileType netrw setl bufhidden=wipe
-" Autoload statusline
-"---------------------------------------
-" Load statusline script
-if filereadable(expand("~/.vim/autoload/statusline.vim"))
- source ~/.vim/autoload/statusline.vim
+" Reload config
+augroup ReloadVimrc
+ autocmd!
+ autocmd BufWritePost $MYVIMRC nested source $MYVIMRC |
+ \ doautocmd ColorScheme |
+ \ call autoload#statusline#ActivateStatusline() |
+ \ echon "Reloaded .vimrc" |
+ \ redraw!
+augroup END
+
+" Auto format
+augroup FormatOnSave
+ autocmd!
+ autocmd BufWritePre * call PreserveCursorFormat()
+augroup END
+
+" ============================================================================
+" Statusline Configuration
+" ============================================================================
+let s:statusline_file = expand('~/.vim/autoload/statusline.vim')
+if filereadable(s:statusline_file)
+ execute 'source ' . fnameescape(s:statusline_file)
+
+ augroup StatuslineConfig
+ autocmd!
+ autocmd VimEnter * call autoload#statusline#ActivateStatusline()
+ autocmd ColorScheme * call autoload#statusline#UpdateStslineColors()
+ autocmd VimEnter * redrawstatus!
+ augroup END
+
+ set laststatus=2
+ set statusline=%!StatusLine()
+
+ augroup StatuslineOverride
+ autocmd!
+ autocmd FileType help,gitcommit,netrw setlocal statusline=%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
+ augroup END
endif
-" Call the statusline activation function
-call autoload#statusline#ActivateStatusline()
+" ============================================================================
+" GUI Configuration
+" ============================================================================
+if has('gui_running')
+ color slate
+
+ if has('mac')
+ set guifont=Menlo\ Regular:h14
+ elseif has('win32')
+ set guifont=Consolas:h12
+ else
+ set guifont=Monospace\ 11
+ endif
+
+ set guioptions-=T
+ set guioptions-=r
+ set guioptions-=L
+ set guioptions-=m
+
+ autocmd VimEnter * :Lexplore | wincmd p
+endif
+
+" ============================================================================
+" Final Setup
+" ============================================================================
+syntax on
+filetype plugin indent on
+setlocal keywordprg=:help
+setlocal iskeyword+=:
+
+" Load matchit for better % matching
+if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
+ runtime! macros/matchit.vim
+endif
-"-------------------------------------------------------------------------------
+" ============================================================================