Skip to content

Instantly share code, notes, and snippets.

@AlexRogalskiy
Last active March 18, 2022 13:42
Show Gist options
  • Save AlexRogalskiy/d8a09fcbaf19a581669e747403254351 to your computer and use it in GitHub Desktop.
Save AlexRogalskiy/d8a09fcbaf19a581669e747403254351 to your computer and use it in GitHub Desktop.
Alias vim
set background=dark
highlight clear
let colors_name = "alias"
"Set environment to 256 colours
set t_Co=256
if version > 580
hi clear
if exists("syntax_on")
syntax reset
endif
endif
if version > 800
set termguicolors
endif
function! s:hi(group, fg, bg, gui)
execute "hi " . a:group .
\ " guifg=" . s:colors[a:fg] .
\ " guibg=" . s:colors[a:bg] .
\ " gui=" . a:gui .
\ " ctermfg=" . a:fg .
\ " ctermbg=" . a:bg .
\ " cterm=" . a:gui
endfunction
let s:colors = {
\ "00": "#000000",
\ "01": "#800000",
\ "02": "#008000",
\ "03": "#808000",
\ "04": "#000080",
\ "05": "#800080",
\ "06": "#008080",
\ "07": "#c0c0c0",
\ "08": "#808080",
\ "09": "#ff0000",
\ "10": "#00ff00",
\ "11": "#ffff00",
\ "12": "#0000ff",
\ "13": "#ff00ff",
\ "14": "#00ffff",
\ "15": "#ffffff",
\ "16": "#000000",
\ "17": "#00005g",
\ "18": "#000087",
\ "19": "#0000af",
\ "20": "#0000d7",
\ "21": "#0000ff",
\ "22": "#005f00",
\ "23": "#005f5f",
\ "24": "#005f87",
\ "25": "#005faf",
\ "26": "#005fd7",
\ "27": "#005fff",
\ "28": "#008700",
\ "29": "#00875f",
\ "30": "#008787",
\ "31": "#0087af",
\ "32": "#0087d7",
\ "33": "#0087ff",
\ "34": "#00af00",
\ "35": "#00af5f",
\ "36": "#00af87",
\ "37": "#00afaf",
\ "38": "#00afd7",
\ "39": "#00afff",
\ "40": "#00d700",
\ "41": "#00d75f",
\ "42": "#00d787",
\ "43": "#00d7af",
\ "44": "#00d7d7",
\ "45": "#00d7ff",
\ "46": "#00ff00",
\ "47": "#00ff5f",
\ "48": "#00ff87",
\ "49": "#00ffaf",
\ "50": "#00ffd7",
\ "51": "#00ffff",
\ "52": "#5f0000",
\ "53": "#5f005f",
\ "54": "#5f0087",
\ "55": "#5f00af",
\ "56": "#5f00d7",
\ "57": "#5f00ff",
\ "58": "#5f5f00",
\ "59": "#5f5f5f",
\ "60": "#5f5f87",
\ "61": "#5f5faf",
\ "62": "#5f5fd7",
\ "63": "#5f5fff",
\ "64": "#5f8700",
\ "65": "#5f875f",
\ "66": "#5f8787",
\ "67": "#5f87af",
\ "68": "#5f87d7",
\ "69": "#5f87ff",
\ "70": "#5faf00",
\ "71": "#5faf5f",
\ "72": "#5faf87",
\ "73": "#5fafaf",
\ "74": "#5fafd7",
\ "75": "#5fafff",
\ "76": "#5fd700",
\ "77": "#5fd75f",
\ "78": "#5fd787",
\ "79": "#5fd7af",
\ "80": "#5fd7d7",
\ "81": "#5fd7ff",
\ "82": "#5fff00",
\ "83": "#5fff5f",
\ "84": "#5fff87",
\ "85": "#5fffaf",
\ "86": "#5fffd7",
\ "87": "#5fffff",
\ "88": "#870000",
\ "89": "#87005f",
\ "90": "#870087",
\ "91": "#8700af",
\ "92": "#8700d7",
\ "93": "#8700ff",
\ "94": "#875f00",
\ "95": "#875f5f",
\ "96": "#875f87",
\ "97": "#875faf",
\ "98": "#875fd7",
\ "99": "#875fff",
\ "100": "#878700",
\ "101": "#87875f",
\ "102": "#878787",
\ "103": "#8787af",
\ "104": "#8787d7",
\ "105": "#8787ff",
\ "106": "#87af00",
\ "107": "#87af5f",
\ "108": "#87af87",
\ "109": "#87afaf",
\ "110": "#87afd7",
\ "111": "#87afff",
\ "112": "#87d700",
\ "113": "#87d75f",
\ "114": "#87d787",
\ "115": "#87d7af",
\ "116": "#87d7d7",
\ "117": "#87d7ff",
\ "118": "#87ff00",
\ "119": "#87ff5f",
\ "120": "#87ff87",
\ "121": "#87ffaf",
\ "122": "#87ffd7",
\ "123": "#87ffff",
\ "124": "#af0000",
\ "125": "#af005f",
\ "126": "#af0087",
\ "127": "#af00af",
\ "128": "#af00d7",
\ "129": "#af00ff",
\ "130": "#af5f00",
\ "131": "#af5f5f",
\ "132": "#af5f87",
\ "133": "#af5faf",
\ "134": "#af5fd7",
\ "135": "#af5fff",
\ "136": "#af8700",
\ "137": "#af875f",
\ "138": "#af8787",
\ "139": "#af87af",
\ "140": "#af87d7",
\ "141": "#af87ff",
\ "142": "#afaf00",
\ "143": "#afaf5f",
\ "144": "#afaf87",
\ "145": "#afafaf",
\ "146": "#afafd7",
\ "147": "#afafff",
\ "148": "#afd700",
\ "149": "#afd75f",
\ "150": "#afd787",
\ "151": "#afd7af",
\ "152": "#afd7d7",
\ "153": "#afd7ff",
\ "154": "#afff00",
\ "155": "#afff5f",
\ "156": "#afff87",
\ "157": "#afffaf",
\ "158": "#afffd7",
\ "159": "#afffff",
\ "160": "#d70000",
\ "161": "#d7005f",
\ "162": "#d70087",
\ "163": "#d700af",
\ "164": "#d700d7",
\ "165": "#d700ff",
\ "166": "#d75f00",
\ "167": "#d75f5f",
\ "168": "#d75f87",
\ "169": "#d75faf",
\ "170": "#d75fd7",
\ "171": "#d75fff",
\ "172": "#d78700",
\ "173": "#d7875f",
\ "174": "#d78787",
\ "175": "#d787af",
\ "176": "#d787d7",
\ "177": "#d787ff",
\ "178": "#d7af00",
\ "179": "#d7af5f",
\ "180": "#d7af87",
\ "181": "#d7afaf",
\ "182": "#d7afd7",
\ "183": "#d7afff",
\ "184": "#d7d700",
\ "185": "#d7d75f",
\ "186": "#d7d787",
\ "187": "#d7d7af",
\ "188": "#d7d7d7",
\ "189": "#d7d7ff",
\ "190": "#d7ff00",
\ "191": "#d7ff5f",
\ "192": "#d7ff87",
\ "193": "#d7ffaf",
\ "194": "#d7ffd7",
\ "195": "#d7ffff",
\ "196": "#ff0000",
\ "197": "#ff005f",
\ "198": "#ff0087",
\ "199": "#ff00af",
\ "200": "#ff00d7",
\ "201": "#ff00ff",
\ "202": "#ff5f00",
\ "203": "#ff5f5f",
\ "204": "#ff5f87",
\ "205": "#ff5faf",
\ "206": "#ff5fd7",
\ "207": "#ff5fff",
\ "208": "#ff8700",
\ "209": "#ff875f",
\ "210": "#ff8787",
\ "211": "#ff87af",
\ "212": "#ff87d7",
\ "213": "#ff87ff",
\ "214": "#ffaf00",
\ "215": "#ffaf5f",
\ "216": "#ffaf87",
\ "217": "#ffafaf",
\ "218": "#ffafd7",
\ "219": "#ffafff",
\ "220": "#ffd700",
\ "221": "#ffd75f",
\ "222": "#ffd787",
\ "223": "#ffd7af",
\ "224": "#ffd7d7",
\ "225": "#ffd7ff",
\ "226": "#ffff00",
\ "227": "#ffff5f",
\ "228": "#ffff87",
\ "229": "#ffffaf",
\ "230": "#ffffd7",
\ "231": "#ffffff",
\ "232": "#080808",
\ "233": "#121212",
\ "234": "#1c1c1c",
\ "235": "#262626",
\ "236": "#303030",
\ "237": "#3a3a3a",
\ "238": "#444444",
\ "239": "#4e4e4e",
\ "240": "#585858",
\ "241": "#626262",
\ "242": "#6c6c6c",
\ "243": "#767676",
\ "244": "#808080",
\ "245": "#8a8a8a",
\ "246": "#949494",
\ "247": "#9e9e9e",
\ "248": "#a8a8a8",
\ "249": "#b2b2b2",
\ "250": "#bcbcbc",
\ "251": "#c6c6c6",
\ "252": "#d0d0d0",
\ "253": "#dadada",
\ "254": "#e4e4e4",
\ "255": "#eeeeee",
\ "NONE": "NONE"
\ }
let s:none = "NONE"
let s:bold = "bold"
let s:italic = "italic"
let s:underline = "underline"
let s:bg_dark = "232"
let s:bg = "234"
let s:bg_light = "235"
let s:text_dark = "240"
let s:text = "254"
let s:text_light = "15"
let s:warn = "196"
let s:colour_1 = "229" " yellow
let s:colour_2 = "229" " yellow
let s:colour_3 = "197" " hot pink
let s:colour_4 = "147" " light purple
let s:colour_5 = "214" " orange
let s:colour_6 = "190" " green
call s:hi("Comment", s:text_dark, s:none, s:italic)
call s:hi("Constant", s:colour_6, s:none, s:none)
call s:hi("Function", s:colour_6, s:none, s:none)
call s:hi("Identifier", s:colour_3, s:none, s:bold)
call s:hi("Keyword", s:text_light, s:none, s:none)
call s:hi("Number", s:colour_4, s:none, s:none)
call s:hi("PreProc", s:colour_3, s:none, s:bold)
call s:hi("Statement", s:text_light, s:none, s:none)
call s:hi("Special", s:colour_4, s:none, s:none)
call s:hi("JavaScriptBraces", s:colour_5, s:none, s:none)
call s:hi("String", s:colour_1, s:none, s:none)
call s:hi("Type", s:colour_4, s:none, s:none)
call s:hi("DiffAdd", s:none, s:bg_dark, s:none)
call s:hi("DiffChange", s:none, s:bg, s:none)
call s:hi("DiffText", s:none, s:bg, s:none)
call s:hi("DiffDelete", s:warn, s:none, s:none)
call s:hi("Cursor", s:bg, s:text, s:none)
call s:hi("CursorLine", s:none, s:bg_light, s:none)
call s:hi("CursorLinenr", s:colour_1, s:bg_light, s:none)
call s:hi("MatchParen", s:bg, s:colour_5, s:none)
call s:hi("Linenr", s:text_dark, s:bg_dark, s:none)
call s:hi("Normal", s:text, s:bg, s:none)
call s:hi("Nontext", s:text_dark, s:none, s:none)
call s:hi("Search", s:bg, s:colour_1, s:none)
call s:hi("Statusline", s:text_light, s:bg_dark, s:none)
call s:hi("Tabline", s:text_light, s:bg_dark, s:none)
call s:hi("TablineFill", s:text_light, s:bg_dark, s:none)
call s:hi("TablineSel", s:colour_1, s:bg_dark, s:none)
call s:hi("SignColumn", s:text_light, s:bg_dark, s:none)
call s:hi("Visual", s:bg, s:text, s:none)
call s:hi("Warning", s:warn, s:bg_dark, s:none)
call s:hi("HtmlBold", s:none, s:none, s:bold)
call s:hi("HtmlLink", s:none, s:none, s:underline)
call s:hi("Pmenu", s:colour_1, s:bg_light, s:none)
call s:hi("PmenuSel", s:bg_light, s:colour_1, s:none)
hi! link Directory Special
hi! link JavaScriptParens JavaScriptBraces
hi! link JavaScriptNumber Number
hi! link JavaScriptBoolean Number
hi! link JavaScriptNull Number
hi! link JavaScriptGlobal JavaScriptIdentifier
hi! link JavaScriptFunction PreProc
hi! link JavaScriptReserved PreProc
hi! link JavaScriptConditional PreProc
hi! link JavaScriptRepeat PreProc
hi! link JavaScriptException PreProc
hi! link JavaScriptStatement PreProc
hi! link JavaScriptMessage Normal
hi! link JavaScriptOperator Special
hi! link JavaScriptLabel Special
hi! link JsonKeyword Function
hi! link JsonBraces JavaScriptBraces
hi! link JsonParens JavaScriptParens
hi! link JsonNumber JavaScriptNumber
hi! link JsonBoolean JavaScriptBoolean
hi! link JsonNull JavaScriptNull
hi! link HtmlHead Normal
hi! link HtmlTitle Normal
hi! link HtmlTagName Function
hi! link HtmlSpecialTagName HtmlTagName
hi! link HtmlEndTag HtmlTag
hi! link HtmlH1 HtmlBold
hi! link HtmlH2 HtmlH1
hi! link HtmlH3 HtmlH1
hi! link HtmlH4 HtmlH1
hi! link HtmlH5 HtmlH1
hi! link HtmlH6 HtmlH1
hi! link XmlEndTag XmlTag
hi! link PhpClasses Normal
hi! link PhpMethods Normal
hi! link PhpMethodsVar PhpMethods
hi! link PhpStatement PreProc
hi! link PhpConditional PreProc
hi! link PhpRepeat PreProc
hi! link PhpException PreProc
hi! link PhpBoolean Number
hi! link PhpSpecialFunction PhpFunctions
hi! link PhpOperator Special
hi! link PhpVarSelector Special
hi! link PhpRelation Special
hi! link PhpComparison Special
hi! link PhpType Number
hi! link SpellBad Warning
hi! link SpellCap Warning
hi! link Error Warning
hi! link CssTagName Identifier
hi! link CssStyle Type
hi! link CssAttrRegion Function
hi! link CssColor CssAttrRegion
hi! link CssUnitDecorators CssAttrRegion
hi! link CssValueLength CssAttrRegion
hi! link CssValueNumber CssAttrRegion
hi! link CssBraces JavaScriptBraces
set noautochdir "Change working directory when opening file
set completeopt=menu "Autocomplete
set encoding=utf-8 "Set encoding to UTF-8
set history=999 "Keep a history of commands
set fileencodings=utf-8,latin2 "File encodings
set fileformats=unix,dos "File formats
set foldmethod=marker "Specify folds with markers
set hidden "Remember undo after quitting
set nobackup "No backup files
set nocompatible "Use Vim improvements
set noerrorbells "Turn off beep on error
set nofoldenable "Disable folding
set noswapfile "Don't use swap files
set visualbell "Visual bell instead of beep on error
set mouse=a "Enable mouse in all modes
set nowrap "Do not wrap lines
set nowritebackup "No backup before overwriting files
set norelativenumber "Show relative line numbers
set number "Show line numbers
set omnifunc=syntaxcomplete#Complete "Enable autocomplete
set scrolloff=5 "Vertical scroll offset
set showmatch "Show matching bracket
set sidescroll=1 "Better horizontal scrolling
set sidescrolloff=5 "Horizontal scroll offset
set t_vb="" "No terminal visual bell
set wildmenu "Show wild menu
set wildmode=full "Complete first match
set updatetime=250
set cursorline "Highlight the current line
set nospell "Disable spell checking
set wildignore+=*/tmp/*,*/cache/*,*/.git/*,tags,*.jpg,*.png,*.gif
syntax on "Turn on syntax highlighting
let mapleader = "\\"
let g:mapleader = "\\"
"Plugins
filetype off
"set rtp+=~/.config/nvim/bundle/Vundle.vim
call plug#begin()
Plug 'Valloric/YouCompleteMe'
Plug 'editorconfig/editorconfig-vim'
Plug 'ekalinin/Dockerfile.vim'
Plug 'evidens/vim-twig'
Plug 'godlygeek/tabular'
Plug 'ludovicchabant/vim-gutentags'
Plug 'mxw/vim-jsx'
Plug 'posva/vim-vue'
Plug 'tmhedberg/matchit'
Plug 'tomtom/tcomment_vim'
Plug 'shougu/unite.vim'
Plug 'vimlab/neojs'
Plug 'neomake/neomake'
Plug 'w0rp/ale'
Plug 'rainglow/vim'
call plug#end()
"Load filetype specific plugins
filetype plugin indent on
"SEARCH OPTIONS
set ignorecase "Case insensitive search
set incsearch "Incremental search
set hlsearch "Highlight search
set smartcase "Case sensitive search if upper case chars are used
"Center page on the next/previous search
map N Nzz
map n nzz
"INDENTATION OPTIONS
set autoindent "Auto-indent new lines
set nocindent "Use smartindent instead
set noexpandtab "Use tabs, not spaces
set shiftwidth=2 "Tab width for indentation
set smartindent "Smart indentation
set tabstop=2 "Tab width
set nolist "List invisible characters
set listchars=tab:→\ ,eol:↵,trail:.
"Prevent smartindent from removing leading whitespace before #
:inoremap # X#
set cinkeys -=0#
set indentkeys -=0#
"AUTO COMMANDS
"Indent JavaScript code with two spaces
au Filetype javascript setlocal expandtab tabstop=2 shiftwidth=2
"Indent JSON code with two spaces
au Filetype json setlocal expandtab tabstop=2 shiftwidth=2
"Indent sass code with tabs
au Filetype sass setlocal noexpandtab tabstop=2 shiftwidth=2
"Disable auto-comment
au FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" JSX
let g:jsx_ext_required = 0
"CTAGS OPTIONS
set tags+=tags;$HOME
"Set the names of flags
let tlist_php_settings = 'php;c:class;f:function;d:constant'
"Close all folds except for current file
let Tlist_File_Fold_Auto_Close = 1
"Make tlist pane active when opened
let Tlist_GainFocus_On_ToggleOpen = 1
"Width of window
let Tlist_WinWidth = 40
"Close tlist when a selection is made
let Tlist_Close_On_Select = 1
"GUI OPTIONS
set laststatus=2 "Show status line
set noruler "Don't show the cursor position
set showtabline=2 "Always show the tabline
set tabline=%!MyTabLine() "Custom tabline
set statusline= "Custom statusline
set statusline+=%F
set statusline+=%=
set statusline+=%#tablinesel#%m%*
" set statusline+=(hl:%{SyntaxItem()})
set statusline+=(%{strlen(&ft)?&ft:'?'},%{&fenc},%{&ff})
function! SyntaxItem()
return synIDattr(synID(line("."),col("."),1),"name")
endfunction
function! MyTabLine()
let s = ''
for i in range(tabpagenr('$'))
if i + 1 == tabpagenr()
let s .= '%#TabLineSel#'
else
let s .= '%#TabLine#'
endif
" the label is made by MyTabLabel()
let s .= ' %{MyTabLabel(' . ( i + 1 ) . ')} '
endfor
" after the last tab fill with TabLineFill and reset tab page nr
let s .= '%#TabLineFill#%T'
return s
endfunction
function! MyTabLabel(n)
let label = ''
let bufnrlist = tabpagebuflist(a:n)
"Buffer name
let name = bufname(bufnrlist[tabpagewinnr(v:lnum) - 1])
if name == ''
if &buftype == 'quickfix'
let name = '[Quickfix List]'
else
let name = '[No Name]'
endif
else
"Show only the filename
let name = fnamemodify(name,":t")
endif
let label .= name
"Number of windows
let wincount = tabpagewinnr(a:n, '$')
if wincount > 1
let label .= ' (' . wincount . ')'
endif
return label
endfunction
colorscheme alias
"MISC
if has("autocmd")
autocmd BufEnter * :syntax sync fromstart
"Restore cursor position when re-opening file
autocmd BufReadPost * normal `"
"ActionScript files
autocmd BufRead,BufNewFile *.as set filetype=javascript
"TypeScript files
autocmd BufRead,BufNewFile *.ts set filetype=typescript
"Less files
autocmd BufRead,BufNewFile *.less set filetype=css
"Drupal file extensions
autocmd BufRead,BufNewFile *.module,*.install set filetype=php
"Remove trailing whitespace and DOS line endings on save
autocmd BufWritePre *.php,*.rb,*.js,*.ts,*.html,*.css,*.sass,*.scss :call StripTrailingWhitespace()
"Vagrant
autocmd BufRead,BufNewFile Vagrantfile set filetype=ruby
"Apply .vimrc changes on save
autocmd BufWritePost .vimrc so %
"Custom mappings for plugins
autocmd VimEnter * call Plugins()
endif
"Strip trailing whitespace without moving the cursor
function! StripTrailingWhitespace()
let l = line(".")
let c = col(".")
%s/\(\s\|\)\+$//e
call cursor(l, c)
endfunction
"PLUGIN OPTIONS
function! Plugins()
"Tabular
if exists(":Tabularize")
nnoremap <Leader>t= :Tabularize /=>\?<CR>
vnoremap <Leader>t= :Tabularize /=>\?<CR>
nnoremap <Leader>t: :Tabularize /:\zs<CR>
vnoremap <Leader>t: :Tabularize /:\zs<CR>
endif
endfunction
"ESLint
let g:ale_fixers = {
\ 'javascript': ['eslint']
\ }
let g:ale_fix_on_save = 1
"CUSTOM COMMANDS & MAPPINGS
"Avoid holding shift in normal mode
noremap ; :
noremap : ;
"Edit .vimrc
nnoremap <Leader>v :e ~/.config/nvim/init.vim<CR>
"Stop highlighting search words
nnoremap <Esc><Esc> :nohlsearch<CR>
"Toggle highlighting of special chars
nnoremap <Space> :set list!<CR>
"Delete all buffers
nnoremap <silent> <Leader>bd :%bd!<CR>
"Toggle statusline
nnoremap <silent> <Leader>s :exec &laststatus == 1 ? "set laststatus=2" : "set laststatus=1"<CR>
"Generate tags list
nnoremap <Leader>cg :!/usr/bin/ctags -R .<CR>
"Easier tab navigation
nnoremap <silent> <C-Tab> :tabnext<CR>
nnoremap <silent> <C-S-Tab> :tabprevious<CR>
nnoremap <silent> <C-t> :tabnew<CR>
nnoremap <silent> <C-w> :tabclose<CR>
"Shift blocks visually
vnoremap < <gv
vnoremap > >gv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment