1
0
Fork 0
vim-rc/vimrc
John Solncev af07768694 Status line update.
Status line:
 - Show git branch on status line;
 - Rename and change colors for status line.
2021-04-01 01:17:13 +03:00

121 lines
3.3 KiB
VimL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"Функция получения текущего режима редактора
function GetMode()
let l:editor_mode = mode()
let l:editor_modes_list = [
\ "NORMAL",
\ "INSERT",
\ "VISUAL",
\ "VISUAL-LINE",
\ "VISUAL-BLOCK",
\ "REPLACE"
\ ]
if l:editor_mode == "n"
return l:editor_modes_list[0]
elseif l:editor_mode == "i"
return l:editor_modes_list[1]
elseif l:editor_mode == "v"
return l:editor_modes_list[2]
elseif l:editor_mode == "V"
return l:editor_modes_list[3]
elseif l:editor_mode =="\<C-v>"
return l:editor_modes_list[4]
elseif l:editor_mode == "R"
return l:editor_modes_list[5]
else
return "?MODE"
endif
endfunction
"Git branch
function GetGitBranchName()
return system('git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d "\n"')
endfunction
function StatuslineGetGitBranch()
let l:branch = GetGitBranchName()
return strlen(l:branch) > 0 ? l:branch : ''
endfunction
"Менеджер плагинов: Vim-Plug
"Подключение плагинов (для установки - :PlugInstal)
call plug#begin('~/.vim/plugged')
Plug 'preservim/nerdtree'
Plug 'airblade/vim-gitgutter'
call plug#end()
"Включаем подсветку синтаксиса
syntax on
set nocompatible
" Включение поддержки мыши
"set mouse=a
set encoding=utf8
"Включает колонку нумерации строк
set number
set numberwidth=4
set cursorline
"Не показывать режим (он отображается в нашей строке статуса)
set noshowmode
"Настройки строки статуса
set laststatus=2
set statusline=
set statusline+=%#StatusLineEditorMode#\ %{GetMode()}\
if strlen(GetGitBranchName()) > 0
set statusline+=%#StatusLineGitBranch#\ %{StatuslineGetGitBranch()}\
endif
set statusline+=%#StatusLineFileName#\ %f\
set statusline+=%#StatusLineFileFormat#\ %{&ff}\
set statusline+=%#StatusLineEmpty#%=
set statusline+=%#StatusLineReadOnlyFlag#\ %r\
set statusline+=%#StatusLineEncoding#\ %{&fileencoding?&fileencoding:&encoding}\
set statusline+=%#StatusLineFileType#\ %{&ft}\
set statusline+=%#StatusLinePercentPos#\ %p%%\
set statusline+=%#StatusLinePosition#\ %l:%c\
"Выключает перенос строк
set nowrap
"Автоподстановка табов
set smarttab
"Замена табов на пробелы
set expandtab
"Установка отступа на 4 символа
set tabstop=4
set shiftwidth=4
set softtabstop=4
"Автодополнение отступов
set autoindent
set smartindent
"Кеймапы для NERDTree
nmap <C-n> :NERDTreeToggle<CR>
"Кеймапы для запуска Python скриптов
autocmd BufRead *.py nmap <F5> :!python3 %<CR>
autocmd BufRead *.py nmap <F6> :!sudo python3 %<CR>
autocmd BufRead *.py nmap <F9> :!pep8 --max-line-length=230 %<CR>
"Кеймапы запуска Bash скриптов
autocmd BufRead *.sh nnoremap <F5> :!bash %<CR>
"Перенос сток для .md файлов
autocmd BufRead *.md set wrap
"Кеймапы обновления темы vim
autocmd BufRead *.vim nnoremap <F5> :source %<CR>
"Установка своей цветовой схемы
colorscheme my_first_scheme