[vim] docstrings and readme generator
This commit is contained in:
@@ -21,8 +21,6 @@ endfunction
|
||||
" 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')
|
||||
@@ -32,11 +30,13 @@ function! ShowDocumentation()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" [docs] Coc-vim hotkeys
|
||||
" Use K to show documentation in preview window.
|
||||
nnoremap <silent> K :call ShowDocumentation()<CR>
|
||||
" 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)
|
||||
|
||||
45
vim/readme.py
Normal file
45
vim/readme.py
Normal file
@@ -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))
|
||||
47
vim/vimrc
47
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 <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
|
||||
|
||||
@@ -61,14 +80,10 @@ endfunction
|
||||
|
||||
nnoremap <C-b> :call ToggleColors()<CR>
|
||||
|
||||
" tabs navigation
|
||||
nnoremap <C-S-tab> :tabprevious<CR>
|
||||
nnoremap <C-tab> :tabnext<CR>
|
||||
nnoremap <C-t> :tabnew<CR>
|
||||
inoremap <C-S-tab> <Esc>:tabprevious<CR>i
|
||||
inoremap <C-tab> <Esc>:tabnext<CR>i
|
||||
inoremap <C-t> <Esc>:tabnew<CR>i
|
||||
" [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 <leader>gu :GitGutterUndoHunk<CR> " undo git change under the line
|
||||
nnoremap <leader>gu :GitGutterUndoHunk<CR>| " undo git change under the line
|
||||
|
||||
"
|
||||
" Magit plugin config
|
||||
" [docs] Magit plugin config
|
||||
"
|
||||
nnoremap <leader>gs :Magit<CR>| " git status
|
||||
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
|
||||
nnoremap <leader>gp :call GitPullPush("push")<CR>| " git Push
|
||||
nnoremap <leader>gP :call GitPullPush("pull")<CR>| " git Pull
|
||||
|
||||
"
|
||||
" NERDTree plugin config
|
||||
" [docs] NERDTree plugin config
|
||||
"
|
||||
nnoremap <leader>n :NERDTreeFocus<CR>
|
||||
nnoremap <C-n> :NERDTree<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
|
||||
|
||||
@@ -130,8 +145,8 @@ command! -bang -nargs=* Rg call
|
||||
\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>
|
||||
|
||||
Reference in New Issue
Block a user