-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cosmetic/usability bug with marking paths. #123
Conversation
This commit addresses justinmk#76 and more specifically, this comment: justinmk#76 (comment). It likely needs some cleanup, but it basically works. A few notes: - Syntax rules for DirvishFullPath and DirvishArg must follow the other rules, otherwise they may be overriden (see :h syn-priority). - I am not sure whether \v has any effect in syntax rule, as the manual says that syntax patterns are always magic (:h syn-pattern). - map() has been replaced by a for loop: this way the code is cleaner (IMO) and the resulting syntax rules shorter. - I am not sure what the place for the condition testing for b:current_syntax is. That might need to be changed.
There likely should be a |
syntax/dirvish.vim
Outdated
exe 'syntax match DirvishPathTail =\v[^\'.s:sep.']+\'.s:sep.'$=' | ||
exe 'syntax match DirvishSuffix =[^\'.s:sep.']*\%('.join(map(split(&suffixes, ','), s:escape), '\|') . '\)$=' | ||
|
||
for p in argv() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will set g:p
, better use s:p
.
syntax/dirvish.vim
Outdated
@@ -5,16 +5,18 @@ endif | |||
let s:sep = exists('+shellslash') && !&shellslash ? '\' : '/' | |||
let s:escape = 'substitute(escape(v:val, ".$~"), "*", ".*", "g")' | |||
|
|||
" Define (again). Other windows may need the old definitions ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment is still relevant, so that I don't repeat the mistake :)
@lifepillar Thank you! This was very bothersome. I think I can finally tag 1.0 after this. It seems to work. LMK if you're at a stopping point. |
Yeah that's left over from before I knew better. I think
Good call, should put that comment in the code.
Yes that was to avoid duplicate rules. |
I've left |
Can't do that (AFAIK) because other windows (showing the same Dirvish buffer) may have their own local arglists which used the existing buffer-local However, it's not a big problem, a
It's to avoid redundant definitions for " Define once (per buffer).
if !exists('b:current_syntax')
exe 'syntax match DirvishPathHead =\v.*\'.s:sep.'\ze[^\'.s:sep.']+\'.s:sep.'?$= conceal'
exe 'syntax match DirvishPathTail =\v[^\'.s:sep.']+\'.s:sep.'$='
exe 'syntax match DirvishSuffix =[^\'.s:sep.']*\%('.join(map(split(&suffixes, ','), s:escape), '\|') . '\)$='
endif |
@justinmk i have one question kinda related to this. Would you agree on support for custom columns/flags/whatever you want to call it, per single path, something like this https://github.com/Xuyuanp/nerdtree-git-plugin? as @lifepillar noted, it's really hard to work with these paths and concealing. In my git plugin for divish i somehow managed to conceal these paths, but it's really messy. It would simplify managing these things, but i assume it would complicate handling paths for other things. |
@kristijanhusak Left-side column would be possible after #70 is addressed, because that will entail adding some whitespace for indentation. Though I don't plan to work on it anytime soon. Right-side "column" can be achieved with "virtual text" which is supported by Nvim 0.3.2 (prerelease), and I assume Vim will eventually have a similar feature. Anything else will be a mess. If there's some way to get left-side column support before #70 , without a ton of code, I'd be in favor. |
For voodoo reasons it may not be best practice. ref #123
Match DirvishArg to full path and mark it with "contains=DirvishPathHead". ref #123
Merged, thanks @lifepillar . I was also able to simplify it in 9c67fa7. |
This commit addresses #76
and more specifically, this comment: #76 (comment).
It likely needs some cleanup, but it basically works.
A few notes:
rules, otherwise they may be overriden (see :h syn-priority).
says that syntax patterns are always magic (:h syn-pattern).
(IMO) and the resulting syntax rules shorter.
b:current_syntax is. That might need to be changed.