lint
This commit is contained in:
parent
677125cbe1
commit
bcee7e3b07
38 changed files with 2330 additions and 1772 deletions
.config/nvim/lua/plugins/cmp
|
@ -1,104 +1,110 @@
|
|||
local M = { "hrsh7th/nvim-cmp" }
|
||||
|
||||
M.dependencies = {
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
}
|
||||
|
||||
M.event = "InsertEnter"
|
||||
|
||||
M.opts = function()
|
||||
local cmp = require "cmp"
|
||||
local snip_status_ok, luasnip = pcall(require, "luasnip")
|
||||
local lspkind_status_ok, lspkind = pcall(require, "lspkind")
|
||||
if not snip_status_ok then return end
|
||||
local cmp = require("cmp")
|
||||
local snip_status_ok, luasnip = pcall(require, "luasnip")
|
||||
local lspkind_status_ok, lspkind = pcall(require, "lspkind")
|
||||
if not snip_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local border_opts = {
|
||||
border = "rounded",
|
||||
winhighlight = "Normal:NormalFloat,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None",
|
||||
}
|
||||
local border_opts = {
|
||||
border = "rounded",
|
||||
winhighlight = "Normal:NormalFloat,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None",
|
||||
}
|
||||
|
||||
local function has_words_before()
|
||||
local line, col = (unpack or table.unpack)(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match "%s" == nil
|
||||
end
|
||||
local function has_words_before()
|
||||
local line, col = (unpack or table.unpack)(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
return {
|
||||
enabled = function()
|
||||
local dap_prompt = require("funcs").is_available("cmp-dap")
|
||||
and vim.tbl_contains({ "dap-repl", "dapui_watches", "dapui_hover" },
|
||||
vim.api.nvim_get_option_value("filetype", { buf = 0 }))
|
||||
if vim.api.nvim_get_option_value("buftype", { buf = 0 }) == "prompt" and not dap_prompt then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
preselect = cmp.PreselectMode.None,
|
||||
formatting = {
|
||||
fields = { "kind", "abbr", "menu" },
|
||||
format = lspkind_status_ok and lspkind.cmp_format(require("plugins.misc.lspkind").opts) or nil,
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args) luasnip.lsp_expand(args.body) end,
|
||||
},
|
||||
duplicates = {
|
||||
nvim_lsp = 1,
|
||||
luasnip = 1,
|
||||
cmp_tabnine = 1,
|
||||
buffer = 1,
|
||||
path = 1,
|
||||
},
|
||||
confirm_opts = {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = false,
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(border_opts),
|
||||
documentation = cmp.config.window.bordered(border_opts),
|
||||
},
|
||||
mapping = {
|
||||
["<Up>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Select },
|
||||
["<Down>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Select },
|
||||
["<C-p>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert },
|
||||
["<C-n>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert },
|
||||
["<C-k>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert },
|
||||
["<C-j>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert },
|
||||
["<C-u>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
|
||||
["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
|
||||
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
|
||||
["<C-y>"] = cmp.config.disable,
|
||||
["<C-e>"] = cmp.mapping { i = cmp.mapping.abort(), c = cmp.mapping.close() },
|
||||
["<CR>"] = cmp.mapping.confirm { select = false },
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
sources = cmp.config.sources {
|
||||
{ name = "nvim_lsp", priority = 1000 },
|
||||
{ name = "luasnip", priority = 750 },
|
||||
{ name = "buffer", priority = 500 },
|
||||
{ name = "path", priority = 250 },
|
||||
},
|
||||
}
|
||||
return {
|
||||
enabled = function()
|
||||
local dap_prompt = require("funcs").is_available("cmp-dap")
|
||||
and vim.tbl_contains(
|
||||
{ "dap-repl", "dapui_watches", "dapui_hover" },
|
||||
vim.api.nvim_get_option_value("filetype", { buf = 0 })
|
||||
)
|
||||
if vim.api.nvim_get_option_value("buftype", { buf = 0 }) == "prompt" and not dap_prompt then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
preselect = cmp.PreselectMode.None,
|
||||
formatting = {
|
||||
fields = { "kind", "abbr", "menu" },
|
||||
format = lspkind_status_ok and lspkind.cmp_format(require("plugins.misc.lspkind").opts) or nil,
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
duplicates = {
|
||||
nvim_lsp = 1,
|
||||
luasnip = 1,
|
||||
cmp_tabnine = 1,
|
||||
buffer = 1,
|
||||
path = 1,
|
||||
},
|
||||
confirm_opts = {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = false,
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(border_opts),
|
||||
documentation = cmp.config.window.bordered(border_opts),
|
||||
},
|
||||
mapping = {
|
||||
["<Up>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
|
||||
["<Down>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
|
||||
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||
["<C-k>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||
["<C-j>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||
["<C-u>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
|
||||
["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
|
||||
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
|
||||
["<C-y>"] = cmp.config.disable,
|
||||
["<C-e>"] = cmp.mapping({ i = cmp.mapping.abort(), c = cmp.mapping.close() }),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp", priority = 1000 },
|
||||
{ name = "luasnip", priority = 750 },
|
||||
{ name = "buffer", priority = 500 },
|
||||
{ name = "path", priority = 250 },
|
||||
}),
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -2,11 +2,11 @@ local M = { "rcarriga/cmp-dap" }
|
|||
|
||||
M.dependencies = { "nvim-dap" }
|
||||
M.config = function()
|
||||
require("cmp").setup.filetype({ "dap-repl", "dapui_watches", "dapui_hover" }, {
|
||||
sources = {
|
||||
{ name = "dap" },
|
||||
},
|
||||
})
|
||||
require("cmp").setup.filetype({ "dap-repl", "dapui_watches", "dapui_hover" }, {
|
||||
sources = {
|
||||
{ name = "dap" },
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
return {
|
||||
require('plugins.cmp.cmp'),
|
||||
require('plugins.cmp.dap'),
|
||||
require('plugins.cmp.luasnip'),
|
||||
require("plugins.cmp.cmp"),
|
||||
require("plugins.cmp.dap"),
|
||||
require("plugins.cmp.luasnip"),
|
||||
}
|
||||
|
|
|
@ -7,14 +7,16 @@ M.build = "make install_jsregexp"
|
|||
M.dependencies = { "rafamadriz/friendly-snippets" }
|
||||
|
||||
M.opts = {
|
||||
history = true,
|
||||
delete_check_events = "TextChanged",
|
||||
region_check_events = "CursorMoved",
|
||||
history = true,
|
||||
delete_check_events = "TextChanged",
|
||||
region_check_events = "CursorMoved",
|
||||
}
|
||||
|
||||
M.config = function(_, opts)
|
||||
require("luasnip").config.setup(opts)
|
||||
vim.tbl_map(function(type) require("luasnip.loaders.from_" .. type).lazy_load() end, { "vscode", "snipmate", "lua" })
|
||||
require("luasnip").config.setup(opts)
|
||||
vim.tbl_map(function(type)
|
||||
require("luasnip.loaders.from_" .. type).lazy_load()
|
||||
end, { "vscode", "snipmate", "lua" })
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue