Files
dotfiles/vim/vimrc
2025-03-09 21:06:42 +03:00

210 lines
6.5 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.
" TODO: fzf enable search through hidden files - https://www.reddit.com/r/neovim/comments/fzeccx/how_can_i_make_fzf_include_hidden_directories/
" * fixed for Rg, but not for Files yet
" TODO: fix fzf search the same dir in different windows https://vimways.org/2019/vim-and-the-working-directory/
" TODO: create readme file about navigation
filetype plugin indent on "Включает определение типа файла, загрузку...
"... соответствующих ему плагинов и файлов отступов
set nobackup
set nowritebackup
set noswapfile
set encoding=utf-8
syntax enable
set timeoutlen=300 ttimeoutlen=0 " https://www.johnhawthorn.com/2012/09/vi-escape-delays/
set clipboard=unnamed
set nocompatible
" For coc-vim. Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
set signcolumn=yes
" linenumbers, in relative manner
set number relativenumber
set splitbelow
set splitright
" [docs] split navigation
" switching between splits
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
nnoremap <C-h> <C-w>h
" resizing splits
noremap <silent> <C-Left> :vertical resize +3<CR>
noremap <silent> <C-Right> :vertical resize -3<CR>
noremap <silent> <C-Up> :resize +3<CR>
noremap <silent> <C-Down> :resize -3<CR>
set backspace=indent,eol,start
filetype plugin indent on
let hostname = substitute(system('hostname'), '\n', '', '')
if empty(glob('~/.vim/autoload/plug.vim')) "Если vim-plug не стоит
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
"И скачать его оттуда
"А после прогнать команду PlugInstall, о которой мы сейчас поговорим
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/bundle') "Начать искать плагины в этой директории
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'Yggdroot/indentLine'
Plug 'tpope/vim-commentary'
Plug 'airblade/vim-gitgutter'
Plug 'jreybert/vimagit'
Plug 'preservim/nerdtree'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'justinmk/vim-sneak'
Plug 'towolf/vim-helm'
Plug 'pearofducks/ansible-vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'elzr/vim-json'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'hashivim/vim-terraform'
" Plug 'Exafunction/codeium.vim'
Plug 'habamax/vim-godot'
call plug#end() "Перестать это делать
"
" Colors configuration
"
set term=xterm-256color
colorscheme atom-dark-256
let g:airline_theme='dark'
function ToggleColors()
if (g:colors_name == "atom-dark-256")
colorscheme antiphoton
let g:airline_theme='light'
else
colorscheme atom-dark-256
let g:airline_theme='dark'
endif
endfunction
nnoremap <C-b> :call ToggleColors()<CR>
" [docs] tabs navigation
" go left
nnoremap H gT
" go right
nnoremap L gt
" Changing <leader> key from \ to <space>
nnoremap <SPACE> <Nop>
let mapleader=" "
" Folding params
set foldlevelstart=20
"
" Vim-Airline plugin config
"
" To enable powerfonts you first need to install it system-wide: https://github.com/ryanoasis/nerd-fonts#font-installation
" Then you need to enable Non-ASCII font displaying on your terminal settings
let g:airline_powerline_fonts = 0 " Disable powerline fonts
let g:airline#extensions#keymap#enabled = 0 " Do not show keyboard mapping
let g:airline_section_z = "㏑:%l/%L:%c" " Custom minimalistic current position section
" let g:airline_section_y = '{…}%3{codeium#GetStatusString()}'
let g:Powerline_symbols='unicode' " Unicode support
"
" [docs] Gitgutter plugin config
"
let g:gitgutter_override_sign_column_highlight = 1
set updatetime=100
nnoremap <leader>gu :GitGutterUndoHunk<CR>| " undo git change under the line
"
" [docs] Magit plugin config
"
nnoremap <leader>gs :Magit<CR>| " git status
function GitPullPush(cmd)
echo system('git '.a:cmd)
" redraw!
endfunction
nnoremap <leader>gp :call GitPullPush("push")<CR>| " git Push
nnoremap <leader>gP :call GitPullPush("pull")<CR>| " git Pull
"
" [docs] NERDTree plugin config
"
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
let NERDTreeShowHidden=1
" 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
"
" fzf plugin config
"
let g:fzf_preview_window = 'right:50%'
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.8 } }
command! -bang -nargs=* Rg call
\fzf#vim#grep('rg
\ --hidden
\ --no-ignore
\ -g !node_modules/ -g !.git/
\ --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>),
\1,
\fzf#vim#with_preview({'options': '--exact --delimiter : --nth 4..'}), <bang>0) " is for strict search by default and other unknown stuff is to exclude filenames from search results
" [docs] fzf hotkeys
nnoremap <silent> <Leader>ag :Rg <C-R><C-W><CR>| " searching for word ander cursor
nnoremap <silent> <Leader>b :Buffers<CR>
nnoremap <silent> <Leader>f :Files<CR>
nnoremap <silent> <Leader>gr :Rg<CR>
nnoremap <silent> <Leader>/ :BLines<CR>
nnoremap <silent> <Leader>' :Marks<CR>
"nnoremap <silent> <Leader>g :Commits<CR>
nnoremap <silent> <Leader>H :Helptags<CR>
nnoremap <silent> <Leader>hh :History<CR>
nnoremap <silent> <Leader>h: :History:<CR>
nnoremap <silent> <Leader>h/ :History/<CR>
"
" Ansible plugin config
"
let g:ansible_unindent_after_newline = 1
let g:ansible_attribute_highlight = "ob"
let g:ansible_extra_keywords_highlight = 1
let g:ansible_name_highlight = 'b'
let g:ansible_yamlKeyName = 'yamlKey'
"
" CoC plugin settings
"
if hostname == "i113855042"
let g:coc_user_config = '~/.vim/coc-lsp/coc-settings-cloudia.json'
else
let g:coc_user_config = '~/.vim/coc-lsp/coc-settings.json'
endif
let g:coc_global_extensions = ['coc-pyright', 'coc-sh', 'coc-go']
function! s:enable_coc_for_type()
let l:filesuffix_whitelist = ['py', 'sh', 'go', 'gd', 'gdscript']
if index(l:filesuffix_whitelist, expand('%:e')) == -1
let b:coc_enabled = 0
endif
endfunction
autocmd BufRead,BufNewFile * call s:enable_coc_for_type()
source ~/.vim/coc-lsp/coc.vim
"
" vim-sneak plugin settings
"
let g:sneak#label = 1
" YAML files config
autocmd FileType yaml,yml setlocal ts=2 sts=2 sw=2 expandtab
let g:indentLine_char = '⦙'
" vim-go settings
let g:go_fmt_autosave = 1