]> git.wincent.com - docvim.git/log
docvim.git
6 years agoDRY up injection
Greg Hurrell [Wed, 8 Jun 2016 06:15:31 +0000 (23:15 -0700)] 
DRY up injection

6 years agoAuto-inject @commands annotation when necessary
Greg Hurrell [Wed, 8 Jun 2016 06:11:33 +0000 (23:11 -0700)] 
Auto-inject @commands annotation when necessary

6 years agoFix lints
Greg Hurrell [Wed, 8 Jun 2016 06:10:35 +0000 (23:10 -0700)] 
Fix lints

6 years agoMore elegant solution for state passthrough
Greg Hurrell [Wed, 8 Jun 2016 02:07:23 +0000 (19:07 -0700)] 
More elegant solution for state passthrough

6 years agoAvoid unwanted intermediate list in `cosmosOf uniplate`
Greg Hurrell [Wed, 8 Jun 2016 01:41:34 +0000 (18:41 -0700)] 
Avoid unwanted intermediate list in `cosmosOf uniplate`

Who knows: perhaps Haskell's magical laziness would have made these equivalent,
or perhaps this still ends up producing an intermediate list. But at least it
*looks* better.

Figured out by poring over the function list in the lens docs looking for likely
candidates.

6 years agoUse mapM_ rather than mapM in the Section visitor
Greg Hurrell [Tue, 7 Jun 2016 16:39:59 +0000 (09:39 -0700)] 
Use mapM_ rather than mapM in the Section visitor

To make it clear that we don't care about the results, only the state.

6 years agoAdd Section visitor
Greg Hurrell [Tue, 7 Jun 2016 16:26:51 +0000 (09:26 -0700)] 
Add Section visitor

It's job is to check which kinds of annotations we have, in order to decide
which sections we need to render.

I am probably doing something clowny with the way I am mashing uniplate and
lenses etc together, but it does seem to work. That last `get`/`put` case is a
smell, but needed it given my use of `cosmosOf`; not sure how to avoid that.
Also, not sure why `mapM` does the right thing here, but it does.

6 years agoTry to trick linter about duplication
Greg Hurrell [Tue, 7 Jun 2016 14:29:42 +0000 (07:29 -0700)] 
Try to trick linter about duplication

It's been warning about this since forever:

```
Found:
  first <- firstLine
  rest <- many otherLine
  let nodes = concatMap appendWhitespace (first : rest)
  let compressed = compress nodes
  return
    (if last compressed == Whitespace then init compressed else
       compressed)

Why not:
  Combine with lib/Docvim/Parse.hs:202:7

lib/Docvim/Parse.hs:164:7: Warning: Reduce duplication
Found:
  first <- firstLine
  rest <- many otherLine
  let nodes = concatMap appendWhitespace (first : rest)
  let compressed = compress nodes
  return
    (if last compressed == Whitespace then init compressed else
       compressed)

Why not:
  Combine with lib/Docvim/Parse.hs:285:7
```

However, it is too smart. Even with this change, it still complains:

```
Found:
  first <- firstLine
  rest <- many otherLine
  let nodes = concatMap appendWhitespace (first : rest)
  let compressed = compress nodes
  return
    (if last compressed == Whitespace then init compressed else
       compressed)

Why not:
  Combine with lib/Docvim/Parse.hs:282:7

lib/Docvim/Parse.hs:165:7: Suggestion: Reduce duplication
Found:
  rest <- many otherLine
  let nodes = concatMap appendWhitespace (first : rest)
  let compressed = compress nodes
  return
    (if last compressed == Whitespace then init compressed else
       compressed)

Why not:
  Combine with lib/Docvim/Parse.hs:203:7
```

This one is tricky to factor out because of the dependence on bindings visible
within the scope of the defined functions, and also the monadic execution
context. I think the linter *is* probably right that there is a code smell here,
though; I just have to figure out how to remove it.

6 years agoAdd @option headings to Markdown printer
Greg Hurrell [Tue, 7 Jun 2016 14:23:35 +0000 (07:23 -0700)] 
Add @option headings to Markdown printer

6 years agoAdd a target for |:Command| links in Markdown
Greg Hurrell [Tue, 7 Jun 2016 14:15:11 +0000 (07:15 -0700)] 
Add a target for |:Command| links in Markdown

6 years agoRemove unnecessary explicit anchors in headings
Greg Hurrell [Tue, 7 Jun 2016 14:11:03 +0000 (07:11 -0700)] 
Remove unnecessary explicit anchors in headings

GitHub is going to add them anyway. Note that our |:Ack| links
don't work, because we aren't rendering that link target (we should).

6 years agoDo some linkification in the Markdown printer
Greg Hurrell [Tue, 7 Jun 2016 14:02:09 +0000 (07:02 -0700)] 
Do some linkification in the Markdown printer

This is provisional as I think putting the explicit link targets in the heading
for GitHub is wrong.

6 years agoTeach Markdown printer about @mapping and @command
Greg Hurrell [Tue, 7 Jun 2016 07:38:03 +0000 (00:38 -0700)] 
Teach Markdown printer about @mapping and @command

6 years agoAdd @mapping support to Vim printer
Greg Hurrell [Tue, 7 Jun 2016 07:28:20 +0000 (00:28 -0700)] 
Add @mapping support to Vim printer

6 years agoGet @command annotation working
Greg Hurrell [Tue, 7 Jun 2016 07:16:46 +0000 (00:16 -0700)] 
Get @command annotation working

6 years agoMake wrapping aware of concealed characters
Greg Hurrell [Tue, 7 Jun 2016 02:04:40 +0000 (19:04 -0700)] 
Make wrapping aware of concealed characters

This is the cheap-but-approximate approach. Results are reasonable, costs are
very low, and the consequences of being (slightly) wrong are livable. Let's go
with this for now.

6 years agoKill a stray comment
Greg Hurrell [Mon, 6 Jun 2016 15:57:19 +0000 (08:57 -0700)] 
Kill a stray comment

6 years agoUse worktree as issue tracker
Greg Hurrell [Mon, 6 Jun 2016 15:48:07 +0000 (08:48 -0700)] 
Use worktree as issue tracker

Taking standards to new lows.

6 years agoFix misplaced whitespace in output
Greg Hurrell [Mon, 6 Jun 2016 15:47:16 +0000 (08:47 -0700)] 
Fix misplaced whitespace in output

6 years agoAdd test showing @option output
Greg Hurrell [Mon, 6 Jun 2016 15:41:05 +0000 (08:41 -0700)] 
Add test showing @option output

Something buggy in the parser: note that we have to explicitly say "none" for
the no-default case, but I intended that to be simply omittable.

6 years agoPrint options
Greg Hurrell [Mon, 6 Jun 2016 15:31:14 +0000 (08:31 -0700)] 
Print options

Alignment will need a bit of work here, but this is a good first draft.

Specifically, if we want things to look like this in the UI:

                                g:SomeOpt
    g:SomeOpt        string (default: 10)

The output will actually need to be:

                                *g:SomeOpt*
    |g:SomeOpt|        string (default: 10)

Because `|` and `*` don't take up any width due to being concealed by Vim.

6 years agoFix lints
Greg Hurrell [Mon, 6 Jun 2016 14:46:18 +0000 (07:46 -0700)] 
Fix lints

6 years agoUse actual max int rather than hard-coded constant
Greg Hurrell [Mon, 6 Jun 2016 14:38:46 +0000 (07:38 -0700)] 
Use actual max int rather than hard-coded constant

6 years agoHandle overlength headings
Greg Hurrell [Mon, 6 Jun 2016 14:36:52 +0000 (07:36 -0700)] 
Handle overlength headings

#uglycode

6 years agoFix duplicate content
Greg Hurrell [Mon, 6 Jun 2016 14:17:10 +0000 (07:17 -0700)] 
Fix duplicate content

6 years agoInitial cut at @mapping, @command, @option, @function
Greg Hurrell [Mon, 6 Jun 2016 13:55:27 +0000 (06:55 -0700)] 
Initial cut at @mapping, @command, @option, @function

Still some bugs to sort out (eg. duplicate symbol table entry due to extra
`MappingsAnnotation` when we perform extraction) and polish to apply (not
actually printing the options/functions etc).

6 years agoMake Vim headings work by colocating link targets on same line
Greg Hurrell [Mon, 6 Jun 2016 08:03:58 +0000 (01:03 -0700)] 
Make Vim headings work by colocating link targets on same line

