fix: modify nvim-cmp
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
run:
|
||||
tests: false
|
||||
timeout: 1m
|
||||
linters:
|
||||
enable:
|
||||
- govet
|
||||
@@ -12,8 +13,12 @@ linters:
|
||||
- gofmt
|
||||
- stylecheck
|
||||
- revive
|
||||
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
|
||||
disable-all: true
|
||||
linters-settings:
|
||||
staticcheck:
|
||||
# SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
|
||||
checks: ["all"]
|
||||
revive:
|
||||
# Maximum number of open files at the same time.
|
||||
# See https://github.com/mgechev/revive#command-line-flags
|
||||
|
||||
@@ -134,7 +134,7 @@ alias alert='terminal-notifier -title "Terminal" -message "Done with task! Exit
|
||||
# git
|
||||
alias gitb="git branch --show-current | tr -d '\n' | pbcopy"
|
||||
alias ct="go test -gcflags=all=-l -cover ./..."
|
||||
alias ci="golangci-lint run ./..."
|
||||
alias ci="golangci-lint -c=~/.dotfile/.golangci.yml run ./..."
|
||||
alias gt="go test -gcflags=all=-l "
|
||||
alias swg="swag init -o docs -g "
|
||||
alias sws="swagger serve -F=swagger"
|
||||
|
||||
@@ -74,8 +74,8 @@ vim.api.nvim_set_keymap('', '<C-q>', ':call QuickFixToggle()<CR>', {noremap = tr
|
||||
|
||||
|
||||
-- nvim-compe key map
|
||||
vim.cmd('inoremap <silent><expr> <C-Space> compe#complete()')
|
||||
vim.cmd("inoremap <silent><expr> <CR> compe#confirm('<CR>')")
|
||||
vim.cmd("inoremap <silent><expr> <C-e> compe#close('<C-e>')")
|
||||
vim.cmd("inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })")
|
||||
vim.cmd("inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })")
|
||||
-- vim.cmd('inoremap <silent><expr> <C-Space> compe#complete()')
|
||||
-- vim.cmd("inoremap <silent><expr> <CR> compe#confirm('<CR>')")
|
||||
-- vim.cmd("inoremap <silent><expr> <C-e> compe#close('<C-e>')")
|
||||
-- vim.cmd("inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })")
|
||||
-- vim.cmd("inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })")
|
||||
|
||||
@@ -12,7 +12,7 @@ require('pluginconfig/neotest')
|
||||
require('pluginconfig/numb')
|
||||
require('pluginconfig/nvim-autopairs')
|
||||
require('pluginconfig/nvim-colorizer')
|
||||
require('pluginconfig/nvim-compe')
|
||||
require('pluginconfig/nvim-cmp')
|
||||
require('pluginconfig/fzf-lua')
|
||||
require('pluginconfig/nvim-tree') -- This plugin must be required somewhere before colorscheme. Placing it after will break navigation keymappings
|
||||
require('pluginconfig/nvim-treesitter')
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
local lspkind = require('lspkind')
|
||||
local cmp = require 'cmp'
|
||||
|
||||
local function keymapping(cmp)
|
||||
return {
|
||||
-- 上一个
|
||||
['<C-k>'] = cmp.mapping.select_prev_item(),
|
||||
-- 下一个
|
||||
['<C-j>'] = cmp.mapping.select_next_item(),
|
||||
-- 出现补全
|
||||
['<A-.>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
||||
-- 取消
|
||||
['<A-,>'] = cmp.mapping({
|
||||
i = cmp.mapping.abort(),
|
||||
c = cmp.mapping.close(),
|
||||
}),
|
||||
-- 确认
|
||||
-- Accept currently selected item. If none selected, `select` first item.
|
||||
-- Set `select` to `false` to only confirm explicitly selected items.
|
||||
['<CR>'] = cmp.mapping.confirm({
|
||||
select = true,
|
||||
behavior = cmp.ConfirmBehavior.Replace
|
||||
}),
|
||||
-- ['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
|
||||
['<C-u>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
||||
['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
||||
}
|
||||
end
|
||||
|
||||
cmp.setup {
|
||||
-- 指定 snippet 引擎
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
-- For `vsnip` users.
|
||||
vim.fn["vsnip#anonymous"](args.body)
|
||||
|
||||
-- For `luasnip` users.
|
||||
-- require('luasnip').lsp_expand(args.body)
|
||||
|
||||
-- For `ultisnips` users.
|
||||
-- vim.fn["UltiSnips#Anon"](args.body)
|
||||
|
||||
-- For `snippy` users.
|
||||
-- require'snippy'.expand_snippet(args.body)
|
||||
end,
|
||||
},
|
||||
-- 来源
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
-- For vsnip users.
|
||||
{ name = 'vsnip' },
|
||||
-- For luasnip users.
|
||||
-- { name = 'luasnip' },
|
||||
--For ultisnips users.
|
||||
-- { name = 'ultisnips' },
|
||||
-- -- For snippy users.
|
||||
-- { name = 'snippy' },
|
||||
}, { { name = 'buffer' },
|
||||
{ name = 'path' }
|
||||
}),
|
||||
|
||||
-- 快捷键
|
||||
mapping = keymapping(cmp),
|
||||
-- 使用lspkind-nvim显示类型图标
|
||||
formatting = {
|
||||
format = lspkind.cmp_format({
|
||||
with_text = true, -- do not show text alongside icons
|
||||
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
|
||||
before = function(entry, vim_item)
|
||||
-- Source 显示提示来源
|
||||
vim_item.menu = "[" .. string.upper(entry.source.name) .. "]"
|
||||
return vim_item
|
||||
end
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
-- Use buffer source for `/`.
|
||||
cmp.setup.cmdline('/', {
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':'.
|
||||
cmp.setup.cmdline(':', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
@@ -1,150 +0,0 @@
|
||||
vim.o.completeopt = "menuone,noselect"
|
||||
|
||||
require'compe'.setup {
|
||||
enabled = true,
|
||||
autocomplete = true,
|
||||
debug = false,
|
||||
min_length = 1,
|
||||
preselect = 'enable',
|
||||
throttle_time = 80,
|
||||
source_timeout = 200,
|
||||
incomplete_delay = 400,
|
||||
max_abbr_width = 100,
|
||||
max_kind_width = 100,
|
||||
max_menu_width = 100,
|
||||
documentation = true,
|
||||
|
||||
source = {
|
||||
path = {kind = " (Path)"},
|
||||
buffer = {kind = " (Buffer)"},
|
||||
calc = {kind = " (Calc)"},
|
||||
vsnip = {kind = " (Snippet)"},
|
||||
nvim_lsp = {kind = " (LSP)"},
|
||||
-- nvim_lua = {kind = " "},
|
||||
nvim_lua = false,
|
||||
spell = {kind = " (Spell)"},
|
||||
tags = false,
|
||||
vim_dadbod_completion = true,
|
||||
-- snippets_nvim = {kind = " "},
|
||||
-- ultisnips = {kind = " "},
|
||||
-- treesitter = {kind = " "},
|
||||
emoji = {kind = " ﲃ (Emoji)", filetypes={"markdown", "text"}}
|
||||
-- for emoji press : (idk if that in compe tho)
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
-- m
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
|
||||
-- local t = function(str)
|
||||
-- return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||
-- end
|
||||
|
||||
-- local check_back_space = function()
|
||||
-- local col = vim.fn.col('.') - 1
|
||||
-- if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
|
||||
-- return true
|
||||
-- else
|
||||
-- return false
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- -- Use (s-)tab to:
|
||||
-- --- move to prev/next item in completion menuone
|
||||
-- --- jump to prev/next snippet's placeholder
|
||||
-- _G.tab_complete = function()
|
||||
-- if vim.fn.pumvisible() == 1 then
|
||||
-- return t "<C-n>"
|
||||
-- elseif vim.fn.call("vsnip#available", {1}) == 1 then
|
||||
-- return t "<Plug>(vsnip-expand-or-jump)"
|
||||
-- elseif check_back_space() then
|
||||
-- return t "<Tab>"
|
||||
-- else
|
||||
-- return vim.fn['compe#complete']()
|
||||
-- end
|
||||
-- end
|
||||
-- _G.s_tab_complete = function()
|
||||
-- if vim.fn.pumvisible() == 1 then
|
||||
-- return t "<C-p>"
|
||||
-- elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
|
||||
-- return t "<Plug>(vsnip-jump-prev)"
|
||||
-- else
|
||||
-- return t "<S-Tab>"
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||
-- vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||
-- vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||
-- vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local t = function(str)
|
||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||
end
|
||||
|
||||
local check_back_space = function()
|
||||
local col = vim.fn.col('.') - 1
|
||||
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Use (s-)tab to:
|
||||
--- move to prev/next item in completion menuone
|
||||
--- jump to prev/next snippet's placeholder
|
||||
_G.tab_complete = function()
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
return t "<C-n>"
|
||||
elseif vim.fn.call("vsnip#available", {1}) == 1 then
|
||||
return t "<Plug>(vsnip-expand-or-jump)"
|
||||
elseif check_back_space() then
|
||||
return t "<Tab>"
|
||||
else
|
||||
return vim.fn['compe#complete']()
|
||||
end
|
||||
end
|
||||
_G.s_tab_complete = function()
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
return t "<C-p>"
|
||||
elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
|
||||
return t "<Plug>(vsnip-jump-prev)"
|
||||
else
|
||||
return t "<S-Tab>"
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||
+12
-3
@@ -60,8 +60,18 @@ return require("packer").startup(function(use)
|
||||
-- Debugging
|
||||
use { "mfussenegger/nvim-dap", opt = true }
|
||||
|
||||
-- Autocomplete
|
||||
use { "hrsh7th/nvim-compe", opt = true }
|
||||
-- nvim-cmp
|
||||
use 'hrsh7th/cmp-nvim-lsp' -- { name = nvim_lsp }
|
||||
use 'hrsh7th/cmp-buffer' -- { name = 'buffer' },
|
||||
use 'hrsh7th/cmp-path' -- { name = 'path' }
|
||||
use 'hrsh7th/cmp-cmdline' -- { name = 'cmdline' }
|
||||
use 'hrsh7th/nvim-cmp'
|
||||
-- vsnip
|
||||
use 'hrsh7th/cmp-vsnip' -- { name = 'vsnip' }
|
||||
use 'hrsh7th/vim-vsnip'
|
||||
use 'rafamadriz/friendly-snippets'
|
||||
-- lspkind
|
||||
use 'onsails/lspkind-nvim'
|
||||
|
||||
-- Treesitter
|
||||
use { "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" }
|
||||
@@ -155,7 +165,6 @@ return require("packer").startup(function(use)
|
||||
require_plugin("telescope.nvim")
|
||||
require_plugin('telescope-project.nvim')
|
||||
require_plugin("nvim-dap")
|
||||
require_plugin("nvim-compe")
|
||||
require_plugin("nvim-ts-autotag")
|
||||
require_plugin('vim-matchup')
|
||||
require_plugin("nvim-tree.lua")
|
||||
|
||||
Reference in New Issue
Block a user