diff --git a/nvim/autoload/gemini_protocol.vim b/nvim/autoload/gemini_protocol.vim new file mode 100644 index 0000000..6b12bd2 --- /dev/null +++ b/nvim/autoload/gemini_protocol.vim @@ -0,0 +1,135 @@ +if !has_key(g:, 'gemini_follow_redirects') + " Do not set to false with the current gmni version + " It doesn't output redirect header to stdout + " Only use with submodule version + let g:gemini_follow_redirects = v:true +endif +if !has_key(g:, 'gemini_max_redirects') + let g:gemini_max_redirects = 5 +endif +if !has_key(g:, 'gemini_gmni_command') + let g:gemini_gmni_command = shellescape(get(split(globpath(&rtp, 'gmni/gmni'), '\n'), 0, 'gmni')) +endif +if !has_key(g:, 'gemini_connect_with') + let g:gemini_connect_with = 'gmni' +endif + +let s:url_regexp = '\v^[^:]+:\/\/%([^\@]+\@)?([^:\/]+)%(:(\d+))?%(\/.*)?$' + +function! s:construct_command(url) + if g:gemini_connect_with ==? 'gmni' + return g:gemini_gmni_command . ' -j once -iN ' . (g:gemini_follow_redirects ? '-R ' . g:gemini_max_redirects . ' -L ' : '') . shellescape(a:url) . ' 2>/dev/null' + endif + + let l:domain = substitute(a:url, s:url_regexp, '\1', '') + let l:port = substitute(a:url, s:url_regexp, '\2', '') + if l:port == '' + let l:port = '1965' + endif + + if g:gemini_connect_with ==? 'openssl' + return 'echo ' . shellescape(a:url . "\r") . ' | openssl s_client -connect ' . shellescape(l:domain . ':' . l:port) . ' -quiet 2>/dev/null' + endif + + if g:gemini_connect_with ==? 'ncat' + return 'echo ' . shellescape(a:url) . ' | ncat -C --ssl --no-shutdown ' . shellescape(l:domain) . ' ' . shellescape(l:port) + endif + + echoerr 'Gemini: invalid gemini_connect_with value: ' . shellescape(g:gemini_connect_with) + return 'echo' +endfunction + +let s:redirects = 0 +function! s:read_gemini(url) + let l:svpos = winsaveview() + setlocal bl ro noswapfile bh=hide fenc= + if &ft == '' + setlocal ft=gmi + else + let &ft=&ft + endif + exe '%read ++bin !' . s:construct_command(a:url) + keepjumps normal! ggJ + let l:header = getline(1) + let b:gemini_header = l:header + keepjumps 1delete _ + keepjumps call winrestview(l:svpos) + if l:header[0] == '3' + let l:new_url = trim(l:header[3:]) + if has_key(g:, 'Gemini_redirect_function') && s:redirects < g:gemini_max_redirects + let s:redirects += 1 + let l:new_url = g:Gemini_redirect_function(l:new_url) + if type(l:new_url) == 1 + " String was returned + 0file + exe 'file ' . fnameescape(l:new_url) + return s:read_gemini(l:new_url) + endif + else + " This plugin doesn't know, how to join urls, + " '/...', '//...' are not handled properly by :find + call append(0, '=> ' . l:new_url . ' Redirect') + endif + let s:redirects = 0 + return + endif + let s:redirects = 0 + if l:header[0] == '1' + let l:url = matchstr(a:url, '\v^[^\?\#]+') . '?' . s:uriencode(input(l:header[3:] . ': ')) + 0file + exe 'file ' . fnameescape(l:url) + return s:read_gemini(l:url) + endif + if l:header[0] == '2' + return + endif + if l:header == '' + let l:header = 'No data' + endif + " Output doesn't seem to work from autocommands + function! s:error_message(...) closure + redraw + echohl WarningMsg + echomsg 'Gemini: ' . l:header + echohl None + endfunction + call timer_start(0, funcref('s:error_message')) + return +endfunction + +function! s:uriencode(str) + let l:res = '' + let l:digits = '0123456789ABCDEF' + for l:i in range(len(a:str)) + let l:c = a:str[l:i] + if match(l:c, '\v^[A-Za-z0-9_]$') == -1 + let l:n = char2nr(l:c) + let l:lo = l:digits[l:n % 16] + let l:hi = l:digits[l:n / 16] + let l:c = '%' . l:hi . l:lo + endif + let l:res .= l:c + endfor + return l:res +endfunction + +aug GeminiProtocol + au! + au BufReadCmd gemini://* exe "sil doau BufReadPre ".fnameescape(expand(""))|call s:read_gemini(expand(""))|exe "sil doau BufReadPost ".fnameescape(expand("")) + au FileReadCmd gemini://* exe "sil doau FileReadPre ".fnameescape(expand(""))|call s:read_gemini(expand(""))|exe "sil doau FileReadPost ".fnameescape(expand("")) +aug END + + + + + + + + + + + + + + + diff --git a/nvim/init.vim b/nvim/init.vim index b6fa756..bd6dd98 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -28,6 +28,18 @@ Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' } Plug 'nanotee/zoxide.vim' Plug 'vimwiki/vimwiki' Plug 'mattn/calendar-vim' +Plug 'camspiers/animate.vim' +Plug 'camspiers/lens.vim' +" Better Syntax Support +Plug 'sheerun/vim-polyglot' +" File Explorer +Plug 'scrooloose/NERDTree' +" Auto pairs for '(' '[' '{' +Plug 'jiangmiao/auto-pairs' + +" Git +Plug 'airblade/vim-gitgutter' +Plug 'tpope/vim-fugitive' call plug#end() let g:molokai_original = 1 @@ -45,14 +57,40 @@ set nocompatible let g:livepreview_previewer = 'zathura' +" Map Leader let mapleader = "," +" Note taking (Mardown, Spelling) let g:vimwiki_list = [{'path': '~/vimwiki/', \ 'syntax': 'markdown', 'ext': '.md'}] -:map :setlocal spell! spelllang=en +:map :setlocal spell! spelllang=en_gb +au BufNewFile ~/vimwiki/diary/*.md :silent 0r !~/.config/nvim/generate-vimwiki-diary-template '%' + let NERDTreeMapOpenInTab='' -au BufNewFile ~/vimwiki/diary/*.md :silent 0r !~/.config/nvim/generate-vimwiki-diary-template '%' +let g:fzf_nvim_statusline = 0 " disable statusline overwriting + +"remaps +nnoremap :Files +nnoremap a :Windows +nnoremap h :History + +" Switching windows +map h +map j +map k +map l + +" Basic cmd commands +nnoremap :!touch +nnoremap :!crf +nnoremap :!mdkir +nnoremap :!mv% + +" Indents +vmap < >gv + diff --git a/nvim/spell/en.utf-8.add b/nvim/spell/en.utf-8.add index 9c0d4b9..bd47619 100644 --- a/nvim/spell/en.utf-8.add +++ b/nvim/spell/en.utf-8.add @@ -23,3 +23,8 @@ init vimwiki PlugInstall mapleader +Todo +nvim +config +lol +CSCU9A3 diff --git a/nvim/spell/en.utf-8.add.spl b/nvim/spell/en.utf-8.add.spl index 705c6c2..6f9638c 100644 Binary files a/nvim/spell/en.utf-8.add.spl and b/nvim/spell/en.utf-8.add.spl differ