Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ require'cmp'.setup.cmdline('/', {
})
```

Completions for Command-line window `q:`
Add `{ name = 'cmdline' }` to your nvim-cmp sources in the same way, as you would add any other source.

For the buffer source to work, [cmp-buffer](https://github.com/hrsh7th/cmp-buffer) is needed.
3 changes: 2 additions & 1 deletion lua/cmp_cmdline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ source.get_trigger_characters = function()
end

source.is_available = function()
return vim.api.nvim_get_mode().mode == 'c'
return (vim.api.nvim_get_mode().mode == 'c'
or vim.api.nvim_get_var('cmp_cmdline_cmdwin_active') == true)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use vim.fn.getcmdwintype() ~= ''

end

source.complete = function(self, params, callback)
Expand Down
6 changes: 6 additions & 0 deletions plugin/cmp-cmdline.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let g:cmp_cmdline_cmdwin_active = v:false
augroup cmp_cmdline
autocmd!
autocmd CmdWinEnter * let g:cmp_cmdline_cmdwin_active = v:true
autocmd CmdWinLeave * let g:cmp_cmdline_cmdwin_active = v:false
augroup END