docvim 0.3.1.6 → 0.3.2.0
raw patch · 9 files changed
+939/−132 lines, 9 filesdep ~docvimPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: docvim
API changes (from Hackage documentation)
Files
- docvim.cabal +4/−4
- lib/Text/Docvim/Printer/Markdown.hs +12/−0
- lib/Text/Docvim/Printer/Vim.hs +15/−1
- tests/Tasty.hs +3/−0
- tests/fixtures/integration/loupe/golden/ast.golden +603/−57
- tests/fixtures/integration/loupe/golden/markdown.golden +76/−1
- tests/fixtures/integration/loupe/golden/plaintext.golden +79/−8
- tests/fixtures/integration/loupe/input/autoload/loupe/private.vim +10/−45
- tests/fixtures/integration/loupe/input/plugin/loupe.vim +137/−16
docvim.cabal view
@@ -1,5 +1,5 @@ name: docvim-version: 0.3.1.6+version: 0.3.2.0 cabal-version: >=1.10 build-type: Simple license: MIT@@ -173,7 +173,7 @@ source-repository this type: git location: https://github.com/wincent/docvim.git- tag: 0.3.1.6+ tag: 0.3.2.0 library exposed-modules:@@ -223,7 +223,7 @@ main-is: Main.hs build-depends: base >=4.8.2.0 && <5,- docvim >=0.3.1.6+ docvim >=0.3.2.0 default-language: Haskell2010 hs-source-dirs: src ghc-options: -W -Wall@@ -247,7 +247,7 @@ deepseq >=1.4.1.1, directory >=1.2.2.0, dlist >=0.7.1.2,- docvim >=0.3.1.6,+ docvim >=0.3.2.0, filepath >=1.4.0.0, lens >=4.13, mtl >=2.2.1,
lib/Text/Docvim/Printer/Markdown.hs view
@@ -1,6 +1,10 @@+{-# LANGUAGE CPP #-}+ module Text.Docvim.Printer.Markdown (markdown) where +#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>))+#endif import Control.Monad.Reader import Data.List import Data.Maybe@@ -38,6 +42,7 @@ CommandsAnnotation -> h2 "Commands" DocBlock d -> nodes d Fenced f -> return $ fenced f ++ "\n\n"+ FunctionAnnotation {} -> function n FunctionDeclaration {} -> nodes $ functionBody n FunctionsAnnotation -> h2 "Functions" HeadingAnnotation h -> h2 h@@ -160,6 +165,13 @@ where target = linkTargets [":" ++ name] annotation = rstrip $ name ++ " " ++ fromMaybe "" params command _ = invalidNode++function :: Node -> Env+function (FunctionAnnotation name) = do+ content <- h3 $ "`" ++ name ++ "()`"+ return $ target ++ content+ where target = linkTargets [name ++ "()"]+function _ = invalidNode mapping :: String -> Env mapping name = h3 $ "`" ++ name ++ "`"
lib/Text/Docvim/Printer/Vim.hs view
@@ -1,8 +1,11 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE MultiWayIf #-} module Text.Docvim.Printer.Vim (vimHelp) where +#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>))+#endif import Control.Arrow import Control.Monad import Control.Monad.Reader@@ -127,8 +130,9 @@ CommandsAnnotation -> heading "commands" DocBlock d -> nodes d Fenced f -> fenced f- FunctionsAnnotation -> heading "functions"+ FunctionAnnotation {} -> function n FunctionDeclaration {} -> nodes $ functionBody n+ FunctionsAnnotation -> heading "functions" HeadingAnnotation h -> heading h Link l -> append $ link l LinkTargets l -> linkTargets l True@@ -212,6 +216,16 @@ -- (and do similar for other sections) -- once that is done, drop the extra newline above command _ = invalidNode++function :: Node -> Env+function (FunctionAnnotation name) = do+ lhs <- append $ name ++ "()"+ ws <- append " "+ target' <- linkTargets [name ++ "()"] False+ trailing <- append "\n"+ return $ concat [lhs, ws, target', trailing]+-- TODO indent what follows+function _ = invalidNode mapping :: String -> Env mapping name = linkTargets [name] True
tests/Tasty.hs view
@@ -1,8 +1,11 @@+{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-type-defaults #-} module Main (main) where +#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>))+#endif import Control.DeepSeq import Control.Exception hiding (assert) import Data.ByteString.Lazy.Char8 (pack, unpack)
tests/fixtures/integration/loupe/golden/ast.golden view
@@ -6,6 +6,7 @@ , "Installation" , "Mappings" , "Options"+ , "Functions" , "Overrides" , "Related" , "Website"@@ -666,17 +667,49 @@ [ Unit [ FunctionDeclaration { functionBang = True- , functionName = "loupe#private#very_magic_slash"+ , functionName = "loupe#hlmatch" , functionArguments = ArgumentList [] , functionAttributes = [ "abort" ] , functionBody =+ [ Empty+ , LetStatement+ { letLexpr = "l:highlight"+ , letValue = "get(g:, 'LoupeHighlightGroup', 'IncSearch')"+ }+ , GenericStatement "if empty(l:highlight)"+ , GenericStatement "return"+ , GenericStatement "endif"+ , GenericStatement "if has('autocmd')"+ , GenericStatement "augroup LoupeHightlightMatch"+ , GenericStatement "autocmd!"+ , GenericStatement "augroup END"+ , GenericStatement "endif"+ , GenericStatement "call loupe#private#clear_highlight()"+ , LetStatement+ { letLexpr = "l:pattern" , letValue = "'\\c\\%#' . @/" }+ , GenericStatement "if exists('*matchadd')"+ , LetStatement+ { letLexpr = "w:loupe_hlmatch"+ , letValue = "matchadd(l:highlight, l:pattern)"+ }+ , GenericStatement "endif"+ ]+ }+ ]+ , Unit+ [ FunctionDeclaration+ { functionBang = True+ , functionName = "loupe#private#very_magic_slash"+ , functionArguments = ArgumentList [ Argument "slash" ]+ , functionAttributes = [ "abort" ]+ , functionBody = [ GenericStatement "if getcmdtype() != ':'"- , GenericStatement "return '/'"+ , GenericStatement "return a:slash" , GenericStatement "endif" , LetStatement { letLexpr = "l:pos" , letValue = "getcmdpos()" } , LetStatement { letLexpr = "l:cmd" , letValue = "getcmdline()" } , GenericStatement "if len(l:cmd) + 1 != l:pos"- , GenericStatement "return '/'"+ , GenericStatement "return a:slash" , GenericStatement "endif" , GenericStatement "while 1" , LetStatement@@ -688,9 +721,10 @@ , GenericStatement "endif" , GenericStatement "endwhile" , GenericStatement "if index(['g', 's', 'v'], l:cmd) != -1"- , GenericStatement "return loupe#private#prepare_highlight('/\\v')"+ , GenericStatement+ "return loupe#private#prepare_highlight(a:slash . '\\v')" , GenericStatement "endif"- , GenericStatement "return '/'"+ , GenericStatement "return a:slash" ] } , FunctionDeclaration@@ -777,8 +811,7 @@ [ GenericStatement "if has('autocmd')" , GenericStatement "augroup LoupeHightlightMatch" , GenericStatement "autocmd!"- , GenericStatement- "autocmd CursorMoved * :call loupe#private#hlmatch()"+ , GenericStatement "autocmd CursorMoved * :call loupe#hlmatch()" , GenericStatement "augroup END" , GenericStatement "endif" , GenericStatement "return a:result"@@ -807,41 +840,11 @@ , functionArguments = ArgumentList [] , functionAttributes = [ "abort" ] , functionBody =- [ GenericStatement "if !v:hlsearch"+ [ GenericStatement "if !exists('v:hlsearch') || !v:hlsearch" , GenericStatement "call loupe#private#clear_highlight()" , GenericStatement "endif" ] }- , FunctionDeclaration- { functionBang = True- , functionName = "loupe#private#hlmatch"- , functionArguments = ArgumentList []- , functionAttributes = [ "abort" ]- , functionBody =- [ Empty- , LetStatement- { letLexpr = "l:highlight"- , letValue = "get(g:, 'LoupeHighlightGroup', 'IncSearch')"- }- , GenericStatement "if empty(l:highlight)"- , GenericStatement "return"- , GenericStatement "endif"- , GenericStatement "if has('autocmd')"- , GenericStatement "augroup LoupeHightlightMatch"- , GenericStatement "autocmd!"- , GenericStatement "augroup END"- , GenericStatement "endif"- , GenericStatement "call loupe#private#clear_highlight()"- , LetStatement- { letLexpr = "l:pattern" , letValue = "'\\c\\%#' . @/" }- , GenericStatement "if exists('*matchadd')"- , LetStatement- { letLexpr = "w:loupe_hlmatch"- , letValue = "matchadd(l:highlight, l:pattern)"- }- , GenericStatement "endif"- ]- } ] , Unit [ GenericStatement@@ -867,10 +870,10 @@ , GenericStatement "set smartcase \" Case-sensitive search if search string includes a capital letter." , LetStatement- { letLexpr = "s:map"+ { letLexpr = "s:clear" , letValue = "get(g:, 'LoupeClearHighlightMap', 1)" }- , GenericStatement "if s:map"+ , GenericStatement "if s:clear" , GenericStatement "if !hasmapto('<Plug>(LoupeClearHighlight)') && maparg('<leader>n', 'n') ==# ''" , GenericStatement@@ -918,28 +921,94 @@ "xnoremap <expr> ? loupe#private#prepare_highlight('?' . <SID>MagicString())" , GenericStatement "if !empty(s:MagicString())" , GenericStatement- "cnoremap <expr> / loupe#private#very_magic_slash()"- , GenericStatement "endif"- , LetStatement- { letLexpr = "s:center"- , letValue = "get(g:, 'LoupeCenterResults', 1)"- }- , LetStatement- { letLexpr = "s:center_string"- , letValue = "s:center ? 'zz' : ''"- }+ "cnoremap <expr> ! loupe#private#very_magic_slash('!')" , GenericStatement- "execute 'nnoremap <silent> # #' . s:center_string . ':call loupe#private#hlmatch()<CR>'"+ "cnoremap <expr> # loupe#private#very_magic_slash('#')" , GenericStatement- "execute 'nnoremap <silent> * *' . s:center_string . ':call loupe#private#hlmatch()<CR>'"+ "cnoremap <expr> $ loupe#private#very_magic_slash('$')" , GenericStatement- "execute 'nnoremap <silent> N N' . s:center_string . ':call loupe#private#hlmatch()<CR>'"+ "cnoremap <expr> % loupe#private#very_magic_slash('%')" , GenericStatement- "execute 'nnoremap <silent> g# g#' . s:center_string . ':call loupe#private#hlmatch()<CR>'"+ "cnoremap <expr> & loupe#private#very_magic_slash('&')" , GenericStatement- "execute 'nnoremap <silent> g* g*' . s:center_string . ':call loupe#private#hlmatch()<CR>'"+ "cnoremap <expr> ' loupe#private#very_magic_slash(\"'\")" , GenericStatement- "execute 'nnoremap <silent> n n' . s:center_string . ':call loupe#private#hlmatch()<CR>'"+ "cnoremap <expr> ( loupe#private#very_magic_slash('(')"+ , GenericStatement+ "cnoremap <expr> ) loupe#private#very_magic_slash(')')"+ , GenericStatement+ "cnoremap <expr> * loupe#private#very_magic_slash('*')"+ , GenericStatement+ "cnoremap <expr> + loupe#private#very_magic_slash('+')"+ , GenericStatement+ "cnoremap <expr> , loupe#private#very_magic_slash(',')"+ , GenericStatement+ "cnoremap <expr> - loupe#private#very_magic_slash('-')"+ , GenericStatement+ "cnoremap <expr> . loupe#private#very_magic_slash('.')"+ , GenericStatement+ "cnoremap <expr> / loupe#private#very_magic_slash('/')"+ , GenericStatement+ "cnoremap <expr> : loupe#private#very_magic_slash(':')"+ , GenericStatement+ "cnoremap <expr> ; loupe#private#very_magic_slash(';')"+ , GenericStatement+ "cnoremap <expr> < loupe#private#very_magic_slash('<')"+ , GenericStatement+ "cnoremap <expr> = loupe#private#very_magic_slash('=')"+ , GenericStatement+ "cnoremap <expr> > loupe#private#very_magic_slash('>')"+ , GenericStatement+ "cnoremap <expr> ? loupe#private#very_magic_slash('?')"+ , GenericStatement+ "cnoremap <expr> @ loupe#private#very_magic_slash('@')"+ , GenericStatement+ "cnoremap <expr> [ loupe#private#very_magic_slash('[')"+ , GenericStatement+ "cnoremap <expr> ] loupe#private#very_magic_slash(']')"+ , GenericStatement+ "cnoremap <expr> ^ loupe#private#very_magic_slash('^')"+ , GenericStatement+ "cnoremap <expr> _ loupe#private#very_magic_slash('_')"+ , GenericStatement+ "cnoremap <expr> ` loupe#private#very_magic_slash('`')"+ , GenericStatement+ "cnoremap <expr> { loupe#private#very_magic_slash('{')"+ , GenericStatement+ "cnoremap <expr> } loupe#private#very_magic_slash('}')"+ , GenericStatement+ "cnoremap <expr> ~ loupe#private#very_magic_slash('~')"+ , GenericStatement "endif"+ , FunctionDeclaration+ { functionBang = True+ , functionName = "s:map"+ , functionArguments =+ ArgumentList [ Argument "keys" , Argument "name" ]+ , functionAttributes = []+ , functionBody =+ [ Empty+ , LetStatement+ { letLexpr = "s:center"+ , letValue = "get(g:, 'LoupeCenterResults', 1)"+ }+ , LetStatement+ { letLexpr = "s:center_string"+ , letValue = "s:center ? 'zz' : ''"+ }+ , GenericStatement "if !hasmapto('<Plug>(Loupe' . a:name . ')')"+ , GenericStatement+ "execute 'nmap <silent> ' . a:keys . ' <Plug>(Loupe' . a:name . ')'"+ , GenericStatement "endif"+ , GenericStatement+ "execute 'nnoremap <silent> <Plug>(Loupe' . a:name . ')' . ' ' . a:keys . s:center_string . ':call loupe#hlmatch()<CR>'"+ ]+ }+ , GenericStatement "call s:map('#', 'Octothorpe')"+ , GenericStatement "call s:map('*', 'Star')"+ , GenericStatement "call s:map('N', 'N')"+ , GenericStatement "call s:map('g#', 'GOctothorpe')"+ , GenericStatement "call s:map('g*', 'GStar')"+ , GenericStatement "call s:map('n', 'n')" , GenericStatement "if has('autocmd') && has('extra_search')" , GenericStatement "augroup LoupeCleanUp" , GenericStatement "autocmd!"@@ -1129,6 +1198,384 @@ , Plaintext "." ] ]+ , MappingAnnotation "<Plug>(LoupeOctothorpe)"+ , Paragraph+ [ Plaintext "Loupe"+ , Whitespace+ , Plaintext "maps"+ , Whitespace+ , Link "#"+ , Whitespace+ , Plaintext "to"+ , Whitespace+ , Link "<Plug>(LoupeOctothorpe)"+ , Whitespace+ , Plaintext "in"+ , Whitespace+ , Plaintext "order"+ , Whitespace+ , Plaintext "to"+ , Whitespace+ , Plaintext "implement"+ , Whitespace+ , Plaintext "custom"+ , Whitespace+ , Plaintext "highlighting"+ , Whitespace+ , Plaintext "and"+ , Whitespace+ , Plaintext "line-centering"+ , Whitespace+ , Plaintext "for"+ , Whitespace+ , Plaintext "the"+ , Whitespace+ , Plaintext "current"+ , Whitespace+ , Plaintext "match."+ ]+ , Paragraph+ [ Plaintext "To"+ , Whitespace+ , Plaintext "prevent"+ , Whitespace+ , Plaintext "this"+ , Whitespace+ , Plaintext "from"+ , Whitespace+ , Plaintext "happening,"+ , Whitespace+ , Plaintext "create"+ , Whitespace+ , Plaintext "an"+ , Whitespace+ , Plaintext "alternate"+ , Whitespace+ , Plaintext "mapping"+ , Whitespace+ , Plaintext "in"+ , Whitespace+ , Plaintext "your"+ , Whitespace+ , Link ".vimrc"+ , Plaintext ":"+ ]+ , Fenced [ "nmap <Nop> <Plug>(LoupeOctothorpe)" ]+ , MappingAnnotation "<Plug>(LoupeStar)"+ , Paragraph+ [ Plaintext "Loupe"+ , Whitespace+ , Plaintext "maps"+ , Whitespace+ , Link "star"+ , Whitespace+ , Plaintext "to"+ , Whitespace+ , Link "<Plug>(LoupeStar)"+ , Whitespace+ , Plaintext "in"+ , Whitespace+ , Plaintext "order"+ , Whitespace+ , Plaintext "to"+ , Whitespace+ , Plaintext "implement"+ , Whitespace+ , Plaintext "custom"+ , Whitespace+ , Plaintext "highlighting"+ , Whitespace+ , Plaintext "and"+ , Whitespace+ , Plaintext "line-centering"+ , Whitespace+ , Plaintext "for"+ , Whitespace+ , Plaintext "the"+ , Whitespace+ , Plaintext "current"+ , Whitespace+ , Plaintext "match."+ ]+ , Paragraph+ [ Plaintext "To"+ , Whitespace+ , Plaintext "prevent"+ , Whitespace+ , Plaintext "this"+ , Whitespace+ , Plaintext "from"+ , Whitespace+ , Plaintext "happening,"+ , Whitespace+ , Plaintext "create"+ , Whitespace+ , Plaintext "an"+ , Whitespace+ , Plaintext "alternate"+ , Whitespace+ , Plaintext "mapping"+ , Whitespace+ , Plaintext "in"+ , Whitespace+ , Plaintext "your"+ , Whitespace+ , Link ".vimrc"+ , Plaintext ":"+ ]+ , Fenced [ "nmap <Nop> <Plug>(LoupeStar)" ]+ , MappingAnnotation "<Plug>(LoupeN)"+ , Paragraph+ [ Plaintext "Loupe"+ , Whitespace+ , Plaintext "maps"+ , Whitespace+ , Link "N"+ , Whitespace+ , Plaintext "to"+ , Whitespace+ , Link "<Plug>(LoupeN)"+ , Whitespace+ , Plaintext "in"+ , Whitespace+ , Plaintext "order"+ , Whitespace+ , Plaintext "to"+ , Whitespace+ , Plaintext "implement"+ , Whitespace+ , Plaintext "custom"+ , Whitespace+ , Plaintext "highlighting"+ , Whitespace+ , Plaintext "and"+ , Whitespace+ , Plaintext "line-centering"+ , Whitespace+ , Plaintext "for"+ , Whitespace+ , Plaintext "the"+ , Whitespace+ , Plaintext "current"+ , Whitespace+ , Plaintext "match."+ ]+ , Paragraph+ [ Plaintext "To"+ , Whitespace+ , Plaintext "prevent"+ , Whitespace+ , Plaintext "this"+ , Whitespace+ , Plaintext "from"+ , Whitespace+ , Plaintext "happening,"+ , Whitespace+ , Plaintext "create"+ , Whitespace+ , Plaintext "an"+ , Whitespace+ , Plaintext "alternate"+ , Whitespace+ , Plaintext "mapping"+ , Whitespace+ , Plaintext "in"+ , Whitespace+ , Plaintext "your"+ , Whitespace+ , Link ".vimrc"+ , Plaintext ":"+ ]+ , Fenced [ "nmap <Nop> <Plug>(LoupeN)" ]+ , MappingAnnotation "<Plug>(LoupeGOctothorpe)"+ , Paragraph+ [ Plaintext "Loupe"+ , Whitespace+ , Plaintext "maps"+ , Whitespace+ , Link "g#"+ , Whitespace+ , Plaintext "to"+ , Whitespace+ , Link "<Plug>(LoupeGOctothorpe)"+ , Whitespace+ , Plaintext "in"+ , Whitespace+ , Plaintext "order"+ , Whitespace+ , Plaintext "to"+ , Whitespace+ , Plaintext "implement"+ , Whitespace+ , Plaintext "custom"+ , Whitespace+ , Plaintext "highlighting"+ , Whitespace+ , Plaintext "and"+ , Whitespace+ , Plaintext "line-centering"+ , Whitespace+ , Plaintext "for"+ , Whitespace+ , Plaintext "the"+ , Whitespace+ , Plaintext "current"+ , Whitespace+ , Plaintext "match."+ ]+ , Paragraph+ [ Plaintext "To"+ , Whitespace+ , Plaintext "prevent"+ , Whitespace+ , Plaintext "this"+ , Whitespace+ , Plaintext "from"+ , Whitespace+ , Plaintext "happening,"+ , Whitespace+ , Plaintext "create"+ , Whitespace+ , Plaintext "an"+ , Whitespace+ , Plaintext "alternate"+ , Whitespace+ , Plaintext "mapping"+ , Whitespace+ , Plaintext "in"+ , Whitespace+ , Plaintext "your"+ , Whitespace+ , Link ".vimrc"+ , Plaintext ":"+ ]+ , Fenced [ "nmap <Nop> <Plug>(LoupeGOctothorpe)" ]+ , MappingAnnotation "<Plug>(LoupeGStar)"+ , Paragraph+ [ Plaintext "Loupe"+ , Whitespace+ , Plaintext "maps"+ , Whitespace+ , Link "gstar"+ , Whitespace+ , Plaintext "to"+ , Whitespace+ , Link "<Plug>(LoupeGStar)"+ , Whitespace+ , Plaintext "in"+ , Whitespace+ , Plaintext "order"+ , Whitespace+ , Plaintext "to"+ , Whitespace+ , Plaintext "implement"+ , Whitespace+ , Plaintext "custom"+ , Whitespace+ , Plaintext "highlighting"+ , Whitespace+ , Plaintext "and"+ , Whitespace+ , Plaintext "line-centering"+ , Whitespace+ , Plaintext "for"+ , Whitespace+ , Plaintext "the"+ , Whitespace+ , Plaintext "current"+ , Whitespace+ , Plaintext "match."+ ]+ , Paragraph+ [ Plaintext "To"+ , Whitespace+ , Plaintext "prevent"+ , Whitespace+ , Plaintext "this"+ , Whitespace+ , Plaintext "from"+ , Whitespace+ , Plaintext "happening,"+ , Whitespace+ , Plaintext "create"+ , Whitespace+ , Plaintext "an"+ , Whitespace+ , Plaintext "alternate"+ , Whitespace+ , Plaintext "mapping"+ , Whitespace+ , Plaintext "in"+ , Whitespace+ , Plaintext "your"+ , Whitespace+ , Link ".vimrc"+ , Plaintext ":"+ ]+ , Fenced [ "nmap <Nop> <Plug>(LoupeGStar)" ]+ , MappingAnnotation "<Plug>(Loupen)"+ , Paragraph+ [ Plaintext "Loupe"+ , Whitespace+ , Plaintext "maps"+ , Whitespace+ , Link "n"+ , Whitespace+ , Plaintext "to"+ , Whitespace+ , Link "<Plug>(Loupen)"+ , Whitespace+ , Plaintext "in"+ , Whitespace+ , Plaintext "order"+ , Whitespace+ , Plaintext "to"+ , Whitespace+ , Plaintext "implement"+ , Whitespace+ , Plaintext "custom"+ , Whitespace+ , Plaintext "highlighting"+ , Whitespace+ , Plaintext "and"+ , Whitespace+ , Plaintext "line-centering"+ , Whitespace+ , Plaintext "for"+ , Whitespace+ , Plaintext "the"+ , Whitespace+ , Plaintext "current"+ , Whitespace+ , Plaintext "match."+ ]+ , Paragraph+ [ Plaintext "To"+ , Whitespace+ , Plaintext "prevent"+ , Whitespace+ , Plaintext "this"+ , Whitespace+ , Plaintext "from"+ , Whitespace+ , Plaintext "happening,"+ , Whitespace+ , Plaintext "create"+ , Whitespace+ , Plaintext "an"+ , Whitespace+ , Plaintext "alternate"+ , Whitespace+ , Plaintext "mapping"+ , Whitespace+ , Plaintext "in"+ , Whitespace+ , Plaintext "your"+ , Whitespace+ , Link ".vimrc"+ , Plaintext ":"+ ]+ , Fenced [ "nmap <Nop> <Plug>(Loupen)" ] , OptionsAnnotation , OptionAnnotation "g:LoupeHighlightGroup" "string" (Just "IncSearch")@@ -1380,6 +1827,23 @@ , Plaintext "0:" ] , Fenced [ "let g:LoupeCenterResults=0" ]+ , FunctionsAnnotation+ , FunctionAnnotation "loupe#hlmatch"+ , Paragraph+ [ Plaintext "Apply"+ , Whitespace+ , Plaintext "highlighting"+ , Whitespace+ , Plaintext "to"+ , Whitespace+ , Plaintext "the"+ , Whitespace+ , Plaintext "current"+ , Whitespace+ , Plaintext "search"+ , Whitespace+ , Plaintext "match."+ ] , FooterAnnotation , HeadingAnnotation "Overrides" , Paragraph@@ -1425,7 +1889,32 @@ , Whitespace , Plaintext "box\"" , Whitespace- , Plaintext "experience:"+ , Plaintext "experience."+ , Whitespace+ , Plaintext "The"+ , Whitespace+ , Plaintext "following"+ , Whitespace+ , Plaintext "overrides"+ , Whitespace+ , Plaintext "will"+ , Whitespace+ , Plaintext "be"+ , Whitespace+ , Plaintext "set"+ , Whitespace+ , Plaintext "unless"+ , Whitespace+ , Plaintext "suppressed"+ , Whitespace+ , Plaintext "or"+ , Whitespace+ , Plaintext "overridden"+ , Whitespace+ , Plaintext "(see"+ , Whitespace+ , Link "loupe-suppress-overrides"+ , Plaintext "):" ] , IndentAnnotation , LinkTargets [ "loupe-history-override" ]@@ -1651,6 +2140,9 @@ , Plaintext "characters)." ] , DedentAnnotation+ , LinkTargets [ "loupe-suppress-overrides" ]+ , SubheadingAnnotation+ "Preventing Loupe overrides from taking effect" , Paragraph [ Plaintext "To" , Whitespace@@ -2400,6 +2892,60 @@ [ Plaintext "https://www.youtube.com/watch?v=aHm36-na4-4" ] ] , HeadingAnnotation "History"+ , Paragraph+ [ Plaintext "1.1"+ , Whitespace+ , Plaintext "(15"+ , Whitespace+ , Plaintext "June"+ , Whitespace+ , Plaintext "2016)"+ ]+ , List+ [ ListItem+ [ Plaintext "Make"+ , Whitespace+ , Plaintext "compatible"+ , Whitespace+ , Plaintext "with"+ , Whitespace+ , Plaintext "older"+ , Whitespace+ , Plaintext "versions"+ , Whitespace+ , Plaintext "of"+ , Whitespace+ , Plaintext "Vim"+ , Whitespace+ , Plaintext "that"+ , Whitespace+ , Plaintext "do"+ , Whitespace+ , Plaintext "not"+ , Whitespace+ , Plaintext "have"+ , Whitespace+ , Link "v:hlsearch"+ , Plaintext "."+ ]+ , ListItem+ [ Plaintext "Add"+ , Whitespace+ , Plaintext "support"+ , Whitespace+ , Plaintext "for"+ , Whitespace+ , Plaintext "special"+ , Whitespace+ , Plaintext "delimiters"+ , Whitespace+ , Plaintext "with"+ , Whitespace+ , Link ":substitute"+ , Whitespace+ , Plaintext "command."+ ]+ ] , SubheadingAnnotation "1.0 (28 December 2015)" , List [ ListItem
tests/fixtures/integration/loupe/golden/markdown.golden view
@@ -68,6 +68,66 @@ - An alternative mapping for <strong>[`<Plug>(LoupeClearHighlight)`](#user-content-plugloupeclearhighlight)</strong> has already been set up from a <strong>`.vimrc`</strong>. - The mapping has been suppressed by setting <strong>`g:LoupeClearHighlightMap`</strong> to 1 in your <strong>`.vimrc`</strong>. +### `<Plug>(LoupeOctothorpe)`<a name="loupe-plugloupeoctothorpe" href="#user-content-loupe-plugloupeoctothorpe"></a>++Loupe maps <strong>`#`</strong> to <strong>[`<Plug>(LoupeOctothorpe)`](#user-content-plugloupeoctothorpe)</strong> in order to implement custom highlighting and line-centering for the current match.++To prevent this from happening, create an alternate mapping in your <strong>`.vimrc`</strong>:++```+nmap <Nop> <Plug>(LoupeOctothorpe)+```++### `<Plug>(LoupeStar)`<a name="loupe-plugloupestar" href="#user-content-loupe-plugloupestar"></a>++Loupe maps <strong>`star`</strong> to <strong>[`<Plug>(LoupeStar)`](#user-content-plugloupestar)</strong> in order to implement custom highlighting and line-centering for the current match.++To prevent this from happening, create an alternate mapping in your <strong>`.vimrc`</strong>:++```+nmap <Nop> <Plug>(LoupeStar)+```++### `<Plug>(LoupeN)`<a name="loupe-plugloupen" href="#user-content-loupe-plugloupen"></a>++Loupe maps <strong>`N`</strong> to <strong>[`<Plug>(LoupeN)`](#user-content-plugloupen)</strong> in order to implement custom highlighting and line-centering for the current match.++To prevent this from happening, create an alternate mapping in your <strong>`.vimrc`</strong>:++```+nmap <Nop> <Plug>(LoupeN)+```++### `<Plug>(LoupeGOctothorpe)`<a name="loupe-plugloupegoctothorpe" href="#user-content-loupe-plugloupegoctothorpe"></a>++Loupe maps <strong>`g#`</strong> to <strong>[`<Plug>(LoupeGOctothorpe)`](#user-content-plugloupegoctothorpe)</strong> in order to implement custom highlighting and line-centering for the current match.++To prevent this from happening, create an alternate mapping in your <strong>`.vimrc`</strong>:++```+nmap <Nop> <Plug>(LoupeGOctothorpe)+```++### `<Plug>(LoupeGStar)`<a name="loupe-plugloupegstar" href="#user-content-loupe-plugloupegstar"></a>++Loupe maps <strong>`gstar`</strong> to <strong>[`<Plug>(LoupeGStar)`](#user-content-plugloupegstar)</strong> in order to implement custom highlighting and line-centering for the current match.++To prevent this from happening, create an alternate mapping in your <strong>`.vimrc`</strong>:++```+nmap <Nop> <Plug>(LoupeGStar)+```++### `<Plug>(Loupen)`<a name="loupe-plugloupen" href="#user-content-loupe-plugloupen"></a>++Loupe maps <strong>`n`</strong> to <strong>[`<Plug>(Loupen)`](#user-content-plugloupen)</strong> in order to implement custom highlighting and line-centering for the current match.++To prevent this from happening, create an alternate mapping in your <strong>`.vimrc`</strong>:++```+nmap <Nop> <Plug>(Loupen)+```+ ## Options<a name="loupe-options" href="#user-content-loupe-options"></a> <p align="right"><a name="gloupehighlightgroup" href="#user-content-gloupehighlightgroup"><code>g:LoupeHighlightGroup</code></a></p>@@ -117,9 +177,16 @@ let g:LoupeCenterResults=0 ``` +## Functions<a name="loupe-functions" href="#user-content-loupe-functions"></a>++<p align="right"><a name="loupehlmatch" href="#user-content-loupehlmatch"><code>loupe#hlmatch()</code></a></p>+### `loupe#hlmatch()`<a name="loupe-loupehlmatch" href="#user-content-loupe-loupehlmatch"></a>++Apply highlighting to the current search match.+ ## Overrides<a name="loupe-overrides" href="#user-content-loupe-overrides"></a> -Loupe sets a number of search-related Vim settings to reasonable defaults in order to provide a good "out of the box" experience:+Loupe sets a number of search-related Vim settings to reasonable defaults in order to provide a good "out of the box" experience. The following overrides will be set unless suppressed or overridden (see <strong>[`loupe-suppress-overrides`](#user-content-loupe-suppress-overrides)</strong>): <p align="right"><a name="loupe-history-override" href="#user-content-loupe-history-override"><code>loupe-history-override</code></a></p> 'history'@@ -151,6 +218,9 @@ Turned on (overrides 'ignorecase', making the search pattern case-sensitive whenever it containers uppercase characters). +<p align="right"><a name="loupe-suppress-overrides" href="#user-content-loupe-suppress-overrides"><code>loupe-suppress-overrides</code></a></p>+### Preventing Loupe overrides from taking effect<a name="loupe-preventing-loupe-overrides-from-taking-effect" href="#user-content-loupe-preventing-loupe-overrides-from-taking-effect"></a>+ To override any of these choices, you can place overrides in an <strong>`after-directory`</strong> (ie. `~/.vim/after/plugin/loupe.vim`). For example: ```@@ -248,6 +318,11 @@ - https://www.youtube.com/watch?v=aHm36-na4-4 ## History<a name="loupe-history" href="#user-content-loupe-history"></a>++1.1 (15 June 2016)++- Make compatible with older versions of Vim that do not have <strong>`v:hlsearch`</strong>.+- Add support for special delimiters with <strong>`:substitute`</strong> command. ### 1.0 (28 December 2015)<a name="loupe-10-28-december-2015" href="#user-content-loupe-10-28-december-2015"></a>
tests/fixtures/integration/loupe/golden/plaintext.golden view
@@ -6,13 +6,14 @@ 2. Installation |loupe-installation| 3. Mappings |loupe-mappings| 4. Options |loupe-options|-5. Overrides |loupe-overrides|-6. Related |loupe-related|-7. Website |loupe-website|-8. License |loupe-license|-9. Development |loupe-development|-10. Authors |loupe-authors|-11. History |loupe-history|+5. Functions |loupe-functions|+6. Overrides |loupe-overrides|+7. Related |loupe-related|+8. Website |loupe-website|+9. License |loupe-license|+10. Development |loupe-development|+11. Authors |loupe-authors|+12. History |loupe-history| INTRO *loupe-intro* @@ -97,6 +98,60 @@ - The mapping has been suppressed by setting |g:LoupeClearHighlightMap| to 1 in your |.vimrc|. ++ *<Plug>(LoupeOctothorpe)*+Loupe maps |#| to |<Plug>(LoupeOctothorpe)| in order to implement custom+highlighting and line-centering for the current match.++To prevent this from happening, create an alternate mapping in your |.vimrc|:+>+ nmap <Nop> <Plug>(LoupeOctothorpe)+<++ *<Plug>(LoupeStar)*+Loupe maps |star| to |<Plug>(LoupeStar)| in order to implement custom+highlighting and line-centering for the current match.++To prevent this from happening, create an alternate mapping in your |.vimrc|:+>+ nmap <Nop> <Plug>(LoupeStar)+<++ *<Plug>(LoupeN)*+Loupe maps |N| to |<Plug>(LoupeN)| in order to implement custom highlighting and+line-centering for the current match.++To prevent this from happening, create an alternate mapping in your |.vimrc|:+>+ nmap <Nop> <Plug>(LoupeN)+<++ *<Plug>(LoupeGOctothorpe)*+Loupe maps |g#| to |<Plug>(LoupeGOctothorpe)| in order to implement custom+highlighting and line-centering for the current match.++To prevent this from happening, create an alternate mapping in your |.vimrc|:+>+ nmap <Nop> <Plug>(LoupeGOctothorpe)+<++ *<Plug>(LoupeGStar)*+Loupe maps |gstar| to |<Plug>(LoupeGStar)| in order to implement custom+highlighting and line-centering for the current match.++To prevent this from happening, create an alternate mapping in your |.vimrc|:+>+ nmap <Nop> <Plug>(LoupeGStar)+<++ *<Plug>(Loupen)*+Loupe maps |n| to |<Plug>(Loupen)| in order to implement custom highlighting and+line-centering for the current match.++To prevent this from happening, create an alternate mapping in your |.vimrc|:+>+ nmap <Nop> <Plug>(Loupen)+< OPTIONS *loupe-options* @@ -148,10 +203,17 @@ > let g:LoupeCenterResults=0 <+FUNCTIONS *loupe-functions*++loupe#hlmatch() *loupe#hlmatch()*++Apply highlighting to the current search match.+ OVERRIDES *loupe-overrides* Loupe sets a number of search-related Vim settings to reasonable defaults in-order to provide a good "out of the box" experience:+order to provide a good "out of the box" experience. The following overrides+will be set unless suppressed or overridden (see |loupe-suppress-overrides|): *loupe-history-override*@@ -195,6 +257,10 @@ Turned on (overrides 'ignorecase', making the search pattern case-sensitive whenever it containers uppercase characters). ++ *loupe-suppress-overrides*+Preventing Loupe overrides from taking effect ~+ To override any of these choices, you can place overrides in an |after-directory| (ie. `~/.vim/after/plugin/loupe.vim`). For example: >@@ -303,6 +369,11 @@ - https://www.youtube.com/watch?v=aHm36-na4-4 HISTORY *loupe-history*++1.1 (15 June 2016)++- Make compatible with older versions of Vim that do not have |v:hlsearch|.+- Add support for special delimiters with |:substitute| command. 1.0 (28 December 2015) ~
tests/fixtures/integration/loupe/input/autoload/loupe/private.vim view
@@ -3,20 +3,22 @@ " Dynamically returns "/" or "/\v" depending on the location of the just-typed " "/" within the command-line. Only "/" that looks to be at the start of a-" command gets replaced.+" command gets replaced. The "slash" is itself configurable via the `slash`+" argument, meaning that this function can be used in conjunction with other+" pattern delimiters like "?" and "@" etc (ie. "?" -> "?\v", "@" -> "@\v"). " " Doesn't handle the full list of possible range types (specified in `:h " cmdline-ranges`), but catches the most common ones.-function! loupe#private#very_magic_slash() abort+function! loupe#private#very_magic_slash(slash) abort if getcmdtype() != ':'- return '/'+ return a:slash endif " For simplicity, only consider "/" typed at the end of the command-line. let l:pos=getcmdpos() let l:cmd=getcmdline() if len(l:cmd) + 1 != l:pos- return '/'+ return a:slash endif " Skip over ranges@@ -30,10 +32,10 @@ endwhile if index(['g', 's', 'v'], l:cmd) != -1- return loupe#private#prepare_highlight('/\v')+ return loupe#private#prepare_highlight(a:slash . '\v') endif - return '/'+ return a:slash endfunction function! s:strip_ranges(cmdline)@@ -68,7 +70,7 @@ if has('autocmd') augroup LoupeHightlightMatch autocmd!- autocmd CursorMoved * :call loupe#private#hlmatch()+ autocmd CursorMoved * :call loupe#hlmatch() augroup END endif return a:result@@ -93,44 +95,7 @@ " from another window and we should clean up the straggling match and the " window-local variable. function! loupe#private#cleanup() abort- if !v:hlsearch+ if !exists('v:hlsearch') || !v:hlsearch call loupe#private#clear_highlight()- endif-endfunction--" Apply highlighting to the current search match.-function! loupe#private#hlmatch() abort- ""- " @option g:LoupeHighlightGroup string IncSearch- " Specifies the |:highlight| group used to emphasize the match currently under- " the cursor for the current search pattern. Defaults to "IncSearch" (ie.- " |hl-IncSearch|). For example:- "- " ```- " let g:LoupeHighlightGroup='Error'- " ```- "- " To prevent any special highlighting from being applied, set this option to- " "" (ie. the empty string).- let l:highlight=get(g:, 'LoupeHighlightGroup', 'IncSearch')- if empty(l:highlight)- return- endif-- if has('autocmd')- augroup LoupeHightlightMatch- autocmd!- augroup END- endif-- call loupe#private#clear_highlight()-- " \c case insensitive- " \%# current cursor position- " @/ current search pattern- let l:pattern='\c\%#' . @/-- if exists('*matchadd')- let w:loupe_hlmatch=matchadd(l:highlight, l:pattern) endif endfunction
tests/fixtures/integration/loupe/input/plugin/loupe.vim view
@@ -79,7 +79,8 @@ " # Overrides " " Loupe sets a number of search-related Vim settings to reasonable defaults in-" order to provide a good "out of the box" experience:+" order to provide a good "out of the box" experience. The following overrides+" will be set unless suppressed or overridden (see |loupe-suppress-overrides|): " " @indent " *loupe-history-override*@@ -120,6 +121,9 @@ " " @dedent "+" *loupe-suppress-overrides*+" ## Preventing Loupe overrides from taking effect+" " To override any of these choices, you can place overrides in an " |after-directory| (ie. `~/.vim/after/plugin/loupe.vim`). For example: "@@ -239,6 +243,11 @@ " " # History "+" 1.1 (15 June 2016)+"+" - Make compatible with older versions of Vim that do not have |v:hlsearch|.+" - Add support for special delimiters with |:substitute| command.+" " ## 1.0 (28 December 2015) " " - Renamed the |<Plug>LoupeClearHighlight| mapping to@@ -288,8 +297,8 @@ " ``` " let g:LoupeClearHighlightMap=0 " ```-let s:map=get(g:, 'LoupeClearHighlightMap', 1)-if s:map+let s:clear=get(g:, 'LoupeClearHighlightMap', 1)+if s:clear if !hasmapto('<Plug>(LoupeClearHighlight)') && maparg('<leader>n', 'n') ==# '' nmap <silent> <unique> <leader>n <Plug>(LoupeClearHighlight) endif@@ -348,27 +357,139 @@ xnoremap <expr> / loupe#private#prepare_highlight('/' . <SID>MagicString()) xnoremap <expr> ? loupe#private#prepare_highlight('?' . <SID>MagicString()) if !empty(s:MagicString())- cnoremap <expr> / loupe#private#very_magic_slash()+ " Any single-byte character may be used as a delimiter except \, ", | and+ " alphanumerics. See `:h E146`.+ cnoremap <expr> ! loupe#private#very_magic_slash('!')+ cnoremap <expr> # loupe#private#very_magic_slash('#')+ cnoremap <expr> $ loupe#private#very_magic_slash('$')+ cnoremap <expr> % loupe#private#very_magic_slash('%')+ cnoremap <expr> & loupe#private#very_magic_slash('&')+ cnoremap <expr> ' loupe#private#very_magic_slash("'")+ cnoremap <expr> ( loupe#private#very_magic_slash('(')+ cnoremap <expr> ) loupe#private#very_magic_slash(')')+ cnoremap <expr> * loupe#private#very_magic_slash('*')+ cnoremap <expr> + loupe#private#very_magic_slash('+')+ cnoremap <expr> , loupe#private#very_magic_slash(',')+ cnoremap <expr> - loupe#private#very_magic_slash('-')+ cnoremap <expr> . loupe#private#very_magic_slash('.')+ cnoremap <expr> / loupe#private#very_magic_slash('/')+ cnoremap <expr> : loupe#private#very_magic_slash(':')+ cnoremap <expr> ; loupe#private#very_magic_slash(';')+ cnoremap <expr> < loupe#private#very_magic_slash('<')+ cnoremap <expr> = loupe#private#very_magic_slash('=')+ cnoremap <expr> > loupe#private#very_magic_slash('>')+ cnoremap <expr> ? loupe#private#very_magic_slash('?')+ cnoremap <expr> @ loupe#private#very_magic_slash('@')+ cnoremap <expr> [ loupe#private#very_magic_slash('[')+ cnoremap <expr> ] loupe#private#very_magic_slash(']')+ cnoremap <expr> ^ loupe#private#very_magic_slash('^')+ cnoremap <expr> _ loupe#private#very_magic_slash('_')+ cnoremap <expr> ` loupe#private#very_magic_slash('`')+ cnoremap <expr> { loupe#private#very_magic_slash('{')+ cnoremap <expr> } loupe#private#very_magic_slash('}')+ cnoremap <expr> ~ loupe#private#very_magic_slash('~') endif +function! s:map(keys, name)+ ""+ " @option g:LoupeCenterResults boolean 1+ "+ " Controls whether the match's line is vertically centered within the window+ " when jumping (via |n|, |N| etc). To disable, set to 0:+ "+ " ```+ " let g:LoupeCenterResults=0+ " ```+ let s:center=get(g:, 'LoupeCenterResults', 1)+ let s:center_string=s:center ? 'zz' : ''++ if !hasmapto('<Plug>(Loupe' . a:name . ')')+ execute 'nmap <silent> ' . a:keys . ' <Plug>(Loupe' . a:name . ')'+ endif+ execute 'nnoremap <silent> <Plug>(Loupe' . a:name . ')' .+ \ ' ' .+ \ a:keys .+ \ s:center_string .+ \ ':call loupe#hlmatch()<CR>'+endfunction+ ""-" @option g:LoupeCenterResults boolean 1+" @mapping <Plug>(LoupeOctothorpe) "-" Controls whether the match's line is vertically centered within the window-" when jumping (via |n|, |N| etc). To disable, set to 0:+" Loupe maps |#| to |<Plug>(LoupeOctothorpe)| in order to implement custom+" highlighting and line-centering for the current match. "+" To prevent this from happening, create an alternate mapping in your |.vimrc|:+" " ```-" let g:LoupeCenterResults=0+" nmap <Nop> <Plug>(LoupeOctothorpe) " ```-let s:center=get(g:, 'LoupeCenterResults', 1)-let s:center_string=s:center ? 'zz' : ''+call s:map('#', 'Octothorpe') -execute 'nnoremap <silent> # #' . s:center_string . ':call loupe#private#hlmatch()<CR>'-execute 'nnoremap <silent> * *' . s:center_string . ':call loupe#private#hlmatch()<CR>'-execute 'nnoremap <silent> N N' . s:center_string . ':call loupe#private#hlmatch()<CR>'-execute 'nnoremap <silent> g# g#' . s:center_string . ':call loupe#private#hlmatch()<CR>'-execute 'nnoremap <silent> g* g*' . s:center_string . ':call loupe#private#hlmatch()<CR>'-execute 'nnoremap <silent> n n' . s:center_string . ':call loupe#private#hlmatch()<CR>'+""+" @mapping <Plug>(LoupeStar)+"+" Loupe maps |star| to |<Plug>(LoupeStar)| in order to implement custom+" highlighting and line-centering for the current match.+"+" To prevent this from happening, create an alternate mapping in your |.vimrc|:+"+" ```+" nmap <Nop> <Plug>(LoupeStar)+" ```+call s:map('*', 'Star')++""+" @mapping <Plug>(LoupeN)+"+" Loupe maps |N| to |<Plug>(LoupeN)| in order to implement custom+" highlighting and line-centering for the current match.+"+" To prevent this from happening, create an alternate mapping in your |.vimrc|:+"+" ```+" nmap <Nop> <Plug>(LoupeN)+" ```+call s:map('N', 'N')++""+" @mapping <Plug>(LoupeGOctothorpe)+"+" Loupe maps |g#| to |<Plug>(LoupeGOctothorpe)| in order to implement custom+" highlighting and line-centering for the current match.+"+" To prevent this from happening, create an alternate mapping in your |.vimrc|:+"+" ```+" nmap <Nop> <Plug>(LoupeGOctothorpe)+" ```+call s:map('g#', 'GOctothorpe')++""+" @mapping <Plug>(LoupeGStar)+"+" Loupe maps |gstar| to |<Plug>(LoupeGStar)| in order to implement custom+" highlighting and line-centering for the current match.+"+" To prevent this from happening, create an alternate mapping in your |.vimrc|:+"+" ```+" nmap <Nop> <Plug>(LoupeGStar)+" ```+call s:map('g*', 'GStar')++""+" @mapping <Plug>(Loupen)+"+" Loupe maps |n| to |<Plug>(Loupen)| in order to implement custom+" highlighting and line-centering for the current match.+"+" To prevent this from happening, create an alternate mapping in your |.vimrc|:+"+" ```+" nmap <Nop> <Plug>(Loupen)+" ```+call s:map('n', 'n') " Clean-up stray `matchadd()` vestiges. if has('autocmd') && has('extra_search')