ericpruitt / tmux.vim Goto Github PK
View Code? Open in Web Editor NEWVim syntax file for tmux configuration files
Vim syntax file for tmux configuration files
It currently still has 2.3 (git-14dc2ac).
Thanks for the handy plugin.
There is a small issue though: by default, if it's installed via plugin manager, it won't be loaded, because the directory structure is like:
tmux.vim
│
...
└── vim
├── ftdetect
│ └── tmux.vim
├── ftplugin
│ └── tmux.vim
└── syntax
└── tmux.vim
A workaround if you use vim-plug
is:
Plug 'ericpruitt/tmux.vim', { 'do': 'ln -sf vim/* .' }
Maybe the default directory structure can be changed?
The ftplugin/tmux.vim does not set a value to the option 'comments'.
This means that the user's value is used which can be anything, thus breaking functionality relying on 'comments', e.g. reformatting.
Other ftplugins set this option to a value suitable for their language. For tmux.conf
I would recommend something like
setlocal comments=:#
While we are at it. It's a good habit to provide an "undo" functionality, e.g.
let b:undo_ftplugin = "setlocal comments< commentstring<"
setlocal comments=:#
setlocal commentstring=#\ %s
The following snippet is not highlighted correctly:
set-option -g status-right "\
#[fg=black,bg=brightwhite,bold] #H \
"
in particular:
The reason for this is probably that line continuation is not supported. From tmux(1)
If the last character of a line is \, the line is joined with the follow‐
ing line (the \ and the newline are completely removed). This is called
line continuation and applies both inside and outside quoted strings and
in comments, but not inside braces.
No clue how to implement that but the c syntax highlighting supports this (It has also a cBadContinuation highlighting in case you accidentially add a space after the backslash).
As I am using the oh-my-tmux configuration from gpakosz/.tmux, my main configuration file is actually .tmux.conf.local
. Standard vim configuration (without vim-polyglot) still uses the general conf highlighting here, but with this plugin it does not apply any kind of syntax highlighting at all.
I added this line
autocmd BufNewFile,BufRead {.,}tmux.conf.* setfiletype tmux
to my init.vim
and it works for now. I suggest adding it to ftdetect.vim
to support all kinds of modded configurations, if the wildcard does not cause any problems.
tmux 3.0 introduces {}-strings. From tmux(1):
Command arguments may be specified as strings surrounded by single (')
quotes, double quotes (") or braces ({}). This is required when the ar‐
gument contains any special character. Single and double quoted strings
cannot span multiple lines except with line continuation. Braces can
span multiple lines.
It would be nice to support these in some way, e.g. highlight as string. Or introduce a new highlighting group/colour-flavour for these kinds of strings.
changes can be found in here
Normally, when moving the cursor onto the [
]
, (
)
or {
}
characters in vim then the matching bracket/parenthesis/curly brace is also highlighted in a way so we can tell the difference which one is selected and which one is the matching pair based on the different syntax highlighting.
For the [
]
brackets the tmux syntax highlighting is working as expected: the selected and matching brackets has different fg/bg colours:
But for the (
)
or {
}
characters the tmux syntax highlighting use the same bg and no fg
for both the selected and the matching parenthesis/brace, so it is hard to tell which pair is actually selected and what type of bracket it is:
I don't have experience with writing vim syntax highlighters, so I'm not exactly sure what the issue with these lines in the syntax/tmux.vim file, but commenting them out restores the normal selected/matching bracket behavior:
syn region tmuxFormatString start=/#[#DFhHIPSTW]/ end=// contained keepend
syn region tmuxFormatString start=/#{/ skip=/#{.\{-}}/ end=/}/ contained keepend
syn region tmuxFormatString start=/#(/ skip=/#(.\{-})/ end=/)/ contained keepend
But of course then we lose the nice syntax highlighting for the variables:
There's another tmux config syntax and feature plugin at https://github.com/tmux-plugins/vim-tmux
Worth combining efforts?
Currently spellchecking is done everywhere. It might be a good idea to restrict spell checking to actual user content instead to keywords.
Vim seems to support two modes approaches
@spell: do not spellcheck anything unless the corresponding syntax item is marked with @spell
@Nospell: do spellcheck everything but the items marked with @Nospell
For the former approach it seems to be sufficent to add @Spell
to the contains
field of tmuxComment
and tmuxString
(or their substitutes from #14) like so
syn region tmuxComment start=/#/ skip=/\\\@<!\\$/ end=/$/ contains=tmuxTodo,@Spell
syn region tmuxString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=tmuxFormatString,@Spell
syn region tmuxString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end='$' contains=tmuxFormatString,@Spell
As of tmux.git:126d364abe2e8c063efa5a888de69
, the command server-info
(and its alias info
) is now a command-alias for show-messages -JT
. Similarly, split-pane
, splitp
, choose-window
, and choose-session
are all defined as such:
$ tmux show-options -s command-alias
command-alias[0] split-pane=split-window
command-alias[1] splitp=split-window
command-alias[2] "server-info=show-messages -JT"
command-alias[3] "info=show-messages -JT"
command-alias[4] "choose-window=choose-tree -w"
command-alias[5] "choose-session=choose-tree -s"
It looks as if these entries are defined in options-table.c
.
Patch: keith/tmux.vim@7945de9
(not verified)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.