Skip to content

Source for nvim-cmp which reads results from command-line or search histories

License

Notifications You must be signed in to change notification settings

dmitmel/cmp-cmdline-history

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

cmp-cmdline-history

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.

See also: cmp-cmdline

Usage

Basic example: will complete previously typed Ex commands when in the command-line mode.

cmp.setup.cmdline(':', {
  sources = {
    { name = 'cmdline_history' },
  },
})

A more advanced example: this will also setup the history completion for all other command-line modes.

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 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:

autocmd FileType vim lua require('cmp').setup.buffer({
\   sources = {
\     {
\       name = 'cmdline_history',
\       opts = { history_type = ':' },
\     },
\   },
\ })

About

Source for nvim-cmp which reads results from command-line or search histories

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages