Git Product home page Git Product logo

vim-quickui's Introduction

What Is It ?

There are many keymaps defined in my .vimrc. Getting tired from checking .vimrc time to time when I forget some, based on the latest +popup feature (vim 8.2), I created this vim-quickui plugin to introduce some basic UI components to enrich vim's interactive experience:

  • Well designed and carefully colored Borland/Turbo C++ flavor ui system combined with vim's productivity.
  • Can be accessed by keyboard only while mouse is also supported.
  • Navigate with the usual Vim keys like h/j/k/l, confirm with ENTER/SPACE and cancel with ESC/Ctrl+[.
  • Tip for each entry can display in the cmdline when you are moving the cursor around.
  • Available widgets: menu, listbox, inputbox, textbox.. (coming soon)
  • Fully customizable, including color scheme and borders.
  • Corresponding experience in both Vim and NeoVim.
  • Pure vim-script, +python is not required.
  • No longer have to be afraid to forget keymaps anymore.

Just see this GIF demonstration below:

Trying to share my configuration to my friends, I found that they did't have patience to remember all the keymaps in my vimrc, but text ui is quite acceptable for them.

Content

Relative Projects

Plugins powered by QuickUI:

Requirements

  • Vim: 8.2 or later.
  • NeoVim: 0.4.0 or later.

Installation

Plug 'skywind3000/vim-quickui'

For more information, please see the User Manual.

Gallery Screenshot

Menu

Display a dropdown menubar at top of the screen, use hjkl or mouse to navigate:

Customizable border style:

Menu color schemes:

See: Menu help.

Listbox

When you have hundres of items to deal with, menu is not enough to hold them. Then you will need a listbox.

It has scroll bar, content can be scrolled by keyboard or mouse wheel. You can search items with / or ? command.

It can be used to select buffers or functions in current file:

The cursor will stay in the current function initially. Navigate and press enter to jump to the selected function.

See: Listbox help.

Inputbox

Prompt user to input a string in a TUI box:

Could be used as a drop-in replacement of input() function.

See: Input box help.

Context menu

Context menu imitates Windows context menu (triggered by your mouse right button), which will display around the cursor:

It is usually used to present some commands that will do something with source code in the current line.

The border can be changed too:

Because some terminals or fonts cannot display unicode borders correctly, so QuickUI choose ascii border characters by default. But you can change it as you like.

See: Context menu help.

Textbox

Textbox is used to display arbitrary text in a popup window.

Display vim help with syntax highlighting in the textbox:

With textbox, you can read the help text at anytime in a popup, without creating a new split window.

Display vim messages:

Navigating the messages with HJKL or PageUp/PageDown is much more convenient than using :messages.

See: Text box help.

Preview window

Preview window is used to replace traditional pedit command and can be used to display certain file in a small popup window around your cursor:

Sometimes I just want a glimpse to the definition of the current word under cursor without actually open that file, the preview window is much helpful for this.

Use it to preview quickfix result:

If you have many items in the quickfix window, instead of open them one by one, you are able to press p in the quickfix window and preview them in the popup.

See: Preview window help.

Terminal

The terminal widget can allow you open a terminal in the popup window:

This feature require vim 8.2.200 (nvim 0.4.0) or later, it enables you to run various tui programs in a dialog window.

See: Terminal help.

Confirm dialog

This widget offers user a dialog, from which a choice can be made:

It returns the number of the choice. For the first choice, this is 1.

See: Confirm dialog help.

User Manual

To get started, please visit:

For more examples, see my config.

Who Am I ?

My name is Lin Wei, and I am a strong advocate of open source and a passionate vim user. I embarked on my programming journey in the early 1990s. During that time, Borland’s Turbo Pascal/C++ served as the prevailing IDE, and I fondly reminisce about those days. After returning home from school, I would eagerly power on my computer, launch Turbo C++ 3.1, and delve into the world of creating games in MS-DOS.

I even imitated Turbo C++ and made my own editor when I moved to Watcom C++:

Because I didn't own a proper editor/IDE for Watcom C++ at that time.

During my transition to Windows, I encountered a multitude of GUI editors, ranging from UltraEdit and EditPlus to Notepad++ and even gedit and geany. However, none of them managed to fulfill my requirements completely. Each day, I found myself grappling with the constant need to learn new IDEs, editors, or frameworks, which left me exhausted and disconnected from the true joy of programming. It was not until I discovered vim that everything changed. Instantly, I became enamored with its capabilities and found my passion for programming reignited.

With the continuous evolution of Vim, thanks to Bram’s unwavering efforts, the release of version 8.2 has brought forth exciting possibilities. It dawned on me that perhaps I can now incorporate some of the cool features from 25 years ago into Vim. Just like my experiences as a middle school student, learning to create PC games during the golden era of the 1990s, I can now infuse my everyday work with a nostalgic Borland/Turbo C++ flavor, courtesy of Vim.

The time has come for me to transform these ideas into reality, and it all begins with this plugin.

Credit

like vim-quickui? Follow the repository on GitHub and vote for it on vim.org. And if you're feeling especially charitable, follow skywind3000 on Twitter and GitHub.

vim-quickui's People

Contributors

freed-wu avatar jimmyhuang454 avatar lsaint avatar pangpangpangpangpang avatar qiushihao avatar roachsinai avatar skywind3000 avatar stkid avatar thomasfeher avatar vim90 avatar wookayin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-quickui's Issues

How to custom quick search?

I tried blow settings:

call quickui#menu#install('&Regex', [
			\ ['Search Colors', '/\v#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})', ''],
			\ ['Search 0~255', '/\v([1-2][0-5]{2}|[1-9][0-9]|[0-9])', '/\v([1-2][0-5]{2}|[1-9][0-9]|[0-9])'],
			\ ])

But can't use n or N to nevigate.

Poject specific .nvimrc file doesn't load

Hi. first of all, let me thank you for this amazing plugin.
I'm a c/c++ developer. Depending on each project(and each build system and other factors) i prefer to create a .vimrc(.nvimrc for neovim) and put it in the root of project.

This is the content of .nvimrc for my current project:

" clear all the menus
call quickui#menu#reset()

call quickui#menu#install('&C++', [
            \ [ 'make-&debug-mode', ":w<CR> :term cd build; cmake -DCMAKE_BUILD_TYPE=Debug ../; cd ..; ln -s build/compile_commands.json .; cd build/; make;<CR>" ],
            \ [ 'run-debu&g-mode', ":w<CR> :term debug/neodm<CR>" ],
            \ [ '&make-release-mode', ":w<CR> :term cd build; cmake -DCMAKE_BUILD_TYPE=Release ../; cd ..; ln -s build/compile_commands.json .; cd build/; make;<CR>" ],
            \ [ '&run-release-mode', ":w<CR> :term release/neodm<CR>" ],
            \ [ '&clear', ":w<CR> :term rm -rfv build/**; rm -rfv debug/**; rm -rfv release/**; rm -rfv compile_commands.json<CR>" ],
            \ ], '<auto>', 'cpp')

" enable to display tips in the cmdline
let g:quickui_show_tip = 1

" hit space twice to open menu
noremap <space><space> :call quickui#menu#open()<cr>

let g:clang_format#code_style="webkit"
let g:clang_format#auto_format=1
let g:clang_format#auto_formatexpr=1
let g:clang_format#auto_format_on_insert_leave=1

And i put these lines in my init.vim:(To enable project specifics setting.)

" Enable Project-Specific Settings
" Just add .vimrc in every project you want!
set exrc
set secure

But unfortunately it doesn't work and vim-quickui seems can't load local .nvimrc file.


Os: void-linux

Neovim: v0.4.3

Error detected when processing /home/user/.config/nvim/init.vim:

Error when using set this line in init.vim

call quickui#menu#install(section, items [, weight [, filetypes]])

when starting vim the following errors appear

Error detected when processing /home/user/.config/nvim/init.vim:
line 36:
E121: Undefined variable: section
E116: Invalid arguments for the quickui#menu#install function
Press ENTER or type a command to continue

I am not using any plugin. The quickUI folder is at home / .config / nvim / pack / plugins / vim-quickui

I'm using Ubuntu 30.04.2 LTS

I found the plugin very good, but I couldn't use it, if anyone has any tips on how to solve it. I thank.

How to switch tag preview window

When quickui#tools#preview_tag('') is called,quickui will circularly display the next one. How to make it display the previous one? Could you provide some functions switching the preview window to the next/previous tag for user?

When preview window gets closed (rather than autoclose), the popup should disappear

The preview window would usually get auto-closed, but in some cases it is not "automatically" closed when a user move their focus onto it (#9) and close manually, or when any other vim functions/commands are executed that close the preview window --- there remains only a floating window that draws the border without the content which is already closed.

Since the border window is not focusable and there is no way to close this popup border window, it would remain forever. Using a sort of autocmd (WinClose, etc. --- but not sure), we need to make sure they are cleaned up when the main preview window is lost.

quickui#tools#preview_tag bug, may be related with Alt -> meta map

I have mapped alt -> meta key according to your article, and this bug only happend when I use vim, not neovim
For example , I use <M-/> to previvew tags :nnoremap <silent> <M-/> :call quickui#tools#preview_tag('')<Cr>.
If where is only one tag , and I press <M-/> two times, the first press works good, the second invoke /.
As the same , <M-?> inoke ?, but <C-j>, <C-m>, <C-g> ....., etc have no bugs

How to execute commands that we can only use them in normal mode?

I'm using coc.nvim as Intellisense engine for neovim. I want to use vim-quickui to remap it's functionalities:
https://github.com/neoclide/coc.nvim#example-vim-configuration

But most of it's command only execute in normal mode:
https://github.com/neoclide/coc.nvim/blob/master/doc/coc.txt#L663

My question is how configure vim-quickui to execute coc.nvim commands. Imagin i have this menu:

call quickui#menu#install('C&oc', [
            \ [ "&config", 'CocConfig' ],
            \ [ "code-&action", '<Plug>(coc-codeaction)' ],
            \ [ "codeaction-&selected", '<Plug>(coc-codeaction-selected)' ],
            \ [ "co&mmand", '<Plug>(coc-command)' ],
            \ [ "dia&gnostics", '<Plug>(coc-diagnostics)' ],
 \ ])

But it won't works and gives me this error:

Error detected while processing function quickui#menu#open[8]..quickui#menu#nvim_open_menu:
line 94:
E488: Trailing characters: (coc-command)
Press ENTER or type command to continue

how to select a command without hitting <enter> ?

Just like in normal mode, input :xxx -a -b -c (something_i_want_to_input_dynamically)

When i select an item from quickui#menu#, is there a way to just show :xxx -a -b -c at the bottom and let me input something else dynamically then hit enter manually?

duplicate menu items if open multiple files with same extension

Hi. I added a file called srt.vim in here:
/home/linarcx/.config/nvim/after/ftplugin/srt.vim

contains:

set formatoptions-=cro
" tsy
call quickui#menu#install('&Srt', [
            \ [ '&tips', "vsplit tips.txt" ],
            \ [ '&search', "call SearchLine()" ],
            \ [ '&yank', "YankPiece" ],
            \ ], '<auto>', 'srt')

And when i open .srt files i can see the menu:
https://ibb.co/pr1yt1t

But the problem is that, if i open more than one menu, it start to duplicate menu-items:
https://ibb.co/6RCvYgH

How to prevent this problem?

Make the floating window scrollable or able to have cursor on it

Some plugins like git-messenger.vim that opens up a floating window allow:

(i) to move cursor to the window (e.g. CTRL-W W) --- and then one can navigate using movement keys,
(ii) to scroll the window using mouse wheels.

This would be particularly useful when one need to see more lines a bit off around the symbol definition, quickfix location, etc. The current behavior is that the floating window opened by quickui is not focusable nor scrollable.

It would be great if we can customize this behavior with an argument!

action fails in multiple lines

I set the menu for comment the line using the caw plugin.
the menu is writen as ["&Comment", 'call feedkeys("gcc")']
this works well for the single line. but when I select multiple lines during the visual mode, it cannot comment the selected lines but the first line.

I has mapped the key to trigger the menu
xnoremap :call quickui#menu#open()

Set my terminal background to color scheme or none

How can I use a condition to transfer between my color scheme and "None"(transparet as my expected)?

['&Transparent %{&ctermbg=? "bg":"None"}', 'highlight Normal!']
Setting above seems to be a syntactic error.
I wonder how to do such kind of setting.

Thanks for advance!

can not use Capital character to be hotkey

let content = [  [' &A', 'echo 100' ],  [' &2', 'echo 200' ],  [' &3', 'echo 300' ],  [' &4' ],  [' &5', 'echo 500' ], ]
let opts = {'title': 'select one'}
call quickui#listbox#open(content, opts)

press A will not work.

and can user use as hotkeys?

is there grammar let content menu can set some sub menu in one list ? now i use func to open another content menu...

function Ida_menu()
    let content_ida = [
                    \ ["&2\tida 75 32",'AR C:\tools\program\ida\IDA_Pro_75_Portable\ida.exe '.g:cocexpl_node_path],
                    \ ["&4\tida 75 64",'AR C:\"ools\program\ida\IDA_Pro_75_Portable\ida64.exe '.g:cocexpl_node_path],
                    \ ]
    let opts = {'index':g:quickui#context#cursor}
    call quickui#context#open(content_ida, opts)
endfunction

let content = [
            \ ["&i\tida \>", 'call Ida_menu()'],
            \ ['-'],
            \ ]
let opts = {'index':g:quickui#context#cursor}
call quickui#context#open(content, opts)

wrong style 0 spacers

when quickui_border_style is set to 0 (no border mode) spacers (["--", "" ]) still render as hyphens, it's expected to be empty instead.

能不能搞个表单功能?

有个表单功能这个东西就齐活儿了,可以真的做为一个UI来用了,比如说输入个姓名,邮件地址之类的。我自己查了一段时间,没搞明白怎么弄。。。

How to call quickui function in another plugin?

I'm writing a little plugin and try to call quickui#textbox#open in my own plugin, but it doesn't popup the textbox window. Could you give some example?

This is the demo code in my plugin:

    let l:result = "These are demo content!!"
    let x = substitute(l:result, '[\n\r]\+\%$', '', 'g')
    let content = filter(split(x, "\n"), 'v:key != ""')
    let opts = {"close":"button", "title":"Notes"}
    call quickui#textbox#open(content, opts)

Can't change relativenumber in current buffer

Hi. i want to change relative number option in current buffer. So, tried this is my last try:

....
\ [ "relati&ve number %{&relativenumber? 'OFF':'ON'}", ':set relativenumber!' ],
....

But it won't work.
Edit: This line is a part of call quickui#menu#install().

Bug in displaying tips in the cmdline.

nvim-qt, wim10
Tips can't be displayed if the context is too long. etc:

call quickui#menu#install('&Regex', [
			\ ['Others', '', '固化分组\(\)\@>    非捕获型括号\%(\)    界定边界\zs \ze    magic模式下,花括号{}需要使用\转义,但与之对应的闭括号则可省略,因为Vim会自动推测我们的意图'],
			\ ])

Menubar above my tabline

So how could I always show the menubar above my tabline without pressing double space
?
怎么把这菜单栏整在tabline上面?然后我就是要在没有按空格键的情况下一直显示它.

signcolumn for preview windows (or more general window options)

In function quickui#preview#display, we have some default window options set:

let cmdlist = ['setlocal signcolumn=no norelativenumber']

But I would want to have signcolumn enabled. I wish there were a configuration point for this (say opts.signcolumn).

More generally, a user may want to execute an arbitrary lines of vim commands to configure the preview window --- including many setlocal options, window highlights, custom keymappings, etc. What would be a suggested way for this?

Hide scrollbar option for preview window

