diff options
| author | srdusr <trevorgray@srdusr.com> | 2025-08-30 19:22:59 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2025-08-30 19:22:59 +0200 |
| commit | 19120d4f9761c67d99ed1ce3da6084b83f5a49c9 (patch) | |
| tree | f234cad1bdad88114a63c9702144da487024967a /.vim | |
| parent | 5928998af5404ae2be84c6cecc10ebf84bd3f3ed (diff) | |
| download | dotfiles-19120d4f9761c67d99ed1ce3da6084b83f5a49c9.tar.gz dotfiles-19120d4f9761c67d99ed1ce3da6084b83f5a49c9.zip | |
Linux-specific dotfiles
Diffstat (limited to '.vim')
| -rw-r--r-- | .vim/autoload/statusline.vim | 227 | ||||
| m--------- | .vim/pack/plugins/start/vim-tmux-navigator | 0 | ||||
| -rw-r--r-- | .vim/vimrc | 296 |
3 files changed, 0 insertions, 523 deletions
diff --git a/.vim/autoload/statusline.vim b/.vim/autoload/statusline.vim deleted file mode 100644 index 5e5a671..0000000 --- a/.vim/autoload/statusline.vim +++ /dev/null @@ -1,227 +0,0 @@ -"" 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. - -" Color pallet -" Green - #2BBB4F (BG) - #080808 (FG) -" Blue - #4799EB -" Violet - #986FEC -" Yellow - #D7A542 -" Orange - #EB754D -" Grey1 - #202020 -" Grey - #303030 - -" Define color variables -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:StslineColorDark3 = '#303030' - -" Define colors -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 - -" 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 - -" 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 ' - endif - - call autoload#statusline#UpdateStslineColors() - - 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 -endfunction - -" Get git branch name -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 b:GitBranch = " " . substitute(l:gitrevparse, '\n', '', 'g') . " " - execute 'highlight StslineBackColorFGPriColorBG guifg=' . g:StslineBackColor . ' guibg=' . g:StslineSecColor - 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 ==# '' - 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 = ' ' - else - let b:FiletypeIcon = ' ' - endif -endfunction - -" Automatically update git branch name when entering a buffer -augroup GetGitBranch - 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() -augroup END - -call autoload#statusline#ActivateStatusline() - diff --git a/.vim/pack/plugins/start/vim-tmux-navigator b/.vim/pack/plugins/start/vim-tmux-navigator deleted file mode 160000 -Subproject 38b1d0402c4600543281dc85b3f51884205674b diff --git a/.vim/vimrc b/.vim/vimrc deleted file mode 100644 index ce034e9..0000000 --- a/.vim/vimrc +++ /dev/null @@ -1,296 +0,0 @@ -"=============================================================================== -" 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 -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 relativenumber -set hidden -set noerrorbells -set nowrap -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 - -" 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 -let g:netrw_fastbrowse = 0 -autocmd FileType netrw setl bufhidden=wipe - -" Faster vimgrep/grep via ripgrep -if executable("rg") - set grepprg=rg\ --vimgrep\ --no-heading - set grepformat=%f:%l:%c:%m,%f:%l:%m -endif - - -"=============================================================================== -" Colorscheme -"=============================================================================== - -" enable syntax, plugins (for netrw) and indentation -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 - - -"------------------------------------------------------------------------------- - - -"=============================================================================== -" Functions/Scripts -"=============================================================================== - -" Enable mouse scrollback -"--------------------------------------- -set mouse=a -tnoremap <Esc> <C-\><C-n> -tnoremap <c-b> <c-\><c-n> -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 -endfunction - -"------------------------------------------------------------------------------- - -" :Rename {newname} -"--------------------------------------- -function! RenameFile() - let old_name = expand('%') - let new_name = input('New file name: ', expand('%'), 'file') - if new_name != '' && new_name != old_name - exec ':saveas ' . new_name - exec ':silent !rm ' . old_name - redraw! - endif -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') - -endfunction - -" Function to refresh tmux status -function! s:UpdateTmux() abort - call system('tmux refresh-client -S') -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() -augroup END -endif - -"------------------------------------------------------------------------------- - - -"=============================================================================== -" Statusline Configuration -"=============================================================================== - -" Autoload statusline -"--------------------------------------- -" Load statusline script -if filereadable(expand("~/.vim/autoload/statusline.vim")) - source ~/.vim/autoload/statusline.vim -endif - -" Call the statusline activation function -call autoload#statusline#ActivateStatusline() - -"------------------------------------------------------------------------------- |