6 years agoAdd entries to symbol table for generated headings
Greg Hurrell [Mon, 6 Jun 2016 06:53:25 +0000 (23:53 -0700)] 
Add entries to symbol table for generated headings

6 years agoAutogen headings in Vim printer too
Greg Hurrell [Mon, 6 Jun 2016 06:38:46 +0000 (23:38 -0700)] 
Autogen headings in Vim printer too

6 years agoAdd auto-generated headings to Markdown printer
Greg Hurrell [Mon, 6 Jun 2016 06:19:08 +0000 (23:19 -0700)] 
Add auto-generated headings to Markdown printer

For @functions, @commands, @mappings, @options.

6 years agoAdd basic support for @options, @functions and @commands annotations
Greg Hurrell [Mon, 6 Jun 2016 05:14:09 +0000 (22:14 -0700)] 
Add basic support for @options, @functions and @commands annotations

Still need to auto-emit headings for these, but I think they basically work.
Also need to make `Option`, `Function` and `Command` visitors.

6 years agoOverhaul testing and compilation
Greg Hurrell [Sun, 5 Jun 2016 14:06:32 +0000 (07:06 -0700)] 
Overhaul testing and compilation

We now "compile" in the test suite, meaning that we pipe our translation units
through the various extraction transforms after parsing. This means three main
things:

- Everything is nested inside a `Project` node type now, consisting of one or
  more translation units.
- Nodes within the project are ordered (or reordered) to maintain desired
  section ordering.
- As we add more phases to "compilation" (eg. automated insertion of table
  of contents etc), these will get reflected in the test suite automatically.

As part of this, extracted test-specific bits out into a new `Util` module (ie.
pretty-printing methods, convenience functions) and the "compile" pipeline into
a `Compile` module.

6 years agoAdd a missing type annotation
Greg Hurrell [Sun, 5 Jun 2016 08:46:09 +0000 (01:46 -0700)] 
Add a missing type annotation

6 years agoDon't rely on transformers
Greg Hurrell [Sun, 5 Jun 2016 08:44:47 +0000 (01:44 -0700)] 
Don't rely on transformers

Don't want two monad transformer libraries at play here
needlessly.

6 years agoKill off an out-of-date comment
Greg Hurrell [Sun, 5 Jun 2016 08:40:24 +0000 (01:40 -0700)] 
Kill off an out-of-date comment

6 years agoFix copy pasta error
Greg Hurrell [Sun, 5 Jun 2016 08:40:07 +0000 (01:40 -0700)] 
Fix copy pasta error

Suprised neither the compiler nor the tests seemed to
complain about this.

6 years agoDRY up other visitors
Greg Hurrell [Sun, 5 Jun 2016 08:35:55 +0000 (01:35 -0700)] 
DRY up other visitors

6 years agoMore simplification
Greg Hurrell [Sun, 5 Jun 2016 08:22:31 +0000 (01:22 -0700)] 
More simplification

6 years agoTrim down imports
Greg Hurrell [Sun, 5 Jun 2016 08:15:18 +0000 (01:15 -0700)] 
Trim down imports

6 years agoMore DRYing
Greg Hurrell [Sun, 5 Jun 2016 08:03:07 +0000 (01:03 -0700)] 
More DRYing

6 years agoFurther visitor DRYing
Greg Hurrell [Sun, 5 Jun 2016 07:57:30 +0000 (00:57 -0700)] 
Further visitor DRYing

6 years agoTidy indentation
Greg Hurrell [Sun, 5 Jun 2016 07:43:06 +0000 (00:43 -0700)] 
Tidy indentation

6 years agoFix lints
Greg Hurrell [Sun, 5 Jun 2016 07:37:04 +0000 (00:37 -0700)] 
Fix lints

6 years agoExtract Visitor module
Greg Hurrell [Sun, 5 Jun 2016 07:30:29 +0000 (00:30 -0700)] 
Extract Visitor module

First step in factoring out some of the duplication here.

6 years agoRemove some old comments
Greg Hurrell [Sun, 5 Jun 2016 06:23:47 +0000 (23:23 -0700)] 
Remove some old comments

6 years agoFix indentation
Greg Hurrell [Sun, 5 Jun 2016 06:23:31 +0000 (23:23 -0700)] 
Fix indentation