Since preview windows are usually small, scrollbar can take precious space and look noisy. I would prefer if I could hide them with some option. (But keep the window scrollable, similar to how vim does it with set guioptions -=rL)

Thanks,
Vjekoslav

How to copy the text on the `textbox`

I use quickui#textbox#command() to show result of some tool(e.g. dictionary query tool). Sometime I want to copy the result to vim register or system clipboard, I don't know how to get it.

Is it possible?

image

Actual man page of vim as popup

I was pretty hyped about getting a man so I made this :

nnoremap K "ayiw:call quickui#tools#display_help("<C-R>a")<CR>

But I noticed that it won't recognise things as let or nocompatible etc...

I was wondering that was possible to get that

In case of the command i made just yank the current word sets it the "a" register and then print it inside the brackets of the called function

I did this to replace the default K command

Btw love your work <3

obey mousemodel=popup_setpos

I would like for the popup menu created via map <RightMouse> <Cmd>call quickui#context#open(content, quick_opts)<CR> to appear where I click with mousemodel=popup_setpos. Is this a vim-quickui or (neo)vim limitation ?

vmap menu 不正常

Noremap 同个 menu, 快捷键按了一个之后就返回,操作正常, 但是 vmap 同个 menu, 按了一个快捷键之后会重新跳出 menu, 跳出的次数跟 menu size 同样多次

Change settings when opening tags after preview

Thank for this amazing plugin! I found strange behavior in "Preview quickfix": if I first preview a tag and then open it, the new window maintains the same colors and settings of preview window (also cursorline).

This only occurs with set switchbuf+=usetab,newtab, indeed using the same tab the color scheme is not changed.

Do I need to define some colors? Thanks for help!

E492: Not an editor command: ^M

配色文件中有空白字符,导致在linux环境下报错

Error detected while processing /home/liubang/.vim/.cache/.cache/init.vim/.dein/colors/quickui/gruvbox.vim:
line    1:
E492: Not an editor command: ^M

Feature Request: vim-clap source provider

vim-clap supports custom providers.

Would be nice add this feature so we can call a custom search for all items on menu, just like the ctrl+shift+p shortcut on VSCode.

Actually vim-clap has Clap command, but this is pretty verbose, showing all commands loaded.

How to chain two command?

I want to build my proeject:

call quickui#menu#install('&C++', [
            \ [ 'make-&debug-mode', 'normal :w; normal :term cd build; ']
            \ ], '<auto>', 'cpp')

As you can save i want to first save the file and then open a terminal. but it won't work.

after loading a new colorscheme, the highlight will disappear.

this is a test.vim

if !has('nvim')
	set nocompatible
endif
set runtimepath +=$GITHUBWORKSPACE/skywind3000/vim-quickui
	let g:quickui_show_tip = 1
	call quickui#menu#reset()
	call quickui#menu#install('Pla&y', [
				\ ['--', ''],
				\ ['Eas&y', 'SudokuEasy'],
				\ ['Medi&um', 'SudokuMedium'],
				\ ['Har&d', 'SudokuHard'],
				\ ['&VeryHard', 'SudokuVeryHard'],
				\ ])

then gvim -u test.vim
image
colorscheme default
image

thanks!

neovim support

Do you have any plans to support neovim ?

I tried your plugin with the latest stable neovim version (0.4.3) and got the following errors (for context I was trying to run the sample code):

Error detected while processing function quickui#menu#open[5]..quickui#menu#create:
line   15:
E117: Unknown function: popup_create
E15: Invalid expression: popup_create([s:cmenu.inst.text], {'hidden':1, 'wrap':0})
line   16:
E121: Undefined variable: winid
E116: Invalid arguments for function winbufnr
E15: Invalid expression: winbufnr(winid)
line   17:
E121: Undefined variable: winid
E15: Invalid expression: winid
line   18:
E121: Undefined variable: bufnr
E15: Invalid expression: bufnr
line   24:
E121: Undefined variable: winid
E116: Invalid arguments for function popup_move
line   25:
E121: Undefined variable: winid
E116: Invalid arguments for function setwinvar
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.