From 5deea3cdd3a0a09db48dfab65e0a5fd5b00d29c1 Mon Sep 17 00:00:00 2001 From: Dmitry Chumak Date: Tue, 22 Nov 2022 01:00:23 +0300 Subject: [PATCH 1/9] [vim] disable swapfile --- vim/vimrc | 1 + 1 file changed, 1 insertion(+) diff --git a/vim/vimrc b/vim/vimrc index dd614eb..a7fc463 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -7,6 +7,7 @@ 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/ From a8eb8d46b0fbdc1367348cd952aba1879578c316 Mon Sep 17 00:00:00 2001 From: Dmitry Chumak Date: Tue, 22 Nov 2022 01:01:43 +0300 Subject: [PATCH 2/9] [vim] coc-sh added --- vim/vimrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index dd614eb..9a6322a 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -154,9 +154,9 @@ let g:ansible_yamlKeyName = 'yamlKey' " " CoC plugin settings " -let g:coc_global_extensions = ['coc-pyright'] +let g:coc_global_extensions = ['coc-pyright', 'coc-sh'] function! s:enable_coc_for_type() - let l:filesuffix_whitelist = ['py'] + let l:filesuffix_whitelist = ['py', 'sh'] if index(l:filesuffix_whitelist, expand('%:e')) == -1 let b:coc_enabled = 0 endif From 9758e40086011d6f2599535e1b73cb68685c8b9e Mon Sep 17 00:00:00 2001 From: Dmitry Chumak Date: Mon, 13 Feb 2023 17:41:12 +0300 Subject: [PATCH 3/9] [dotfiles] added zhsrc --- install.conf.yaml | 1 + zsh/zshrc | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 zsh/zshrc diff --git a/install.conf.yaml b/install.conf.yaml index ab4931e..b04c0b3 100644 --- a/install.conf.yaml +++ b/install.conf.yaml @@ -7,6 +7,7 @@ - link: ~/.tmux.conf: tmux.conf ~/.vim: vim + ~/.zshrc: zsh/zshrc - shell: - [git submodule update --init --recursive, Installing submodules] diff --git a/zsh/zshrc b/zsh/zshrc new file mode 100644 index 0000000..59ed118 --- /dev/null +++ b/zsh/zshrc @@ -0,0 +1,7 @@ +if type brew &>/dev/null +then + FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}" + + autoload -Uz compinit + compinit +fi From f83547919e9a1efad87e4b2be6eb53f0aac2a641 Mon Sep 17 00:00:00 2001 From: Dmitry Chumak Date: Mon, 13 Feb 2023 17:56:41 +0300 Subject: [PATCH 4/9] [vim] json files config --- vim/ftplugin/json.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vim/ftplugin/json.vim b/vim/ftplugin/json.vim index bd55dee..035bbc4 100644 --- a/vim/ftplugin/json.vim +++ b/vim/ftplugin/json.vim @@ -1,2 +1,13 @@ +" au! BufRead,BufNewFile *.json set filetype=json +" augroup json_autocmd +" autocmd! +" autocmd FileType json set autoindent +" autocmd FileType json set formatoptions=tcq2l +" autocmd FileType json set textwidth=78 shiftwidth=2 +" autocmd FileType json set softtabstop=2 tabstop=2 +" autocmd FileType json set expandtab +" autocmd FileType json set foldmethod=syntax +" augroup END set conceallevel=0 let g:indentLine_setConceal = 0 +autocmd FileType json setlocal ts=2 sts=2 sw=2 expandtab From 3633c5bf6ae57eccf143db6e9bab89cde654c66f Mon Sep 17 00:00:00 2001 From: Dmitry Chumak Date: Mon, 13 Feb 2023 17:57:40 +0300 Subject: [PATCH 5/9] [vim] flutter and dart config --- vim/ftplugin/dart.vim | 7 +++++++ vim/vimrc | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 vim/ftplugin/dart.vim diff --git a/vim/ftplugin/dart.vim b/vim/ftplugin/dart.vim new file mode 100644 index 0000000..3b13e73 --- /dev/null +++ b/vim/ftplugin/dart.vim @@ -0,0 +1,7 @@ +set tabstop=2 +set shiftwidth=2 +set expandtab +set smartindent + +xmap a (coc-codeaction-selected) +nmap a (coc-codeaction-selected) diff --git a/vim/vimrc b/vim/vimrc index a7fc463..153ee14 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -155,9 +155,9 @@ let g:ansible_yamlKeyName = 'yamlKey' " " CoC plugin settings " -let g:coc_global_extensions = ['coc-pyright'] +let g:coc_global_extensions = ['coc-pyright', 'coc-flutter'] function! s:enable_coc_for_type() - let l:filesuffix_whitelist = ['py'] + let l:filesuffix_whitelist = ['py', 'dart'] if index(l:filesuffix_whitelist, expand('%:e')) == -1 let b:coc_enabled = 0 endif From d66e7899d4b264ef878f8fee22dc49a85cd1eb64 Mon Sep 17 00:00:00 2001 From: Dmitry Chumak Date: Mon, 13 Feb 2023 18:12:23 +0300 Subject: [PATCH 6/9] [vim] docstrings and readme generator --- vim/coc.vim | 6 +++--- vim/readme.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ vim/vimrc | 47 +++++++++++++++++++++++++++++++---------------- 3 files changed, 79 insertions(+), 19 deletions(-) create mode 100644 vim/readme.py diff --git a/vim/coc.vim b/vim/coc.vim index 53b64ee..abfa0d4 100644 --- a/vim/coc.vim +++ b/vim/coc.vim @@ -21,8 +21,6 @@ endfunction " inoremap c coc#refresh() " endif -" Use K to show documentation in preview window. -nnoremap K :call ShowDocumentation() function! ShowDocumentation() if CocAction('hasProvider', 'hover') @@ -32,11 +30,13 @@ function! ShowDocumentation() endif endfunction +" [docs] Coc-vim hotkeys +" Use K to show documentation in preview window. +nnoremap K :call ShowDocumentation() " Use `[g` and `]g` to navigate diagnostics " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. nmap [g (coc-diagnostic-prev) nmap ]g (coc-diagnostic-next) - " GoTo code navigation. nmap gd (coc-definition) nmap gy (coc-type-definition) diff --git a/vim/readme.py b/vim/readme.py new file mode 100644 index 0000000..65397bd --- /dev/null +++ b/vim/readme.py @@ -0,0 +1,45 @@ +import re + +config = [line.strip() for line in open("coc.vim", "r").readlines()] + +def string_to_reject(string): + result = False + if string in ["\""]: + result = True + + return result + +def string_to_accept(string): + result = False + accepted_keywords = ["nnoremap", "nmap", "noremap", "\""] + + result = any(subs in string for subs in accepted_keywords) + + return result + +def header(string): + string = re.sub(r"^\" \[docs\]", "###", string) + + return f"\n{string}\n" + +doc_block_started = False +doc_lines = [] + +for line in config: + if "[docs]" in line: + doc_block_started = True + doc_lines.append(header(line)) + continue + elif line == "": + doc_block_started = False + continue + + if doc_block_started and string_to_accept(line) and not string_to_reject(line): + if not line.startswith("\"") and not line.startswith("#"): + line = f" {line}" + else: + line = re.sub(r"^\"\s*", "", line) + line = f"{line}\n" + doc_lines.append(line) + +print("\n".join(doc_lines)) diff --git a/vim/vimrc b/vim/vimrc index 153ee14..8d9764f 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -11,10 +11,29 @@ set noswapfile set encoding=utf-8 syntax enable 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 + +" linenumbers, in relative manner set number relativenumber + +set splitbelow +set splitright + +" [docs] split navigation +" switching between splits +nnoremap j +nnoremap k +nnoremap l +nnoremap h +" resizing splits +noremap :vertical resize +3 +noremap :vertical resize -3 +noremap :resize +3 +noremap :resize -3 + set backspace=indent,eol,start filetype plugin indent on @@ -61,14 +80,10 @@ endfunction nnoremap :call ToggleColors() -" tabs navigation -nnoremap :tabprevious -nnoremap :tabnext -nnoremap :tabnew -inoremap :tabpreviousi -inoremap :tabnexti -inoremap :tabnewi +" [docs] tabs navigation +" go left nnoremap H gT +" go right nnoremap L gt @@ -89,30 +104,30 @@ let g:airline_section_z = "㏑:%l/%L:%c" " Custom minimalistic current position let g:Powerline_symbols='unicode' " Unicode support " -" Gitgutter plugin config +" [docs] Gitgutter plugin config " let g:gitgutter_override_sign_column_highlight = 1 set updatetime=100 -nnoremap gu :GitGutterUndoHunk " undo git change under the line +nnoremap gu :GitGutterUndoHunk| " undo git change under the line " -" Magit plugin config +" [docs] Magit plugin config " -nnoremap gs :Magit| " git status +nnoremap gs :Magit| " git status function GitPullPush(cmd) echo system('git '.a:cmd) " redraw! endfunction -nnoremap gp :call GitPullPush("push")| " git Push -nnoremap gP :call GitPullPush("pull")| " git Pull +nnoremap gp :call GitPullPush("push")| " git Push +nnoremap gP :call GitPullPush("pull")| " git Pull " -" NERDTree plugin config +" [docs] NERDTree plugin config " nnoremap n :NERDTreeFocus -nnoremap :NERDTree nnoremap :NERDTreeToggle 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 @@ -130,8 +145,8 @@ command! -bang -nargs=* Rg call \1, \fzf#vim#with_preview({'options': '--exact --delimiter : --nth 4..'}), 0) " is for strict search by default and other unknown stuff is to exclude filenames from search results +" [docs] fzf hotkeys nnoremap ag :Rg | " searching for word ander cursor - nnoremap b :Buffers nnoremap f :Files nnoremap gr :Rg From 796ed77d8560277d2f58bbe626e1ee528c81b913 Mon Sep 17 00:00:00 2001 From: Dmitry Chumak Date: Mon, 13 Feb 2023 18:14:17 +0300 Subject: [PATCH 7/9] [vim] json plugin --- vim/vimrc | 1 + 1 file changed, 1 insertion(+) diff --git a/vim/vimrc b/vim/vimrc index 8d9764f..ec9608e 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -59,6 +59,7 @@ call plug#begin('~/.vim/bundle') "Начать искать плагины в э Plug 'towolf/vim-helm' Plug 'pearofducks/ansible-vim' Plug 'neoclide/coc.nvim', {'branch': 'release'} + Plug 'elzr/vim-json' call plug#end() "Перестать это делать " From 96ce5d056b5372f760276fb61ca4c8aabb6fdc0d Mon Sep 17 00:00:00 2001 From: Dmitry Chumak Date: Fri, 5 May 2023 15:44:44 +0300 Subject: [PATCH 8/9] [vim] use system clipboard --- vim/vimrc | 1 + 1 file changed, 1 insertion(+) diff --git a/vim/vimrc b/vim/vimrc index ae66434..9a15521 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -11,6 +11,7 @@ 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 " For coc-vim. Always show the signcolumn, otherwise it would shift the text each time " diagnostics appear/become resolved. From 3ea4f8d9b623ea9834e1a58d92e0419443631304 Mon Sep 17 00:00:00 2001 From: Dmitry Chumak Date: Fri, 9 Jun 2023 13:43:53 +0300 Subject: [PATCH 9/9] [vim] set nocompatible --- vim/vimrc | 1 + 1 file changed, 1 insertion(+) diff --git a/vim/vimrc b/vim/vimrc index 9a15521..884cfb0 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -12,6 +12,7 @@ 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.