6 years agoSuppress unwanted trailing whitespace
Greg Hurrell [Sun, 5 Jun 2016 06:12:13 +0000 (23:12 -0700)] 
Suppress unwanted trailing whitespace

6 years agoFurther refine hard-wrapping
Greg Hurrell [Sun, 5 Jun 2016 05:03:05 +0000 (22:03 -0700)] 
Further refine hard-wrapping

6 years agoBe better about hard-wrap placement
Greg Hurrell [Sun, 5 Jun 2016 04:26:53 +0000 (21:26 -0700)] 
Be better about hard-wrap placement

Still needs a refactor, but the output is better.

6 years agoRename `hardwrap` -> `textwidth`
Greg Hurrell [Sun, 5 Jun 2016 03:39:46 +0000 (20:39 -0700)] 
Rename `hardwrap` -> `textwidth`

Because I want to use the name `hardwrap` for a function as part of some
imminent refactoring.

6 years agoAlign
Greg Hurrell [Sun, 5 Jun 2016 03:37:14 +0000 (20:37 -0700)] 
Align

6 years agoAlways link unconditionally in Vim help output
Greg Hurrell [Sun, 5 Jun 2016 03:35:11 +0000 (20:35 -0700)] 
Always link unconditionally in Vim help output

May not even need the symbol table at all in this printer, but we'll keep it
around for now, just in case.

6 years agoReplace a literal that I missed with a constant
Greg Hurrell [Sun, 5 Jun 2016 03:32:40 +0000 (20:32 -0700)] 
Replace a literal that I missed with a constant

6 years agoMove hardwrapping from `plaintext` into `append`
Greg Hurrell [Sat, 4 Jun 2016 22:01:56 +0000 (15:01 -0700)] 
Move hardwrapping from `plaintext` into `append`

Solves a bunch of issues, creates others, which I will have to fix in a
follow-up. The code itself is a complex, fragile, ugly, clusterfuck, so consider
this a work-in-progress.

Additionally, there are some unfortunate breaks which were there before and
continue to be there, like just inside parens, and things like that. Will need
to sort all that out too.

6 years agoTidy
Greg Hurrell [Sat, 4 Jun 2016 20:36:54 +0000 (13:36 -0700)] 
Tidy

6 years agoGet rid of meaningless distinction in Markdown printer
Greg Hurrell [Sat, 4 Jun 2016 20:35:40 +0000 (13:35 -0700)] 
Get rid of meaningless distinction in Markdown printer

All the cases must return Env, so let's put them all together
whether or not they explicitly access the state.

6 years agoShare integration tests inputs across output types
Greg Hurrell [Sat, 4 Jun 2016 14:20:49 +0000 (07:20 -0700)] 
Share integration tests inputs across output types

May eventually share other things too (I still have some
manual symlinks going on), but this is a good start.

6 years agoMake slurping a little more robust
Greg Hurrell [Sat, 4 Jun 2016 14:01:40 +0000 (07:01 -0700)] 
Make slurping a little more robust

But note remaining caveat inline. This really
should only be used to trim whitespace, at least
for now.

6 years agoRemove unwanted blank lines before fenced code blocks
Greg Hurrell [Sat, 4 Jun 2016 13:52:46 +0000 (06:52 -0700)] 
Remove unwanted blank lines before fenced code blocks

But note that this is a little bit fragile, even though
the tests pass. More work can be done to make this more
robust.

6 years agoFix some lints
Greg Hurrell [Sat, 4 Jun 2016 07:00:06 +0000 (00:00 -0700)] 
Fix some lints

6 years agoReorder things
Greg Hurrell [Sat, 4 Jun 2016 06:57:40 +0000 (23:57 -0700)] 
Reorder things

6 years agoEliminate unwanted trailing whitespace
Greg Hurrell [Sat, 4 Jun 2016 04:20:39 +0000 (21:20 -0700)] 
Eliminate unwanted trailing whitespace

6 years agoInitial primitive cut at hard wrapping
Greg Hurrell [Sat, 4 Jun 2016 02:17:40 +0000 (19:17 -0700)] 
Initial primitive cut at hard wrapping

This isn't ideal as noted inline (no rollback yet, which means we wind up with
trailing whitespace), but it is a reasonable start.

