Adds deoplete
This commit is contained in:
parent
61e6b1ad2c
commit
fa2e44a582
5 changed files with 89 additions and 210 deletions
Binary file not shown.
68
rplugin/python3/deoplete/sources/contacts.py
Normal file
68
rplugin/python3/deoplete/sources/contacts.py
Normal file
|
@ -0,0 +1,68 @@
|
|||
# Modified by Jonathan Hodgson
|
||||
|
||||
# Originally from https://github.com/michaeladler/deoplete-abook/blob/master/rplugin/python3/deoplete/sources/abook.py
|
||||
# Original Copyright:
|
||||
# Copyright (c) 2017 Filip Szymański. All rights reserved.
|
||||
# Use of this source code is governed by an MIT license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import configparser
|
||||
import os.path
|
||||
import re
|
||||
|
||||
from .base import Base # pylint: disable=E0401
|
||||
|
||||
|
||||
# pylint: disable=W0201,W0613
|
||||
class Source(Base):
|
||||
COLON_PATTERN = re.compile(r':\s?')
|
||||
COMMA_PATTERN = re.compile(r'.+,\s?')
|
||||
HEADER_PATTERN = re.compile(r'^(Bcc|Cc|From|Reply-To|To):(\s?|.+,\s?)')
|
||||
|
||||
def __init__(self, vim):
|
||||
super().__init__(vim)
|
||||
|
||||
self.__cache = []
|
||||
|
||||
self.filetypes = ['mail']
|
||||
self.mark = '[abook]'
|
||||
self.matchers = ['matcher_length', 'matcher_full_fuzzy']
|
||||
self.min_pattern_length = 0
|
||||
self.name = 'abook'
|
||||
|
||||
def on_init(self, context):
|
||||
self.__datafile = context['vars'].get('deoplete#sources#abook#datafile',
|
||||
os.path.expanduser('~/.abook/addressbook'))
|
||||
if not os.path.isfile(self.__datafile):
|
||||
self.vim.err_write('[deoplete-abook] No such file: {0}\n'.format(self.__datafile))
|
||||
|
||||
def on_event(self, context):
|
||||
self.__make_cache()
|
||||
|
||||
def gather_candidates(self, context):
|
||||
if self.HEADER_PATTERN.search(context['input']) is not None:
|
||||
if not self.__cache:
|
||||
self.__make_cache()
|
||||
|
||||
return self.__cache
|
||||
|
||||
def get_complete_position(self, context):
|
||||
colon = self.COLON_PATTERN.search(context['input'])
|
||||
comma = self.COMMA_PATTERN.search(context['input'])
|
||||
return max(colon.end() if colon is not None else -1,
|
||||
comma.end() if comma is not None else -1)
|
||||
|
||||
def __make_cache(self):
|
||||
addressbook = configparser.ConfigParser()
|
||||
addressbook.read(self.__datafile)
|
||||
for section in addressbook.sections():
|
||||
emails = addressbook.get(section, 'email', fallback=None)
|
||||
if emails is not None:
|
||||
name = addressbook.get(section, 'name', fallback=None)
|
||||
for email in emails.split(','):
|
||||
if name is not None:
|
||||
email = '"{0}" <{1}>'.format(name, email)
|
||||
|
||||
self.__cache.append({'word': email})
|
||||
|
||||
# vim: ts=4 et sw=4
|
4
spell/en.utf-8.add
Normal file
4
spell/en.utf-8.add
Normal file
|
@ -0,0 +1,4 @@
|
|||
Hodgson
|
||||
offline
|
||||
blog
|
||||
setup
|
BIN
spell/en.utf-8.add.spl
Normal file
BIN
spell/en.utf-8.add.spl
Normal file
Binary file not shown.
225
vimrc
225
vimrc
|
@ -27,7 +27,7 @@ colorscheme base16-gruvbox-dark-hard
|
|||
set autoread
|
||||
|
||||
" Turn on mouse Interaction
|
||||
set mouse=a
|
||||
" set mouse=a
|
||||
|
||||
" Set spelcheck language
|
||||
set spelllang=en_gb
|
||||
|
@ -94,8 +94,10 @@ set cursorline
|
|||
let &t_SI = "\e[5 q"
|
||||
let &t_EI = "\e[1 q"
|
||||
|
||||
" optional reset cursor on start:
|
||||
augroup myCmds
|
||||
" reset cursor on start
|
||||
" In zsh I have a bar when in insert mode and a box when in visual. I want
|
||||
" vim to automatically switch to a box when I open it
|
||||
augroup cursorToBox
|
||||
au!
|
||||
autocmd VimEnter * silent !echo -ne "\e[1 q"
|
||||
augroup END
|
||||
|
@ -157,196 +159,21 @@ nnoremap <leader>/ = :FzfRg
|
|||
let g:typescript_indent_disable = 1
|
||||
|
||||
|
||||
" deoplete
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
" Quick tex options {{{2
|
||||
" HTML {{{3
|
||||
" let g:quicktex_html = {
|
||||
" \' ' : "\<ESC>/<+.*+>\<CR>\"_c/+>/e\<CR>",
|
||||
" \';b' : "<b><+++></b> <++>",
|
||||
" \';i' : "<em><+++></em> <++>",
|
||||
" \';1' : "<h1><+++></h1> <++>",
|
||||
" \';2' : "<h2><+++></h2> <++>",
|
||||
" \';3' : "<h3><+++></h3> <++>",
|
||||
" \';p' : "<p><+++></p> <++>",
|
||||
" \';a' : "<a href=\"<++>\"><+++></a> <++>",
|
||||
" \';ul' : "<ul>\<CR><li><+++></li>\<CR></ul>\<CR>\<CR><++>",
|
||||
" \';ol' : "<ol>\<CR><li><+++></li>\<CR></ol>\<CR>\<CR><++>",
|
||||
" \';li' : "<li><++></li>",
|
||||
" \}
|
||||
" " CSS {{{3
|
||||
" let g:quicktex_css = {
|
||||
" \' ' : "\<ESC>/<+.*+>\<CR>\"_c/+>/e\<CR>",
|
||||
" \
|
||||
" \'w' : "width: <+++>;\<CR><++>",
|
||||
" \'h' : "height: <+++>;\<CR><++>",
|
||||
" \'mw' : "max-width: <+++>;\<CR><++>",
|
||||
" \'mh' : "max-height: <+++>;\<CR><++>",
|
||||
" \'t' : "top: <+++>;\<CR><++>",
|
||||
" \'b' : "bottom: <+++>;\<CR><++>",
|
||||
" \'l' : "left: <+++>;\<CR><++>",
|
||||
" \'r' : "right: <+++>;\<CR><++>",
|
||||
" \'pos' : "position: <+++>;\<CR><++>",
|
||||
" \
|
||||
" \'m' : "margin: <+++>;\<CR><++>",
|
||||
" \'mt' : "margin-top: <+++>;\<CR><++>",
|
||||
" \'mb' : "margin-bottom: <+++>;\<CR><++>",
|
||||
" \'ml' : "margin-left: <+++>;\<CR><++>",
|
||||
" \'mr' : "margin-right: <+++>;\<CR><++>",
|
||||
" \
|
||||
" \'p' : "padding: <+++>;\<CR><++>",
|
||||
" \'pt' : "padding-top: <+++>;\<CR><++>",
|
||||
" \'pb' : "padding-bottom: <+++>;\<CR><++>",
|
||||
" \'pl' : "padding-left: <+++>;\<CR><++>",
|
||||
" \'pr' : "padding-right: <+++>;\<CR><++>",
|
||||
" \
|
||||
" \'bor' : "border: <+++>;\<CR><++>",
|
||||
" \'bort' : "border-top: <+++>;\<CR><++>",
|
||||
" \'borb' : "border-bottom: <+++>;\<CR><++>",
|
||||
" \'borl' : "border-left: <+++>;\<CR><++>",
|
||||
" \'borr' : "border-right: <+++>;\<CR><++>",
|
||||
" \
|
||||
" \';abs' : "position: absolute;\<CR><++>",
|
||||
" \';rel' : "position: relative;\<CR><++>",
|
||||
" \';fix' : "position: fixed;\<CR><++>",
|
||||
" \
|
||||
" \';block' : "display: block;\<CR><++>",
|
||||
" \';inl' : "display: inline;\<CR><++>",
|
||||
" \';inb' : "display: inline-block;\<CR><++>",
|
||||
" \';flex' : "display: flex;\<CR><++>",
|
||||
" \';inf' : "display: inline-flex;\<CR><++>",
|
||||
" \
|
||||
" \'include' : "@import \"<+++>\";\<CR><++>",
|
||||
" \'@include' : "@import \"<+++>\";\<CR><++>",
|
||||
" \'require' : "@import \"<+++>\";\<CR><++>",
|
||||
" \'@require' : "@import \"<+++>\";\<CR><++>",
|
||||
" \'import' : "@import \"<+++>\";\<CR><++>",
|
||||
" \
|
||||
" \'media' : "@media (<+++>){\<CR><++>\<CR>}",
|
||||
" \';minw' : "@media (min-width: <+++>){\<CR><++>\<CR>}",
|
||||
" \';mindw' : "@media (min-width: @min-desktop-width){\<CR><+++>\<CR>}",
|
||||
" \}
|
||||
" let g:quicktex_less = g:quicktex_css
|
||||
"
|
||||
" " JS {{{3
|
||||
" let g:quicktex_javascript = {
|
||||
" \' ' : "\<ESC>/<+.*+>\<CR>\"_c/+>/e\<CR>",
|
||||
" \
|
||||
" \';fun' : "function <+++>(<++>){\<CR><++>\<CR>}",
|
||||
" \
|
||||
" \}
|
||||
" " Latex Normal {{{3
|
||||
" let g:quicktex_tex = {
|
||||
" \' ' : "\<ESC>/<+.*+>\<CR>\"_c/+>/e\<CR>",
|
||||
" \';b' : "\\textbf{<+++>} <++>",
|
||||
" \';e' : "\\emph{<+++>} <++>",
|
||||
" \'prf' : "\\begin{proof}\<CR><+++>\<CR>\\end{proof}",
|
||||
" \';m' : "$<+++>$ <++>",
|
||||
" \';M' : "\\[ <+++> \\] <++>",
|
||||
" \';ma' : "$a$ ",
|
||||
" \';mb' : "$b$ ",
|
||||
" \';mc' : "$c$ ",
|
||||
" \';md' : "$d$ ",
|
||||
" \';me' : "$e$ ",
|
||||
" \';mf' : "$f$ ",
|
||||
" \';mg' : "$g$ ",
|
||||
" \';mh' : "$h$ ",
|
||||
" \';mi' : "$i$ ",
|
||||
" \';mj' : "$j$ ",
|
||||
" \';mk' : "$k$ ",
|
||||
" \';ml' : "$l$ ",
|
||||
" \';mm' : "$m$ ",
|
||||
" \';mn' : "$n$ ",
|
||||
" \';mo' : "$o$ ",
|
||||
" \';mp' : "$p$ ",
|
||||
" \';mq' : "$q$ ",
|
||||
" \';mr' : "$r$ ",
|
||||
" \';ms' : "$s$ ",
|
||||
" \';mt' : "$t$ ",
|
||||
" \';mu' : "$u$ ",
|
||||
" \';mv' : "$v$ ",
|
||||
" \';mw' : "$w$ ",
|
||||
" \';mx' : "$x$ ",
|
||||
" \';my' : "$y$ ",
|
||||
" \';mz' : "$z$ ",
|
||||
" \';mA' : "$A$ ",
|
||||
" \';mB' : "$B$ ",
|
||||
" \';mC' : "$C$ ",
|
||||
" \';mD' : "$D$ ",
|
||||
" \';mE' : "$E$ ",
|
||||
" \';mF' : "$F$ ",
|
||||
" \';mG' : "$G$ ",
|
||||
" \';mH' : "$H$ ",
|
||||
" \';mI' : "$I$ ",
|
||||
" \';mJ' : "$J$ ",
|
||||
" \';mK' : "$K$ ",
|
||||
" \';mL' : "$L$ ",
|
||||
" \';mM' : "$M$ ",
|
||||
" \';mN' : "$N$ ",
|
||||
" \';mO' : "$O$ ",
|
||||
" \';mP' : "$P$ ",
|
||||
" \';mQ' : "$Q$ ",
|
||||
" \';mR' : "$R$ ",
|
||||
" \';mS' : "$S$ ",
|
||||
" \';mT' : "$T$ ",
|
||||
" \';mU' : "$U$ ",
|
||||
" \';mV' : "$V$ ",
|
||||
" \';mW' : "$W$ ",
|
||||
" \';mX' : "$X$ ",
|
||||
" \';mY' : "$Y$ ",
|
||||
" \';mZ' : "$Z$ ",
|
||||
" \}
|
||||
"
|
||||
" " Latex Maths {{{3
|
||||
" let g:quicktex_math = {
|
||||
" \' ' : "\<ESC>/<+.*+>\<CR>\"_c/+>/e\<CR>",
|
||||
" \';b' : "\\mathbf{<+++>} <++>",
|
||||
" \';B' : "\\mathbb{<+++>} <++>",
|
||||
" \'fr' : '\mathcal{R} ',
|
||||
" \'eq' : '= ',
|
||||
" \'set' : '\{ <+++> \} <++>',
|
||||
" \'frac' : '\frac{<+++>}{<++>} <++>',
|
||||
" \'in' : '\in ',
|
||||
" \'bn' : '\mathbb{N} ',
|
||||
" \}
|
||||
"
|
||||
" " Markdown {{{3
|
||||
" let g:quicktex_markdown = {
|
||||
" \' ' : "\<ESC>/<+.*+>\<CR>\"_c/+>/e\<CR>",
|
||||
" \';b' : "**<+++>** <++>",
|
||||
" \';i' : "*<+++>* <++>",
|
||||
" \';a' : "[<+++>](<+url+>) <++>",
|
||||
" \}
|
||||
" let g:quicktex_pandoc = g:quicktex_markdown
|
||||
" " PHP {{{3
|
||||
" let g:quicktex_php = {
|
||||
" \' ' : "\<ESC>/<+.*+>\<CR>\"_c/+>/e\<CR>",
|
||||
" \';ob' : "ob_start();\<CR><+++>\<CR>ob_get_clean();",
|
||||
" \';vd' : "var_dump(<+++>);",
|
||||
" \';obvd' : "ob_start();\<CR>var_dump(<+++>);\<CR>echo htmlspecialchars(ob_get_clean());",
|
||||
" \';nl' : "echo '<br />';",
|
||||
" \}
|
||||
" If I am running neovim, I want deoplete to start
|
||||
if has('nvim')
|
||||
let g:deoplete#enable_at_startup = 1
|
||||
endif
|
||||
|
||||
|
||||
"}}}
|
||||
"}}}
|
||||
|
||||
|
||||
" Functions {{{1
|
||||
|
||||
function! NextMark()
|
||||
execute "normal! /(<.>)\<cr>zvda("
|
||||
execute "startinsert"
|
||||
endfunction
|
||||
|
||||
function! NewHtml()
|
||||
read ~/Templates/html
|
||||
normal! ggdd
|
||||
setlocal filetype=html
|
||||
"call NextMark()
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -356,20 +183,6 @@ function! NewLatex()
|
|||
setlocal filetype=tex
|
||||
endfunction
|
||||
|
||||
" Strip the newline from the end of a string
|
||||
function! Chomp(str)
|
||||
return substitute(a:str, '\n$', '', '')
|
||||
endfunction
|
||||
|
||||
" Find a file and pass it to cmd
|
||||
function! DmenuOpen(cmd)
|
||||
let fname = Chomp(system("git ls-files | rofi -dmenu -i -l 20 -p " . a:cmd))
|
||||
if empty(fname)
|
||||
return
|
||||
endif
|
||||
execute a:cmd . " " . fname
|
||||
endfunction
|
||||
|
||||
" Moves to open window, or focuses it
|
||||
" https://www.reddit.com/r/vim/comments/8f80o3/awesome_way_to_navigate_windows_and_autocreate/
|
||||
function! WinMove(key)
|
||||
|
@ -392,7 +205,7 @@ command! WpSalts :r! curl https://api.wordpress.org/secret-key/1.1/salt 2> /dev/
|
|||
|
||||
|
||||
" Mappings {{{1
|
||||
" Move lines up/down/left/right using arrow keys
|
||||
" Move lines up/down or chars left/right using arrow keys
|
||||
nnoremap <Down> ddp
|
||||
nnoremap <Up> ddkP
|
||||
nnoremap <Right> xp
|
||||
|
@ -406,19 +219,16 @@ nnoremap : ;
|
|||
vnoremap ; :
|
||||
vnoremap : ;
|
||||
|
||||
" Move lines up/down/left/right using arrow keys
|
||||
nnoremap <Down> ddp
|
||||
nnoremap <Up> ddkP
|
||||
nnoremap <Right> xp
|
||||
nnoremap <Left> xhP
|
||||
|
||||
" Compiles documents
|
||||
" The uppercase versions don't push enter an extra time resulting in seeing
|
||||
" the output of the compile command. Useful for debugging
|
||||
nnoremap <leader>cc :w! \| !compiler <c-r>%<CR><CR>
|
||||
nnoremap <leader>cC :w! \| !compiler <c-r>%<CR>
|
||||
nnoremap <leader>cf :w! \| !compiler <c-r>% fplreport<CR><CR>
|
||||
nnoremap <leader>cF :w! \| !compiler <c-r>% fplreport<CR>
|
||||
nnoremap <leader>cl :w! \| !compiler <c-r>% letter<CR><CR>
|
||||
nnoremap <leader>cL :w! \| !compiler <c-r>% letter<CR>
|
||||
|
||||
" Opens the compiled documetn
|
||||
" If something like html, it doesn't need to be compiled first
|
||||
nnoremap <leader>co :!opout <c-r>%<CR><CR>
|
||||
|
||||
" Activate spelling
|
||||
|
@ -428,7 +238,6 @@ nnoremap <F7> :set spell!<cr>
|
|||
noremap <ScrollWheelUp> <nop>
|
||||
noremap <ScrollWheelDown> <nop>
|
||||
|
||||
" nnoremap <c-o> :call DmenuOpen("e")<cr>
|
||||
|
||||
" make ctrl + hjkl move + create windows
|
||||
nnoremap <C-h> :call WinMove('h')<cr>
|
||||
|
@ -497,8 +306,6 @@ inoremap <expr> <c-c> fzf#vim#complete({
|
|||
\ 'options': '--multi',
|
||||
\ 'down': '30%' })
|
||||
|
||||
" Set double space in insert mode to go to next mark and enter insert mode
|
||||
"inoremap <leader><leader> <Esc>:call NextMark()<cr>
|
||||
|
||||
" Stops vim doing anything when terminal gains or looses focus
|
||||
noremap <silent> <Esc>[I <nop>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue