From 7b5070ab3e96d86b9ca44793623eb4f5ad31607c Mon Sep 17 00:00:00 2001 From: gryf Date: Sat, 13 Jul 2024 18:05:13 +0200 Subject: [PATCH] Asciidoc support --- README.rst | 4 ++-- vimrc | 50 +++++++++++++++++++++++--------------------------- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/README.rst b/README.rst index 7a074f9..5726fad 100644 --- a/README.rst +++ b/README.rst @@ -10,14 +10,14 @@ will automatically install all the plugins. It should be cloned as is into `$HOME`` directory, i.e: .. code:: console - + cd $HOME git clone https://github.com/gryf/.vim or in ``$XDG_COFIG_HOME`` directory, which usually is set to ``$HOME/.config``: .. code:: console - + git clone https://github.com/gryf/.vim ~/.config/vim .. _vim-plug: https://github.com/junegunn/vim-plug diff --git a/vimrc b/vimrc index 69ab1fe..9095efc 100644 --- a/vimrc +++ b/vimrc @@ -38,7 +38,7 @@ Plug 'gryf/pythonhelper', { 'for': 'python' } Plug 'gryf/snipmate.vim' Plug 'gryf/vim-latex-compiler', { 'for': 'tex' } Plug 'gryf/wombat256grf' -Plug 'gryf/zoom.vim' " control gui font size with '+' or '-; keys. +Plug 'gryf/zoom.vim' " control gui font size with '+' or '-; keys. Plug 'habamax/vim-rst', { 'for': 'rst' } Plug 'honza/vim-snippets' Plug 'kien/ctrlp.vim' @@ -206,6 +206,12 @@ map :call CycleDiffAlgorithm() map :call ToggleHex() " }}} "FileTypes: specific vim behaviour {{{ +function s:SetAsciiDoc() "{{{2 + " AsciiDoc specific options + setlocal makeprg=asciidoc\ -b\ html5\ \"%\" + map :ShowInBrowser +endfunction +"}}} function s:SetPythonSettings() "{{{2 " Python specific options setlocal cinkeys-=0# @@ -252,18 +258,7 @@ function s:SetMarkdownSettings() "{{{2 setlocal autoindent setlocal formatoptions=tcq "set VIms default - function! ShowInBrowser() - let l:uri = expand("%:p:r") . ".html" - call system(g:browser . " " . l:uri) - echohl Statement - echo "Opened '" . l:uri ."' in " . g:browser - echohl None - endfunction - - if !exists(":ShowInBrowser") - command ShowInBrowser call s:ShowInBrowser() - map :ShowInBrowser - endif + map :ShowInBrowser " autocmd BufWritePost *.md :silent make endfunction @@ -312,20 +307,7 @@ function s:SetRestSettings() "{{{2 setlocal formatoptions=tcq "set VIms default syn spell toplevel - function! ShowInBrowser() - let l:uri = expand("%:p:r") . ".html" - silent make - call system(g:browser . " " . l:uri) - - echohl Statement - echo "Opened '" . l:uri ."' in " . g:browser - echohl None - endfunction - - if !exists(":ShowInBrowser") - command ShowInBrowser call s:ShowInBrowser() - map :ShowInBrowser - endif + map :ShowInBrowser function! WordFrequency() range let all = split(join(getline(a:firstline, a:lastline)), '\k\+') @@ -380,6 +362,7 @@ autocmd BufRead *.ass, *asm set filetype=kickass autocmd WinEnter * setlocal cursorline autocmd WinLeave * setlocal nocursorline +autocmd FileType asciidoc call SetAsciiDoc() autocmd FileType python call SetPythonSettings() autocmd FileType json call SetJavaScriptSettings() autocmd FileType javascript call SetJavaScriptSettings() @@ -577,6 +560,19 @@ endfunction "}}} " FUNCTIONS: usefull functions for all of the files {{{ +" open file in a browser. Usefull for documentation filetypes like reST, md or +" asciidoc +function! ShowInBrowser() + let l:uri = expand("%:p:r") . ".html" + silent make + call system(g:browser . " " . l:uri) + + echohl Statement + echo "Opened '" . l:uri ."' in " . g:browser + echohl None +endfunction +command ShowInBrowser call s:ShowInBrowser() + " Simple wrapper for :make command function Make() echohl Statement