]> git.wincent.com - pinnacle.git/log
pinnacle.git
4 months agofeat: add functions for darkening/lightening highlight groups main master
Greg Hurrell [Sat, 28 May 2022 17:44:43 +0000 (19:44 +0200)] 
feat: add functions for darkening/lightening highlight groups

I'm not documenting these yet as I they are probably riddled with bugs,
but they seem to work in the simple test cases that I have tried out so
far. Specifically, I'm doing this in my dotfiles to make floating
windows look better:

    local dark = vim.o.background == 'dark'
    local factor = dark and 0.15 or -0.15
    local normal = pinnacle.adjust_lightness('Normal', factor)
    vim.cmd('highlight! clear NormalFloat')
    vim.cmd('highlight! NormalFloat ' .. pinnacle.highlight(normal))
    normal['fg'] = dark and '#ffffff' or '#000000'
    vim.cmd('highlight! clear FloatBorder')
    vim.cmd('highlight! FloatBorder ' .. pinnacle.highlight(normal))

15 months agochore: update "master" → "main"
Greg Hurrell [Sat, 12 Jun 2021 17:01:41 +0000 (19:01 +0200)] 
chore: update "master" → "main"

17 months agoMerge branch 'pull/4'
Greg Hurrell [Fri, 9 Apr 2021 17:28:46 +0000 (19:28 +0200)] 
Merge branch 'pull/4'

Closes: https://github.com/wincent/pinnacle/pull/4
* pull/4:
  docs: update AUTHORS listing
  fix: explicitly check vim.fn.has() value

17 months agodocs: update AUTHORS listing
Greg Hurrell [Fri, 9 Apr 2021 17:27:57 +0000 (19:27 +0200)] 
docs: update AUTHORS listing

With this delicious invocation:

    cd ~/code/docvim
    ./dist-newstyle/build/x86_64-osx/ghc-8.4.4/docvim-0.3.2.1/x/docvim/build/docvim/docvim \
        -c ~/code/pinnacle \
        -v \
        ~/code/pinnacle/doc/pinnacle.txt ~/code/pinnacle/README.md

17 months agofix: explicitly check vim.fn.has() value
Khue Nguyen [Fri, 9 Apr 2021 17:04:58 +0000 (13:04 -0400)] 
fix: explicitly check vim.fn.has() value

23 months agodocs: fix typo in a code comment
Greg Hurrell [Tue, 13 Oct 2020 21:07:11 +0000 (23:07 +0200)] 
docs: fix typo in a code comment

23 months agofix: capture/extract highlight without relying on nvim_exec
Greg Hurrell [Tue, 13 Oct 2020 21:03:01 +0000 (23:03 +0200)] 
fix: capture/extract highlight without relying on nvim_exec

As noted in the comments, it sometimes returns an empty string for
reasons I don't know. So let's just side-step it anyway.

23 months agorefactor: drop "silent" from capture_highlight call
Greg Hurrell [Tue, 13 Oct 2020 19:23:58 +0000 (21:23 +0200)] 
refactor: drop "silent" from capture_highlight call

This was needed historically, but I thought it might be causing
inconsistent behavior nowadays.

I was seeing errors in Corpus if I activated it too soon after opening
Vim (no errors if I waited though).

    Error detected while processing function <SNR>106_CheckColorScheme:
    E5108: Error executing lua ...g/nvim/pack/bundle/opt/pinnacle/lua/wincent/pinnacle.lua:25: attempt to index local 'original' (a nil value)
    E416: missing equal sign: 0
    E416: missing equal sign: null

(Many of these, but those show the basic patterns.)

Adding some debug info, I could see that the `:hi` command we were
trying to use was returning empty strings for some of the groups:

    {
      "StatusLine:  StatusLine     xxx ctermfg=12 ctermbg=11 guifg=#b8b8b8 guibg=#383838",
      "MatchParen:  MatchParen     xxx ctermbg=8 guibg=#585858",
      "StatusLine:  StatusLine     xxx ctermfg=12 ctermbg=11 guifg=#b8b8b8 guibg=#383838",
      "Comment:     Comment        xxx ctermfg=8 guifg=#585858",
      "DiffText:    DiffText       xxx cterm=bold ctermfg=4 ctermbg=10 gui=bold guifg=#7cafc2 guibg=#282828",
      "ModeMsg:     ModeMsg        xxx cterm=bold ctermfg=2 gui=bold guifg=#a1b56c",
      "StatusLine:  StatusLine     xxx ctermfg=12 ctermbg=11 guifg=#b8b8b8 guibg=#383838",
      "MatchParen:  MatchParen     xxx ctermbg=8 guibg=#585858",
      "StatusLine:  StatusLine     xxx ctermfg=12 ctermbg=11 guifg=#b8b8b8 guibg=#383838",
      "Comment:",
      "DiffText:",
      "ModeMsg:",
      "StatusLine:",
      "PmenuSel:",
      "Underlined:",
      "ModeMsg:"
    }

So, this explains the errors. Our `capture_highlight` call is
occasionally getting an empty string back. Subsequent attempts to match
a pattern in the string fail, leading to a `nil` return on the Lua side
and a `null` coercion on the Vim side. I have no idea why the first few
calls all work fine and subsequent calls, even for groups like `ModeMsg`
that previously worked, do not.

In this commit I drop the `silent` in an effort to make the errors go
away. It doesn't work (we're still getting empty strings), but it does
show that we don't need the silent any more, so let's just go with it
and keep exploring.

23 months agorefactor!: remove sub_newlines and capture_line from Lua API
Greg Hurrell [Mon, 12 Oct 2020 14:19:57 +0000 (16:19 +0200)] 
refactor!: remove sub_newlines and capture_line from Lua API

Because these are ancient methods that were only added to support
ancient versions of Vim (ie. before `execute()` existed). For context,
see:

- https://github.com/wincent/wincent/commit/3b0b2950cdcb09d23c87f0167c207d8c837cb1b2
- https://github.com/wincent/wincent/commit/386edd17854e609fe9dd9736524798e7057eefe7

Back in the old days, we used to capture the output of `:highlight`
with `:redir`, and it was sensitive to terminal width, which meant that
lines could wrap and wreak havoc. In newer Vim we just use `execute()`
which is width-agnostic, and in Neovim we can be even more direct
and call `nvim_exec()`. ie. instead of going Lua to Vimscript (eg.
`vim.fn.execute`) to turn a string into a command to run, we can go from
Lua directly to running the command.

23 months agodocs: fix typo in function name
Greg Hurrell [Mon, 12 Oct 2020 14:09:00 +0000 (16:09 +0200)] 
docs: fix typo in function name

23 months agodocs: note the addition of the alternative Lua-based API
Greg Hurrell [Mon, 12 Oct 2020 13:43:33 +0000 (15:43 +0200)] 
docs: note the addition of the alternative Lua-based API

23 months agofeat: add Lua implementation
Greg Hurrell [Mon, 12 Oct 2020 13:37:42 +0000 (15:37 +0200)] 
feat: add Lua implementation

For use inside Neovim. You can replace calls to the autoloaded Vimscript
function with calls to the Lua implementation; they should be
equivalent.

eg. these two are equivalent:

    :call pinnacle#italicize('Comment')
    :lua require'wincent.pinnacle'.italicize('Comment')

2 years agofix: don't use trim() without checking first to see if it exists
Greg Hurrell [Fri, 8 May 2020 19:37:19 +0000 (21:37 +0200)] 
fix: don't use trim() without checking first to see if it exists

The stock Vim that comes with macOS High Sierra doesn't have `trim()`.

2 years agofeat: teach pinnacle#decorate() to accept a comma-separated list
Greg Hurrell [Wed, 6 May 2020 18:10:50 +0000 (20:10 +0200)] 
feat: teach pinnacle#decorate() to accept a comma-separated list

Incidentally, first time I've tried running docvim on this machine, and
I couldn't get any of the old build or install methods working, due to
bit rot:

    git clone ...
    cd docvim
    brew install stack # didn't have stack on this machine
    stack build # build fails
    stack install docvim # install fails
    cabal install docvim # install fails
    cabal v2-build # victory!

After that I could do the actual doc-gen with:

    ./dist-newstyle/build/x86_64-osx/ghc-8.4.4/docvim-0.3.2.1/x/docvim/build/docvim/docvim \
      -c ~/code/pinnacle \
      -v \
      ~/code/pinnacle/doc/pinnacle.txt \
      ~/code/pinnacle/README.md

3 years agoPrepare for 1.0 release 1.0
Greg Hurrell [Wed, 6 Mar 2019 11:00:02 +0000 (12:00 +0100)] 
Prepare for 1.0 release

3 years agoAvoid potential issues with nested :redir calls by preferring execute()
Greg Hurrell [Mon, 18 Feb 2019 23:02:42 +0000 (00:02 +0100)] 
Avoid potential issues with nested :redir calls by preferring execute()

3 years agoRemove awkward cast
Greg Hurrell [Tue, 4 Dec 2018 18:10:51 +0000 (19:10 +0100)] 
Remove awkward cast

3 years agoRebuild help docs with docvim tweaked to make functions into subheadings
Greg Hurrell [Tue, 4 Dec 2018 13:54:29 +0000 (14:54 +0100)] 
Rebuild help docs with docvim tweaked to make functions into subheadings

They weren't standing out at all, so this should help.

3 years agoIgnore local tags file
Greg Hurrell [Tue, 4 Dec 2018 13:38:51 +0000 (14:38 +0100)] 
Ignore local tags file

3 years agoAdd missing function documentation
Greg Hurrell [Tue, 4 Dec 2018 13:36:19 +0000 (14:36 +0100)] 
Add missing function documentation

Pretty thin as far as documentation goes, but better than nothing.

3 years agoAdd pinnacle#dump(), counterpart to pinnacle#highlight()
Greg Hurrell [Tue, 4 Dec 2018 13:17:27 +0000 (14:17 +0100)] 
Add pinnacle#dump(), counterpart to pinnacle#highlight()

Oh what fun it is to program in Vimscript. That `filter` call needs to
use string comparison because "any string" == 0 despite the fact that
strings are truthy... The `filter` expression must return 0 or not-0.

Given that pinnacle#dump() will return a prefix key if applicable (term,
cterm or guiterm), make sure pinnacle#highlight() can consume
dictionaries with those keys.

3 years agoRemove unnecessary s:prefix from
Greg Hurrell [Tue, 4 Dec 2018 13:13:59 +0000 (14:13 +0100)] 
Remove unnecessary s:prefix from

From the `synIDattr` help:

    {mode} can be "gui", "cterm" or "term", to get the attributes
    for that mode. When {mode} is omitted, or an invalid value is
    used, the attributes for the currently active highlighting are
    used (GUI, cterm or term).

So, we don't need the explicit s:prefix here; behavior should be
unchanged.

4 years agoMerge branch 'pull/3'
Greg Hurrell [Wed, 5 Sep 2018 21:09:22 +0000 (23:09 +0200)] 
Merge branch 'pull/3'

Closes: https://github.com/wincent/pinnacle/pull/3
* pull/3:
  doc: Update AUTHORS section
  Add check that termguicolors is also set

4 years agodoc: Update AUTHORS section
Greg Hurrell [Wed, 5 Sep 2018 21:07:41 +0000 (23:07 +0200)] 
doc: Update AUTHORS section

Note that there are some minor changes in the generated output due to
updates to docvim since the last time I generated the documentation.

4 years agoAdd check that termguicolors is also set
codybuell [Tue, 4 Sep 2018 18:23:47 +0000 (14:23 -0400)] 
Add check that termguicolors is also set

When setting the prefix var also make sure that termguicolors is
enabled.

5 years agoPrep for 0.3.1 release 0.3.1
Greg Hurrell [Thu, 8 Jun 2017 01:45:42 +0000 (18:45 -0700)] 
Prep for 0.3.1 release

5 years agoUse `empty` instead of `==`
Greg Hurrell [Thu, 8 Jun 2017 01:44:24 +0000 (18:44 -0700)] 
Use `empty` instead of `==`

Arguably more transparent, and avoids questions about list equality in
VimL compared with other languages (eg. JavaScript, which isn't
referentially transparent, so `[] != []`).

5 years agoFix regex capture groups
Greg Hurrell [Wed, 7 Jun 2017 21:26:52 +0000 (14:26 -0700)] 
Fix regex capture groups

This is hard to read, but given something like:

  (a)*(b)(c)*

And input like:

  aaaaaabccccc

Vim is going to capture only the last "a" matched by "(a)*".

To make it capture the whole thing we need to turn:

  (a)*

into:

  (%(a)*)

ie. make the inner "(a)" non-capturing.

With Vim's unfortunate escaping, these examples get a bit uglier:

   \(\%(a\)*\)

instead of:

  (%(a)*)

and so on...

This fixes the issue we had where a group like `Underlined`:

  term=underline cterm=underline ctermfg=1 gui=underline guifg=#cc6666

was being emboldened incorrectly as:

  cterm=bold ctermfg=1 gui=bold,underline guifg=#cc6666

Because the following sequence would occur:

1. Search for "gui=...", identifying "ctermfg=..." as the prefix and
   "guifg=..." as the suffix.
2. Throw away "cterm=bold" while reconstructing the new highlight,
   because it was not correctly captured.
3. etc... all bets are off here because we've already thrown away data.

5 years agodoc: Fix a date in the history section
Greg Hurrell [Wed, 7 Jun 2017 03:47:41 +0000 (20:47 -0700)] 
doc: Fix a date in the history section

5 years agoPrepare for 0.3 release 0.3
Greg Hurrell [Wed, 7 Jun 2017 03:43:38 +0000 (20:43 -0700)] 
Prepare for 0.3 release

