Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dmitmel/cmp-cmdline-history
Source for nvim-cmp which reads results from command-line or search histories
https://github.com/dmitmel/cmp-cmdline-history
nvim-cmp
Last synced: 6 days ago
JSON representation
Source for nvim-cmp which reads results from command-line or search histories
- Host: GitHub
- URL: https://github.com/dmitmel/cmp-cmdline-history
- Owner: dmitmel
- License: cc0-1.0
- Created: 2021-10-27T11:39:39.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-05-04T08:46:03.000Z (over 2 years ago)
- Last Synced: 2024-08-02T13:33:14.696Z (3 months ago)
- Topics: nvim-cmp
- Language: Lua
- Homepage:
- Size: 5.86 KB
- Stars: 75
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# cmp-cmdline-history
[nvim-cmp](https://github.com/hrsh7th/nvim-cmp) source for getting completions from command-line (`:` or Ex-mode) or search (`/` and `?`) histories. Intended for use with the recently-introduced [cmdline completion feature](https://github.com/hrsh7th/nvim-cmp/pull/362).
See also: [cmp-cmdline](https://github.com/hrsh7th/cmp-cmdline)
## Usage
Basic example: will complete previously typed Ex commands when in the command-line mode.
```lua
cmp.setup.cmdline(':', {
sources = {
{ name = 'cmdline_history' },
},
})
```A more advanced example: this will also setup the history completion for all other command-line modes.
```lua
for _, cmd_type in ipairs({':', '/', '?', '@'}) do
cmp.setup.cmdline(cmd_type, {
sources = {
{ name = 'cmdline_history' },
},
})
end
```By default this source will read the history for the current mode, but you can also force it to use some other mode with the `history_type` option. The possible values for it can be found in [`:help hist-names`](https://neovim.io/doc/user/builtin.html#hist-names) and [`:help getcmdtype()`](). Not sure how this can be useful, but I guess you could use it to autocomplete Ex commands in a Vimscript file:
```vim
autocmd FileType vim lua require('cmp').setup.buffer({
\ sources = {
\ {
\ name = 'cmdline_history',
\ opts = { history_type = ':' },
\ },
\ },
\ })
```