diff --git a/rplugin/python3/deoplete/sources/__pycache__/contacts.cpython-38.pyc b/rplugin/python3/deoplete/sources/__pycache__/contacts.cpython-38.pyc new file mode 100644 index 0000000..917429d Binary files /dev/null and b/rplugin/python3/deoplete/sources/__pycache__/contacts.cpython-38.pyc differ diff --git a/rplugin/python3/deoplete/sources/contacts.py b/rplugin/python3/deoplete/sources/contacts.py new file mode 100644 index 0000000..0d76e6e --- /dev/null +++ b/rplugin/python3/deoplete/sources/contacts.py @@ -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 diff --git a/spell/en.utf-8.add b/spell/en.utf-8.add new file mode 100644 index 0000000..b15b19a --- /dev/null +++ b/spell/en.utf-8.add @@ -0,0 +1,4 @@ +Hodgson +offline +blog +setup diff --git a/spell/en.utf-8.add.spl b/spell/en.utf-8.add.spl new file mode 100644 index 0000000..d8de30d Binary files /dev/null and b/spell/en.utf-8.add.spl differ diff --git a/vimrc b/vimrc index 3f607bf..a83940e 100644 --- a/vimrc +++ b/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 @@ -151,202 +153,27 @@ let g:fzf_command_prefix = 'Fzf' nnoremap f = :FzfFiles nnoremap b = :FzfBuffers nnoremap h = :FzfHelptags -nnoremap / = :FzfRg +nnoremap / = :FzfRg " typescript let g:typescript_indent_disable = 1 +" deoplete +" If I am running neovim, I want deoplete to start +if has('nvim') + let g:deoplete#enable_at_startup = 1 +endif - - -" Quick tex options {{{2 -" HTML {{{3 -" let g:quicktex_html = { -" \' ' : "\/<+.*+>\\"_c/+>/e\", -" \';b' : "<+++> <++>", -" \';i' : "<+++> <++>", -" \';1' : "

<+++>

<++>", -" \';2' : "

<+++>

<++>", -" \';3' : "

<+++>

<++>", -" \';p' : "

<+++>

<++>", -" \';a' : "\"><+++> <++>", -" \';ul' : "
    \
  • <+++>
  • \
\\<++>", -" \';ol' : "
    \
  1. <+++>
  2. \
\\<++>", -" \';li' : "
  • <++>
  • ", -" \} -" " CSS {{{3 -" let g:quicktex_css = { -" \' ' : "\/<+.*+>\\"_c/+>/e\", -" \ -" \'w' : "width: <+++>;\<++>", -" \'h' : "height: <+++>;\<++>", -" \'mw' : "max-width: <+++>;\<++>", -" \'mh' : "max-height: <+++>;\<++>", -" \'t' : "top: <+++>;\<++>", -" \'b' : "bottom: <+++>;\<++>", -" \'l' : "left: <+++>;\<++>", -" \'r' : "right: <+++>;\<++>", -" \'pos' : "position: <+++>;\<++>", -" \ -" \'m' : "margin: <+++>;\<++>", -" \'mt' : "margin-top: <+++>;\<++>", -" \'mb' : "margin-bottom: <+++>;\<++>", -" \'ml' : "margin-left: <+++>;\<++>", -" \'mr' : "margin-right: <+++>;\<++>", -" \ -" \'p' : "padding: <+++>;\<++>", -" \'pt' : "padding-top: <+++>;\<++>", -" \'pb' : "padding-bottom: <+++>;\<++>", -" \'pl' : "padding-left: <+++>;\<++>", -" \'pr' : "padding-right: <+++>;\<++>", -" \ -" \'bor' : "border: <+++>;\<++>", -" \'bort' : "border-top: <+++>;\<++>", -" \'borb' : "border-bottom: <+++>;\<++>", -" \'borl' : "border-left: <+++>;\<++>", -" \'borr' : "border-right: <+++>;\<++>", -" \ -" \';abs' : "position: absolute;\<++>", -" \';rel' : "position: relative;\<++>", -" \';fix' : "position: fixed;\<++>", -" \ -" \';block' : "display: block;\<++>", -" \';inl' : "display: inline;\<++>", -" \';inb' : "display: inline-block;\<++>", -" \';flex' : "display: flex;\<++>", -" \';inf' : "display: inline-flex;\<++>", -" \ -" \'include' : "@import \"<+++>\";\<++>", -" \'@include' : "@import \"<+++>\";\<++>", -" \'require' : "@import \"<+++>\";\<++>", -" \'@require' : "@import \"<+++>\";\<++>", -" \'import' : "@import \"<+++>\";\<++>", -" \ -" \'media' : "@media (<+++>){\<++>\}", -" \';minw' : "@media (min-width: <+++>){\<++>\}", -" \';mindw' : "@media (min-width: @min-desktop-width){\<+++>\}", -" \} -" let g:quicktex_less = g:quicktex_css -" -" " JS {{{3 -" let g:quicktex_javascript = { -" \' ' : "\/<+.*+>\\"_c/+>/e\", -" \ -" \';fun' : "function <+++>(<++>){\<++>\}", -" \ -" \} -" " Latex Normal {{{3 -" let g:quicktex_tex = { -" \' ' : "\/<+.*+>\\"_c/+>/e\", -" \';b' : "\\textbf{<+++>} <++>", -" \';e' : "\\emph{<+++>} <++>", -" \'prf' : "\\begin{proof}\<+++>\\\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 = { -" \' ' : "\/<+.*+>\\"_c/+>/e\", -" \';b' : "\\mathbf{<+++>} <++>", -" \';B' : "\\mathbb{<+++>} <++>", -" \'fr' : '\mathcal{R} ', -" \'eq' : '= ', -" \'set' : '\{ <+++> \} <++>', -" \'frac' : '\frac{<+++>}{<++>} <++>', -" \'in' : '\in ', -" \'bn' : '\mathbb{N} ', -" \} -" -" " Markdown {{{3 -" let g:quicktex_markdown = { -" \' ' : "\/<+.*+>\\"_c/+>/e\", -" \';b' : "**<+++>** <++>", -" \';i' : "*<+++>* <++>", -" \';a' : "[<+++>](<+url+>) <++>", -" \} -" let g:quicktex_pandoc = g:quicktex_markdown -" " PHP {{{3 -" let g:quicktex_php = { -" \' ' : "\/<+.*+>\\"_c/+>/e\", -" \';ob' : "ob_start();\<+++>\ob_get_clean();", -" \';vd' : "var_dump(<+++>);", -" \';obvd' : "ob_start();\var_dump(<+++>);\echo htmlspecialchars(ob_get_clean());", -" \';nl' : "echo '
    ';", -" \} - - -"}}} "}}} - - " Functions {{{1 -function! NextMark() - execute "normal! /(<.>)\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 ddp nnoremap ddkP nnoremap xp @@ -406,19 +219,16 @@ nnoremap : ; vnoremap ; : vnoremap : ; -" Move lines up/down/left/right using arrow keys -nnoremap ddp -nnoremap ddkP -nnoremap xp -nnoremap 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 cc :w! \| !compiler % nnoremap cC :w! \| !compiler % -nnoremap cf :w! \| !compiler % fplreport -nnoremap cF :w! \| !compiler % fplreport nnoremap cl :w! \| !compiler % letter nnoremap cL :w! \| !compiler % letter + +" Opens the compiled documetn +" If something like html, it doesn't need to be compiled first nnoremap co :!opout % " Activate spelling @@ -428,7 +238,6 @@ nnoremap :set spell! noremap noremap -" nnoremap :call DmenuOpen("e") " make ctrl + hjkl move + create windows nnoremap :call WinMove('h') @@ -497,8 +306,6 @@ inoremap fzf#vim#complete({ \ 'options': '--multi', \ 'down': '30%' }) -" Set double space in insert mode to go to next mark and enter insert mode -"inoremap :call NextMark() " Stops vim doing anything when terminal gains or looses focus noremap [I