mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-24 02:10:05 +08:00
feat(mail): add mail layer option
This commit is contained in:
parent
fa43ef2043
commit
31ab74f8be
@ -10,10 +10,12 @@
|
|||||||
" @section mail, layers-mail
|
" @section mail, layers-mail
|
||||||
" @parentsection layers
|
" @parentsection layers
|
||||||
" The `mail` layer provides basic function to connected to mail server.
|
" The `mail` layer provides basic function to connected to mail server.
|
||||||
"
|
" NOTE: this layer is still wip now.
|
||||||
" @subsection layer options
|
" @subsection layer options
|
||||||
"
|
"
|
||||||
" 1. `ssh_port`: set the port of mail server
|
" 1. `imap_host`: set the imap server host
|
||||||
|
" 2. `imap_port`: set the imap server port
|
||||||
|
" 3. `imap_login`: set the login of imap server
|
||||||
"
|
"
|
||||||
" @subsection key bindings
|
" @subsection key bindings
|
||||||
" >
|
" >
|
||||||
@ -21,15 +23,30 @@
|
|||||||
" SPC a m open mail client
|
" SPC a m open mail client
|
||||||
" <
|
" <
|
||||||
|
|
||||||
|
if exists('s:imap_host')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:imap_host = 'imap.163.com'
|
||||||
|
let s:imap_port = 143
|
||||||
|
let s:imap_login = ''
|
||||||
|
|
||||||
function! SpaceVim#layers#mail#plugins() abort
|
function! SpaceVim#layers#mail#plugins() abort
|
||||||
return [
|
return [
|
||||||
\ [g:_spacevim_root_dir . 'bundle/vim-mail', {'merged' : 0, 'loadconf' : 1}],
|
\ [g:_spacevim_root_dir . 'bundle/vim-mail', {'merged' : 0, 'loadconf' : 1}],
|
||||||
\ ]
|
\ ]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! SpaceVim#layers#mail#set_variable(opt) abort
|
||||||
|
let s:imap_host = get(a:opt, 'imap_host', s:imap_host)
|
||||||
|
let s:imap_port = get(a:opt, 'imap_port', s:imap_port)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! SpaceVim#layers#mail#config() abort
|
function! SpaceVim#layers#mail#config() abort
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['a', 'm'], 'call mail#client#open()', 'Start mail client', 1)
|
call SpaceVim#mapping#space#def('nnoremap', ['a', 'm'], 'call mail#client#open()', 'Start mail client', 1)
|
||||||
|
let g:mail_imap_host = s:imap_port
|
||||||
|
let g:mail_imap_port = s:imap_port
|
||||||
|
let g:mail_imap_login = s:imap_login
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SpaceVim#layers#mail#health() abort
|
function! SpaceVim#layers#mail#health() abort
|
||||||
|
@ -92,7 +92,7 @@ function! mail#client#open()
|
|||||||
let username = input('USERNAME: ')
|
let username = input('USERNAME: ')
|
||||||
let password = input('PASSWORD: ')
|
let password = input('PASSWORD: ')
|
||||||
if !empty(username) && !empty(password)
|
if !empty(username) && !empty(password)
|
||||||
call mail#client#connect('imap.163.com', 143)
|
call mail#client#connect(g:mail_imap_host, g:mail_imap_port)
|
||||||
call mail#client#send(mail#command#login(username, password))
|
call mail#client#send(mail#command#login(username, password))
|
||||||
call mail#client#send(mail#command#select(mail#client#win#currentDir()))
|
call mail#client#send(mail#command#select(mail#client#win#currentDir()))
|
||||||
call mail#client#send(mail#command#fetch('1:15', 'BODY[HEADER.FIELDS ("DATE" "FROM" "SUBJECT")]'))
|
call mail#client#send(mail#command#fetch('1:15', 'BODY[HEADER.FIELDS ("DATE" "FROM" "SUBJECT")]'))
|
||||||
|
@ -12,6 +12,9 @@ let g:mail_method = 'imap'
|
|||||||
let g:mail_sending_name = 'Shidong Wang'
|
let g:mail_sending_name = 'Shidong Wang'
|
||||||
let g:mail_sending_address = 'wsdjeg@163.com'
|
let g:mail_sending_address = 'wsdjeg@163.com'
|
||||||
let g:mail_logger_silent = 0
|
let g:mail_logger_silent = 0
|
||||||
|
|
||||||
|
let g:mail_imap_host = get(g:, 'mail_imap_host', 'imap.163.com')
|
||||||
|
|
||||||
if !exists('g:mail_directory')
|
if !exists('g:mail_directory')
|
||||||
let g:mail_directory = expand('~/.vim-mail/')
|
let g:mail_directory = expand('~/.vim-mail/')
|
||||||
endif
|
endif
|
||||||
|
@ -4624,11 +4624,13 @@ The following key bindings will be enabled when this layer is loaded:
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
MAIL *SpaceVim-layers-mail*
|
MAIL *SpaceVim-layers-mail*
|
||||||
|
|
||||||
The `mail` layer provides basic function to connected to mail server.
|
The `mail` layer provides basic function to connected to mail server. NOTE:
|
||||||
|
this layer is still wip now.
|
||||||
LAYER OPTIONS
|
LAYER OPTIONS
|
||||||
|
|
||||||
1. `ssh_port`: set the port of mail server
|
1. `imap_host`: set the imap server host
|
||||||
|
2. `imap_port`: set the imap server port
|
||||||
|
3. `imap_login`: set the login of imap server
|
||||||
|
|
||||||
KEY BINDINGS
|
KEY BINDINGS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user