Can menus in Vim be made "dynamic"? - vim

i.e. to show a value (let's say, for the purpose of this example, set tabstop? ... 8), but when that value changes to show the changed value?
I'm playing with Vim to see if I could setup a menu which would display some of my more used settings to save up on set setting? ... any ideas?

I also find it a little bit unusual to put settings values into the menu (a menu item usually is associated with an action that is triggered by selecting it), and would also recommend using either the 'statusline' (for settings that you want to see in parallel for each open buffer) or 'titlestring' (for settings that you only need for the current buffer).
You can use the :menu and :unmenu command to dynamically create and update menu items. Unlike the above mentioned mechanisms, however, Vim will not automatically trigger the updates; you have to do this with :autocmds on the appropriate events (e.g. CursorHold) yourself.

Related

Sublime Text plugin development: modifying the Quick Panel to add a custom text title or label?

I'm developing a Sublime Text 3 plugin which uses the quick panel a.k.a. the command palette.
I would like to add a textual title/label at the top of the quick panel when the user opens my plugin's quick panel menu, because my plugin runs in various modes and I want to make it clear which mode is currently running (Test, Pre-Live, Live, etc.)
Is this possible, and how?
This a mockup of what I want to achieve:
This is not possible in a quick panel, no. The only thing you can provide to the quick panel display-wise is the list of items that you want the user to choose from. Each item in the list can contain multiple lines of data however (with the restriction that every row has to contain the same number of lines):
Something like that could potentially be used to provide context on the items in the list that allows the user to know what mode you're in.
The Command Palette and the quick panel aren't the same thing (although they are visually similar); the command palette only displays commands that you can choose. By using an input handler, you can customize the display somewhat:
In this sample, View Package File is the selected command, but the command has control over what that text says (it's just the command name by default). You also have the power to provide a "preview" (basically any extra information that you want) about the currently selected item:
So given that, depending on your use case your command could present its interface in the command palette to give this kind of contextual clue.

vim: where is the autocompletion preview window for ctags generated tags?

The documentation for the "completeopt" options says:
...
A comma separated list of options for Insert mode completion
|ins-completion|. The supported values are:
...
preview Show extra information about the currently selected
completion in the preview window. Only works in
combination with "menu" or "menuone".
For me this sounds that if "menu" and "preview" is set, you always get a preview window for the current autocompleted item, so for a ctags tag I expected to see a preview of the file, where the item is defined (the same as I would press CTRL-W-} on a tag under the cursor).
But it seems this preview window is only available for omni-completion, if the set omnifunc supports it. How could I also get a preview window for autocompleted tags?
The built-in completions don't have much additional stuff to show, so this feature is only available for custom completions (as you'd correctly assumed), namely via the info attribute in the returned completion items, see :help complete-items.
If you really would like additional information about tags (but there isn't much, see :help tags-file-format), you'd have to write a custom completion (sourced from taglist()) and populate the mentioned info attribute.
This is far from perfect but you can set showfulltag to get more information for each suggestion.
Without set showfulltag:
With set showfulltag:
As you can see, the completion menu becomes a little crowded and you must skip entries but well…
Using the preview window would be so much nicer.
See :help 'showfulltag'.

Bash and dialog UI, how to change color dynamically

I have a simple bash script, which I use to maintain some log etc files on a server, and most of the time the tools works in "normal mode". For UI I use the dialog tool.
However, sometimes I have some condition that requires more careful attention, and I would like at those times to change the background color of dialog, to draw more attention to the issue.
I know that by changing the screen_color attribute in .dialogrc, I can define custom colors for the dialogs, but that affects all windows, and is not what I want.
Is there some way to dynamically set this variable so that only specific dialogs would have different colors, and everything else unaffected?
For a given dialog process, you can select a specific configuration file using the environment variable DIALOGRC (see manual).

Vim omnicompletion: optional preview window

I've searched for different types of workarounds to deal with the preview window splitting the current window to display documentation when doing a selection in Omnicompletion, like closing the preview window if it exists when you leave insert mode.
However, those solutions are impractical. Sometimes you may want to go into the preview window to read some documentation about the current completing module, but with the autocommand in place this would not be possible.
Even if it would, I am looking to have the documentation never show up because I really don't want it.
Reading the source code in pythoncomplete.vim I see that the value for the documentation is hard coded and it will force the preview window to show up if this has any contents (it skips this if it can't come up with docs for the module).
Is there a global option that I am not aware to tell Vim to never display docs? Or be able to toggle it?
If I do want to read the docs in a split window allow me to do so (maybe with some shortcut) otherwise don't show me anything.
I really want to avoid having to copy/paste pythoncomplete.vim to tweak this particular setting to my liking.
The preview is controlled by the global 'completeopt' setting. To turn that off, use
:set completeopt-=preview

Notepad++ tab color

Is there a way to change the color of a tab (in the tab bar) according to the path of the file?
I tried with the PythonScript plugin, but couldn't find a method to change the color of a tab.
I need this because I edit scripts from two environments at the same time, from a LIVE environment, and from a development environment, and I need to be extra careful when editing a LIVE file.
I was looking for a programmatic way to change the color of the tabs, and reviewed the online documentation of Notepad++ but did not find anything about it. So, instead, I propose the following method for your case, it could be helpful to always know which of your files are from the development environment and which from the live environment:
Open a blank instance of Notepad++:
Now start a macro recording: Press Start Recording button on Notepad++ toolbar:
Open a new document
Now you'll have two open blank tabs.
Right click newly open tab and click in option Move to other view from contextual menu
You'll have a window splitted vertically and your two tabs will be displayed next to each other. You'll use these two tabs as separated "containers" for your files
Press Stop Recording button:
Save your just recorded macro:
assign a keyboard shortcut:
Now you can run that recorded macro (from Macro menu, or invoking keyboard shortcut you assigned), every time you want to work on your two environments.
(Optional) Right click vertical separator between "containers" and click Rotate to right
Now your "containers" will be split horizontally and will be displayed one above the other. Personally, I'd recommend you this layout.
Click on the tab at first "container" and from there, open all your "dev" environment files; and analogously open all your "live" environment files from second "container". Note that currently selected container has a more intensely coloured active tab.
If you notice that your working space is small, drag the separator to increase your current "container" size, but I recommend you not to take it completely towards the end, because it will make difficult to differentiate which of the two "containers" you are working on.
Note: If you, mistakenly opened a file of an environment from the wrong "container" you'll always be able to fix that by dragging the tab and dropping it to the other "container":
So you'll always keep control of what files must be on each container.
That's it. I hope this info will be helpful for you.
About changing the color of the tab (not folder specific).
Notepad++ has a file called stylers.xml, located in the roaming folder or in the program folder. It also depends in the installation & windows version. If it does not exists then it is self generated.
At the very end of the file, it says
<WidgetStyle name="Inactive tabs" styleID="0" fgColor="xxxxx" bgColor="xxxxxx" />
And here it is possible to change the color of the inactive tab.
However, it does not work, it is a bug that has been "fixed" countless of times in the past. To the date, the current version 6.2.3 UNICODE, changing the values does nothing.
So far, editing the stylers.xml:
6.2.3 = does nothing
design guideline, gray + gray = not good.
6.2.0 = does nothing
6.1.8 = works.
Nice contrast
6.1 = works.
5.9.8 = works.
5.7 = edit works.
ps: sadly,it is not possible to change the fonts of the tabs.
Wanted to add this as a comment, the button's not there.
You can solve your actual problem by using multiple instances of notepad++, refer this. You can save different sessions and optionally use the "Open File In Solution (OFIS)" plug-in.
I've if you've picked a different Style like 'Black Board', then you will have to change these setting in it's .XML in '/themes', and these setting are found at the bottom of the file.

Resources