6 years agoRemove last use of Append
Greg Hurrell [Sat, 4 Jun 2016 02:09:32 +0000 (19:09 -0700)] 
Remove last use of Append

6 years agoConvert one more `Append`
Greg Hurrell [Thu, 2 Jun 2016 14:24:06 +0000 (07:24 -0700)] 
Convert one more `Append`

6 years agoContinue `Append` -> `append` conversion
Greg Hurrell [Thu, 2 Jun 2016 14:18:28 +0000 (07:18 -0700)] 
Continue `Append` -> `append` conversion

6 years agoUpdate `fenced` to use `append`
Greg Hurrell [Thu, 2 Jun 2016 14:01:04 +0000 (07:01 -0700)] 
Update `fenced` to use `append`

I wanted to write this using `>>=` but evidently that is not the right tool.

6 years agoInline `return` call inside `fenced` function
Greg Hurrell [Thu, 2 Jun 2016 07:43:14 +0000 (00:43 -0700)] 
Inline `return` call inside `fenced` function

Step 1 of ?.

6 years agoDrop excess blank lines after fenced code blocks in Vim output
Greg Hurrell [Thu, 2 Jun 2016 07:41:17 +0000 (00:41 -0700)] 
Drop excess blank lines after fenced code blocks in Vim output

6 years agoCreate append helper and start using it
Greg Hurrell [Thu, 2 Jun 2016 07:20:19 +0000 (00:20 -0700)] 
Create append helper and start using it

6 years agoFeel the linter love
Greg Hurrell [Thu, 2 Jun 2016 02:19:09 +0000 (19:19 -0700)] 
Feel the linter love

6 years agoGet some TODOs out of the work tree
Greg Hurrell [Thu, 2 Jun 2016 02:12:27 +0000 (19:12 -0700)] 
Get some TODOs out of the work tree

Horrible hygiene I know, but I need to compensate the functional purity somehow.

6 years agoAdd partial line to Vim printer context
Greg Hurrell [Wed, 1 Jun 2016 17:37:28 +0000 (10:37 -0700)] 
Add partial line to Vim printer context

This will be used to perform current line width calculations, so that we can
decide whether or not to hard-wrap.

6 years agoUse operations list in Vim printer
Greg Hurrell [Wed, 1 Jun 2016 17:27:28 +0000 (10:27 -0700)] 
Use operations list in Vim printer

Let's see if I can use this to implement hard-wrapping. It is very ugly, but if
I can get it working I'll have some tests in place and can then try refactoring.

6 years agoDeal with linebreaks inside list items
Greg Hurrell [Wed, 1 Jun 2016 08:07:58 +0000 (01:07 -0700)] 
Deal with linebreaks inside list items

6 years agoFix unwanted stripping of leading whitespace
Greg Hurrell [Wed, 1 Jun 2016 07:55:06 +0000 (00:55 -0700)] 
Fix unwanted stripping of leading whitespace

Stripping trailing whitespace is desired, but the leading
strip was actually busting the output.

6 years agoFix excess line at break tags in blockquotes
Greg Hurrell [Wed, 1 Jun 2016 07:49:28 +0000 (00:49 -0700)] 
Fix excess line at break tags in blockquotes

6 years agoAdd some tests
Greg Hurrell [Wed, 1 Jun 2016 07:39:05 +0000 (00:39 -0700)] 
Add some tests

Revealing some still-unresolved issues to be fixed.

6 years agoShow how linebreaks can be contextual
Greg Hurrell [Wed, 1 Jun 2016 07:33:46 +0000 (00:33 -0700)] 
Show how linebreaks can be contextual

6 years agoFurther flesh out README
Greg Hurrell [Wed, 1 Jun 2016 07:23:16 +0000 (00:23 -0700)] 
Further flesh out README

6 years agoEven sillier example of putting monadic state
Greg Hurrell [Wed, 1 Jun 2016 02:12:35 +0000 (19:12 -0700)] 
Even sillier example of putting monadic state

6 years agoSilly demonstration of getting at monadic state
Greg Hurrell [Wed, 1 Jun 2016 02:07:20 +0000 (19:07 -0700)] 
Silly demonstration of getting at monadic state

Doesn't affect the output, but proves that I can `get` the state.