5 years agoFix regex for decorating existing patterns
Greg Hurrell [Wed, 7 Jun 2017 02:29:10 +0000 (19:29 -0700)] 
Fix regex for decorating existing patterns

Was only working with one prefix and one suffix:

  a=b c=d e=f

(finding c=d).

Would fail given:

  a=b c=d e=f g=h

Which means that it would end up creating a dupe rule for "c=d",
potentially, which Vim would then collapse.

5 years agoPrefer underline over undercurl
Greg Hurrell [Wed, 7 Jun 2017 02:28:02 +0000 (19:28 -0700)] 
Prefer underline over undercurl

Should be equivalent, but the former is more likely to be supported than
the latter according to some docs that I read that I can no longer find.

5 years agoAdd utility functions for constructing highlights piecemeal
Greg Hurrell [Fri, 21 Apr 2017 01:49:53 +0000 (18:49 -0700)] 
Add utility functions for constructing highlights piecemeal

Example usage:

```
execute 'highlight User1 ' .
      \ pinnacle#highlight({
      \   'bg': pinnacle#extract_bg('Error'),
      \   'fg': pinnacle#extract_fg('Normal'),
      \   'term': 'bold'
      \ })
```

5 years agodoc: remove two copy-pasta'd references to docvim
Greg Hurrell [Mon, 9 Jan 2017 02:41:44 +0000 (13:11 +1030)] 
doc: remove two copy-pasta'd references to docvim

5 years agoPrepare for 0.2 release 0.2
Greg Hurrell [Mon, 9 Jan 2017 02:34:47 +0000 (13:04 +1030)] 
Prepare for 0.2 release

5 years agoMerge branch 'pull/2'
Greg Hurrell [Fri, 6 Jan 2017 13:52:50 +0000 (00:22 +1030)] 
Merge branch 'pull/2'

Closes: https://github.com/wincent/pinnacle/pull/2
* pull/2:
  doc: Update AUTHORS section
  add pinnacle#underline()

5 years agodoc: Update AUTHORS section
Greg Hurrell [Fri, 6 Jan 2017 13:52:35 +0000 (00:22 +1030)] 
doc: Update AUTHORS section

5 years agoadd pinnacle#underline()
kylpo [Fri, 30 Dec 2016 06:25:12 +0000 (22:25 -0800)] 
add pinnacle#underline()

5 years agoAdd empty .watchmanconfig
Greg Hurrell [Wed, 12 Oct 2016 01:06:36 +0000 (18:06 -0700)] 
Add empty .watchmanconfig

Allows a Watchman instance configured with `enforce_root_files` to watch
this directory even if `root_files` does not contain any of the files in
the directory. (Necessary to get around undesired corporate
`/etc/watchman.json` config.)

6 years agoAdd docvim-generated documentation
Greg Hurrell [Sun, 12 Jun 2016 22:11:09 +0000 (15:11 -0700)] 
Add docvim-generated documentation

6 years agoFix the other URL
Greg Hurrell [Sun, 12 Jun 2016 22:09:57 +0000 (15:09 -0700)] 
Fix the other URL

6 years agoProvide correct URL to vim.org scripts page
Greg Hurrell [Sun, 12 Jun 2016 22:08:36 +0000 (15:08 -0700)] 
Provide correct URL to vim.org scripts page

6 years agoDon't let verbose info mess with operation
Greg Hurrell [Wed, 4 May 2016 01:44:39 +0000 (18:44 -0700)] 
Don't let verbose info mess with operation

`'verbose'` > 0 will lead us to capture output like:

  Comment xxx term=bold,italic cterm=italic ctermfg=8 gui=italic guifg=#65737e
  Last set from ~/code/wincent/roles/dotfiles/files/.vim/after/plugin/color.vim

which will lead to `E416: missing equal sign` errors when we try to use the
captured output.

So, force `'verbose'` to 0 for the duration of the capture.

6 years agoIgnore release archives
Greg Hurrell [Wed, 30 Mar 2016 15:20:26 +0000 (08:20 -0700)] 
Ignore release archives

6 years agodoc: Fix straggling references 0.1
Greg Hurrell [Wed, 30 Mar 2016 14:59:38 +0000 (07:59 -0700)] 
doc: Fix straggling references

To Docvim, and the script number placeholder.

6 years agoMake best guess at final script number
Greg Hurrell [Wed, 30 Mar 2016 14:59:38 +0000 (07:59 -0700)] 
Make best guess at final script number

6 years agoInitial import
Greg Hurrell [Wed, 30 Mar 2016 14:59:38 +0000 (07:59 -0700)] 
Initial import

From my dotfiles repo (https://github.com/wincent/wincent), commit
cad99e82bf78497ac4c2b9aee1bc8.