Compare commits

...

8 Commits

3 changed files with 97 additions and 3 deletions

56
vim/coc.vim Normal file
View File

@@ -0,0 +1,56 @@
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1):
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" " Use <c-space> to trigger completion.
" if has('nvim')
" inoremap <silent><expr> <c-space> coc#refresh()
" else
" inoremap <silent><expr> <Leader>c coc#refresh()
" endif
" Use K to show documentation in preview window.
nnoremap <silent> K :call ShowDocumentation()<CR>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
endif
endfunction
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
"set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)

6
vim/ftplugin/python.vim Normal file
View File

@@ -0,0 +1,6 @@
fu PyRun() range
echo system('python -c ' . shellescape(join(getline(a:firstline, a:lastline), "\n")))
endf
vmap <F5> :call PyRun()<CR>

View File

@@ -1,11 +1,18 @@
" TODO: fzf enable search through hidden files - https://www.reddit.com/r/neovim/comments/fzeccx/how_can_i_make_fzf_include_hidden_directories/ " 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: fix fzf search the same dir in different windows https://vimways.org/2019/vim-and-the-working-directory/
" TODO: create readme file about navigation " TODO: create readme file about navigation
filetype plugin indent on "Включает определение типа файла, загрузку... filetype plugin indent on "Включает определение типа файла, загрузку...
"... соответствующих ему плагинов и файлов отступов "... соответствующих ему плагинов и файлов отступов
set nobackup
set nowritebackup
set encoding=utf-8 set encoding=utf-8
syntax enable syntax enable
set timeoutlen=300 ttimeoutlen=0 " https://www.johnhawthorn.com/2012/09/vi-escape-delays/ set timeoutlen=300 ttimeoutlen=0 " https://www.johnhawthorn.com/2012/09/vi-escape-delays/
" For coc-vim. Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
set signcolumn=yes
set number relativenumber set number relativenumber
set backspace=indent,eol,start set backspace=indent,eol,start
filetype plugin indent on filetype plugin indent on
@@ -22,6 +29,7 @@ call plug#begin('~/.vim/bundle') "Начать искать плагины в э
Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes' Plug 'vim-airline/vim-airline-themes'
Plug 'Yggdroot/indentLine' Plug 'Yggdroot/indentLine'
Plug 'tpope/vim-commentary'
Plug 'airblade/vim-gitgutter' Plug 'airblade/vim-gitgutter'
Plug 'jreybert/vimagit' Plug 'jreybert/vimagit'
Plug 'preservim/nerdtree' Plug 'preservim/nerdtree'
@@ -30,6 +38,7 @@ call plug#begin('~/.vim/bundle') "Начать искать плагины в э
Plug 'towolf/vim-helm' Plug 'towolf/vim-helm'
Plug 'pearofducks/ansible-vim' Plug 'pearofducks/ansible-vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end() "Перестать это делать call plug#end() "Перестать это делать
" "
@@ -88,8 +97,9 @@ nnoremap <leader>gu :GitGutterUndoHunk<CR> " undo git change under the line
" "
" Magit plugin config " Magit plugin config
" "
nnoremap <leader>gs :Magit<CR> " git status nnoremap <leader>gs :Magit<CR>| " git status
nnoremap <leader>gp :! git push<CR> " git Push nnoremap <leader>gp :! git push<CR>| " git Push
nnoremap <leader>gP :! git pull<CR>| " git Pull
" "
" NERDTree plugin config " NERDTree plugin config
@@ -105,7 +115,15 @@ autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTr
" fzf plugin config " fzf plugin config
" "
let g:fzf_preview_window = 'right:50%' let g:fzf_preview_window = 'right:50%'
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } } let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.8 } }
command! -bang -nargs=* Rg call
\fzf#vim#grep('rg
\ --hidden
\ -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
nnoremap <silent> <Leader>b :Buffers<CR> nnoremap <silent> <Leader>b :Buffers<CR>
nnoremap <silent> <Leader>f :Files<CR> nnoremap <silent> <Leader>f :Files<CR>
@@ -127,6 +145,20 @@ let g:ansible_extra_keywords_highlight = 1
let g:ansible_name_highlight = 'b' let g:ansible_name_highlight = 'b'
let g:ansible_yamlKeyName = 'yamlKey' let g:ansible_yamlKeyName = 'yamlKey'
"
" CoC plugin settings
"
let g:coc_global_extensions = ['coc-pyright']
source ~/.vim/coc.vim
function! s:enable_coc_for_type()
let l:filesuffix_whitelist = ['py']
if index(l:filesuffix_whitelist, expand('%:e')) == -1
let b:coc_enabled = 0
endif
endfunction
autocmd BufRead,BufNewFile * call s:enable_coc_for_type()
" YAML files config " YAML files config
autocmd FileType yaml,yml setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType yaml,yml setlocal ts=2 sts=2 sw=2 expandtab
let g:indentLine_char = '⦙' let g:indentLine_char = '⦙'