notmuch-vim icon indicating copy to clipboard operation
notmuch-vim copied to clipboard

cursorline set when composing

Open dwarfmaster opened this issue 9 years ago • 4 comments

I have cursorline enabled all the time when I edit text files, but since the syntax file override the definition of CursorLine, I end up with a line reversed, making it hard to see the cursor. I haven't found any satisfying way to solve this, but it should be mentionned in the documentation (I made a quick patch [1]).

[1] https://gist.github.com/lucas8/0b9ad409857e103f4985

dwarfmaster avatar Jul 05 '15 14:07 dwarfmaster

@lucas8 thx for bringing this up. I also have issues with this, but not so much in Compose but Show. The high contrast of current/next line makes it hard for me to follow the text. I usually place the cursor on a line outside of the current paragraph I read.

I actually don't know if this is an issue in notmuch-vim or one in vim. The CursorLine gets set in syntax/notmuch-folder.vim. That setting seems to make its way all through the buffers till Compose. Is that expected?

On "fixing things up": It would be better to do that in ~/.vim/after/syntax/notmuch-*.vim. There you can change any colour to whatever you like ;) Nevertheless I think this is somewhat disturbing and would be good if it's killed ;) reversed CursorLine should stay in notmuch-folders and notmuch-search but go away in show and compose. Is that OK?

ff2000 avatar Jul 11 '15 08:07 ff2000

Do you think that patch is OK? Then I will commit this change.

diff --git a/syntax/notmuch-compose.vim b/syntax/notmuch-compose.vim
index 19adb75..9635cdd 100644
--- a/syntax/notmuch-compose.vim
+++ b/syntax/notmuch-compose.vim
@@ -5,3 +5,5 @@ syntax match  nmComposeHelpLine      /Notmuch-Help:/ contained

 highlight link nmComposeHelp        Include
 highlight link nmComposeHelpLine    Error
+
+highlight CursorLine term=NONE cterm=NONE gui=NONE
diff --git a/syntax/notmuch-show.vim b/syntax/notmuch-show.vim
index c3a98b7..7b383c2 100644
--- a/syntax/notmuch-show.vim
+++ b/syntax/notmuch-show.vim
@@ -22,3 +22,5 @@ highlight link nmShowMsgHeadKey  Macro
 "highlight link nmShowMsgHeadVal  NONE

 highlight Folded term=reverse ctermfg=LightGrey ctermbg=Black guifg=LightGray guibg=Bl
+
+highlight CursorLine term=NONE cterm=NONE gui=NONE

This will just revert the CursorLine highlighting (if I understand vim docs correctly).

ff2000 avatar Jul 11 '15 08:07 ff2000

Eek - doesn't work as expected. This setting then gets propagated back when I close show/compose buffers, so no reversed CursorLine anymore in folders/search buffers. Is that caused by the way notmuch-vim creates buffers?

ff2000 avatar Jul 11 '15 08:07 ff2000

Another problem with your solution is that it disable cursorline highlighting, instead of resetting it to its previous value. A solution could be to store the highlight setting for CurrsorLine at launch time and set it when entering show or compose mode, but I'm not sure it is feasible. Furthermore it won't solve the fact it is propagating through buffers.

EDIT: Two remarks

  • CursorLine is not set in notmuch-search, so the fact it is propagating through buffers is actually used.
  • In folders view, calling :set syntax=notmuch-folders manually resets the CursorLine to its right value, so we could call it from the plugin when changing buffers.

dwarfmaster avatar Jul 11 '15 09:07 dwarfmaster