mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-13 02:05:40 +08:00
Fix: replace the function markdown-insert-URL with a new one. (#2617)
* Fix: replace the function markdown-insert-URL with a new one. * Doc: update docs for the new markdown_insert_URL. * Fix: a very very smal promotion.
This commit is contained in:
parent
e97974ff35
commit
e8d39bea00
@ -58,8 +58,8 @@ function! SpaceVim#layers#lang#markdown#config() abort
|
|||||||
let g:mkdp_browserfunc = 'openbrowser#open'
|
let g:mkdp_browserfunc = 'openbrowser#open'
|
||||||
" }}}
|
" }}}
|
||||||
call SpaceVim#mapping#space#regesit_lang_mappings('markdown', function('s:mappings'))
|
call SpaceVim#mapping#space#regesit_lang_mappings('markdown', function('s:mappings'))
|
||||||
nnoremap <silent> <plug>(markdown-insert-link) :call <SID>markdown_insert_url()<Cr>
|
nnoremap <silent> <plug>(markdown-insert-link) :call <SID>markdown_insert_url(0)<Cr>
|
||||||
xnoremap <silent> <plug>(markdown-insert-link) :call <SID>markdown_insert_url()<Cr>
|
xnoremap <silent> <plug>(markdown-insert-link) :<C-u> call <SID>markdown_insert_url(1)<Cr>
|
||||||
augroup spacevim_layer_lang_markdown
|
augroup spacevim_layer_lang_markdown
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd FileType markdown setlocal omnifunc=htmlcomplete#CompleteTags
|
autocmd FileType markdown setlocal omnifunc=htmlcomplete#CompleteTags
|
||||||
@ -100,19 +100,22 @@ function! s:generate_remarkrc() abort
|
|||||||
return f
|
return f
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:markdown_insert_url() abort
|
function! s:markdown_insert_url(visual) abort
|
||||||
let pos1 = getpos("'<")
|
if !empty(@+)
|
||||||
let pos2 = getpos("'>")
|
let l:save_register_unnamed = @"
|
||||||
let scope = sort([pos1[2], pos2[2]], 'n')
|
if a:visual
|
||||||
"FIXME: list scope is not same as string scope index.
|
normal! gvx
|
||||||
let url = @+
|
else
|
||||||
if !empty(url)
|
normal! diw
|
||||||
let line = getline(pos1[1])
|
endif
|
||||||
let splits = [line[:scope[0]], line[scope[0] : scope[1]], line[scope[1]:]]
|
let @" = '[' . @" . '](' . @+ . ')'
|
||||||
let result = splits[0] . '[' . splits[1] . '](' . url . ')' . splits[2]
|
if col('.') == col('$') - 1
|
||||||
call setline(pos1[1], result)
|
normal! p
|
||||||
|
else
|
||||||
|
normal! P
|
||||||
|
endif
|
||||||
|
let @" = l:save_register_unnamed
|
||||||
endif
|
endif
|
||||||
keepjumps call cursor(pos1[1], scope[0])
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" this function need context_filetype.vim
|
" this function need context_filetype.vim
|
||||||
|
@ -71,8 +71,8 @@ npm install --global prettier
|
|||||||
|
|
||||||
## 快捷键
|
## 快捷键
|
||||||
|
|
||||||
| 快捷键 | 模式 | 按键描述 |
|
| 快捷键 | 模式 | 按键描述 |
|
||||||
| ---------- | ------ | -------------------------- |
|
| ---------- | ------------- | -------------------------------------- |
|
||||||
| `SPC b f` | Normal | 格式化当前文件 |
|
| `SPC b f` | Normal | 格式化当前文件 |
|
||||||
| `SPC l k` | Normal | 增加链接 URL |
|
| `SPC l k` | Normal/Visual | 为光标下的单词或者选中文本增加链接 URL |
|
||||||
| `SPC l p` | Normal | 通过浏览器实时预览当前文件 |
|
| `SPC l p` | Normal | 通过浏览器实时预览当前文件 |
|
||||||
|
@ -70,8 +70,8 @@ Bullet marker to use for list items (`'-'`, `'*'`, or `'+'`, default: `'-'`).
|
|||||||
|
|
||||||
## Key bindings
|
## Key bindings
|
||||||
|
|
||||||
| Key bindings | mode | Descriptions |
|
| Key bindings | mode | Descriptions |
|
||||||
| ------------ | ------ | -------------------------- |
|
| ------------ | ------------- | --------------------------------------------- |
|
||||||
| `SPC b f` | Normal | Format current buffer |
|
| `SPC b f` | Normal | Format current buffer |
|
||||||
| `SPC l k` | Normal | Add URL |
|
| `SPC l k` | Normal/Visual | Add URL for word under cursor or slected word |
|
||||||
| `SPC l p` | Normal | Real-time markdown preview |
|
| `SPC l p` | Normal | Real-time markdown preview |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user