mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
use nvim-cmp for cmd line completion
- remove wilder.nvim and its config - add blink.cmp config as backup solution
This commit is contained in:
parent
b69dcb3a6b
commit
999a1733cf
@ -69,7 +69,6 @@ and how to set up on different platforms (Linux, macOS, and Windows).
|
|||||||
+ File tree explorer via [nvim-tree.lua](https://github.com/nvim-tree/nvim-tree.lua).
|
+ File tree explorer via [nvim-tree.lua](https://github.com/nvim-tree/nvim-tree.lua).
|
||||||
+ Better quickfix list with [nvim-bqf](https://github.com/kevinhwang91/nvim-bqf).
|
+ Better quickfix list with [nvim-bqf](https://github.com/kevinhwang91/nvim-bqf).
|
||||||
+ Show search index and count with [nvim-hlslens](https://github.com/kevinhwang91/nvim-hlslens).
|
+ Show search index and count with [nvim-hlslens](https://github.com/kevinhwang91/nvim-hlslens).
|
||||||
+ Command line auto-completion via [wilder.nvim](https://github.com/gelguy/wilder.nvim).
|
|
||||||
+ User-defined mapping hint via [which-key.nvim](https://github.com/folke/which-key.nvim).
|
+ User-defined mapping hint via [which-key.nvim](https://github.com/folke/which-key.nvim).
|
||||||
+ Asynchronous code execution via [asyncrun.vim](https://github.com/skywind3000/asyncrun.vim).
|
+ Asynchronous code execution via [asyncrun.vim](https://github.com/skywind3000/asyncrun.vim).
|
||||||
+ Code highlighting via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).
|
+ Code highlighting via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).
|
||||||
@ -111,12 +110,6 @@ For more UI demos, check [here](https://github.com/jdhao/nvim-config/issues/15).
|
|||||||
<img src="https://user-images.githubusercontent.com/16662357/128590833-aaa05d53-19ef-441d-a5a9-ba1bbd3936c1.gif" width="800">
|
<img src="https://user-images.githubusercontent.com/16662357/128590833-aaa05d53-19ef-441d-a5a9-ba1bbd3936c1.gif" width="800">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## Command-line autocompletion with wilder.nvim
|
|
||||||
|
|
||||||
<p align="center">
|
|
||||||
<img src="https://user-images.githubusercontent.com/16662357/147677787-8e5d229a-a16a-420e-98f5-88f2a1be84a2.gif" width="800">
|
|
||||||
</p>
|
|
||||||
|
|
||||||
## Tags
|
## Tags
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
|
|||||||
@ -7,6 +7,7 @@ require("cmp_path")
|
|||||||
require("cmp_buffer")
|
require("cmp_buffer")
|
||||||
require("cmp_omni")
|
require("cmp_omni")
|
||||||
require("cmp_nvim_ultisnips")
|
require("cmp_nvim_ultisnips")
|
||||||
|
require("cmp_cmdline")
|
||||||
|
|
||||||
local MiniIcons = require("mini.icons")
|
local MiniIcons = require("mini.icons")
|
||||||
|
|
||||||
@ -71,6 +72,23 @@ cmp.setup.filetype("tex", {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
cmp.setup.cmdline("/", {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = {
|
||||||
|
{ name = "buffer" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
cmp.setup.cmdline(":", {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = "path" },
|
||||||
|
}, {
|
||||||
|
{ name = "cmdline" },
|
||||||
|
}),
|
||||||
|
matching = { disallow_symbol_nonprefix_matching = false },
|
||||||
|
})
|
||||||
|
|
||||||
-- see https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance#how-to-add-visual-studio-code-dark-theme-colors-to-the-menu
|
-- see https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance#how-to-add-visual-studio-code-dark-theme-colors-to-the-menu
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
highlight! link CmpItemMenu Comment
|
highlight! link CmpItemMenu Comment
|
||||||
|
|||||||
@ -104,7 +104,7 @@ keymap.set("n", "<leader>v", "printf('`[%s`]', getregtype()[0])", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- Always use very magic mode for searching
|
-- Always use very magic mode for searching
|
||||||
keymap.set("n", "/", [[/\v]])
|
-- keymap.set("n", "/", [[/\v]])
|
||||||
|
|
||||||
-- Search in selected region
|
-- Search in selected region
|
||||||
-- xnoremap / :<C-U>call feedkeys('/\%>'.(line("'<")-1).'l\%<'.(line("'>")+1)."l")<CR>
|
-- xnoremap / :<C-U>call feedkeys('/\%>'.(line("'<")-1).'l\%<'.(line("'>")+1)."l")<CR>
|
||||||
|
|||||||
@ -26,15 +26,79 @@ local plugin_specs = {
|
|||||||
{ "hrsh7th/cmp-path", lazy = true },
|
{ "hrsh7th/cmp-path", lazy = true },
|
||||||
{ "hrsh7th/cmp-buffer", lazy = true },
|
{ "hrsh7th/cmp-buffer", lazy = true },
|
||||||
{ "hrsh7th/cmp-omni", lazy = true },
|
{ "hrsh7th/cmp-omni", lazy = true },
|
||||||
|
{ "hrsh7th/cmp-cmdline", lazy = true },
|
||||||
{ "quangnguyen30192/cmp-nvim-ultisnips", lazy = true },
|
{ "quangnguyen30192/cmp-nvim-ultisnips", lazy = true },
|
||||||
{
|
{
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
name = "nvim-cmp",
|
name = "nvim-cmp",
|
||||||
event = "InsertEnter",
|
event = "VeryLazy",
|
||||||
config = function()
|
config = function()
|
||||||
require("config.nvim-cmp")
|
require("config.nvim-cmp")
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
--{
|
||||||
|
-- "saghen/blink.cmp",
|
||||||
|
-- -- optional: provides snippets for the snippet source
|
||||||
|
-- dependencies = { "rafamadriz/friendly-snippets" },
|
||||||
|
|
||||||
|
-- -- use a release tag to download pre-built binaries
|
||||||
|
-- version = "1.*",
|
||||||
|
|
||||||
|
-- ---@module 'blink.cmp'
|
||||||
|
-- ---@type blink.cmp.Config
|
||||||
|
-- opts = {
|
||||||
|
-- -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
|
||||||
|
-- -- 'super-tab' for mappings similar to vscode (tab to accept)
|
||||||
|
-- -- 'enter' for enter to accept
|
||||||
|
-- -- 'none' for no mappings
|
||||||
|
-- --
|
||||||
|
-- keymap = {
|
||||||
|
-- preset = "default",
|
||||||
|
-- ["<Tab>"] = { "select_next", "fallback" },
|
||||||
|
-- ["<S-Tab>"] = { "select_prev", "fallback" },
|
||||||
|
-- ["<Enter>"] = { "select_and_accept", "fallback" },
|
||||||
|
-- ["<C-U>"] = { "scroll_documentation_up", "fallback" },
|
||||||
|
-- ["<C-D>"] = { "scroll_documentation_down", "fallback" },
|
||||||
|
-- },
|
||||||
|
|
||||||
|
-- appearance = {
|
||||||
|
-- -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
|
||||||
|
-- -- Adjusts spacing to ensure icons are aligned
|
||||||
|
-- nerd_font_variant = "mono",
|
||||||
|
-- },
|
||||||
|
|
||||||
|
-- -- (Default) Only show the documentation popup when manually triggered
|
||||||
|
-- completion = {
|
||||||
|
-- documentation = {
|
||||||
|
-- auto_show = true,
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
|
||||||
|
-- -- Default list of enabled providers defined so that you can extend it
|
||||||
|
-- -- elsewhere in your config, without redefining it, due to `opts_extend`
|
||||||
|
-- sources = {
|
||||||
|
-- default = { "lsp", "path", "buffer" },
|
||||||
|
-- },
|
||||||
|
|
||||||
|
-- -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
|
||||||
|
-- -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
|
||||||
|
-- -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
|
||||||
|
-- --
|
||||||
|
-- -- See the fuzzy documentation for more information
|
||||||
|
-- fuzzy = { implementation = "prefer_rust_with_warning" },
|
||||||
|
-- cmdline = {
|
||||||
|
-- completion = {
|
||||||
|
-- menu = {
|
||||||
|
-- auto_show = true,
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- keymap = {
|
||||||
|
-- ["<Enter>"] = { "select_and_accept", "fallback" },
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- opts_extend = { "sources.default" },
|
||||||
|
--},
|
||||||
{
|
{
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
event = { "BufRead", "BufNewFile" },
|
event = { "BufRead", "BufNewFile" },
|
||||||
@ -251,9 +315,13 @@ local plugin_specs = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
-- Snippet engine and snippet template
|
-- Snippet engine and snippet template
|
||||||
{ "SirVer/ultisnips", dependencies = {
|
{
|
||||||
"honza/vim-snippets",
|
"SirVer/ultisnips",
|
||||||
}, event = "InsertEnter" },
|
dependencies = {
|
||||||
|
"honza/vim-snippets",
|
||||||
|
},
|
||||||
|
event = "InsertEnter",
|
||||||
|
},
|
||||||
|
|
||||||
-- Automatic insertion and deletion of a pair of characters
|
-- Automatic insertion and deletion of a pair of characters
|
||||||
{
|
{
|
||||||
@ -263,10 +331,13 @@ local plugin_specs = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
-- Comment plugin
|
-- Comment plugin
|
||||||
{ "tpope/vim-commentary", keys = {
|
{
|
||||||
{ "gc", mode = "n" },
|
"tpope/vim-commentary",
|
||||||
{ "gc", mode = "v" },
|
keys = {
|
||||||
} },
|
{ "gc", mode = "n" },
|
||||||
|
{ "gc", mode = "v" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
-- Multiple cursor plugin like Sublime Text?
|
-- Multiple cursor plugin like Sublime Text?
|
||||||
-- 'mg979/vim-visual-multi'
|
-- 'mg979/vim-visual-multi'
|
||||||
@ -307,9 +378,6 @@ local plugin_specs = {
|
|||||||
event = { "InsertEnter" },
|
event = { "InsertEnter" },
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Auto format tools
|
|
||||||
{ "sbdchd/neoformat", cmd = { "Neoformat" } },
|
|
||||||
|
|
||||||
-- Git command inside vim
|
-- Git command inside vim
|
||||||
{
|
{
|
||||||
"tpope/vim-fugitive",
|
"tpope/vim-fugitive",
|
||||||
@ -464,12 +532,6 @@ local plugin_specs = {
|
|||||||
cmd = { "OSCYank", "OSCYankReg" },
|
cmd = { "OSCYank", "OSCYankReg" },
|
||||||
},
|
},
|
||||||
|
|
||||||
-- The missing auto-completion for cmdline!
|
|
||||||
{
|
|
||||||
"gelguy/wilder.nvim",
|
|
||||||
build = ":UpdateRemotePlugins",
|
|
||||||
},
|
|
||||||
|
|
||||||
-- showing keybindings
|
-- showing keybindings
|
||||||
{
|
{
|
||||||
"folke/which-key.nvim",
|
"folke/which-key.nvim",
|
||||||
|
|||||||
@ -240,49 +240,3 @@ endif
|
|||||||
|
|
||||||
""""""""""""""""""""""""""""""nvim-gdb settings""""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""""nvim-gdb settings""""""""""""""""""""""""""""""
|
||||||
nnoremap <leader>dp :<C-U>GdbStartPDB python -m pdb %<CR>
|
nnoremap <leader>dp :<C-U>GdbStartPDB python -m pdb %<CR>
|
||||||
|
|
||||||
""""""""""""""""""""""""""""""wilder.nvim settings""""""""""""""""""""""""""""""
|
|
||||||
call timer_start(250, { -> s:wilder_init() })
|
|
||||||
|
|
||||||
function! s:wilder_init() abort
|
|
||||||
try
|
|
||||||
call wilder#setup({
|
|
||||||
\ 'modes': [':', '/', '?'],
|
|
||||||
\ 'next_key': '<Tab>',
|
|
||||||
\ 'previous_key': '<S-Tab>',
|
|
||||||
\ 'accept_key': '<C-y>',
|
|
||||||
\ 'reject_key': '<C-e>'
|
|
||||||
\ })
|
|
||||||
|
|
||||||
call wilder#set_option('pipeline', [
|
|
||||||
\ wilder#branch(
|
|
||||||
\ wilder#cmdline_pipeline({
|
|
||||||
\ 'language': 'python',
|
|
||||||
\ 'fuzzy': 1,
|
|
||||||
\ 'sorter': wilder#python_difflib_sorter(),
|
|
||||||
\ 'debounce': 30,
|
|
||||||
\ }),
|
|
||||||
\ wilder#python_search_pipeline({
|
|
||||||
\ 'pattern': wilder#python_fuzzy_pattern(),
|
|
||||||
\ 'sorter': wilder#python_difflib_sorter(),
|
|
||||||
\ 'engine': 're',
|
|
||||||
\ 'debounce': 30,
|
|
||||||
\ }),
|
|
||||||
\ ),
|
|
||||||
\ ])
|
|
||||||
|
|
||||||
let l:hl = wilder#make_hl('WilderAccent', 'Pmenu', [{}, {}, {'foreground': '#f4468f'}])
|
|
||||||
call wilder#set_option('renderer', wilder#popupmenu_renderer({
|
|
||||||
\ 'highlighter': wilder#basic_highlighter(),
|
|
||||||
\ 'max_height': 15,
|
|
||||||
\ 'highlights': {
|
|
||||||
\ 'accent': l:hl,
|
|
||||||
\ },
|
|
||||||
\ 'left': [' ', wilder#popupmenu_devicons(),],
|
|
||||||
\ 'right': [' ', wilder#popupmenu_scrollbar(),],
|
|
||||||
\ 'apply_incsearch_fix': 0,
|
|
||||||
\ }))
|
|
||||||
catch /^Vim\%((\a\+)\)\=:E117/
|
|
||||||
echohl Error |echomsg "Wilder.nvim missing"| echohl None
|
|
||||||
endtry
|
|
||||||
endfunction
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user