Skip to content

Instantly share code, notes, and snippets.

@zQueal
Created July 7, 2024 08:32
Show Gist options
  • Save zQueal/fd19d98f3a05d4e0a4adf35c026f9bf9 to your computer and use it in GitHub Desktop.
Save zQueal/fd19d98f3a05d4e0a4adf35c026f9bf9 to your computer and use it in GitHub Desktop.
neovim config files
inoremap jk <ESC>
nnoremap n :norm! nzzzv<CR>
nnoremap N :norm! Nzzzv<CR>
nnoremap H ^
nnoremap L $
nnoremap <Return> o<ESC>
nnoremap <Leader>w :up<CR>
nnoremap <Leader>wq :wq<CR>
nnoremap <Leader>q :q<CR>
nnoremap <Leader>qq :qall!<CR>
nnoremap <Leader>k dd
nnoremap <Leader>d :t.<CR>
nnoremap <Leader>af ggVG
nnoremap <Leader>pwd :pwd<CR>
nnoremap <Leader>, :noh<CR>
nnoremap <Space><Space> :%s/\<<C-r>=expand("<cword>")<CR>\>/
nnoremap J <PageDown>
nnoremap K <PageUp>
xnoremap J :m '>+1<CR>gv=gv
xnoremap K :m '<-2<CR>gv=gv
xnoremap <Leader>pp :w !curl -F "f:1=<-" ix.io<CR>
" fix copy and paste
noremap y "+y
noremap p "+p
xnoremap y "+y
xnoremap p "+p
" f keys
nnoremap <F5> :F<CR>
nnoremap <F6> 1G=G<CR>
nnoremap <F7> :MundoToggle<CR>
nnoremap <F8> :PlugUpdate<CR>
" <F9> reserved for folding
nnoremap <F10> :set rnu! rnu?<CR>
" window splits
" the following two lines enable _ to open a horizontal split
" and | to open a vertical split
nnoremap <expr><silent> \| !v:count ? "<C-W>v<C-W><Right>" : '\|'
nnoremap <expr><silent> _ !v:count ? "<C-W>s<C-W><Down>" : '_'
nnoremap <Tab> <C-W>w
nnoremap <S-Tab> <C-W>W
source ~/AppData/Local/nvim/config/plugins.vim
source ~/AppData/Local/nvim/config/settings.vim
source ~/AppData/Local/nvim/config/runtime.vim
source ~/AppData/Local/nvim/config/bindings.vim
source ~/AppData/Local/nvim/config/functions.vim
" source ~/AppData/Local/nvim/config/statusline.vim
call plug#begin('~/.vim/plugged')
Plug 'dmix/elvish.vim'
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-surround'
Plug 'tommcdo/vim-lion'
Plug 'simnalamburt/vim-mundo'
Plug 'roman/golden-ratio'
Plug 'jeetsukumaran/vim-buffergator'
Plug 'mhinz/vim-startify'
Plug 'zqueal/barow'
Plug 'justinmk/vim-sneak'
Plug 'sainnhe/gruvbox-material'
Plug 'NoahTheDuke/vim-just'
Plug 'willothy/wezterm.nvim'
call plug#end()
set runtimepath^="~/.vim/plugged"
let &packpath = &runtimepath
" windows options
if has('win32') || has('win64')
silent! call mkdir($HOME."\\.vim\\backup", "p")
silent! call mkdir($HOME."\\.vim\\swap", "p")
silent! call mkdir($HOME."\\.vim\\undo", "p")
set backup
set swapfile
set undofile
set directory=$HOME\\.vim\\swap\\
set backupdir=$HOME\\.vim\\backup\\
set undodir=$HOME\\.vim\\undo\\
endif
if !has('gui')
silent! colorscheme gruvbox-material
set termencoding=utf-8
endif
if has('gui')
silent! colorscheme gruvbox-material
set guifont="RobotoMono NF":h11
set termencoding=utf-8
endif
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au BufNewFile,BufRead justfile setf make
augroup END
" mapleader
let mapleader = "\<Space>"
set nocompatible
syntax on
filetype plugin indent on
" interface
set path+=** " search down into subfolders / tab-completion for file-related tasks
set go+=m " easier mouse mode for gVim
set background=dark " tell vim what the background color looks like
set noshowmode " don't show mode as airline already does
set laststatus=2 " show status line
set number " show line numbers
set ruler " show current position at bottom
set showcmd " show any commands
set sidescroll=1 " smoother horizontal scrolling
set splitbelow " create new splits below
set splitright " create new splits to the right
set wildmenu " enable wildmenu
set wildmode=longest:full,full " configure wildmenu
set lazyredraw " don't draw everything
set hidden " don't unload buffer if abandoned
set scrolloff=999 " always center cursor where possible
set timeout timeoutlen=400 ttimeoutlen=450 " set quick timeouts
" whitespace
set expandtab " use tabs instead of spaces
set nojoinspaces " use one space, not two, after punctuation
set shiftround " shift to next tabstop
set shiftwidth=2 " amount of space used for indentation
set softtabstop=2 " appearance of tabs
set tabstop=2 " use two spaces for tabs
" folding
set foldmethod=manual " manual folding (below: <mode>)
inoremap <F9> <C-O>za
nnoremap <F9> za
xnoremap <F9> zf
" text appearance
set nowrap " disable line wrapping
set showmatch " show opening and closing character matches
" interaction
set backspace=2 " make backspace work like most other apps
set mouse=a " enable mouse support
" searching
set incsearch " highlight search matches
set ignorecase " set case insensitive searching
set smartcase " case sensitive searching when not all lowercase
" background processes
set autoread " update file when changed outside of vim
set autoindent " auto-indent things
set history=200 " store last 200 commands as history
set ttyfast " indicates a fast terminal connection
" character encoding
if !&readonly
set fileencoding=utf-8
set fileformats=unix,dos
set encoding=utf-8
endif
" autocmd
augroup StartupGroup
autocmd!
autocmd VimEnter * set rnu
autocmd VimEnter * set autochdir
autocmd ColorScheme * highlight Comment cterm=italic
augroup END
set list
set listchars=tab:>-,trail:.
let g:netrw_banner=0
let g:netrw_liststyle=3
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
set laststatus=2
set noshowmode
set termguicolors
function! ActivateStatusline()
call GetFileType()
setlocal statusline=%#StslinePriColorBG#\ %{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\
endfunction
function! DeactivateStatusline()
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
function! StslineMode()
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==#"V"
let g:StslinePriColor = g:StslineColorBlue
let b:CurrentMode = "V-LINE"
elseif l:CurrentMode==#"\<C-v>"
let g:StslinePriColor = g:StslineColorBlue
let b:CurrentMode = "V-BLOCK"
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 UpdateStslineColors()
return b:CurrentMode
endfunction
function! UpdateStslineColors()
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
function! GetGitBranch()
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
function! GetFileType()
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
augroup GetGitBranch
autocmd!
autocmd BufEnter * call GetGitBranch()
augroup END
augroup SetStslineline
autocmd!
autocmd BufEnter,WinEnter * call ActivateStatusline()
autocmd BufLeave,WinLeave * call DeactivateStatusline()
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment