dotfiles/sub/vim/vimrc
2022-08-06 20:25:28 +03:00

306 lines
7.6 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.

set ruler
set laststatus=2
" xclip requiered
set clipboard=unnamedplus
set shell=zsh
" <Leader>
let g:mapleader = ","
set cursorline
" like tabdo but restore the current tab
function! TabDo(command)
let currTab=tabpagenr()
execute 'tabdo ' . a:command
execute 'tabn ' . currTab
endfunction
" like bufdo but restore the current buffer
function! BufDo(command)
let currBuff=bufnr("%")
execute 'bufdo ' . a:command
execute 'buffer ' . currBuff
endfunction
" like windo but restore the current window
function! WinDo(command)
let currwin=winnr()
execute 'windo ' . a:command
execute currwin . 'wincmd w'
endfunction
nnoremap <silent> <Leader>c :call TabDo('set cursorline!') <CR>
inoremap jk <esc>
let g:airline_powerline_fonts = 1 "Включить поддержку Powerline шрифтов
let g:airline#extensions#keymap#enabled = 0 "Не показывать текущий маппинг
let g:airline_section_z = "\ue0a1:%l/%L Col:%c" "Кастомная графа положения курсора
let g:Powerline_symbols='unicode' "Поддержка unicode
let g:airline#extensions#xkblayout#enabled = 0
let g:airline#extensions#branch#enabled=1
nnoremap <Tab> :bnext<CR>
nnoremap <S-Tab> :bprevious<CR>
let g:netrw_banner = 0 " hide banner
let g:netrw_liststyle = 3 " tree instead of plain view
let g:netrw_browse_split = 0
let g:netrw_winsize = 15
let g:netrw_keepdir = 0
" Mirror the NERDTree before showing it. This makes it the same on all tabs.
nnoremap <silent> <leader>nn :NERDTreeMirror<CR>:NERDTreeToggle<CR>
" Toggle focus
nnoremap <silent> <leader>nf :wincmd p<CR>
" Start NERDTree when Vim is started without file arguments.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | wincmd p | endif
" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" Close the tab if NERDTree is the only window remaining in it.
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
let g:NERDTreeMapActivateNode='l'
set ttimeoutlen=0 "Понижаем задержку ввода escape последовательностей
let &t_SI.="\e[5 q" "SI = режим вставки
let &t_SR.="\e[3 q" "SR = режим замены
let &t_EI.="\e[1 q" "EI = нормальный режим
set encoding=utf-8 "Ставит кодировку UTF-8
set nocompatible "Отключает обратную совместимость с Vi
syntax on "Включает подсветку синтаксиса
set expandtab
set smarttab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set smartindent
set nowrap
set ttyfast
set autoread
set history=1000
set undofile
set undoreload=1000
set noerrorbells
set novisualbell
set showcmd
set showtabline=2
set ignorecase
set smartcase
set incsearch
set mousehide
set mouse=a
set colorcolumn=81
set scrolloff=7
set backup
set noswapfile
set backupdir=$HOME/.vim/tmp/backup/
set undodir=$HOME/.vim/tmp/undo/
set directory=$HOME/.vim/tmp/swap/
set viminfo+=n$HOME/.vim/tmp/viminfo
function! MakeDirIfNoExists(path)
if !isdirectory(expand(a:path))
call mkdir(expand(a:path), "p")
endif
endfunction
" make this dirs if no exists previously
silent! call MakeDirIfNoExists(&undodir)
silent! call MakeDirIfNoExists(&backupdir)
silent! call MakeDirIfNoExists(&directory)
set virtualedit=onemore " allow for cursor beyond last character
" toggle hlsearch
nnoremap <silent> <Leader>/ :set invhlsearch<CR>
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
set ffs=unix,mac
set encoding=utf8
" tabs
nnoremap <silent> <C-l> :tabnext<CR>
nnoremap <silent> <C-h> :tabprev<CR>
" hiden chars
nmap <silent> <Leader>eh :set list!<CR>
set listchars=tab:→\ ,eol:↵,trail,extends:↷,precedes:↶
" Autoload configuration when this file changes ($MYVIMRC)
autocmd! BufWritePost init.vim source %
" Plugins
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'morhetz/gruvbox'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-commentary'
Plugin 'ap/vim-css-color'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'preservim/tagbar'
Plugin 'preservim/vimux'
Plugin 'rbgrouleff/bclose.vim'
Plugin 'frazrepo/vim-rainbow'
Plugin 'Pocco81/AutoSave.nvim'
" requiered patch your font
Plugin 'ryanoasis/vim-devicons'
Plugin 'jiangmiao/auto-pairs'
" pyright
Plugin 'neovim/nvim-lspconfig'
Plugin 'hrsh7th/nvim-cmp'
Plugin 'hrsh7th/cmp-nvim-lsp'
Plugin 'saadparwaiz1/cmp_luasnip'
Plugin 'L3MON4D3/LuaSnip'
Plugin 'nvim-lua/plenary.nvim'
Plugin 'powerman/vim-plugin-ruscmd' " Russian navigation
" golang
" Plugin 'fatih/vim-go'
Plugin 'nvim-telescope/telescope.nvim'
Plugin 'nvim-telescope/telescope-fzf-native.nvim', {'do': 'make'}
Plugin 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plugin 'preservim/nerdtree'
call vundle#end()
filetype plugin indent on
" Python
let python_highlight_all = 1
set t_Co=256
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class,match,case
" run file by filetype
autocmd BufEnter * if (&filetype=='python') | nnoremap <silent> <Leader>r :tabnew % <CR> :terminal python3 % <CR> :set nocursorline number norelativenumber <CR> G <CR> | endif
autocmd BufEnter * if (&filetype=='go') | nnoremap <silent> <Leader>r :tabnew % <CR> :terminal go run % <CR> :set nocursorline number norelativenumber <CR> G <CR> | endif
autocmd BufEnter * if (&filetype=='vim') | nnoremap <silent> <Leader>r :so % <CR>
" ctags required
nnoremap <silent> <Leader>t :TagbarToggle <CR>
nnoremap <silent> <Leader>ve :tabnew $MYVIMRC<CR>
set laststatus=2
let g:lightline = {
\ 'colorscheme': 'iceberg',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#head'
\ },
\ }
" Colorscheme
colorscheme gruvbox
set bg=dark
let g:multi_cursor_use_default_mapping=0
" Default mapping
let g:multi_cursor_start_word_key = '<C-n>'
let g:multi_cursor_select_all_word_key = '<A-n>'
let g:multi_cursor_start_key = 'g<C-n>'
let g:multi_cursor_select_all_key = 'g<A-n>'
let g:multi_cursor_next_key = '<C-n>'
let g:multi_cursor_prev_key = '<C-p>'
let g:multi_cursor_skip_key = '<C-x>'
let g:multi_cursor_quit_key = '<Esc>'
au FileType py,go,c,cpp,objc,js call rainbow#load()
let g:rainbow_active = 1
set termguicolors
hi DiagnosticError guifg=Grey
hi DiagnosticWarn guifg=Grey
hi DiagnosticInfo guifg=Grey
hi DiagnosticHint guifg=Grey
nnoremap <Leader>ff <cmd>Telescope find_files<cr>
nnoremap <Leader>fg <cmd>Telescope live_grep<cr>
luafile ~/.config/nvim/lua/init.lua
set number
set relativenumber
function! ToggleRelativeAbsoluteNumber()
if !&number && !&relativenumber
set number
set norelativenumber
elseif &number && !&relativenumber
set nonumber
set relativenumber
elseif !&number && &relativenumber
set number
set relativenumber
elseif &number && &relativenumber
set nonumber
set norelativenumber
endif
endfunction
nnoremap <silent> <Leader>l :call TabDo('call ToggleRelativeAbsoluteNumber()') <CR>
" Quick exiting without save
nnoremap <silent> <Leader>`` :qa!<CR>