6 years agoUse State + Reader monad transformer stack
Greg Hurrell [Tue, 31 May 2016 14:47:02 +0000 (07:47 -0700)] 
Use State + Reader monad transformer stack

Doesn't do anything useful yet, but it will: I want to use this to track current
line width, for the purposes of wrapping. As noted here:

https://ro-che.info/articles/2012-01-02-composing-monads

The order in which I compose the State and Reader monad transformers shouldn't
matter at all. If I end up needing Writer too, I will be able to replace this
with the RWS monad transformer.

6 years agoAdd some fixture files that I previously forgot to include
Greg Hurrell [Tue, 31 May 2016 14:29:18 +0000 (07:29 -0700)] 
Add some fixture files that I previously forgot to include

6 years agoFix indentation
Greg Hurrell [Tue, 31 May 2016 14:27:34 +0000 (07:27 -0700)] 
Fix indentation

6 years agoRename `State` to `Metadata`
Greg Hurrell [Tue, 31 May 2016 14:21:34 +0000 (07:21 -0700)] 
Rename `State` to `Metadata`

State was a terrible name to use in conjunction with the Reader monad, as it
easily leads to confusion with the State monad. Let's just call it `Metadata`
(about the project AST) for now; that's a horribly generic name too, but it is
at least an improvement.

6 years agoUpdate .tmux paths for Vim 8-pre
Greg Hurrell [Tue, 31 May 2016 14:14:44 +0000 (07:14 -0700)] 
Update .tmux paths for Vim 8-pre

6 years agoFix lint
Greg Hurrell [Tue, 31 May 2016 14:13:21 +0000 (07:13 -0700)] 
Fix lint

6 years agoUpgrade README
Greg Hurrell [Tue, 31 May 2016 14:12:21 +0000 (07:12 -0700)] 
Upgrade README

6 years agoHook up plugin and footer extraction
Greg Hurrell [Tue, 31 May 2016 07:38:57 +0000 (00:38 -0700)] 
Hook up plugin and footer extraction

Obviously the horrible `ast2` binding name will have to go away, but this works.

6 years agoExtract footers and plugin sections
Greg Hurrell [Tue, 31 May 2016 07:36:24 +0000 (00:36 -0700)] 
Extract footers and plugin sections

6 years agoFix trailing whitespace at end of file
Greg Hurrell [Tue, 31 May 2016 06:56:10 +0000 (23:56 -0700)] 
Fix trailing whitespace at end of file

6 years agoActually write output files
Greg Hurrell [Tue, 31 May 2016 06:50:29 +0000 (23:50 -0700)] 
Actually write output files

6 years agoSimplify some case statements with the LambdaCase extension
Greg Hurrell [Tue, 31 May 2016 05:55:00 +0000 (22:55 -0700)] 
Simplify some case statements with the LambdaCase extension

Via:

  https://www.schoolofhaskell.com/school/to-infinity-and-beyond/pick-of-the-week/guide-to-ghc-extensions/basic-syntax-extensions

6 years agoUse MultiWayIf extension to make a nested `if` less ugly
Greg Hurrell [Tue, 31 May 2016 05:44:51 +0000 (22:44 -0700)] 
Use MultiWayIf extension to make a nested `if` less ugly

Still pretty ugly though...

Via:

  https://www.schoolofhaskell.com/school/to-infinity-and-beyond/pick-of-the-week/guide-to-ghc-extensions/basic-syntax-extensions

6 years agoSort link targets for Markdown output too
Greg Hurrell [Tue, 31 May 2016 05:37:48 +0000 (22:37 -0700)] 
Sort link targets for Markdown output too

6 years agoSort link targets
Greg Hurrell [Tue, 31 May 2016 05:36:20 +0000 (22:36 -0700)] 
Sort link targets

6 years agoRight-align link targets
Greg Hurrell [Tue, 31 May 2016 05:34:38 +0000 (22:34 -0700)] 
Right-align link targets

6 years agoStart prepping to hangle hard-wrapping
Greg Hurrell [Mon, 30 May 2016 14:36:25 +0000 (07:36 -0700)] 
Start prepping to hangle hard-wrapping

This is going to be ugly...

6 years agoFix @plugin printing in Vim printer
Greg Hurrell [Mon, 30 May 2016 14:28:32 +0000 (07:28 -0700)] 
Fix @plugin printing in Vim printer