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:
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.
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.
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!
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.
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.
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 `[] != []`).
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.
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.)
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.